@a2ui-sdk/react 0.2.2 → 0.3.0

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 CHANGED
@@ -221,6 +221,10 @@ import {
221
221
  useScope,
222
222
  useScopeBasePath,
223
223
 
224
+ // Context Providers & Hooks
225
+ ActionProvider,
226
+ useActionContext,
227
+
224
228
  // Types
225
229
  type A2UIMessage,
226
230
  type A2UIAction,
@@ -265,6 +269,10 @@ import {
265
269
  useScope,
266
270
  useScopeBasePath,
267
271
 
272
+ // Context Providers & Hooks
273
+ ActionProvider,
274
+ useActionContext,
275
+
268
276
  // Types
269
277
  type A2UIMessage,
270
278
  type A2UIAction,
@@ -332,6 +340,46 @@ const { valid, errors } = useValidation(checks)
332
340
  // errors: string[] - list of failed validation messages
333
341
  ```
334
342
 
343
+ ### ActionProvider & useActionContext
344
+
345
+ For advanced use cases, you can create custom action handling middleware by using `ActionProvider` and `useActionContext` directly. This is useful when you need to intercept, transform, or augment actions before they reach your action handler.
346
+
347
+ ```tsx
348
+ import {
349
+ A2UIProvider,
350
+ A2UIRenderer,
351
+ ActionProvider,
352
+ useActionContext,
353
+ } from '@a2ui-sdk/react/0.9'
354
+
355
+ function ActionLogger({ children }: { children: React.ReactNode }) {
356
+ const { onAction } = useActionContext()
357
+
358
+ // You can access the action handler here
359
+ // and potentially wrap it with logging or other middleware logic
360
+
361
+ return <>{children}</>
362
+ }
363
+
364
+ function App() {
365
+ const handleAction = (action: A2UIAction) => {
366
+ console.log('Action:', action)
367
+ }
368
+
369
+ return (
370
+ <A2UIProvider messages={messages}>
371
+ <ActionProvider onAction={handleAction}>
372
+ <ActionLogger>
373
+ <A2UIRenderer />
374
+ </ActionLogger>
375
+ </ActionProvider>
376
+ </A2UIProvider>
377
+ )
378
+ }
379
+ ```
380
+
381
+ **Note:** In most cases, you don't need to use `ActionProvider` directly as `A2UIProvider` already includes it. Use this only for advanced customization scenarios.
382
+
335
383
  ## License
336
384
 
337
385
  Apache-2.0
@@ -44,3 +44,4 @@ export { useDispatchAction } from './hooks/useDispatchAction';
44
44
  export { useDataBinding, useFormBinding } from './hooks/useDataBinding';
45
45
  export { useSurfaceContext } from './contexts/SurfaceContext';
46
46
  export { useDataModelContext } from './contexts/DataModelContext';
47
+ export { ActionProvider, useActionContext } from './contexts/ActionContext';
package/dist/0.8/index.js CHANGED
@@ -1,19 +1,22 @@
1
1
  import { A2UIProvider as r } from "./contexts/A2UIProvider.js";
2
2
  import { A2UIRenderer as n } from "./A2UIRenderer.js";
3
3
  import { ComponentRenderer as m } from "./components/ComponentRenderer.js";
4
- import { standardCatalog as x } from "./standard-catalog/index.js";
5
- import { useDispatchAction as d } from "./hooks/useDispatchAction.js";
4
+ import { standardCatalog as a } from "./standard-catalog/index.js";
5
+ import { useDispatchAction as i } from "./hooks/useDispatchAction.js";
6
6
  import { useDataBinding as s, useFormBinding as u } from "./hooks/useDataBinding.js";
7
- import { useSurfaceContext as c } from "./contexts/SurfaceContext.js";
8
- import { useDataModelContext as A } from "./contexts/DataModelContext.js";
7
+ import { useSurfaceContext as A } from "./contexts/SurfaceContext.js";
8
+ import { useDataModelContext as g } from "./contexts/DataModelContext.js";
9
+ import { ActionProvider as l, useActionContext as v } from "./contexts/ActionContext.js";
9
10
  export {
10
11
  r as A2UIProvider,
11
12
  n as A2UIRenderer,
13
+ l as ActionProvider,
12
14
  m as ComponentRenderer,
13
- x as standardCatalog,
15
+ a as standardCatalog,
16
+ v as useActionContext,
14
17
  s as useDataBinding,
15
- A as useDataModelContext,
16
- d as useDispatchAction,
18
+ g as useDataModelContext,
19
+ i as useDispatchAction,
17
20
  u as useFormBinding,
18
- c as useSurfaceContext
21
+ A as useSurfaceContext
19
22
  };
@@ -34,3 +34,4 @@ export { useDataBinding, useFormBinding, useStringBinding, useDataModel, } from
34
34
  export { useValidation } from './hooks/useValidation';
35
35
  export { useSurfaceContext } from './contexts/SurfaceContext';
36
36
  export { useScope, useScopeBasePath } from './contexts/ScopeContext';
37
+ export { ActionProvider, useActionContext } from './contexts/ActionContext';
package/dist/0.9/index.js CHANGED
@@ -1,24 +1,27 @@
1
1
  import { A2UIProvider as r } from "./contexts/A2UIProvider.js";
2
2
  import { A2UIRenderer as n } from "./A2UIRenderer.js";
3
- import { ComponentRenderer as p } from "./components/ComponentRenderer.js";
3
+ import { ComponentRenderer as a } from "./components/ComponentRenderer.js";
4
4
  import { standardCatalog as s } from "./standard-catalog/index.js";
5
- import { useDispatchAction as d } from "./hooks/useDispatchAction.js";
6
- import { useDataBinding as u, useDataModel as x, useFormBinding as c, useStringBinding as g } from "./hooks/useDataBinding.js";
7
- import { useValidation as S } from "./hooks/useValidation.js";
8
- import { useSurfaceContext as A } from "./contexts/SurfaceContext.js";
9
- import { useScope as D, useScopeBasePath as h } from "./contexts/ScopeContext.js";
5
+ import { useDispatchAction as x } from "./hooks/useDispatchAction.js";
6
+ import { useDataBinding as f, useDataModel as u, useFormBinding as c, useStringBinding as g } from "./hooks/useDataBinding.js";
7
+ import { useValidation as B } from "./hooks/useValidation.js";
8
+ import { useSurfaceContext as S } from "./contexts/SurfaceContext.js";
9
+ import { useScope as D, useScopeBasePath as P } from "./contexts/ScopeContext.js";
10
+ import { ActionProvider as v, useActionContext as I } from "./contexts/ActionContext.js";
10
11
  export {
11
12
  r as A2UIProvider,
12
13
  n as A2UIRenderer,
13
- p as ComponentRenderer,
14
+ v as ActionProvider,
15
+ a as ComponentRenderer,
14
16
  s as standardCatalog,
15
- u as useDataBinding,
16
- x as useDataModel,
17
- d as useDispatchAction,
17
+ I as useActionContext,
18
+ f as useDataBinding,
19
+ u as useDataModel,
20
+ x as useDispatchAction,
18
21
  c as useFormBinding,
19
22
  D as useScope,
20
- h as useScopeBasePath,
23
+ P as useScopeBasePath,
21
24
  g as useStringBinding,
22
- A as useSurfaceContext,
23
- S as useValidation
25
+ S as useSurfaceContext,
26
+ B as useValidation
24
27
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@a2ui-sdk/react",
3
- "version": "0.2.2",
3
+ "version": "0.3.0",
4
4
  "description": "A2UI SDK for React",
5
5
  "homepage": "https://a2ui-sdk.js.org/",
6
6
  "repository": {
@@ -66,8 +66,8 @@
66
66
  "vitest": "^4.0.16"
67
67
  },
68
68
  "dependencies": {
69
- "@a2ui-sdk/types": "0.2.2",
70
- "@a2ui-sdk/utils": "0.2.2",
69
+ "@a2ui-sdk/types": "0.3.0",
70
+ "@a2ui-sdk/utils": "0.3.0",
71
71
  "@radix-ui/react-checkbox": "^1.3.3",
72
72
  "@radix-ui/react-dialog": "^1.1.15",
73
73
  "@radix-ui/react-label": "^2.1.8",