@a2ui-sdk/react 0.1.0 → 0.2.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.
Files changed (99) hide show
  1. package/dist/0.8/components/ComponentRenderer.d.ts +1 -19
  2. package/dist/0.8/components/ComponentRenderer.js +21 -63
  3. package/dist/0.8/components/UnknownComponent.d.ts +3 -3
  4. package/dist/0.8/components/display/AudioPlayerComponent.d.ts +3 -2
  5. package/dist/0.8/components/display/DividerComponent.d.ts +3 -2
  6. package/dist/0.8/components/display/IconComponent.d.ts +3 -2
  7. package/dist/0.8/components/display/ImageComponent.d.ts +3 -2
  8. package/dist/0.8/components/display/TextComponent.d.ts +3 -2
  9. package/dist/0.8/components/display/VideoComponent.d.ts +3 -2
  10. package/dist/0.8/components/display/index.d.ts +1 -1
  11. package/dist/0.8/components/index.d.ts +2 -2
  12. package/dist/0.8/components/interactive/ButtonComponent.d.ts +3 -2
  13. package/dist/0.8/components/interactive/CheckBoxComponent.d.ts +3 -2
  14. package/dist/0.8/components/interactive/DateTimeInputComponent.d.ts +3 -2
  15. package/dist/0.8/components/interactive/MultipleChoiceComponent.d.ts +3 -2
  16. package/dist/0.8/components/interactive/SliderComponent.d.ts +3 -2
  17. package/dist/0.8/components/interactive/TextFieldComponent.d.ts +3 -2
  18. package/dist/0.8/components/interactive/index.d.ts +1 -1
  19. package/dist/0.8/components/layout/CardComponent.d.ts +3 -2
  20. package/dist/0.8/components/layout/ColumnComponent.d.ts +3 -2
  21. package/dist/0.8/components/layout/ListComponent.d.ts +3 -2
  22. package/dist/0.8/components/layout/ModalComponent.d.ts +3 -2
  23. package/dist/0.8/components/layout/RowComponent.d.ts +3 -2
  24. package/dist/0.8/components/layout/TabsComponent.d.ts +3 -2
  25. package/dist/0.8/components/layout/index.d.ts +1 -1
  26. package/dist/0.8/components/types.d.ts +8 -0
  27. package/dist/0.8/contexts/A2UIProvider.d.ts +37 -23
  28. package/dist/0.8/contexts/A2UIProvider.js +16 -22
  29. package/dist/0.8/contexts/ActionContext.js +5 -5
  30. package/dist/0.8/contexts/ComponentsMapContext.d.ts +8 -21
  31. package/dist/0.8/contexts/ComponentsMapContext.js +12 -16
  32. package/dist/0.8/contexts/DataModelContext.js +3 -3
  33. package/dist/0.8/index.d.ts +5 -3
  34. package/dist/0.8/index.js +11 -9
  35. package/dist/0.8/standard-catalog/index.d.ts +57 -0
  36. package/dist/0.8/standard-catalog/index.js +66 -0
  37. package/dist/0.9/A2UIRenderer.d.ts +9 -29
  38. package/dist/0.9/A2UIRenderer.js +27 -26
  39. package/dist/0.9/components/ComponentRenderer.d.ts +5 -19
  40. package/dist/0.9/components/ComponentRenderer.js +30 -17
  41. package/dist/0.9/components/UnknownComponent.d.ts +8 -2
  42. package/dist/0.9/components/UnknownComponent.js +13 -11
  43. package/dist/0.9/components/display/AudioPlayerComponent.d.ts +3 -2
  44. package/dist/0.9/components/display/AudioPlayerComponent.js +16 -14
  45. package/dist/0.9/components/display/DividerComponent.d.ts +3 -2
  46. package/dist/0.9/components/display/DividerComponent.js +4 -5
  47. package/dist/0.9/components/display/IconComponent.d.ts +3 -2
  48. package/dist/0.9/components/display/IconComponent.js +12 -12
  49. package/dist/0.9/components/display/ImageComponent.d.ts +3 -2
  50. package/dist/0.9/components/display/ImageComponent.js +18 -15
  51. package/dist/0.9/components/display/TextComponent.d.ts +3 -2
  52. package/dist/0.9/components/display/TextComponent.js +10 -8
  53. package/dist/0.9/components/display/VideoComponent.d.ts +3 -2
  54. package/dist/0.9/components/display/VideoComponent.js +7 -6
  55. package/dist/0.9/components/index.d.ts +4 -8
  56. package/dist/0.9/components/interactive/ButtonComponent.d.ts +3 -2
  57. package/dist/0.9/components/interactive/ButtonComponent.js +25 -20
  58. package/dist/0.9/components/interactive/CheckBoxComponent.d.ts +3 -2
  59. package/dist/0.9/components/interactive/CheckBoxComponent.js +33 -29
  60. package/dist/0.9/components/interactive/ChoicePickerComponent.d.ts +3 -2
  61. package/dist/0.9/components/interactive/ChoicePickerComponent.js +59 -53
  62. package/dist/0.9/components/interactive/DateTimeInputComponent.d.ts +3 -2
  63. package/dist/0.9/components/interactive/DateTimeInputComponent.js +32 -26
  64. package/dist/0.9/components/interactive/SliderComponent.d.ts +3 -2
  65. package/dist/0.9/components/interactive/SliderComponent.js +38 -32
  66. package/dist/0.9/components/interactive/TextFieldComponent.d.ts +3 -2
  67. package/dist/0.9/components/interactive/TextFieldComponent.js +41 -40
  68. package/dist/0.9/components/layout/CardComponent.d.ts +3 -2
  69. package/dist/0.9/components/layout/CardComponent.js +11 -10
  70. package/dist/0.9/components/layout/ColumnComponent.d.ts +3 -2
  71. package/dist/0.9/components/layout/ColumnComponent.js +26 -23
  72. package/dist/0.9/components/layout/ListComponent.d.ts +3 -2
  73. package/dist/0.9/components/layout/ListComponent.js +30 -27
  74. package/dist/0.9/components/layout/ModalComponent.d.ts +3 -2
  75. package/dist/0.9/components/layout/ModalComponent.js +11 -22
  76. package/dist/0.9/components/layout/RowComponent.d.ts +3 -2
  77. package/dist/0.9/components/layout/RowComponent.js +31 -28
  78. package/dist/0.9/components/layout/TabsComponent.d.ts +3 -2
  79. package/dist/0.9/components/layout/TabsComponent.js +21 -21
  80. package/dist/0.9/components/types.d.ts +8 -0
  81. package/dist/0.9/contexts/A2UIProvider.d.ts +45 -28
  82. package/dist/0.9/contexts/A2UIProvider.js +18 -26
  83. package/dist/0.9/contexts/ActionContext.js +5 -5
  84. package/dist/0.9/contexts/ComponentsMapContext.d.ts +8 -31
  85. package/dist/0.9/contexts/ComponentsMapContext.js +12 -16
  86. package/dist/0.9/contexts/ScopeContext.js +3 -3
  87. package/dist/0.9/contexts/SurfaceContext.d.ts +3 -3
  88. package/dist/0.9/contexts/SurfaceContext.js +3 -3
  89. package/dist/0.9/hooks/useComponent.d.ts +2 -2
  90. package/dist/0.9/hooks/useDataBinding.js +3 -3
  91. package/dist/0.9/index.d.ts +6 -4
  92. package/dist/0.9/index.js +12 -10
  93. package/dist/0.9/standard-catalog/index.d.ts +61 -0
  94. package/dist/0.9/standard-catalog/index.js +69 -0
  95. package/dist/components/ui/button.d.ts +1 -1
  96. package/dist/lib/utils.d.ts +5 -0
  97. package/dist/lib/utils.js +6 -4
  98. package/package.json +14 -5
  99. package/dist/0.9/components/index.js +0 -68
@@ -1,21 +1,17 @@
1
- import { jsx as s } from "react/jsx-runtime";
2
- import { createContext as u, useMemo as p } from "react";
3
- const c = u(null);
4
- function x({
5
- components: n,
6
- defaultComponents: e,
1
+ import { jsx as n } from "react/jsx-runtime";
2
+ import { createContext as m, useMemo as i } from "react";
3
+ import { hasOwn as p } from "../../lib/utils.js";
4
+ const u = m(null);
5
+ function v({
6
+ components: o,
7
7
  children: r
8
8
  }) {
9
- const m = p(() => {
10
- const o = n ?? /* @__PURE__ */ new Map();
11
- return {
12
- customComponents: o,
13
- getComponent: (t) => o.has(t) ? o.get(t) : e[t]
14
- };
15
- }, [n, e]);
16
- return /* @__PURE__ */ s(c.Provider, { value: m, children: r });
9
+ const e = i(() => ({
10
+ getComponent: (t) => p(o, t) ? o[t] : void 0
11
+ }), [o]);
12
+ return /* @__PURE__ */ n(u.Provider, { value: e, children: r });
17
13
  }
18
14
  export {
19
- c as ComponentsMapContext,
20
- x as ComponentsMapProvider
15
+ u as ComponentsMapContext,
16
+ v as ComponentsMapProvider
21
17
  };
@@ -1,7 +1,7 @@
1
1
  import { jsx as C } from "react/jsx-runtime";
2
- import { createContext as P, useContext as f, useState as V, useCallback as a, useMemo as v } from "react";
2
+ import { useContext as P, createContext as f, useState as V, useCallback as a, useMemo as v } from "react";
3
3
  import { mergeAtPath as b, getValueByPath as y, setValueByPath as B } from "@a2ui-sdk/utils/0.8";
4
- const g = P(
4
+ const g = f(
5
5
  null
6
6
  );
7
7
  function E({ children: u }) {
@@ -72,7 +72,7 @@ function E({ children: u }) {
72
72
  return /* @__PURE__ */ C(g.Provider, { value: h, children: u });
73
73
  }
74
74
  function S() {
75
- const u = f(g);
75
+ const u = P(g);
76
76
  if (!u)
77
77
  throw new Error(
78
78
  "useDataModelContext must be used within a DataModelProvider"
@@ -1,7 +1,7 @@
1
1
  /**
2
- * A2UI React Renderer - Public API
2
+ * A2UI SDK for React - Public API
3
3
  *
4
- * This is the main entry point for the A2UI React renderer library.
4
+ * This is the main entry point for the A2UI SDK for React.
5
5
  * Import from '@a2ui-sdk/react/0.8'
6
6
  *
7
7
  * @example
@@ -33,11 +33,13 @@
33
33
  * ```
34
34
  */
35
35
  export type { A2UIMessage, ActionPayload as A2UIAction, Action, ValueSource, } from '@a2ui-sdk/types/0.8';
36
- export type { A2UIProviderProps, ComponentsMap } from './contexts/A2UIProvider';
36
+ export type { A2UIProviderProps } from './contexts/A2UIProvider';
37
37
  export type { A2UIRendererProps } from './A2UIRenderer';
38
+ export type { Catalog, CatalogComponent, CatalogComponents, CatalogFunctions, } from './standard-catalog';
38
39
  export { A2UIProvider } from './contexts/A2UIProvider';
39
40
  export { A2UIRenderer } from './A2UIRenderer';
40
41
  export { ComponentRenderer } from './components/ComponentRenderer';
42
+ export { standardCatalog } from './standard-catalog';
41
43
  export { useDispatchAction } from './hooks/useDispatchAction';
42
44
  export { useDataBinding, useFormBinding } from './hooks/useDataBinding';
43
45
  export { useSurfaceContext } from './contexts/SurfaceContext';
package/dist/0.8/index.js CHANGED
@@ -1,17 +1,19 @@
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";
4
- import { useDispatchAction as f } from "./hooks/useDispatchAction.js";
5
- import { useDataBinding as a, useFormBinding as d } from "./hooks/useDataBinding.js";
6
- import { useSurfaceContext as u } from "./contexts/SurfaceContext.js";
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";
6
+ import { useDataBinding as s, useFormBinding as u } from "./hooks/useDataBinding.js";
7
+ import { useSurfaceContext as c } from "./contexts/SurfaceContext.js";
7
8
  import { useDataModelContext as A } from "./contexts/DataModelContext.js";
8
9
  export {
9
10
  r as A2UIProvider,
10
11
  n as A2UIRenderer,
11
- p as ComponentRenderer,
12
- a as useDataBinding,
12
+ m as ComponentRenderer,
13
+ x as standardCatalog,
14
+ s as useDataBinding,
13
15
  A as useDataModelContext,
14
- f as useDispatchAction,
15
- d as useFormBinding,
16
- u as useSurfaceContext
16
+ d as useDispatchAction,
17
+ u as useFormBinding,
18
+ c as useSurfaceContext
17
19
  };
@@ -0,0 +1,57 @@
1
+ import { ComponentType } from 'react';
2
+ import { TextComponent, ImageComponent, IconComponent, VideoComponent, AudioPlayerComponent, DividerComponent } from '../components/display';
3
+ import { RowComponent, ColumnComponent, ListComponent, CardComponent, TabsComponent, ModalComponent } from '../components/layout';
4
+ import { ButtonComponent, CheckBoxComponent, TextFieldComponent, DateTimeInputComponent, MultipleChoiceComponent, SliderComponent } from '../components/interactive';
5
+ import { A2UIComponentProps } from '../components/types';
6
+ /**
7
+ * Type for a component in the catalog.
8
+ */
9
+ export type CatalogComponent = ComponentType<A2UIComponentProps>;
10
+ /**
11
+ * Type for the components registry in a catalog.
12
+ */
13
+ export type CatalogComponents = Record<string, CatalogComponent>;
14
+ /**
15
+ * Type for functions in a catalog (reserved for future use).
16
+ */
17
+ export type CatalogFunctions = Record<string, unknown>;
18
+ /**
19
+ * Type for a catalog containing components and functions.
20
+ */
21
+ export interface Catalog {
22
+ /** Component registry mapping type names to React components */
23
+ components: CatalogComponents;
24
+ /** Function registry (reserved for future use) */
25
+ functions?: CatalogFunctions;
26
+ }
27
+ /**
28
+ * Standard components included in the default catalog.
29
+ */
30
+ export declare const standardComponents: CatalogComponents;
31
+ /**
32
+ * Standard functions included in the default catalog (reserved for future use).
33
+ */
34
+ /**
35
+ * The standard catalog containing all built-in A2UI v0.8 components and functions.
36
+ *
37
+ * This is the default catalog used when no custom catalog is provided to A2UIProvider.
38
+ *
39
+ * @example
40
+ * ```tsx
41
+ * // Use as-is
42
+ * <A2UIProvider messages={messages} catalog={standardCatalog}>
43
+ * <A2UIRenderer />
44
+ * </A2UIProvider>
45
+ *
46
+ * // Extend with custom components
47
+ * const myCatalog = {
48
+ * ...standardCatalog,
49
+ * components: {
50
+ * ...standardCatalog.components,
51
+ * MyComponent: MyComponentImpl,
52
+ * },
53
+ * }
54
+ * ```
55
+ */
56
+ export declare const standardCatalog: Catalog;
57
+ export { TextComponent, ImageComponent, IconComponent, VideoComponent, AudioPlayerComponent, DividerComponent, RowComponent, ColumnComponent, ListComponent, CardComponent, TabsComponent, ModalComponent, ButtonComponent, CheckBoxComponent, TextFieldComponent, DateTimeInputComponent, MultipleChoiceComponent, SliderComponent, };
@@ -0,0 +1,66 @@
1
+ import { SliderComponent as o } from "../components/interactive/SliderComponent.js";
2
+ import { MultipleChoiceComponent as m } from "../components/interactive/MultipleChoiceComponent.js";
3
+ import { DateTimeInputComponent as t } from "../components/interactive/DateTimeInputComponent.js";
4
+ import { TextFieldComponent as n } from "../components/interactive/TextFieldComponent.js";
5
+ import { CheckBoxComponent as e } from "../components/interactive/CheckBoxComponent.js";
6
+ import { ButtonComponent as r } from "../components/interactive/ButtonComponent.js";
7
+ import { ModalComponent as p } from "../components/layout/ModalComponent.js";
8
+ import { TabsComponent as i } from "../components/layout/TabsComponent.js";
9
+ import { CardComponent as C } from "../components/layout/CardComponent.js";
10
+ import { ListComponent as a } from "../components/layout/ListComponent.js";
11
+ import { ColumnComponent as d } from "../components/layout/ColumnComponent.js";
12
+ import { RowComponent as f } from "../components/layout/RowComponent.js";
13
+ import { DividerComponent as l } from "../components/display/DividerComponent.js";
14
+ import { AudioPlayerComponent as s } from "../components/display/AudioPlayerComponent.js";
15
+ import { VideoComponent as u } from "../components/display/VideoComponent.js";
16
+ import { IconComponent as c } from "../components/display/IconComponent.js";
17
+ import { ImageComponent as T } from "../components/display/ImageComponent.js";
18
+ import { TextComponent as x } from "../components/display/TextComponent.js";
19
+ const I = {
20
+ // Display components
21
+ Text: x,
22
+ Image: T,
23
+ Icon: c,
24
+ Video: u,
25
+ AudioPlayer: s,
26
+ Divider: l,
27
+ // Layout components
28
+ Row: f,
29
+ Column: d,
30
+ List: a,
31
+ Card: C,
32
+ Tabs: i,
33
+ Modal: p,
34
+ // Interactive components
35
+ Button: r,
36
+ CheckBox: e,
37
+ TextField: n,
38
+ DateTimeInput: t,
39
+ MultipleChoice: m,
40
+ Slider: o
41
+ }, q = {
42
+ components: I
43
+ // functions: standardFunctions,
44
+ };
45
+ export {
46
+ s as AudioPlayerComponent,
47
+ r as ButtonComponent,
48
+ C as CardComponent,
49
+ e as CheckBoxComponent,
50
+ d as ColumnComponent,
51
+ t as DateTimeInputComponent,
52
+ l as DividerComponent,
53
+ c as IconComponent,
54
+ T as ImageComponent,
55
+ a as ListComponent,
56
+ p as ModalComponent,
57
+ m as MultipleChoiceComponent,
58
+ f as RowComponent,
59
+ o as SliderComponent,
60
+ i as TabsComponent,
61
+ x as TextComponent,
62
+ n as TextFieldComponent,
63
+ u as VideoComponent,
64
+ q as standardCatalog,
65
+ I as standardComponents
66
+ };
@@ -1,32 +1,12 @@
1
- /**
2
- * A2UIRenderer - Component for rendering A2UI 0.9 surfaces.
3
- *
4
- * This component renders the surfaces from the A2UI context.
5
- * It must be used within an A2UIProvider.
6
- *
7
- * @example
8
- * ```tsx
9
- * import { A2UIProvider, A2UIRenderer, A2UIMessage, A2UIAction } from '@a2ui-sdk/react/0.9'
10
- *
11
- * function App() {
12
- * const messages: A2UIMessage[] = [...]
13
- * const handleAction = (action: A2UIAction) => {
14
- * console.log('Action:', action)
15
- * }
16
- * return (
17
- * <A2UIProvider messages={messages} onAction={handleAction}>
18
- * <A2UIRenderer />
19
- * </A2UIProvider>
20
- * )
21
- * }
22
- * ```
23
- */
1
+ import { ActionHandler } from '@a2ui-sdk/types/0.9';
24
2
  /**
25
3
  * Props for A2UIRenderer.
26
4
  */
27
5
  export interface A2UIRendererProps {
28
6
  /** Optional surface ID to render a specific surface (renders all if not provided) */
29
7
  surfaceId?: string;
8
+ /** Callback when an action is dispatched */
9
+ onAction?: ActionHandler;
30
10
  }
31
11
  /**
32
12
  * Component for rendering A2UI 0.9 surfaces.
@@ -37,18 +17,18 @@ export interface A2UIRendererProps {
37
17
  * @example
38
18
  * ```tsx
39
19
  * // Render all surfaces
40
- * <A2UIProvider messages={messages} onAction={handleAction}>
41
- * <A2UIRenderer />
20
+ * <A2UIProvider messages={messages}>
21
+ * <A2UIRenderer onAction={handleAction} />
42
22
  * </A2UIProvider>
43
23
  *
44
24
  * // Render specific surface
45
- * <A2UIProvider messages={messages} onAction={handleAction}>
46
- * <A2UIRenderer surfaceId="sidebar" />
47
- * <A2UIRenderer surfaceId="main" />
25
+ * <A2UIProvider messages={messages}>
26
+ * <A2UIRenderer surfaceId="sidebar" onAction={handleAction} />
27
+ * <A2UIRenderer surfaceId="main" onAction={handleAction} />
48
28
  * </A2UIProvider>
49
29
  * ```
50
30
  */
51
- export declare function A2UIRenderer({ surfaceId }: A2UIRendererProps): import("react/jsx-runtime").JSX.Element | null;
31
+ export declare function A2UIRenderer({ surfaceId, onAction }: A2UIRendererProps): import("react/jsx-runtime").JSX.Element | null;
52
32
  export declare namespace A2UIRenderer {
53
33
  var displayName: string;
54
34
  }
@@ -1,41 +1,42 @@
1
- import { jsx as i, Fragment as s } from "react/jsx-runtime";
1
+ import { jsx as d } from "react/jsx-runtime";
2
2
  import { useSurfaceContext as a } from "./contexts/SurfaceContext.js";
3
- import { ComponentRenderer as f } from "./components/ComponentRenderer.js";
4
- function c(e) {
5
- if (e.has("root"))
3
+ import { ActionProvider as c } from "./contexts/ActionContext.js";
4
+ import { ComponentRenderer as s } from "./components/ComponentRenderer.js";
5
+ function l(o) {
6
+ if (o.has("root"))
6
7
  return "root";
7
- const t = /* @__PURE__ */ new Set();
8
- for (const r of e.values()) {
8
+ const n = /* @__PURE__ */ new Set();
9
+ for (const r of o.values()) {
9
10
  if ("children" in r) {
10
- const n = r.children;
11
- Array.isArray(n) && n.forEach((o) => t.add(o));
11
+ const t = r.children;
12
+ Array.isArray(t) && t.forEach((e) => n.add(e));
12
13
  }
13
- "child" in r && typeof r.child == "string" && t.add(r.child), "trigger" in r && typeof r.trigger == "string" && t.add(r.trigger), "content" in r && typeof r.content == "string" && t.add(r.content), "tabs" in r && Array.isArray(r.tabs) && r.tabs.forEach((n) => {
14
- n.child && t.add(n.child);
14
+ "child" in r && typeof r.child == "string" && n.add(r.child), "trigger" in r && typeof r.trigger == "string" && n.add(r.trigger), "content" in r && typeof r.content == "string" && n.add(r.content), "tabs" in r && Array.isArray(r.tabs) && r.tabs.forEach((t) => {
15
+ t.child && n.add(t.child);
15
16
  });
16
17
  }
17
- for (const [r] of e)
18
- if (!t.has(r))
18
+ for (const [r] of o)
19
+ if (!n.has(r))
19
20
  return r;
20
21
  }
21
- function l({ surfaceId: e }) {
22
- const { surfaces: t } = a();
23
- if (e) {
24
- const n = t.get(e);
25
- if (!n || !n.created)
22
+ function u({ surfaceId: o, onAction: n }) {
23
+ const { surfaces: r } = a();
24
+ if (o) {
25
+ const e = r.get(o);
26
+ if (!e || !e.created)
26
27
  return null;
27
- const o = c(n.components);
28
- return o ? /* @__PURE__ */ i(f, { surfaceId: e, componentId: o }) : null;
28
+ const i = l(e.components);
29
+ return i ? /* @__PURE__ */ d(c, { onAction: n, children: /* @__PURE__ */ d(s, { surfaceId: o, componentId: i }) }) : null;
29
30
  }
30
- const r = Array.from(t.entries());
31
- return r.length === 0 ? null : /* @__PURE__ */ i(s, { children: r.map(([n, o]) => {
32
- if (!o.created)
31
+ const t = Array.from(r.entries());
32
+ return t.length === 0 ? null : /* @__PURE__ */ d(c, { onAction: n, children: t.map(([e, i]) => {
33
+ if (!i.created)
33
34
  return null;
34
- const d = c(o.components);
35
- return d ? /* @__PURE__ */ i(f, { surfaceId: n, componentId: d }, n) : null;
35
+ const f = l(i.components);
36
+ return f ? /* @__PURE__ */ d(s, { surfaceId: e, componentId: f }, e) : null;
36
37
  }) });
37
38
  }
38
- l.displayName = "A2UI.Renderer";
39
+ u.displayName = "A2UI.Renderer";
39
40
  export {
40
- l as A2UIRenderer
41
+ u as A2UIRenderer
41
42
  };
@@ -1,10 +1,10 @@
1
- import { ComponentType } from 'react';
2
- import { A2UIComponentProps } from '../contexts/ComponentsMapContext';
3
1
  /**
4
- * Component registry mapping component type names to React components.
5
- * This will be populated with actual components.
2
+ * ComponentRenderer - Routes component rendering based on type.
3
+ *
4
+ * Uses the flat discriminator format from 0.9 protocol where
5
+ * the component type is a property on the component itself.
6
+ * Props are spread directly to components like in v0.8.
6
7
  */
7
- export declare const componentRegistry: Record<string, ComponentType<A2UIComponentProps>>;
8
8
  /**
9
9
  * Props for ComponentRenderer.
10
10
  */
@@ -23,17 +23,3 @@ export interface ComponentRendererProps {
23
23
  * ```
24
24
  */
25
25
  export declare const ComponentRenderer: import('react').NamedExoticComponent<ComponentRendererProps>;
26
- /**
27
- * Registers a component type in the default registry.
28
- *
29
- * @param type - The component type name
30
- * @param component - The React component to register
31
- *
32
- * @example
33
- * ```tsx
34
- * registerComponent('CustomChart', ({ surfaceId, component }) => {
35
- * return <Chart data={component.data} />;
36
- * });
37
- * ```
38
- */
39
- export declare function registerComponent(type: string, component: ComponentType<A2UIComponentProps>): void;
@@ -1,14 +1,14 @@
1
- import { jsx as s } from "react/jsx-runtime";
2
- import { memo as l, useContext as C } from "react";
3
- import { useComponent as c } from "../hooks/useComponent.js";
4
- import { ComponentsMapContext as f } from "../contexts/ComponentsMapContext.js";
5
- import { UnknownComponent as u } from "./UnknownComponent.js";
6
- const a = {}, m = /* @__PURE__ */ new Set(), y = l(function({
1
+ import { jsx as i } from "react/jsx-runtime";
2
+ import { memo as c, useContext as l } from "react";
3
+ import { useComponent as f } from "../hooks/useComponent.js";
4
+ import { ComponentsMapContext as u } from "../contexts/ComponentsMapContext.js";
5
+ import { UnknownComponent as a } from "./UnknownComponent.js";
6
+ const r = /* @__PURE__ */ new Set(), y = c(function({
7
7
  surfaceId: n,
8
8
  componentId: o
9
9
  }) {
10
- const e = c(n, o), p = C(f), r = `${n}:${o}`;
11
- if (m.has(r))
10
+ const e = f(n, o), s = l(u), t = `${n}:${o}`;
11
+ if (r.has(t))
12
12
  return console.error(
13
13
  `[A2UI 0.9] Circular reference detected for component "${o}" on surface "${n}". Skipping render.`
14
14
  ), null;
@@ -16,19 +16,32 @@ const a = {}, m = /* @__PURE__ */ new Set(), y = l(function({
16
16
  return console.warn(
17
17
  `[A2UI 0.9] Component not found: ${o} on surface ${n}`
18
18
  ), null;
19
- const i = e.component;
20
- let t;
21
- if (p ? t = p.getComponent(i) : t = a[i], !t)
22
- return /* @__PURE__ */ s(u, { surfaceId: n, component: e });
23
- m.add(r);
19
+ const p = e.component, m = s?.getComponent(p);
20
+ if (!m)
21
+ return /* @__PURE__ */ i(
22
+ a,
23
+ {
24
+ surfaceId: n,
25
+ componentId: o,
26
+ componentType: p
27
+ }
28
+ );
29
+ r.add(t);
30
+ const { component: d, id: x, ...C } = e;
24
31
  try {
25
- return /* @__PURE__ */ s(t, { surfaceId: n, component: e });
32
+ return /* @__PURE__ */ i(
33
+ m,
34
+ {
35
+ surfaceId: n,
36
+ componentId: o,
37
+ ...C
38
+ }
39
+ );
26
40
  } finally {
27
- m.delete(r);
41
+ r.delete(t);
28
42
  }
29
43
  });
30
44
  y.displayName = "A2UI.ComponentRenderer";
31
45
  export {
32
- y as ComponentRenderer,
33
- a as componentRegistry
46
+ y as ComponentRenderer
34
47
  };
@@ -1,11 +1,17 @@
1
- import { A2UIComponentProps } from '../contexts/ComponentsMapContext';
1
+ import { A2UIComponentProps } from './types';
2
+ /**
3
+ * Props for UnknownComponent.
4
+ */
5
+ export interface UnknownComponentProps {
6
+ componentType: string;
7
+ }
2
8
  /**
3
9
  * Fallback component for unknown types.
4
10
  *
5
11
  * Displays a warning box with the unknown component type name
6
12
  * to help developers identify configuration issues.
7
13
  */
8
- export declare function UnknownComponent({ component }: A2UIComponentProps): import("react/jsx-runtime").JSX.Element;
14
+ export declare function UnknownComponent({ componentId, componentType, }: A2UIComponentProps<UnknownComponentProps>): import("react/jsx-runtime").JSX.Element;
9
15
  export declare namespace UnknownComponent {
10
16
  var displayName: string;
11
17
  }
@@ -1,9 +1,11 @@
1
- import { jsxs as p, jsx as t } from "react/jsx-runtime";
2
- function r({ component: n }) {
3
- const o = n.component, e = n.id;
1
+ import { jsxs as e, jsx as r } from "react/jsx-runtime";
2
+ function p({
3
+ componentId: n,
4
+ componentType: o
5
+ }) {
4
6
  return process.env.NODE_ENV === "development" && console.warn(
5
- `[A2UI 0.9] Unknown component type "${o}" (id: ${e}). Make sure the component type is correct or provide a custom component.`
6
- ), /* @__PURE__ */ p(
7
+ `[A2UI 0.9] Unknown component type "${o}" (id: ${n}). Make sure the component type is correct or provide a custom component.`
8
+ ), /* @__PURE__ */ e(
7
9
  "div",
8
10
  {
9
11
  style: {
@@ -17,19 +19,19 @@ function r({ component: n }) {
17
19
  fontFamily: "monospace"
18
20
  },
19
21
  children: [
20
- /* @__PURE__ */ t("strong", { children: "Unknown component:" }),
22
+ /* @__PURE__ */ r("strong", { children: "Unknown component:" }),
21
23
  " ",
22
24
  o,
23
- /* @__PURE__ */ t("br", {}),
24
- /* @__PURE__ */ p("span", { style: { opacity: 0.7 }, children: [
25
+ /* @__PURE__ */ r("br", {}),
26
+ /* @__PURE__ */ e("span", { style: { opacity: 0.7 }, children: [
25
27
  "ID: ",
26
- e
28
+ n
27
29
  ] })
28
30
  ]
29
31
  }
30
32
  );
31
33
  }
32
- r.displayName = "A2UI.UnknownComponent";
34
+ p.displayName = "A2UI.UnknownComponent";
33
35
  export {
34
- r as UnknownComponent
36
+ p as UnknownComponent
35
37
  };
@@ -1,5 +1,6 @@
1
- import { A2UIComponentProps } from '../../contexts/ComponentsMapContext';
1
+ import { AudioPlayerComponentProps } from '@a2ui-sdk/types/0.9/standard-catalog';
2
+ import { A2UIComponentProps } from '../types';
2
3
  /**
3
4
  * AudioPlayer component for playing audio content.
4
5
  */
5
- export declare const AudioPlayerComponent: import('react').NamedExoticComponent<A2UIComponentProps>;
6
+ export declare const AudioPlayerComponent: import('react').NamedExoticComponent<A2UIComponentProps<AudioPlayerComponentProps>>;
@@ -1,21 +1,23 @@
1
- import { jsxs as m, jsx as i } from "react/jsx-runtime";
2
- import { memo as d } from "react";
3
- import { useStringBinding as n } from "../../hooks/useDataBinding.js";
4
- import { cn as u } from "../../../lib/utils.js";
5
- const c = d(function({
6
- surfaceId: e,
7
- component: s
1
+ import { jsxs as d, jsx as n } from "react/jsx-runtime";
2
+ import { memo as u } from "react";
3
+ import { useStringBinding as i } from "../../hooks/useDataBinding.js";
4
+ import { cn as c } from "../../../lib/utils.js";
5
+ const a = u(function({
6
+ surfaceId: o,
7
+ url: l,
8
+ description: s,
9
+ weight: e
8
10
  }) {
9
- const o = s, r = n(e, o.url, ""), t = n(e, o.description, "");
11
+ const r = i(o, l, ""), t = i(o, s, "");
10
12
  if (!r)
11
13
  return null;
12
- const l = o.weight ? { flexGrow: o.weight } : void 0;
13
- return /* @__PURE__ */ m("div", { className: u("flex flex-col gap-2"), style: l, children: [
14
- t && /* @__PURE__ */ i("p", { className: "text-sm text-muted-foreground", children: t }),
15
- /* @__PURE__ */ i("audio", { src: r, controls: !0, className: "w-full", children: "Your browser does not support the audio element." })
14
+ const m = e ? { flexGrow: e } : void 0;
15
+ return /* @__PURE__ */ d("div", { className: c("flex flex-col gap-2"), style: m, children: [
16
+ t && /* @__PURE__ */ n("p", { className: "text-sm text-muted-foreground", children: t }),
17
+ /* @__PURE__ */ n("audio", { src: r, controls: !0, className: "w-full", children: "Your browser does not support the audio element." })
16
18
  ] });
17
19
  });
18
- c.displayName = "A2UI.AudioPlayer";
20
+ a.displayName = "A2UI.AudioPlayer";
19
21
  export {
20
- c as AudioPlayerComponent
22
+ a as AudioPlayerComponent
21
23
  };
@@ -1,5 +1,6 @@
1
- import { A2UIComponentProps } from '../../contexts/ComponentsMapContext';
1
+ import { DividerComponentProps } from '@a2ui-sdk/types/0.9/standard-catalog';
2
+ import { A2UIComponentProps } from '../types';
2
3
  /**
3
4
  * Divider component for visual separation.
4
5
  */
5
- export declare const DividerComponent: import('react').NamedExoticComponent<A2UIComponentProps>;
6
+ export declare const DividerComponent: import('react').NamedExoticComponent<A2UIComponentProps<DividerComponentProps>>;
@@ -1,10 +1,9 @@
1
1
  import { jsx as r } from "react/jsx-runtime";
2
2
  import { memo as t } from "react";
3
3
  import { Separator as e } from "../../../components/ui/separator.js";
4
- const m = t(function({
5
- component: i
4
+ const i = t(function({
5
+ axis: o = "horizontal"
6
6
  }) {
7
- const o = i.axis ?? "horizontal";
8
7
  return /* @__PURE__ */ r(
9
8
  e,
10
9
  {
@@ -13,7 +12,7 @@ const m = t(function({
13
12
  }
14
13
  );
15
14
  });
16
- m.displayName = "A2UI.Divider";
15
+ i.displayName = "A2UI.Divider";
17
16
  export {
18
- m as DividerComponent
17
+ i as DividerComponent
19
18
  };
@@ -1,5 +1,6 @@
1
- import { A2UIComponentProps } from '../../contexts/ComponentsMapContext';
1
+ import { IconComponentProps } from '@a2ui-sdk/types/0.9/standard-catalog';
2
+ import { A2UIComponentProps } from '../types';
2
3
  /**
3
4
  * Icon component for displaying icons from the A2UI icon set.
4
5
  */
5
- export declare const IconComponent: import('react').NamedExoticComponent<A2UIComponentProps>;
6
+ export declare const IconComponent: import('react').NamedExoticComponent<A2UIComponentProps<IconComponentProps>>;