@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.
- package/dist/0.8/A2UIRenderer.d.ts +31 -0
- package/dist/0.8/A2UIRenderer.js +19 -0
- package/dist/0.8/components/ComponentRenderer.d.ts +39 -0
- package/dist/0.8/components/ComponentRenderer.js +76 -0
- package/dist/0.8/components/UnknownComponent.d.ts +18 -0
- package/dist/0.8/components/display/AudioPlayerComponent.d.ts +5 -0
- package/dist/0.8/components/display/AudioPlayerComponent.js +19 -0
- package/dist/0.8/components/display/DividerComponent.d.ts +5 -0
- package/dist/0.8/components/display/DividerComponent.js +18 -0
- package/dist/0.8/components/display/IconComponent.d.ts +5 -0
- package/dist/0.8/components/display/IconComponent.js +68 -0
- package/dist/0.8/components/display/ImageComponent.d.ts +6 -0
- package/dist/0.8/components/display/ImageComponent.js +36 -0
- package/dist/0.8/components/display/TextComponent.d.ts +6 -0
- package/dist/0.8/components/display/TextComponent.js +32 -0
- package/dist/0.8/components/display/VideoComponent.d.ts +5 -0
- package/dist/0.8/components/display/VideoComponent.js +18 -0
- package/dist/0.8/components/display/index.d.ts +9 -0
- package/dist/0.8/components/index.d.ts +7 -0
- package/dist/0.8/components/interactive/ButtonComponent.d.ts +5 -0
- package/dist/0.8/components/interactive/ButtonComponent.js +29 -0
- package/dist/0.8/components/interactive/CheckBoxComponent.d.ts +5 -0
- package/dist/0.8/components/interactive/CheckBoxComponent.js +27 -0
- package/dist/0.8/components/interactive/DateTimeInputComponent.d.ts +5 -0
- package/dist/0.8/components/interactive/DateTimeInputComponent.js +46 -0
- package/dist/0.8/components/interactive/MultipleChoiceComponent.d.ts +7 -0
- package/dist/0.8/components/interactive/MultipleChoiceComponent.js +89 -0
- package/dist/0.8/components/interactive/SliderComponent.d.ts +5 -0
- package/dist/0.8/components/interactive/SliderComponent.js +48 -0
- package/dist/0.8/components/interactive/TextFieldComponent.d.ts +5 -0
- package/dist/0.8/components/interactive/TextFieldComponent.js +44 -0
- package/dist/0.8/components/interactive/index.d.ts +9 -0
- package/dist/0.8/components/layout/CardComponent.d.ts +5 -0
- package/dist/0.8/components/layout/CardComponent.js +14 -0
- package/dist/0.8/components/layout/ColumnComponent.d.ts +5 -0
- package/dist/0.8/components/layout/ColumnComponent.js +58 -0
- package/dist/0.8/components/layout/ListComponent.d.ts +5 -0
- package/dist/0.8/components/layout/ListComponent.js +51 -0
- package/dist/0.8/components/layout/ModalComponent.d.ts +5 -0
- package/dist/0.8/components/layout/ModalComponent.js +25 -0
- package/dist/0.8/components/layout/RowComponent.d.ts +5 -0
- package/dist/0.8/components/layout/RowComponent.js +58 -0
- package/dist/0.8/components/layout/TabsComponent.d.ts +5 -0
- package/dist/0.8/components/layout/TabsComponent.js +29 -0
- package/dist/0.8/components/layout/index.d.ts +9 -0
- package/dist/0.8/contexts/A2UIProvider.d.ts +56 -0
- package/dist/0.8/contexts/A2UIProvider.js +33 -0
- package/dist/0.8/contexts/ActionContext.d.ts +33 -0
- package/dist/0.8/contexts/ActionContext.js +41 -0
- package/dist/0.8/contexts/ComponentsMapContext.d.ts +63 -0
- package/dist/0.8/contexts/ComponentsMapContext.js +21 -0
- package/dist/0.8/contexts/DataModelContext.d.ts +43 -0
- package/dist/0.8/contexts/DataModelContext.js +86 -0
- package/dist/0.8/contexts/SurfaceContext.d.ts +45 -0
- package/dist/0.8/contexts/SurfaceContext.js +88 -0
- package/dist/0.8/hooks/useA2UIMessageHandler.d.ts +41 -0
- package/dist/0.8/hooks/useA2UIMessageHandler.js +54 -0
- package/dist/0.8/hooks/useComponent.d.ts +23 -0
- package/dist/0.8/hooks/useComponent.js +9 -0
- package/dist/0.8/hooks/useDataBinding.d.ts +50 -0
- package/dist/0.8/hooks/useDataBinding.js +28 -0
- package/dist/0.8/hooks/useDispatchAction.d.ts +22 -0
- package/dist/0.8/hooks/useDispatchAction.js +8 -0
- package/dist/0.8/index.d.ts +44 -0
- package/dist/0.8/index.js +17 -0
- package/dist/0.8/utils/dataBinding.d.ts +95 -0
- package/dist/0.8/utils/dataBinding.js +46 -0
- package/dist/0.8/utils/pathUtils.d.ts +63 -0
- package/dist/0.8/utils/pathUtils.js +44 -0
- package/dist/0.9/A2UIRenderer.d.ts +54 -0
- package/dist/0.9/A2UIRenderer.js +41 -0
- package/dist/0.9/components/ComponentRenderer.d.ts +39 -0
- package/dist/0.9/components/ComponentRenderer.js +34 -0
- package/dist/0.9/components/UnknownComponent.d.ts +11 -0
- package/dist/0.9/components/UnknownComponent.js +35 -0
- package/dist/0.9/components/display/AudioPlayerComponent.d.ts +5 -0
- package/dist/0.9/components/display/AudioPlayerComponent.js +21 -0
- package/dist/0.9/components/display/DividerComponent.d.ts +5 -0
- package/dist/0.9/components/display/DividerComponent.js +19 -0
- package/dist/0.9/components/display/IconComponent.d.ts +5 -0
- package/dist/0.9/components/display/IconComponent.js +68 -0
- package/dist/0.9/components/display/ImageComponent.d.ts +6 -0
- package/dist/0.9/components/display/ImageComponent.js +43 -0
- package/dist/0.9/components/display/TextComponent.d.ts +6 -0
- package/dist/0.9/components/display/TextComponent.js +31 -0
- package/dist/0.9/components/display/VideoComponent.d.ts +5 -0
- package/dist/0.9/components/display/VideoComponent.js +30 -0
- package/dist/0.9/components/display/index.d.ts +9 -0
- package/dist/0.9/components/index.d.ts +12 -0
- package/dist/0.9/components/index.js +68 -0
- package/dist/0.9/components/interactive/ButtonComponent.d.ts +6 -0
- package/dist/0.9/components/interactive/ButtonComponent.js +29 -0
- package/dist/0.9/components/interactive/CheckBoxComponent.d.ts +5 -0
- package/dist/0.9/components/interactive/CheckBoxComponent.js +41 -0
- package/dist/0.9/components/interactive/ChoicePickerComponent.d.ts +7 -0
- package/dist/0.9/components/interactive/ChoicePickerComponent.js +80 -0
- package/dist/0.9/components/interactive/DateTimeInputComponent.d.ts +5 -0
- package/dist/0.9/components/interactive/DateTimeInputComponent.js +50 -0
- package/dist/0.9/components/interactive/SliderComponent.d.ts +6 -0
- package/dist/0.9/components/interactive/SliderComponent.js +47 -0
- package/dist/0.9/components/interactive/TextFieldComponent.d.ts +5 -0
- package/dist/0.9/components/interactive/TextFieldComponent.js +57 -0
- package/dist/0.9/components/interactive/index.d.ts +9 -0
- package/dist/0.9/components/layout/CardComponent.d.ts +5 -0
- package/dist/0.9/components/layout/CardComponent.js +15 -0
- package/dist/0.9/components/layout/ColumnComponent.d.ts +6 -0
- package/dist/0.9/components/layout/ColumnComponent.js +50 -0
- package/dist/0.9/components/layout/ListComponent.d.ts +17 -0
- package/dist/0.9/components/layout/ListComponent.js +42 -0
- package/dist/0.9/components/layout/ModalComponent.d.ts +5 -0
- package/dist/0.9/components/layout/ModalComponent.js +30 -0
- package/dist/0.9/components/layout/RowComponent.d.ts +6 -0
- package/dist/0.9/components/layout/RowComponent.js +50 -0
- package/dist/0.9/components/layout/TabsComponent.d.ts +5 -0
- package/dist/0.9/components/layout/TabsComponent.js +30 -0
- package/dist/0.9/components/layout/TemplateRenderer.d.ts +25 -0
- package/dist/0.9/components/layout/TemplateRenderer.js +49 -0
- package/dist/0.9/components/layout/index.d.ts +10 -0
- package/dist/0.9/contexts/A2UIProvider.d.ts +58 -0
- package/dist/0.9/contexts/A2UIProvider.js +34 -0
- package/dist/0.9/contexts/ActionContext.d.ts +33 -0
- package/dist/0.9/contexts/ActionContext.js +47 -0
- package/dist/0.9/contexts/ComponentsMapContext.d.ts +73 -0
- package/dist/0.9/contexts/ComponentsMapContext.js +21 -0
- package/dist/0.9/contexts/ScopeContext.d.ts +53 -0
- package/dist/0.9/contexts/ScopeContext.js +22 -0
- package/dist/0.9/contexts/SurfaceContext.d.ts +50 -0
- package/dist/0.9/contexts/SurfaceContext.js +118 -0
- package/dist/0.9/hooks/useA2UIMessageHandler.d.ts +44 -0
- package/dist/0.9/hooks/useA2UIMessageHandler.js +87 -0
- package/dist/0.9/hooks/useComponent.d.ts +23 -0
- package/dist/0.9/hooks/useComponent.js +9 -0
- package/dist/0.9/hooks/useDataBinding.d.ts +59 -0
- package/dist/0.9/hooks/useDataBinding.js +43 -0
- package/dist/0.9/hooks/useDispatchAction.d.ts +22 -0
- package/dist/0.9/hooks/useDispatchAction.js +17 -0
- package/dist/0.9/hooks/useValidation.d.ts +25 -0
- package/dist/0.9/hooks/useValidation.js +14 -0
- package/dist/0.9/index.d.ts +35 -0
- package/dist/0.9/index.js +26 -0
- package/dist/0.9/utils/dataBinding.d.ts +126 -0
- package/dist/0.9/utils/dataBinding.js +41 -0
- package/dist/0.9/utils/pathUtils.d.ts +109 -0
- package/dist/0.9/utils/pathUtils.js +74 -0
- package/dist/0.9/utils/validation.d.ts +49 -0
- package/dist/0.9/utils/validation.js +75 -0
- package/dist/components/ui/button.d.ts +10 -0
- package/dist/components/ui/button.js +53 -0
- package/dist/components/ui/card.d.ts +9 -0
- package/dist/components/ui/card.js +29 -0
- package/dist/components/ui/checkbox.d.ts +4 -0
- package/dist/components/ui/checkbox.js +31 -0
- package/dist/components/ui/dialog.d.ts +15 -0
- package/dist/components/ui/dialog.js +77 -0
- package/dist/components/ui/input.d.ts +3 -0
- package/dist/components/ui/input.js +21 -0
- package/dist/components/ui/label.d.ts +4 -0
- package/dist/components/ui/label.js +22 -0
- package/dist/components/ui/native-select.d.ts +7 -0
- package/dist/components/ui/select.d.ts +15 -0
- package/dist/components/ui/select.js +144 -0
- package/dist/components/ui/separator.d.ts +4 -0
- package/dist/components/ui/separator.js +26 -0
- package/dist/components/ui/slider.d.ts +4 -0
- package/dist/components/ui/slider.js +63 -0
- package/dist/components/ui/tabs.d.ts +7 -0
- package/dist/components/ui/tabs.js +67 -0
- package/dist/components/ui/textarea.d.ts +3 -0
- package/dist/components/ui/textarea.js +18 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +6 -0
- package/dist/lib/utils.d.ts +2 -0
- package/dist/lib/utils.js +8 -0
- 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,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,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,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,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,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,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,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,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
|
+
};
|