@a2ui-sdk/react 0.0.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 (174) hide show
  1. package/dist/0.8/A2UIRenderer.d.ts +31 -0
  2. package/dist/0.8/A2UIRenderer.js +19 -0
  3. package/dist/0.8/components/ComponentRenderer.d.ts +39 -0
  4. package/dist/0.8/components/ComponentRenderer.js +76 -0
  5. package/dist/0.8/components/UnknownComponent.d.ts +18 -0
  6. package/dist/0.8/components/display/AudioPlayerComponent.d.ts +5 -0
  7. package/dist/0.8/components/display/AudioPlayerComponent.js +19 -0
  8. package/dist/0.8/components/display/DividerComponent.d.ts +5 -0
  9. package/dist/0.8/components/display/DividerComponent.js +18 -0
  10. package/dist/0.8/components/display/IconComponent.d.ts +5 -0
  11. package/dist/0.8/components/display/IconComponent.js +68 -0
  12. package/dist/0.8/components/display/ImageComponent.d.ts +6 -0
  13. package/dist/0.8/components/display/ImageComponent.js +36 -0
  14. package/dist/0.8/components/display/TextComponent.d.ts +6 -0
  15. package/dist/0.8/components/display/TextComponent.js +32 -0
  16. package/dist/0.8/components/display/VideoComponent.d.ts +5 -0
  17. package/dist/0.8/components/display/VideoComponent.js +18 -0
  18. package/dist/0.8/components/display/index.d.ts +9 -0
  19. package/dist/0.8/components/index.d.ts +7 -0
  20. package/dist/0.8/components/interactive/ButtonComponent.d.ts +5 -0
  21. package/dist/0.8/components/interactive/ButtonComponent.js +29 -0
  22. package/dist/0.8/components/interactive/CheckBoxComponent.d.ts +5 -0
  23. package/dist/0.8/components/interactive/CheckBoxComponent.js +27 -0
  24. package/dist/0.8/components/interactive/DateTimeInputComponent.d.ts +5 -0
  25. package/dist/0.8/components/interactive/DateTimeInputComponent.js +46 -0
  26. package/dist/0.8/components/interactive/MultipleChoiceComponent.d.ts +7 -0
  27. package/dist/0.8/components/interactive/MultipleChoiceComponent.js +89 -0
  28. package/dist/0.8/components/interactive/SliderComponent.d.ts +5 -0
  29. package/dist/0.8/components/interactive/SliderComponent.js +48 -0
  30. package/dist/0.8/components/interactive/TextFieldComponent.d.ts +5 -0
  31. package/dist/0.8/components/interactive/TextFieldComponent.js +44 -0
  32. package/dist/0.8/components/interactive/index.d.ts +9 -0
  33. package/dist/0.8/components/layout/CardComponent.d.ts +5 -0
  34. package/dist/0.8/components/layout/CardComponent.js +14 -0
  35. package/dist/0.8/components/layout/ColumnComponent.d.ts +5 -0
  36. package/dist/0.8/components/layout/ColumnComponent.js +58 -0
  37. package/dist/0.8/components/layout/ListComponent.d.ts +5 -0
  38. package/dist/0.8/components/layout/ListComponent.js +51 -0
  39. package/dist/0.8/components/layout/ModalComponent.d.ts +5 -0
  40. package/dist/0.8/components/layout/ModalComponent.js +25 -0
  41. package/dist/0.8/components/layout/RowComponent.d.ts +5 -0
  42. package/dist/0.8/components/layout/RowComponent.js +58 -0
  43. package/dist/0.8/components/layout/TabsComponent.d.ts +5 -0
  44. package/dist/0.8/components/layout/TabsComponent.js +29 -0
  45. package/dist/0.8/components/layout/index.d.ts +9 -0
  46. package/dist/0.8/contexts/A2UIProvider.d.ts +56 -0
  47. package/dist/0.8/contexts/A2UIProvider.js +33 -0
  48. package/dist/0.8/contexts/ActionContext.d.ts +33 -0
  49. package/dist/0.8/contexts/ActionContext.js +41 -0
  50. package/dist/0.8/contexts/ComponentsMapContext.d.ts +63 -0
  51. package/dist/0.8/contexts/ComponentsMapContext.js +21 -0
  52. package/dist/0.8/contexts/DataModelContext.d.ts +43 -0
  53. package/dist/0.8/contexts/DataModelContext.js +86 -0
  54. package/dist/0.8/contexts/SurfaceContext.d.ts +45 -0
  55. package/dist/0.8/contexts/SurfaceContext.js +88 -0
  56. package/dist/0.8/hooks/useA2UIMessageHandler.d.ts +41 -0
  57. package/dist/0.8/hooks/useA2UIMessageHandler.js +54 -0
  58. package/dist/0.8/hooks/useComponent.d.ts +23 -0
  59. package/dist/0.8/hooks/useComponent.js +9 -0
  60. package/dist/0.8/hooks/useDataBinding.d.ts +50 -0
  61. package/dist/0.8/hooks/useDataBinding.js +28 -0
  62. package/dist/0.8/hooks/useDispatchAction.d.ts +22 -0
  63. package/dist/0.8/hooks/useDispatchAction.js +8 -0
  64. package/dist/0.8/index.d.ts +44 -0
  65. package/dist/0.8/index.js +17 -0
  66. package/dist/0.8/utils/dataBinding.d.ts +95 -0
  67. package/dist/0.8/utils/dataBinding.js +46 -0
  68. package/dist/0.8/utils/pathUtils.d.ts +63 -0
  69. package/dist/0.8/utils/pathUtils.js +44 -0
  70. package/dist/0.9/A2UIRenderer.d.ts +54 -0
  71. package/dist/0.9/A2UIRenderer.js +41 -0
  72. package/dist/0.9/components/ComponentRenderer.d.ts +39 -0
  73. package/dist/0.9/components/ComponentRenderer.js +34 -0
  74. package/dist/0.9/components/UnknownComponent.d.ts +11 -0
  75. package/dist/0.9/components/UnknownComponent.js +35 -0
  76. package/dist/0.9/components/display/AudioPlayerComponent.d.ts +5 -0
  77. package/dist/0.9/components/display/AudioPlayerComponent.js +21 -0
  78. package/dist/0.9/components/display/DividerComponent.d.ts +5 -0
  79. package/dist/0.9/components/display/DividerComponent.js +19 -0
  80. package/dist/0.9/components/display/IconComponent.d.ts +5 -0
  81. package/dist/0.9/components/display/IconComponent.js +68 -0
  82. package/dist/0.9/components/display/ImageComponent.d.ts +6 -0
  83. package/dist/0.9/components/display/ImageComponent.js +43 -0
  84. package/dist/0.9/components/display/TextComponent.d.ts +6 -0
  85. package/dist/0.9/components/display/TextComponent.js +31 -0
  86. package/dist/0.9/components/display/VideoComponent.d.ts +5 -0
  87. package/dist/0.9/components/display/VideoComponent.js +30 -0
  88. package/dist/0.9/components/display/index.d.ts +9 -0
  89. package/dist/0.9/components/index.d.ts +12 -0
  90. package/dist/0.9/components/index.js +68 -0
  91. package/dist/0.9/components/interactive/ButtonComponent.d.ts +6 -0
  92. package/dist/0.9/components/interactive/ButtonComponent.js +29 -0
  93. package/dist/0.9/components/interactive/CheckBoxComponent.d.ts +5 -0
  94. package/dist/0.9/components/interactive/CheckBoxComponent.js +41 -0
  95. package/dist/0.9/components/interactive/ChoicePickerComponent.d.ts +7 -0
  96. package/dist/0.9/components/interactive/ChoicePickerComponent.js +80 -0
  97. package/dist/0.9/components/interactive/DateTimeInputComponent.d.ts +5 -0
  98. package/dist/0.9/components/interactive/DateTimeInputComponent.js +50 -0
  99. package/dist/0.9/components/interactive/SliderComponent.d.ts +6 -0
  100. package/dist/0.9/components/interactive/SliderComponent.js +47 -0
  101. package/dist/0.9/components/interactive/TextFieldComponent.d.ts +5 -0
  102. package/dist/0.9/components/interactive/TextFieldComponent.js +57 -0
  103. package/dist/0.9/components/interactive/index.d.ts +9 -0
  104. package/dist/0.9/components/layout/CardComponent.d.ts +5 -0
  105. package/dist/0.9/components/layout/CardComponent.js +15 -0
  106. package/dist/0.9/components/layout/ColumnComponent.d.ts +6 -0
  107. package/dist/0.9/components/layout/ColumnComponent.js +50 -0
  108. package/dist/0.9/components/layout/ListComponent.d.ts +17 -0
  109. package/dist/0.9/components/layout/ListComponent.js +42 -0
  110. package/dist/0.9/components/layout/ModalComponent.d.ts +5 -0
  111. package/dist/0.9/components/layout/ModalComponent.js +30 -0
  112. package/dist/0.9/components/layout/RowComponent.d.ts +6 -0
  113. package/dist/0.9/components/layout/RowComponent.js +50 -0
  114. package/dist/0.9/components/layout/TabsComponent.d.ts +5 -0
  115. package/dist/0.9/components/layout/TabsComponent.js +30 -0
  116. package/dist/0.9/components/layout/TemplateRenderer.d.ts +25 -0
  117. package/dist/0.9/components/layout/TemplateRenderer.js +49 -0
  118. package/dist/0.9/components/layout/index.d.ts +10 -0
  119. package/dist/0.9/contexts/A2UIProvider.d.ts +58 -0
  120. package/dist/0.9/contexts/A2UIProvider.js +34 -0
  121. package/dist/0.9/contexts/ActionContext.d.ts +33 -0
  122. package/dist/0.9/contexts/ActionContext.js +47 -0
  123. package/dist/0.9/contexts/ComponentsMapContext.d.ts +73 -0
  124. package/dist/0.9/contexts/ComponentsMapContext.js +21 -0
  125. package/dist/0.9/contexts/ScopeContext.d.ts +53 -0
  126. package/dist/0.9/contexts/ScopeContext.js +22 -0
  127. package/dist/0.9/contexts/SurfaceContext.d.ts +50 -0
  128. package/dist/0.9/contexts/SurfaceContext.js +118 -0
  129. package/dist/0.9/hooks/useA2UIMessageHandler.d.ts +44 -0
  130. package/dist/0.9/hooks/useA2UIMessageHandler.js +87 -0
  131. package/dist/0.9/hooks/useComponent.d.ts +23 -0
  132. package/dist/0.9/hooks/useComponent.js +9 -0
  133. package/dist/0.9/hooks/useDataBinding.d.ts +59 -0
  134. package/dist/0.9/hooks/useDataBinding.js +43 -0
  135. package/dist/0.9/hooks/useDispatchAction.d.ts +22 -0
  136. package/dist/0.9/hooks/useDispatchAction.js +17 -0
  137. package/dist/0.9/hooks/useValidation.d.ts +25 -0
  138. package/dist/0.9/hooks/useValidation.js +14 -0
  139. package/dist/0.9/index.d.ts +35 -0
  140. package/dist/0.9/index.js +26 -0
  141. package/dist/0.9/utils/dataBinding.d.ts +126 -0
  142. package/dist/0.9/utils/dataBinding.js +41 -0
  143. package/dist/0.9/utils/pathUtils.d.ts +109 -0
  144. package/dist/0.9/utils/pathUtils.js +74 -0
  145. package/dist/0.9/utils/validation.d.ts +49 -0
  146. package/dist/0.9/utils/validation.js +75 -0
  147. package/dist/components/ui/button.d.ts +10 -0
  148. package/dist/components/ui/button.js +53 -0
  149. package/dist/components/ui/card.d.ts +9 -0
  150. package/dist/components/ui/card.js +29 -0
  151. package/dist/components/ui/checkbox.d.ts +4 -0
  152. package/dist/components/ui/checkbox.js +31 -0
  153. package/dist/components/ui/dialog.d.ts +15 -0
  154. package/dist/components/ui/dialog.js +77 -0
  155. package/dist/components/ui/input.d.ts +3 -0
  156. package/dist/components/ui/input.js +21 -0
  157. package/dist/components/ui/label.d.ts +4 -0
  158. package/dist/components/ui/label.js +22 -0
  159. package/dist/components/ui/native-select.d.ts +7 -0
  160. package/dist/components/ui/select.d.ts +15 -0
  161. package/dist/components/ui/select.js +144 -0
  162. package/dist/components/ui/separator.d.ts +4 -0
  163. package/dist/components/ui/separator.js +26 -0
  164. package/dist/components/ui/slider.d.ts +4 -0
  165. package/dist/components/ui/slider.js +63 -0
  166. package/dist/components/ui/tabs.d.ts +7 -0
  167. package/dist/components/ui/tabs.js +67 -0
  168. package/dist/components/ui/textarea.d.ts +3 -0
  169. package/dist/components/ui/textarea.js +18 -0
  170. package/dist/index.d.ts +2 -0
  171. package/dist/index.js +6 -0
  172. package/dist/lib/utils.d.ts +2 -0
  173. package/dist/lib/utils.js +8 -0
  174. package/package.json +75 -0
@@ -0,0 +1,89 @@
1
+ import { jsxs as u, jsx as r, Fragment as S } from "react/jsx-runtime";
2
+ import { memo as T, useCallback as b } from "react";
3
+ import { useDataBinding as y, useFormBinding as $ } from "../../hooks/useDataBinding.js";
4
+ import { Select as j, SelectTrigger as B, SelectValue as D, SelectContent as L, SelectItem as A } from "../../../components/ui/select.js";
5
+ import { Checkbox as O } from "../../../components/ui/checkbox.js";
6
+ import { Label as f } from "../../../components/ui/label.js";
7
+ import { cn as g } from "../../../lib/utils.js";
8
+ const R = T(function({
9
+ surfaceId: t,
10
+ componentId: d,
11
+ label: x,
12
+ selections: k,
13
+ options: o,
14
+ maxAllowedSelections: n
15
+ }) {
16
+ const s = y(t, x, ""), [e, i] = $(
17
+ t,
18
+ k,
19
+ n === 1 ? "" : []
20
+ ), M = b(
21
+ (l) => {
22
+ i(l);
23
+ },
24
+ [i]
25
+ ), N = b(
26
+ (l, c) => {
27
+ const a = Array.isArray(e) ? e : e ? [e] : [];
28
+ if (c) {
29
+ if (n !== void 0 && a.length >= n)
30
+ return;
31
+ i([...a, l]);
32
+ } else
33
+ i(a.filter((h) => h !== l));
34
+ },
35
+ [e, i, n]
36
+ ), m = `multiplechoice-${d}`;
37
+ if (!o || o.length === 0)
38
+ return null;
39
+ if (n === 1) {
40
+ const l = Array.isArray(e) ? e[0] || "" : e;
41
+ return /* @__PURE__ */ u("div", { className: g("flex flex-col gap-2"), children: [
42
+ s && /* @__PURE__ */ r(f, { htmlFor: m, children: s }),
43
+ /* @__PURE__ */ u(j, { value: l, onValueChange: M, children: [
44
+ /* @__PURE__ */ r(B, { id: m, children: /* @__PURE__ */ r(D, { placeholder: "Select an option" }) }),
45
+ /* @__PURE__ */ r(L, { children: o.map((c) => /* @__PURE__ */ r(A, { value: c.value, children: /* @__PURE__ */ r(v, { surfaceId: t, label: c.label }) }, c.value)) })
46
+ ] })
47
+ ] });
48
+ }
49
+ const C = Array.isArray(e) ? e : e ? [e] : [], V = n !== void 0 && C.length >= n;
50
+ return /* @__PURE__ */ u("div", { className: g("flex flex-col gap-2"), children: [
51
+ s && /* @__PURE__ */ r(f, { children: s }),
52
+ o.map((l) => {
53
+ const c = C.includes(l.value), a = !c && V, h = `${m}-${l.value}`;
54
+ return /* @__PURE__ */ u("div", { className: "flex items-center gap-2", children: [
55
+ /* @__PURE__ */ r(
56
+ O,
57
+ {
58
+ id: h,
59
+ checked: c,
60
+ disabled: a,
61
+ onCheckedChange: (F) => N(l.value, F === !0)
62
+ }
63
+ ),
64
+ /* @__PURE__ */ r(
65
+ f,
66
+ {
67
+ htmlFor: h,
68
+ className: g(
69
+ "cursor-pointer",
70
+ a && "cursor-not-allowed opacity-50"
71
+ ),
72
+ children: /* @__PURE__ */ r(v, { surfaceId: t, label: l.label })
73
+ }
74
+ )
75
+ ] }, l.value);
76
+ })
77
+ ] });
78
+ });
79
+ function v({
80
+ surfaceId: p,
81
+ label: t
82
+ }) {
83
+ const d = y(p, t, "");
84
+ return /* @__PURE__ */ r(S, { children: d });
85
+ }
86
+ R.displayName = "A2UI.MultipleChoice";
87
+ export {
88
+ R as MultipleChoiceComponent
89
+ };
@@ -0,0 +1,5 @@
1
+ import { SliderComponentProps } from '@a2ui-sdk/types/0.8';
2
+ /**
3
+ * Slider component - range slider input.
4
+ */
5
+ export declare const SliderComponent: import('react').NamedExoticComponent<SliderComponentProps>;
@@ -0,0 +1,48 @@
1
+ import { jsxs as d, jsx as e } from "react/jsx-runtime";
2
+ import { memo as h, useCallback as x } from "react";
3
+ import { useDataBinding as u, useFormBinding as g } from "../../hooks/useDataBinding.js";
4
+ import { Slider as C } from "../../../components/ui/slider.js";
5
+ import { Label as S } from "../../../components/ui/label.js";
6
+ import { cn as b } from "../../../lib/utils.js";
7
+ const N = h(function({
8
+ surfaceId: o,
9
+ componentId: a,
10
+ label: c,
11
+ value: p,
12
+ minValue: n = 0,
13
+ maxValue: r = 100
14
+ }) {
15
+ const t = u(o, c, ""), [i, l] = g(
16
+ o,
17
+ p,
18
+ n
19
+ ), f = x(
20
+ (s) => {
21
+ s.length > 0 && l(s[0]);
22
+ },
23
+ [l]
24
+ ), m = `slider-${a}`;
25
+ return /* @__PURE__ */ d("div", { className: b("flex flex-col gap-2 py-2"), children: [
26
+ t && /* @__PURE__ */ e(S, { htmlFor: m, children: t }),
27
+ /* @__PURE__ */ e(
28
+ C,
29
+ {
30
+ id: m,
31
+ value: [i],
32
+ onValueChange: f,
33
+ min: n,
34
+ max: r,
35
+ step: 1
36
+ }
37
+ ),
38
+ /* @__PURE__ */ d("div", { className: "flex justify-between text-sm text-muted-foreground", children: [
39
+ /* @__PURE__ */ e("span", { children: n }),
40
+ /* @__PURE__ */ e("span", { className: "font-medium text-foreground", children: i }),
41
+ /* @__PURE__ */ e("span", { children: r })
42
+ ] })
43
+ ] });
44
+ });
45
+ N.displayName = "A2UI.Slider";
46
+ export {
47
+ N as SliderComponent
48
+ };
@@ -0,0 +1,5 @@
1
+ import { TextFieldComponentProps } from '@a2ui-sdk/types/0.8';
2
+ /**
3
+ * TextField component - text input with label.
4
+ */
5
+ export declare const TextFieldComponent: import('react').NamedExoticComponent<TextFieldComponentProps>;
@@ -0,0 +1,44 @@
1
+ import { jsxs as u, jsx as t } from "react/jsx-runtime";
2
+ import { memo as T, useCallback as f } from "react";
3
+ import { useDataBinding as g, useFormBinding as h } from "../../hooks/useDataBinding.js";
4
+ import { Input as b } from "../../../components/ui/input.js";
5
+ import { Textarea as C } from "../../../components/ui/textarea.js";
6
+ import { Label as F } from "../../../components/ui/label.js";
7
+ import { cn as v } from "../../../lib/utils.js";
8
+ const y = {
9
+ shortText: "text",
10
+ longText: "text",
11
+ // Uses textarea
12
+ number: "number",
13
+ date: "date",
14
+ obscured: "password"
15
+ }, N = T(function({
16
+ surfaceId: o,
17
+ componentId: i,
18
+ label: l,
19
+ text: p,
20
+ textFieldType: n = "shortText"
21
+ }) {
22
+ const r = g(o, l, ""), [a, m] = h(o, p, ""), s = f(
23
+ (d) => {
24
+ m(d.target.value);
25
+ },
26
+ [m]
27
+ ), e = `textfield-${i}`, x = y[n] || "text", c = n === "longText";
28
+ return /* @__PURE__ */ u("div", { className: v("flex flex-col gap-2"), children: [
29
+ r && /* @__PURE__ */ t(F, { htmlFor: e, children: r }),
30
+ c ? /* @__PURE__ */ t(
31
+ C,
32
+ {
33
+ id: e,
34
+ value: a,
35
+ onChange: s,
36
+ className: "min-h-[100px]"
37
+ }
38
+ ) : /* @__PURE__ */ t(b, { id: e, type: x, value: a, onChange: s })
39
+ ] });
40
+ });
41
+ N.displayName = "A2UI.TextField";
42
+ export {
43
+ N as TextFieldComponent
44
+ };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * A2UI React Renderer - Interactive Components
3
+ */
4
+ export { ButtonComponent } from './ButtonComponent';
5
+ export { CheckBoxComponent } from './CheckBoxComponent';
6
+ export { TextFieldComponent } from './TextFieldComponent';
7
+ export { DateTimeInputComponent } from './DateTimeInputComponent';
8
+ export { MultipleChoiceComponent } from './MultipleChoiceComponent';
9
+ export { SliderComponent } from './SliderComponent';
@@ -0,0 +1,5 @@
1
+ import { CardComponentProps } from '@a2ui-sdk/types/0.8';
2
+ /**
3
+ * Card component - container with card styling.
4
+ */
5
+ export declare const CardComponent: import('react').NamedExoticComponent<CardComponentProps>;
@@ -0,0 +1,14 @@
1
+ import { jsx as r } from "react/jsx-runtime";
2
+ import { memo as m } from "react";
3
+ import { Card as n, CardContent as t } from "../../../components/ui/card.js";
4
+ import { ComponentRenderer as p } from "../ComponentRenderer.js";
5
+ const a = m(function({
6
+ surfaceId: e,
7
+ child: o
8
+ }) {
9
+ return o ? /* @__PURE__ */ r(n, { children: /* @__PURE__ */ r(t, { className: "p-4", children: /* @__PURE__ */ r(p, { surfaceId: e, componentId: o }) }) }) : /* @__PURE__ */ r(n, {});
10
+ });
11
+ a.displayName = "A2UI.Card";
12
+ export {
13
+ a as CardComponent
14
+ };
@@ -0,0 +1,5 @@
1
+ import { ColumnComponentProps } from '@a2ui-sdk/types/0.8';
2
+ /**
3
+ * Column component - vertical flex container.
4
+ */
5
+ export declare const ColumnComponent: import('react').NamedExoticComponent<ColumnComponentProps>;
@@ -0,0 +1,58 @@
1
+ import { jsx as t } from "react/jsx-runtime";
2
+ import { memo as u } from "react";
3
+ import { useDataModel as d } from "../../hooks/useDataBinding.js";
4
+ import { cn as y } from "../../../lib/utils.js";
5
+ import { getValueByPath as j } from "../../utils/pathUtils.js";
6
+ import { ComponentRenderer as r } from "../ComponentRenderer.js";
7
+ const v = {
8
+ start: "justify-start",
9
+ center: "justify-center",
10
+ end: "justify-end",
11
+ spaceBetween: "justify-between",
12
+ spaceAround: "justify-around",
13
+ spaceEvenly: "justify-evenly"
14
+ }, x = {
15
+ start: "items-start",
16
+ center: "items-center",
17
+ end: "items-end",
18
+ stretch: "items-stretch"
19
+ }, C = u(function({
20
+ surfaceId: s,
21
+ children: e,
22
+ distribution: m = "start",
23
+ alignment: a = "stretch"
24
+ }) {
25
+ const c = d(s), n = y(
26
+ "flex flex-col gap-4",
27
+ v[m],
28
+ x[a]
29
+ );
30
+ if (e?.explicitList)
31
+ return /* @__PURE__ */ t("div", { className: n, children: e.explicitList.map((o) => /* @__PURE__ */ t(
32
+ r,
33
+ {
34
+ surfaceId: s,
35
+ componentId: o
36
+ },
37
+ o
38
+ )) });
39
+ if (e?.template) {
40
+ const { componentId: o, dataBinding: p } = e.template, i = j(c, p);
41
+ if (!i || typeof i != "object")
42
+ return /* @__PURE__ */ t("div", { className: n });
43
+ const l = Object.entries(i);
44
+ return /* @__PURE__ */ t("div", { className: n, children: l.map(([f]) => /* @__PURE__ */ t(
45
+ r,
46
+ {
47
+ surfaceId: s,
48
+ componentId: o
49
+ },
50
+ f
51
+ )) });
52
+ }
53
+ return /* @__PURE__ */ t("div", { className: n });
54
+ });
55
+ C.displayName = "A2UI.Column";
56
+ export {
57
+ C as ColumnComponent
58
+ };
@@ -0,0 +1,5 @@
1
+ import { ListComponentProps } from '@a2ui-sdk/types/0.8';
2
+ /**
3
+ * List component - container for list items.
4
+ */
5
+ export declare const ListComponent: import('react').NamedExoticComponent<ListComponentProps>;
@@ -0,0 +1,51 @@
1
+ import { jsx as t } from "react/jsx-runtime";
2
+ import { memo as d } from "react";
3
+ import { useDataModel as x } from "../../hooks/useDataBinding.js";
4
+ import { cn as u } from "../../../lib/utils.js";
5
+ import { getValueByPath as v } from "../../utils/pathUtils.js";
6
+ import { ComponentRenderer as r } from "../ComponentRenderer.js";
7
+ const L = {
8
+ start: "items-start",
9
+ center: "items-center",
10
+ end: "items-end",
11
+ stretch: "items-stretch"
12
+ }, g = d(function({
13
+ surfaceId: n,
14
+ children: e,
15
+ direction: s = "vertical",
16
+ alignment: a = "stretch"
17
+ }) {
18
+ const p = x(n), o = u(
19
+ "flex gap-3",
20
+ s === "horizontal" ? "flex-row" : "flex-col",
21
+ L[a]
22
+ );
23
+ if (e?.explicitList)
24
+ return /* @__PURE__ */ t("div", { className: o, children: e.explicitList.map((i) => /* @__PURE__ */ t(
25
+ r,
26
+ {
27
+ surfaceId: n,
28
+ componentId: i
29
+ },
30
+ i
31
+ )) });
32
+ if (e?.template) {
33
+ const { componentId: i, dataBinding: c } = e.template, m = v(p, c);
34
+ if (!m || typeof m != "object")
35
+ return /* @__PURE__ */ t("div", { className: o });
36
+ const l = Object.entries(m);
37
+ return /* @__PURE__ */ t("div", { className: o, children: l.map(([f]) => /* @__PURE__ */ t(
38
+ r,
39
+ {
40
+ surfaceId: n,
41
+ componentId: i
42
+ },
43
+ f
44
+ )) });
45
+ }
46
+ return /* @__PURE__ */ t("div", { className: o });
47
+ });
48
+ g.displayName = "A2UI.List";
49
+ export {
50
+ g as ListComponent
51
+ };
@@ -0,0 +1,5 @@
1
+ import { ModalComponentProps } from '@a2ui-sdk/types/0.8';
2
+ /**
3
+ * Modal component - dialog container with trigger.
4
+ */
5
+ export declare const ModalComponent: import('react').NamedExoticComponent<ModalComponentProps>;
@@ -0,0 +1,25 @@
1
+ import { jsxs as p, jsx as o } from "react/jsx-runtime";
2
+ import { memo as l, useState as a } from "react";
3
+ import { Dialog as s, DialogTrigger as d, DialogContent as c } from "../../../components/ui/dialog.js";
4
+ import { ComponentRenderer as t } from "../ComponentRenderer.js";
5
+ const f = l(function({
6
+ surfaceId: e,
7
+ entryPointChild: n,
8
+ contentChild: r
9
+ }) {
10
+ const [m, i] = a(!1);
11
+ return !n || !r ? null : /* @__PURE__ */ p(s, { open: m, onOpenChange: i, children: [
12
+ /* @__PURE__ */ o(d, { asChild: !0, children: /* @__PURE__ */ o("div", { className: "cursor-pointer", children: /* @__PURE__ */ o(
13
+ t,
14
+ {
15
+ surfaceId: e,
16
+ componentId: n
17
+ }
18
+ ) }) }),
19
+ /* @__PURE__ */ o(c, { children: /* @__PURE__ */ o(t, { surfaceId: e, componentId: r }) })
20
+ ] });
21
+ });
22
+ f.displayName = "A2UI.Modal";
23
+ export {
24
+ f as ModalComponent
25
+ };
@@ -0,0 +1,5 @@
1
+ import { RowComponentProps } from '@a2ui-sdk/types/0.8';
2
+ /**
3
+ * Row component - horizontal flex container.
4
+ */
5
+ export declare const RowComponent: import('react').NamedExoticComponent<RowComponentProps>;
@@ -0,0 +1,58 @@
1
+ import { jsx as t } from "react/jsx-runtime";
2
+ import { memo as l } from "react";
3
+ import { useDataModel as u } from "../../hooks/useDataBinding.js";
4
+ import { cn as y } from "../../../lib/utils.js";
5
+ import { getValueByPath as j } from "../../utils/pathUtils.js";
6
+ import { ComponentRenderer as r } from "../ComponentRenderer.js";
7
+ const v = {
8
+ start: "justify-start",
9
+ center: "justify-center",
10
+ end: "justify-end",
11
+ spaceBetween: "justify-between",
12
+ spaceAround: "justify-around",
13
+ spaceEvenly: "justify-evenly"
14
+ }, w = {
15
+ start: "items-start",
16
+ center: "items-center",
17
+ end: "items-end",
18
+ stretch: "items-stretch"
19
+ }, x = l(function({
20
+ surfaceId: s,
21
+ children: e,
22
+ distribution: m = "start",
23
+ alignment: a = "stretch"
24
+ }) {
25
+ const p = u(s), n = y(
26
+ "flex flex-row gap-3",
27
+ v[m],
28
+ w[a]
29
+ );
30
+ if (e?.explicitList)
31
+ return /* @__PURE__ */ t("div", { className: n, children: e.explicitList.map((o) => /* @__PURE__ */ t(
32
+ r,
33
+ {
34
+ surfaceId: s,
35
+ componentId: o
36
+ },
37
+ o
38
+ )) });
39
+ if (e?.template) {
40
+ const { componentId: o, dataBinding: c } = e.template, i = j(p, c);
41
+ if (!i || typeof i != "object")
42
+ return /* @__PURE__ */ t("div", { className: n });
43
+ const f = Object.entries(i);
44
+ return /* @__PURE__ */ t("div", { className: n, children: f.map(([d]) => /* @__PURE__ */ t(
45
+ r,
46
+ {
47
+ surfaceId: s,
48
+ componentId: o
49
+ },
50
+ d
51
+ )) });
52
+ }
53
+ return /* @__PURE__ */ t("div", { className: n });
54
+ });
55
+ x.displayName = "A2UI.Row";
56
+ export {
57
+ x as RowComponent
58
+ };
@@ -0,0 +1,5 @@
1
+ import { TabsComponentProps } from '@a2ui-sdk/types/0.8';
2
+ /**
3
+ * Tabs component - tabbed content container.
4
+ */
5
+ export declare const TabsComponent: import('react').NamedExoticComponent<TabsComponentProps>;
@@ -0,0 +1,29 @@
1
+ import { jsxs as a, jsx as o, Fragment as c } from "react/jsx-runtime";
2
+ import { memo as d } from "react";
3
+ import { useDataBinding as m } from "../../hooks/useDataBinding.js";
4
+ import { Tabs as p, TabsList as s, TabsTrigger as T, TabsContent as h } from "../../../components/ui/tabs.js";
5
+ import { ComponentRenderer as u } from "../ComponentRenderer.js";
6
+ const f = d(function({
7
+ surfaceId: r,
8
+ tabItems: n
9
+ }) {
10
+ if (!n || n.length === 0)
11
+ return null;
12
+ const e = n[0].child;
13
+ return /* @__PURE__ */ a(p, { defaultValue: e, className: "w-full", children: [
14
+ /* @__PURE__ */ o(s, { children: n.map((l, t) => /* @__PURE__ */ o(T, { value: l.child, children: /* @__PURE__ */ o(b, { surfaceId: r, title: l.title, index: t }) }, l.child)) }),
15
+ n.map((l) => /* @__PURE__ */ o(h, { value: l.child, children: /* @__PURE__ */ o(u, { surfaceId: r, componentId: l.child }) }, l.child))
16
+ ] });
17
+ });
18
+ function b({
19
+ surfaceId: i,
20
+ title: r,
21
+ index: n
22
+ }) {
23
+ const e = m(i, r, `Tab ${n + 1}`);
24
+ return /* @__PURE__ */ o(c, { children: e });
25
+ }
26
+ f.displayName = "A2UI.Tabs";
27
+ export {
28
+ f as TabsComponent
29
+ };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * A2UI React Renderer - Layout Components
3
+ */
4
+ export { RowComponent } from './RowComponent';
5
+ export { ColumnComponent } from './ColumnComponent';
6
+ export { ListComponent } from './ListComponent';
7
+ export { CardComponent } from './CardComponent';
8
+ export { TabsComponent } from './TabsComponent';
9
+ export { ModalComponent } from './ModalComponent';
@@ -0,0 +1,56 @@
1
+ import { ReactNode, ComponentType } from 'react';
2
+ import { A2UIMessage, BaseComponentProps } from '@a2ui-sdk/types/0.8';
3
+ /**
4
+ * Type for custom component map.
5
+ */
6
+ export type ComponentsMap = Map<string, ComponentType<BaseComponentProps & Record<string, unknown>>>;
7
+ /**
8
+ * Props for A2UIProvider.
9
+ */
10
+ export interface A2UIProviderProps {
11
+ /** Array of A2UI messages to render */
12
+ messages: A2UIMessage[];
13
+ /** Custom component overrides */
14
+ components?: ComponentsMap;
15
+ children: ReactNode;
16
+ }
17
+ /**
18
+ * Combined provider for all A2UI contexts.
19
+ *
20
+ * Provides:
21
+ * - SurfaceContext: Component tree management
22
+ * - DataModelContext: Data model state
23
+ * - ComponentsMapContext: Custom component overrides
24
+ *
25
+ * @param props - Component props
26
+ * @param props.messages - Array of A2UI messages to render
27
+ * @param props.components - Optional custom component overrides
28
+ * @param props.children - Child components (typically A2UIRenderer)
29
+ *
30
+ * @example
31
+ * ```tsx
32
+ * // Basic usage
33
+ * <A2UIProvider messages={messages}>
34
+ * <A2UIRenderer onAction={handleAction} />
35
+ * </A2UIProvider>
36
+ *
37
+ * // With custom components
38
+ * const customComponents = new Map([
39
+ * ['Button', CustomButton],
40
+ * ['Switch', CustomSwitch],
41
+ * ])
42
+ * <A2UIProvider
43
+ * messages={messages}
44
+ * components={customComponents}
45
+ * >
46
+ * <A2UIRenderer onAction={handleAction} />
47
+ * </A2UIProvider>
48
+ *
49
+ * // With custom middleware for hooks access
50
+ * <A2UIProvider messages={messages}>
51
+ * <MyCustomComponent />
52
+ * <A2UIRenderer onAction={handleAction} />
53
+ * </A2UIProvider>
54
+ * ```
55
+ */
56
+ export declare function A2UIProvider({ messages, components, children, }: A2UIProviderProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,33 @@
1
+ import { jsx as e, Fragment as n } from "react/jsx-runtime";
2
+ import { useEffect as i } from "react";
3
+ import { SurfaceProvider as f } from "./SurfaceContext.js";
4
+ import { DataModelProvider as m } from "./DataModelContext.js";
5
+ import { ComponentsMapProvider as a } from "./ComponentsMapContext.js";
6
+ import { componentRegistry as c } from "../components/ComponentRenderer.js";
7
+ import { useA2UIMessageHandler as p } from "../hooks/useA2UIMessageHandler.js";
8
+ function d({
9
+ messages: r,
10
+ children: t
11
+ }) {
12
+ const { processMessages: o, clear: s } = p();
13
+ return i(() => {
14
+ s(), r && r.length > 0 && o(r);
15
+ }, [r, o, s]), /* @__PURE__ */ e(n, { children: t });
16
+ }
17
+ function A({
18
+ messages: r,
19
+ components: t,
20
+ children: o
21
+ }) {
22
+ return /* @__PURE__ */ e(f, { children: /* @__PURE__ */ e(m, { children: /* @__PURE__ */ e(
23
+ a,
24
+ {
25
+ components: t,
26
+ defaultComponents: c,
27
+ children: /* @__PURE__ */ e(d, { messages: r ?? [], children: o })
28
+ }
29
+ ) }) });
30
+ }
31
+ export {
32
+ A as A2UIProvider
33
+ };
@@ -0,0 +1,33 @@
1
+ import { ReactNode } from 'react';
2
+ import { Action, ActionHandler } from '@a2ui-sdk/types/0.8';
3
+ /**
4
+ * Action context value interface.
5
+ */
6
+ export interface ActionContextValue {
7
+ /** Dispatches an action with resolved context */
8
+ dispatchAction: (surfaceId: string, componentId: string, action: Action) => void;
9
+ /** The action handler callback (if set) */
10
+ onAction: ActionHandler | null;
11
+ }
12
+ /**
13
+ * Action context for A2UI rendering.
14
+ */
15
+ export declare const ActionContext: import('react').Context<ActionContextValue | null>;
16
+ /**
17
+ * Props for ActionProvider.
18
+ */
19
+ export interface ActionProviderProps {
20
+ /** Callback when an action is dispatched */
21
+ onAction?: ActionHandler;
22
+ children: ReactNode;
23
+ }
24
+ /**
25
+ * Provider component for Action dispatching.
26
+ */
27
+ export declare function ActionProvider({ onAction, children }: ActionProviderProps): import("react/jsx-runtime").JSX.Element;
28
+ /**
29
+ * Hook to access the Action context.
30
+ *
31
+ * @throws Error if used outside of ActionProvider
32
+ */
33
+ export declare function useActionContext(): ActionContextValue;
@@ -0,0 +1,41 @@
1
+ import { jsx as m } from "react/jsx-runtime";
2
+ import { useContext as x, createContext as C, useCallback as p, useMemo as f } from "react";
3
+ import { useDataModelContext as v } from "./DataModelContext.js";
4
+ import { resolveActionContext as A } from "../utils/dataBinding.js";
5
+ const s = C(null);
6
+ function P({ onAction: t, children: c }) {
7
+ const { getDataModel: o } = v(), e = p(
8
+ (n, a, r) => {
9
+ if (!t) {
10
+ console.warn("A2UI: Action dispatched but no handler is registered");
11
+ return;
12
+ }
13
+ const u = o(n), d = A(r.context, u), l = {
14
+ surfaceId: n,
15
+ name: r.name,
16
+ context: d,
17
+ sourceComponentId: a
18
+ };
19
+ t(l);
20
+ },
21
+ [t, o]
22
+ ), i = f(
23
+ () => ({
24
+ dispatchAction: e,
25
+ onAction: t ?? null
26
+ }),
27
+ [e, t]
28
+ );
29
+ return /* @__PURE__ */ m(s.Provider, { value: i, children: c });
30
+ }
31
+ function g() {
32
+ const t = x(s);
33
+ if (!t)
34
+ throw new Error("useActionContext must be used within an ActionProvider");
35
+ return t;
36
+ }
37
+ export {
38
+ s as ActionContext,
39
+ P as ActionProvider,
40
+ g as useActionContext
41
+ };