glchat-a2ui-react-renderer 0.1.0 → 0.2.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.
Files changed (75) hide show
  1. package/README.md +68 -116
  2. package/dist/index.d.ts +4 -4
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +5 -7
  5. package/dist/src/AllSurfacesRenderer.d.ts +14 -0
  6. package/dist/src/AllSurfacesRenderer.d.ts.map +1 -0
  7. package/dist/src/AllSurfacesRenderer.js +18 -0
  8. package/dist/src/Provider.d.ts +20 -0
  9. package/dist/src/Provider.d.ts.map +1 -0
  10. package/dist/src/Provider.js +50 -0
  11. package/dist/src/SingleSurfaceRenderer.d.ts +15 -0
  12. package/dist/src/SingleSurfaceRenderer.d.ts.map +1 -0
  13. package/dist/src/SingleSurfaceRenderer.js +9 -0
  14. package/dist/src/components/Button/Button.d.ts +4 -0
  15. package/dist/src/components/Button/Button.d.ts.map +1 -0
  16. package/dist/src/components/Button/Button.js +27 -0
  17. package/dist/src/components/Button/theme.d.ts +14 -0
  18. package/dist/src/components/Button/theme.d.ts.map +1 -0
  19. package/dist/src/components/Button/theme.js +59 -0
  20. package/dist/src/components/Card/Card.d.ts +4 -0
  21. package/dist/src/components/Card/Card.d.ts.map +1 -0
  22. package/dist/src/components/Card/Card.js +16 -0
  23. package/dist/src/components/Card/theme.d.ts +10 -0
  24. package/dist/src/components/Card/theme.d.ts.map +1 -0
  25. package/dist/src/components/Card/theme.js +21 -0
  26. package/dist/src/components/Timeout/Timeout.d.ts +4 -0
  27. package/dist/src/components/Timeout/Timeout.d.ts.map +1 -0
  28. package/dist/src/components/Timeout/Timeout.js +30 -0
  29. package/dist/src/components/Timeout/theme.d.ts +8 -0
  30. package/dist/src/components/Timeout/theme.d.ts.map +1 -0
  31. package/dist/src/components/Timeout/theme.js +12 -0
  32. package/dist/src/utils/catalog.d.ts +7 -0
  33. package/dist/src/utils/catalog.d.ts.map +1 -0
  34. package/dist/src/utils/catalog.js +21 -0
  35. package/dist/src/utils/theme.d.ts +4 -0
  36. package/dist/src/utils/theme.d.ts.map +1 -0
  37. package/dist/src/utils/theme.js +67 -0
  38. package/dist/src/utils/time.d.ts +17 -0
  39. package/dist/src/utils/time.d.ts.map +1 -0
  40. package/dist/src/utils/time.js +28 -0
  41. package/package.json +12 -3
  42. package/styles/globals.css +35 -0
  43. package/dist/src/a2ui/GlchatA2UIProvider.d.ts +0 -4
  44. package/dist/src/a2ui/GlchatA2UIProvider.d.ts.map +0 -1
  45. package/dist/src/a2ui/GlchatA2UIProvider.js +0 -8
  46. package/dist/src/a2ui/GlchatA2UIRenderer.d.ts +0 -4
  47. package/dist/src/a2ui/GlchatA2UIRenderer.d.ts.map +0 -1
  48. package/dist/src/a2ui/GlchatA2UIRenderer.js +0 -6
  49. package/dist/src/a2ui/adapter.d.ts +0 -3
  50. package/dist/src/a2ui/adapter.d.ts.map +0 -1
  51. package/dist/src/a2ui/adapter.js +0 -12
  52. package/dist/src/a2ui/glchatStandardCatalog.d.ts +0 -10
  53. package/dist/src/a2ui/glchatStandardCatalog.d.ts.map +0 -1
  54. package/dist/src/a2ui/glchatStandardCatalog.js +0 -14
  55. package/dist/src/components/custom/Button.d.ts +0 -3
  56. package/dist/src/components/custom/Button.d.ts.map +0 -1
  57. package/dist/src/components/custom/Button.js +0 -14
  58. package/dist/src/components/custom/Card.d.ts +0 -3
  59. package/dist/src/components/custom/Card.d.ts.map +0 -1
  60. package/dist/src/components/custom/Card.js +0 -7
  61. package/dist/src/components/custom/Timeout.d.ts +0 -3
  62. package/dist/src/components/custom/Timeout.d.ts.map +0 -1
  63. package/dist/src/components/custom/Timeout.js +0 -6
  64. package/dist/src/components/ui/Button.d.ts +0 -12
  65. package/dist/src/components/ui/Button.d.ts.map +0 -1
  66. package/dist/src/components/ui/Button.js +0 -38
  67. package/dist/src/components/ui/Card.d.ts +0 -9
  68. package/dist/src/components/ui/Card.d.ts.map +0 -1
  69. package/dist/src/components/ui/Card.js +0 -16
  70. package/dist/src/components/ui/Timeout.d.ts +0 -6
  71. package/dist/src/components/ui/Timeout.d.ts.map +0 -1
  72. package/dist/src/components/ui/Timeout.js +0 -35
  73. package/dist/src/helpers/css.d.ts +0 -6
  74. package/dist/src/helpers/css.d.ts.map +0 -1
  75. package/dist/src/helpers/css.js +0 -7
package/README.md CHANGED
@@ -1,12 +1,12 @@
1
1
  # glchat-a2ui-react-renderer
2
2
 
3
- [`@a2ui-sdk/react`](https://www.npmjs.com/package/@a2ui-sdk/react) with GLChat-specific catalog and styling.
3
+ [`@a2ui/react`](https://www.npmjs.com/package/@a2ui/react) with GLChat-specific styling and component overrides.
4
4
 
5
5
  This package provides:
6
6
 
7
- * **`GlchatA2UIProvider`** – `A2UIProvider` wrapper that uses the GLChat catalog by default.
8
- * **`GlchatA2UIRenderer`** – thin wrapper around `A2UIRenderer`.
9
- * **`glchatStandardCatalog`** – the standard A2UI catalog with GLChat custom components (`Button`, `Card`, `Timeout`) for manual wiring.
7
+ * **`Provider`** – `A2UIProvider` wrapper that automatically registers GLChat's custom components (`Button`, `Card`, `Timeout`).
8
+ * **`SingleSurfaceRenderer`** – thin wrapper around `A2UIRenderer` for a single `surfaceId`. Must be used inside `Provider`.
9
+ * **`AllSurfacesRenderer`** – convenience wrapper that renders every active `surfaceId`. Must be used inside `Provider`.
10
10
  * **Tailwind theming** – `styles/globals.css`, `styles/theme-v4.css`, and `tailwind-config.cjs` for default tokens and utilities.
11
11
 
12
12
  This library provides **GLChat-specific components and styling** while remaining fully compatible with the upstream A2UI renderer.
@@ -34,102 +34,58 @@ Use the GLChat-aware wrappers:
34
34
 
35
35
  ```tsx
36
36
  import {
37
- GlchatA2UIProvider,
38
- GlchatA2UIRenderer,
39
- type A2UIMessage,
40
- type A2UIAction,
37
+ Provider,
38
+ SingleSurfaceRenderer,
39
+ AllSurfacesRenderer,
41
40
  } from 'glchat-a2ui-react-renderer';
41
+ import type { A2UIMessage, ActionPayload } from 'glchat-a2ui-react-renderer';
42
42
 
43
43
  function App() {
44
44
  const messages: A2UIMessage[] = [
45
45
  // A2UI messages from your backend
46
46
  ];
47
47
 
48
- const handleAction = (action: A2UIAction) => {
48
+ const handleAction = (action: ActionPayload) => {
49
49
  console.log('Action received:', action);
50
50
  };
51
51
 
52
52
  return (
53
- <GlchatA2UIProvider messages={messages}>
54
- <GlchatA2UIRenderer onAction={handleAction} />
55
- </GlchatA2UIProvider>
53
+ <Provider messages={messages} onAction={handleAction}>
54
+ <AllSurfacesRenderer />
55
+ </Provider>
56
56
  );
57
57
  }
58
58
 
59
59
  ```
60
- # Custom Catalog
61
60
 
62
- To extend catalog, you can use `glchatStandardCatalog` as the base standard.
61
+ To render a single surface explicitly:
63
62
 
64
63
  ```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
- ];
64
+ <Provider messages={messages} onAction={handleAction}>
65
+ <SingleSurfaceRenderer surfaceId="main" />
66
+ </Provider>
67
+ ```
77
68
 
78
- const customCatalog = {
79
- ...glchatStandardCatalog,
80
- components: {
81
- ...glchatStandardCatalog.components,
82
- Button: CustomButtonComponent,
83
- },
84
- };
69
+ > **Note:** `onAction` is configured on `Provider`. Both `SingleSurfaceRenderer` and `AllSurfacesRenderer` must be rendered inside a `Provider`.
85
70
 
86
- const handleAction = (action: A2UIAction) => {
87
- console.log('Action received:', action);
88
- };
71
+ # Custom Components (optional)
89
72
 
90
- return (
91
- <GlchatA2UIProvider messages={messages} catalog={glchatStandardCatalog}>
92
- <GlchatA2UIRenderer onAction={handleAction} />
93
- </GlchatA2UIProvider>
94
- );
95
- }
96
- ```
73
+ `Provider` automatically registers GLChat's `Button`, `Card`, and `Timeout` overrides — no extra setup needed.
74
+ To add your own node types on top, register them on the singleton `ComponentRegistry` before rendering:
97
75
 
98
76
  ```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';
77
+ import { ComponentRegistry, Types, type A2UIComponentProps } from 'glchat-a2ui-react-renderer';
121
78
 
122
- return (
123
- <Button onClick={handleClick} variant={variant}>
124
- <div>masuk custom button</div>
125
- {child && <ComponentRenderer surfaceId={surfaceId} componentId={child} />}
126
- </Button>
127
- )
79
+ function MyNodeComponent({ node }: Readonly<A2UIComponentProps<Types.CustomNode>>) {
80
+ const label = (node.properties as any).label as string | undefined;
81
+ return <div>{label}</div>;
128
82
  }
129
- ```
130
83
 
131
- Refer to the upstream docs for full API details:
132
- [https://a2ui.org/renderers/](https://a2ui.org/renderers/)
84
+ // GLChat's standard components are already included by Provider.
85
+ // Just register your own additional node types here.
86
+ const registry = ComponentRegistry.getInstance();
87
+ registry.register('MyNodeType', { component: MyNodeComponent as any });
88
+ ```
133
89
 
134
90
  ---
135
91
 
@@ -183,11 +139,12 @@ Import the tokens in your main CSS:
183
139
 
184
140
  ---
185
141
 
186
- # Customizing Colors
142
+ # Customizing Colors (optional)
187
143
 
188
- Override CSS variables after importing `globals.css`:
144
+ The package tokens are declared as plain (unlayered) `:root` rules. To override them, place a plain `:root` block **after** the `globals.css` import in your CSS file. Source order determines the winner when both are unlayered, so your override must come later.
189
145
 
190
146
  ```css
147
+ /* ✅ Works in both Tailwind v3 and v4 */
191
148
  :root {
192
149
  --primary: 220 90% 45%;
193
150
  --background: 0 0% 99%;
@@ -198,6 +155,12 @@ Override CSS variables after importing `globals.css`:
198
155
  }
199
156
  ```
200
157
 
158
+ Button (core variants) uses these tokens by default:
159
+
160
+ - `primary`: `--primary`, `--primary-foreground`, `--ring`
161
+ - `destructive`: `--destructive`, `--destructive-foreground`, `--ring`
162
+ - `outline`: `--background`, `--background-alternate`, `--foreground`, `--border`, `--ring`
163
+
201
164
  You may also extend the theme via:
202
165
 
203
166
  * `tailwind.config.js` (v3)
@@ -207,55 +170,44 @@ You may also extend the theme via:
207
170
 
208
171
  # Exports
209
172
 
210
- ## GLChat wrappers
211
-
212
- * `GlchatA2UIProviderProps`
213
- * `GlchatA2UIRendererProps`
214
-
215
- ## GLChat catalog
173
+ ## Components
216
174
 
217
- * `glchatStandardCatalog` – standard catalog with custom Button, Card, Timeout
175
+ * `Provider`
176
+ * `SingleSurfaceRenderer`
177
+ * `AllSurfacesRenderer`
218
178
 
219
- ## Re-exports from `@a2ui-sdk/react`
220
-
221
- ### Components
222
-
223
- * `A2UIProvider`
224
- * `A2UIRenderer`
225
- * `ComponentRenderer`
226
- * `standardCatalog`
227
-
228
- ### Hooks
229
-
230
- * `useDispatchAction`
231
- * `useDataBinding`
232
- * `useFormBinding`
233
- * `useSurfaceContext`
234
- * `useDataModelContext`
235
- * `useA2UIMessageHandler`
236
-
237
- ### Context
238
-
239
- * `ActionProvider`
240
- * `useActionContext`
241
-
242
- ### Types
179
+ ## Types
243
180
 
181
+ * `ProviderProps`
182
+ * `SingleSurfaceRendererProps`
183
+ * `AllSurfacesRendererProps`
244
184
  * `A2UIMessage`
245
- * `A2UIAction`
246
- * `Action`
247
- * `ValueSource`
248
- * `A2UIProviderProps`
249
- * `A2UIRendererProps`
250
- * `A2UIMessageHandler`
251
-
252
- ### Styles
185
+ * `ActionPayload`
186
+ * `ActionHandler`
187
+
188
+ ## Re-exports from `@a2ui/react`
189
+
190
+ * `Types`
191
+ * `ComponentRegistry`
192
+ * `ComponentNode`
193
+ * `useA2UIComponent`
194
+ * `useA2UI`
195
+ * `classMapToString`
196
+ * `stylesToObject`
197
+ * `A2UIComponentProps`
198
+ * `Theme`
199
+ * `AnyComponentNode`
200
+ * `StringValue`
201
+ * `NumberValue`
202
+ * `BooleanValue`
203
+
204
+ ## Styles
253
205
 
254
206
  * `styles/globals.css`
255
207
  * `styles/theme-v4.css`
256
208
  * `tailwind-config.cjs`
257
209
 
258
- Full documentation:
210
+ Upstream documentation:
259
211
  [https://a2ui.org/renderers/](https://a2ui.org/renderers/)
260
212
 
261
213
  ---
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- export { GlchatA2UIProvider, type GlchatA2UIProviderProps, } from './src/a2ui/GlchatA2UIProvider.js';
2
- export { GlchatA2UIRenderer, type GlchatA2UIRendererProps, } from './src/a2ui/GlchatA2UIRenderer.js';
3
- export { glchatStandardCatalog } from './src/a2ui/glchatStandardCatalog.js';
4
- export * from './src/a2ui/adapter.js';
1
+ export { Provider, type ProviderProps, type A2UIMessage, type ActionPayload, type ActionHandler, } from './src/Provider.js';
2
+ export { SingleSurfaceRenderer, type SingleSurfaceRendererProps, } from './src/SingleSurfaceRenderer.js';
3
+ export { AllSurfacesRenderer, type AllSurfacesRendererProps } from './src/AllSurfacesRenderer.js';
4
+ export { Types, ComponentRegistry, ComponentNode, useA2UIComponent, useA2UI, classMapToString, stylesToObject, type A2UIComponentProps, type Theme, type AnyComponentNode, type StringValue, type NumberValue, type BooleanValue, } from '@a2ui/react';
5
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,kBAAkB,EAClB,KAAK,uBAAuB,GAC7B,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACL,kBAAkB,EAClB,KAAK,uBAAuB,GAC7B,MAAM,kCAAkC,CAAC;AAG1C,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAG5E,cAAc,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,aAAa,GACnB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,qBAAqB,EACrB,KAAK,0BAA0B,GAChC,MAAM,gCAAgC,CAAC;AAExC,OAAO,EAAE,mBAAmB,EAAE,KAAK,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AAGlG,OAAO,EACL,KAAK,EACL,iBAAiB,EACjB,aAAa,EACb,gBAAgB,EAChB,OAAO,EACP,gBAAgB,EAChB,cAAc,EACd,KAAK,kBAAkB,EACvB,KAAK,KAAK,EACV,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,YAAY,GAClB,MAAM,aAAa,CAAC"}
package/dist/index.js CHANGED
@@ -1,7 +1,5 @@
1
- // Wrapper components around @a2ui-sdk/react/0.8 with GLChat defaults
2
- export { GlchatA2UIProvider, } from './src/a2ui/GlchatA2UIProvider.js';
3
- export { GlchatA2UIRenderer, } from './src/a2ui/GlchatA2UIRenderer.js';
4
- // GLChat catalog (extended upstream standard with custom components)
5
- export { glchatStandardCatalog } from './src/a2ui/glchatStandardCatalog.js';
6
- // Re-exports from @a2ui-sdk/react/0.8
7
- export * from './src/a2ui/adapter.js';
1
+ export { Provider, } from './src/Provider.js';
2
+ export { SingleSurfaceRenderer, } from './src/SingleSurfaceRenderer.js';
3
+ export { AllSurfacesRenderer } from './src/AllSurfacesRenderer.js';
4
+ // Re-exports from the official `@a2ui/react`
5
+ export { Types, ComponentRegistry, ComponentNode, useA2UIComponent, useA2UI, classMapToString, stylesToObject, } from '@a2ui/react';
@@ -0,0 +1,14 @@
1
+ import type { ReactNode } from 'react';
2
+ export type AllSurfacesRendererProps = {
3
+ className?: string;
4
+ fallback?: ReactNode;
5
+ loadingFallback?: ReactNode;
6
+ };
7
+ /**
8
+ * Convenience renderer that mounts an `A2UIRenderer` for every known surface.
9
+ *
10
+ * This lets the consumer avoid thinking about `surfaceId` in the simplest case,
11
+ * while still keeping the main provider/renderer separation (provider owns state + onAction).
12
+ */
13
+ export declare function AllSurfacesRenderer(props: Readonly<AllSurfacesRendererProps>): import("react/jsx-runtime").JSX.Element | null;
14
+ //# sourceMappingURL=AllSurfacesRenderer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AllSurfacesRenderer.d.ts","sourceRoot":"","sources":["../../src/AllSurfacesRenderer.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAMvC,MAAM,MAAM,wBAAwB,GAAG;IACrC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,eAAe,CAAC,EAAE,SAAS,CAAC;CAC7B,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,QAAQ,CAAC,wBAAwB,CAAC,kDAsB5E"}
@@ -0,0 +1,18 @@
1
+ 'use client';
2
+ import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import { A2UIRenderer, useA2UI } from '@a2ui/react';
4
+ import { useA2UIRegistry } from './Provider.js';
5
+ /**
6
+ * Convenience renderer that mounts an `A2UIRenderer` for every known surface.
7
+ *
8
+ * This lets the consumer avoid thinking about `surfaceId` in the simplest case,
9
+ * while still keeping the main provider/renderer separation (provider owns state + onAction).
10
+ */
11
+ export function AllSurfacesRenderer(props) {
12
+ const registry = useA2UIRegistry();
13
+ const { getSurfaces } = useA2UI();
14
+ const surfaceIds = Array.from(getSurfaces().keys());
15
+ if (surfaceIds.length === 0)
16
+ return null;
17
+ return (_jsx(_Fragment, { children: surfaceIds.map((surfaceId) => (_jsx(A2UIRenderer, { surfaceId: surfaceId, registry: registry, className: props.className, fallback: props.fallback, loadingFallback: props.loadingFallback }, surfaceId))) }));
18
+ }
@@ -0,0 +1,20 @@
1
+ import type { ReactNode } from 'react';
2
+ import { ComponentRegistry, type A2UIActionEvent, type ServerToClientMessage } from '@a2ui/react';
3
+ import type { Theme } from '@a2ui/web_core/types/types';
4
+ export type A2UIMessage = ServerToClientMessage;
5
+ export type ActionPayload = A2UIActionEvent;
6
+ export type ActionHandler = (action: ActionPayload) => void | Promise<void>;
7
+ export type ProviderProps = {
8
+ messages?: A2UIMessage[];
9
+ theme?: Theme;
10
+ onAction?: ActionHandler;
11
+ children: ReactNode;
12
+ /**
13
+ * Optional registry override.
14
+ * If not provided, the official singleton registry is used.
15
+ */
16
+ registry?: ComponentRegistry;
17
+ };
18
+ export declare function Provider(props: Readonly<ProviderProps>): import("react/jsx-runtime").JSX.Element;
19
+ export declare function useA2UIRegistry(): ComponentRegistry;
20
+ //# sourceMappingURL=Provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["../../src/Provider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvC,OAAO,EAEL,iBAAiB,EAGjB,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAC3B,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAKxD,MAAM,MAAM,WAAW,GAAG,qBAAqB,CAAC;AAEhD,MAAM,MAAM,aAAa,GAAG,eAAe,CAAC;AAC5C,MAAM,MAAM,aAAa,GAAG,CAAC,MAAM,EAAE,aAAa,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAE5E,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,CAAC,EAAE,WAAW,EAAE,CAAC;IACzB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,QAAQ,CAAC,EAAE,aAAa,CAAC;IACzB,QAAQ,EAAE,SAAS,CAAC;IACpB;;;OAGG;IACH,QAAQ,CAAC,EAAE,iBAAiB,CAAC;CAC9B,CAAC;AAeF,wBAAgB,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,aAAa,CAAC,2CA2CtD;AAED,wBAAgB,eAAe,IAAI,iBAAiB,CAInD"}
@@ -0,0 +1,50 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { createContext, useCallback, useContext, useEffect, useMemo, useRef } from 'react';
4
+ import { A2UIProvider, ComponentRegistry, useA2UI, } from '@a2ui/react';
5
+ import { ensureGlchatComponentsRegistered } from './utils/catalog.js';
6
+ import { mergeGlchatTheme } from './utils/theme.js';
7
+ const A2UIRegistryContext = createContext(null);
8
+ function MessagesProcessor({ messages }) {
9
+ const { processMessages } = useA2UI();
10
+ useEffect(() => {
11
+ if (!messages)
12
+ return;
13
+ processMessages(messages);
14
+ }, [messages, processMessages]);
15
+ return null;
16
+ }
17
+ export function Provider(props) {
18
+ const registry = useMemo(() => props.registry ?? ComponentRegistry.getInstance(), [props.registry]);
19
+ const providerOnActionRef = useRef(props.onAction);
20
+ useEffect(() => {
21
+ providerOnActionRef.current = props.onAction;
22
+ }, [props.onAction]);
23
+ const onAction = useCallback((event) => {
24
+ const userAction = event?.userAction;
25
+ if (!userAction)
26
+ return;
27
+ const handler = providerOnActionRef.current;
28
+ if (!handler)
29
+ return;
30
+ handler({
31
+ actionName: userAction.name,
32
+ sourceComponentId: userAction.sourceComponentId,
33
+ timestamp: userAction.timestamp,
34
+ context: userAction.context ?? {},
35
+ });
36
+ }, []);
37
+ // Register (or override) components after `@a2ui/react` has initialized its defaults.
38
+ // This avoids the official default catalog overwriting our custom component registrations.
39
+ useEffect(() => {
40
+ ensureGlchatComponentsRegistered(registry);
41
+ }, [registry]);
42
+ const theme = useMemo(() => mergeGlchatTheme(props.theme), [props.theme]);
43
+ return (_jsx(A2UIRegistryContext.Provider, { value: registry, children: _jsxs(A2UIProvider, { onAction: onAction, theme: theme, children: [_jsx(MessagesProcessor, { messages: props.messages }), props.children] }) }));
44
+ }
45
+ export function useA2UIRegistry() {
46
+ const registry = useContext(A2UIRegistryContext);
47
+ if (!registry)
48
+ throw new Error('useA2UIRegistry must be used inside Provider');
49
+ return registry;
50
+ }
@@ -0,0 +1,15 @@
1
+ import type { ReactNode } from 'react';
2
+ import { type ComponentRegistry } from '@a2ui/react';
3
+ export type SingleSurfaceRendererProps = {
4
+ /**
5
+ * Surface ID to render.
6
+ * `@a2ui/react` requires this; we default to `main` for compatibility.
7
+ */
8
+ surfaceId?: string;
9
+ className?: string;
10
+ fallback?: ReactNode;
11
+ loadingFallback?: ReactNode;
12
+ registry?: ComponentRegistry;
13
+ };
14
+ export declare function SingleSurfaceRenderer(props: Readonly<SingleSurfaceRendererProps>): import("react/jsx-runtime").JSX.Element;
15
+ //# sourceMappingURL=SingleSurfaceRenderer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SingleSurfaceRenderer.d.ts","sourceRoot":"","sources":["../../src/SingleSurfaceRenderer.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,EAAgB,KAAK,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAInE,MAAM,MAAM,0BAA0B,GAAG;IACvC;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,eAAe,CAAC,EAAE,SAAS,CAAC;IAC5B,QAAQ,CAAC,EAAE,iBAAiB,CAAC;CAC9B,CAAC;AAEF,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,QAAQ,CAAC,0BAA0B,CAAC,2CAahF"}
@@ -0,0 +1,9 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { A2UIRenderer } from '@a2ui/react';
4
+ import { useA2UIRegistry } from './Provider.js';
5
+ export function SingleSurfaceRenderer(props) {
6
+ const registryFromCtx = useA2UIRegistry();
7
+ const registry = props.registry ?? registryFromCtx;
8
+ return (_jsx(A2UIRenderer, { surfaceId: props.surfaceId ?? 'main', registry: registry, className: props.className, fallback: props.fallback, loadingFallback: props.loadingFallback }));
9
+ }
@@ -0,0 +1,4 @@
1
+ import { type A2UIComponentProps } from '@a2ui/react';
2
+ import type { ButtonNode } from '@a2ui/web_core/types/types';
3
+ export declare function CustomButtonComponent({ node, surfaceId, }: Readonly<A2UIComponentProps<ButtonNode>>): import("react/jsx-runtime").JSX.Element;
4
+ //# sourceMappingURL=Button.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../../src/components/Button/Button.tsx"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,kBAAkB,EACxB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,UAAU,EAAkB,MAAM,4BAA4B,CAAC;AAW7E,wBAAgB,qBAAqB,CAAC,EACpC,IAAI,EACJ,SAAS,GACV,EAAE,QAAQ,CAAC,kBAAkB,CAAC,UAAU,CAAC,CAAC,2CAyC1C"}
@@ -0,0 +1,27 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { ComponentNode, classMapToString, stylesToObject, useA2UIComponent, } from '@a2ui/react';
3
+ import { useMemo } from 'react';
4
+ import { getGlchatButtonVariantStyles } from './theme';
5
+ export function CustomButtonComponent({ node, surfaceId, }) {
6
+ const { sendAction, theme } = useA2UIComponent(node, surfaceId);
7
+ const nodeProps = node.properties;
8
+ const { child, action, primary, destructive } = nodeProps;
9
+ const variant = useMemo(() => {
10
+ if (primary)
11
+ return 'primary';
12
+ if (destructive)
13
+ return 'destructive';
14
+ return 'outline';
15
+ }, [primary, destructive]);
16
+ const buttonStyle = useMemo(() => ({
17
+ ...stylesToObject(theme.additionalStyles?.Button),
18
+ ...getGlchatButtonVariantStyles(variant),
19
+ }), [theme.additionalStyles?.Button, variant]);
20
+ const handleClick = () => {
21
+ if (action) {
22
+ sendAction(action);
23
+ }
24
+ };
25
+ const hostStyle = node.weight === void 0 ? undefined : { '--weight': node.weight };
26
+ return (_jsx("div", { className: "a2ui-button", style: hostStyle, children: _jsx("button", { type: "button", className: `glchat-a2ui-button ${classMapToString(theme.components.Button)}`, style: buttonStyle, onClick: handleClick, children: child ? _jsx(ComponentNode, { node: child, surfaceId: surfaceId }) : null }) }));
27
+ }
@@ -0,0 +1,14 @@
1
+ import type { CSSProperties } from 'react';
2
+ import type { Theme } from '@a2ui/web_core/types/types';
3
+ export type GlchatButtonVariant = 'primary' | 'destructive' | 'outline';
4
+ /**
5
+ * Button structural class map.
6
+ */
7
+ export declare const glchatButtonComponents: Theme['components']['Button'];
8
+ /**
9
+ * Button inline styles aligned with package CSS tokens.
10
+ * Variant colors are layered in runtime via `getGlchatButtonVariantStyles`.
11
+ */
12
+ export declare const glchatButtonAdditionalStyles: NonNullable<Theme['additionalStyles']>['Button'];
13
+ export declare function getGlchatButtonVariantStyles(variant: GlchatButtonVariant): CSSProperties;
14
+ //# sourceMappingURL=theme.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../../src/components/Button/theme.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAExD,MAAM,MAAM,mBAAmB,GAAG,SAAS,GAAG,aAAa,GAAG,SAAS,CAAC;AAExE;;GAEG;AACH,eAAO,MAAM,sBAAsB,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC,QAAQ,CAAM,CAAC;AAExE;;;GAGG;AACH,eAAO,MAAM,4BAA4B,EAAE,WAAW,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC,CAAC,QAAQ,CAiB/D,CAAC;AAE5B,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,mBAAmB,GAAG,aAAa,CAwCxF"}
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Button structural class map.
3
+ */
4
+ export const glchatButtonComponents = {};
5
+ /**
6
+ * Button inline styles aligned with package CSS tokens.
7
+ * Variant colors are layered in runtime via `getGlchatButtonVariantStyles`.
8
+ */
9
+ export const glchatButtonAdditionalStyles = {
10
+ display: 'inline-flex',
11
+ alignItems: 'center',
12
+ justifyContent: 'center',
13
+ whiteSpace: 'nowrap',
14
+ borderWidth: '1px',
15
+ borderStyle: 'solid',
16
+ borderRadius: '10px',
17
+ fontWeight: '600',
18
+ fontSize: '1rem',
19
+ lineHeight: '1.5rem',
20
+ padding: '10px 16px',
21
+ cursor: 'pointer',
22
+ transitionProperty: 'color, background-color, background-image, border-color, box-shadow',
23
+ transitionTimingFunction: 'cubic-bezier(0.4, 0, 0.2, 1)',
24
+ transitionDuration: '150ms',
25
+ '--glchat-button-ring-color': 'hsl(var(--ring))',
26
+ };
27
+ export function getGlchatButtonVariantStyles(variant) {
28
+ if (variant === 'primary') {
29
+ return {
30
+ backgroundColor: 'hsl(var(--primary))',
31
+ borderColor: 'hsl(var(--primary))',
32
+ color: 'hsl(var(--primary-foreground))',
33
+ '--glchat-button-bg-hover': 'linear-gradient(hsla(var(--hover)), hsla(var(--hover))), linear-gradient(hsl(var(--primary)), hsl(var(--primary)))',
34
+ '--glchat-button-border-hover': 'hsl(var(--primary))',
35
+ '--glchat-button-bg-active': 'linear-gradient(hsla(var(--hover)), hsla(var(--hover))), linear-gradient(hsl(var(--primary)), hsl(var(--primary)))',
36
+ '--glchat-button-border-active': 'hsl(var(--primary))',
37
+ };
38
+ }
39
+ if (variant === 'destructive') {
40
+ return {
41
+ backgroundColor: 'hsl(var(--destructive))',
42
+ borderColor: 'hsl(var(--destructive))',
43
+ color: 'hsl(var(--destructive-foreground))',
44
+ '--glchat-button-bg-hover': 'linear-gradient(hsla(var(--hover)), hsla(var(--hover))), linear-gradient(hsl(var(--destructive)), hsl(var(--destructive)))',
45
+ '--glchat-button-border-hover': 'hsl(var(--destructive))',
46
+ '--glchat-button-bg-active': 'linear-gradient(hsla(var(--hover)), hsla(var(--hover))), linear-gradient(hsl(var(--destructive)), hsl(var(--destructive)))',
47
+ '--glchat-button-border-active': 'hsl(var(--destructive))',
48
+ };
49
+ }
50
+ return {
51
+ backgroundColor: 'hsl(var(--background))',
52
+ borderColor: 'hsl(var(--border))',
53
+ color: 'hsl(var(--foreground))',
54
+ '--glchat-button-bg-hover': 'linear-gradient(hsla(var(--hover)), hsla(var(--hover))), linear-gradient(hsl(var(--background)), hsl(var(--background)))',
55
+ '--glchat-button-border-hover': 'hsl(var(--border))',
56
+ '--glchat-button-bg-active': 'linear-gradient(hsla(var(--hover)), hsla(var(--hover))), linear-gradient(hsl(var(--background)), hsl(var(--background)))',
57
+ '--glchat-button-border-active': 'hsl(var(--border))',
58
+ };
59
+ }
@@ -0,0 +1,4 @@
1
+ import { type A2UIComponentProps } from '@a2ui/react';
2
+ import type { CardNode } from '@a2ui/web_core/types/types';
3
+ export declare function CustomCardComponent({ node, surfaceId }: Readonly<A2UIComponentProps<CardNode>>): import("react/jsx-runtime").JSX.Element;
4
+ //# sourceMappingURL=Card.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Card.d.ts","sourceRoot":"","sources":["../../../../src/components/Card/Card.tsx"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,kBAAkB,EACxB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAG3D,wBAAgB,mBAAmB,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,QAAQ,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC,2CA2B9F"}
@@ -0,0 +1,16 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { ComponentNode, classMapToString, stylesToObject, useA2UIComponent, } from '@a2ui/react';
3
+ export function CustomCardComponent({ node, surfaceId }) {
4
+ const { theme } = useA2UIComponent(node, surfaceId);
5
+ const props = node.properties;
6
+ const rawChildren = props.children ?? (props.child ? [props.child] : []);
7
+ const children = Array.isArray(rawChildren) ? rawChildren : [];
8
+ const hostStyle = node.weight === void 0 ? undefined : { '--weight': node.weight };
9
+ return (_jsx("div", { className: "a2ui-card", style: hostStyle, children: _jsx("section", { className: classMapToString(theme.components.Card), style: stylesToObject(theme.additionalStyles?.Card), children: children.map((child, index) => {
10
+ const childId = typeof child === 'object' && child !== null && 'id' in child
11
+ ? child.id
12
+ : `child-${index}`;
13
+ const childNode = typeof child === 'object' && child !== null && 'type' in child ? child : null;
14
+ return _jsx(ComponentNode, { node: childNode, surfaceId: surfaceId }, childId);
15
+ }) }) }));
16
+ }
@@ -0,0 +1,10 @@
1
+ import type { Theme } from '@a2ui/web_core/types/types';
2
+ /**
3
+ * Card structural layout classes.
4
+ */
5
+ export declare const glchatCardComponents: Theme['components']['Card'];
6
+ /**
7
+ * Card inline styles aligned with package CSS tokens.
8
+ */
9
+ export declare const glchatCardAdditionalStyles: NonNullable<Theme['additionalStyles']>['Card'];
10
+ //# sourceMappingURL=theme.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../../src/components/Card/theme.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAExD;;GAEG;AACH,eAAO,MAAM,oBAAoB,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC,MAAM,CAE5D,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,0BAA0B,EAAE,WAAW,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC,CAAC,MAAM,CAWrF,CAAC"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Card structural layout classes.
3
+ */
4
+ export const glchatCardComponents = {
5
+ 'layout-p-4': true,
6
+ };
7
+ /**
8
+ * Card inline styles aligned with package CSS tokens.
9
+ */
10
+ export const glchatCardAdditionalStyles = {
11
+ backgroundColor: 'hsl(var(--card))',
12
+ color: 'hsl(var(--card-foreground))',
13
+ borderColor: 'hsl(var(--border))',
14
+ borderWidth: '1px',
15
+ borderStyle: 'solid',
16
+ borderRadius: 'var(--radius)',
17
+ boxShadow: '0 1px 2px 0 rgb(0 0 0 / 0.05)',
18
+ transitionProperty: 'color, background-color, border-color, box-shadow',
19
+ transitionTimingFunction: 'cubic-bezier(0.4, 0, 0.2, 1)',
20
+ transitionDuration: '300ms',
21
+ };
@@ -0,0 +1,4 @@
1
+ import { type A2UIComponentProps } from '@a2ui/react';
2
+ import type { CustomNode } from '@a2ui/web_core/types/types';
3
+ export declare function CustomTimeoutComponent({ node, surfaceId, }: Readonly<A2UIComponentProps<CustomNode>>): import("react/jsx-runtime").JSX.Element;
4
+ //# sourceMappingURL=Timeout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Timeout.d.ts","sourceRoot":"","sources":["../../../../src/components/Timeout/Timeout.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,kBAAkB,EAExB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAM7D,wBAAgB,sBAAsB,CAAC,EACrC,IAAI,EACJ,SAAS,GACV,EAAE,QAAQ,CAAC,kBAAkB,CAAC,UAAU,CAAC,CAAC,2CAwC1C"}