@nine1ie/a2ui-vue 0.1.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 (62) hide show
  1. package/LICENSE +21 -0
  2. package/dist/index.css +1 -0
  3. package/dist/index.js +880 -0
  4. package/dist/renderer/src/A2UIRenderer.vue.d.ts +20 -0
  5. package/dist/renderer/src/A2UIRenderer.vue.d.ts.map +1 -0
  6. package/dist/renderer/src/ComponentResolver.vue.d.ts +8 -0
  7. package/dist/renderer/src/ComponentResolver.vue.d.ts.map +1 -0
  8. package/dist/renderer/src/SurfaceRenderer.vue.d.ts +6 -0
  9. package/dist/renderer/src/SurfaceRenderer.vue.d.ts.map +1 -0
  10. package/dist/renderer/src/component-map.d.ts +4 -0
  11. package/dist/renderer/src/component-map.d.ts.map +1 -0
  12. package/dist/renderer/src/components/container/Card.vue.d.ts +8 -0
  13. package/dist/renderer/src/components/container/Card.vue.d.ts.map +1 -0
  14. package/dist/renderer/src/components/container/Modal.vue.d.ts +8 -0
  15. package/dist/renderer/src/components/container/Modal.vue.d.ts.map +1 -0
  16. package/dist/renderer/src/components/container/Tabs.vue.d.ts +8 -0
  17. package/dist/renderer/src/components/container/Tabs.vue.d.ts.map +1 -0
  18. package/dist/renderer/src/components/display/AudioPlayer.vue.d.ts +8 -0
  19. package/dist/renderer/src/components/display/AudioPlayer.vue.d.ts.map +1 -0
  20. package/dist/renderer/src/components/display/Divider.vue.d.ts +7 -0
  21. package/dist/renderer/src/components/display/Divider.vue.d.ts.map +1 -0
  22. package/dist/renderer/src/components/display/Icon.vue.d.ts +8 -0
  23. package/dist/renderer/src/components/display/Icon.vue.d.ts.map +1 -0
  24. package/dist/renderer/src/components/display/Image.vue.d.ts +8 -0
  25. package/dist/renderer/src/components/display/Image.vue.d.ts.map +1 -0
  26. package/dist/renderer/src/components/display/Text.vue.d.ts +8 -0
  27. package/dist/renderer/src/components/display/Text.vue.d.ts.map +1 -0
  28. package/dist/renderer/src/components/display/Video.vue.d.ts +8 -0
  29. package/dist/renderer/src/components/display/Video.vue.d.ts.map +1 -0
  30. package/dist/renderer/src/components/input/CheckBox.vue.d.ts +8 -0
  31. package/dist/renderer/src/components/input/CheckBox.vue.d.ts.map +1 -0
  32. package/dist/renderer/src/components/input/ChoicePicker.vue.d.ts +8 -0
  33. package/dist/renderer/src/components/input/ChoicePicker.vue.d.ts.map +1 -0
  34. package/dist/renderer/src/components/input/DateTimeInput.vue.d.ts +8 -0
  35. package/dist/renderer/src/components/input/DateTimeInput.vue.d.ts.map +1 -0
  36. package/dist/renderer/src/components/input/Slider.vue.d.ts +8 -0
  37. package/dist/renderer/src/components/input/Slider.vue.d.ts.map +1 -0
  38. package/dist/renderer/src/components/input/TextField.vue.d.ts +8 -0
  39. package/dist/renderer/src/components/input/TextField.vue.d.ts.map +1 -0
  40. package/dist/renderer/src/components/interactive/Button.vue.d.ts +8 -0
  41. package/dist/renderer/src/components/interactive/Button.vue.d.ts.map +1 -0
  42. package/dist/renderer/src/components/layout/Column.vue.d.ts +22 -0
  43. package/dist/renderer/src/components/layout/Column.vue.d.ts.map +1 -0
  44. package/dist/renderer/src/components/layout/List.vue.d.ts +22 -0
  45. package/dist/renderer/src/components/layout/List.vue.d.ts.map +1 -0
  46. package/dist/renderer/src/components/layout/Row.vue.d.ts +22 -0
  47. package/dist/renderer/src/components/layout/Row.vue.d.ts.map +1 -0
  48. package/dist/renderer/src/composables/useA2UI.d.ts +55 -0
  49. package/dist/renderer/src/composables/useA2UI.d.ts.map +1 -0
  50. package/dist/renderer/src/composables/useDataModel.d.ts +8 -0
  51. package/dist/renderer/src/composables/useDataModel.d.ts.map +1 -0
  52. package/dist/renderer/src/composables/useSurface.d.ts +12 -0
  53. package/dist/renderer/src/composables/useSurface.d.ts.map +1 -0
  54. package/dist/renderer/src/index.d.ts +12 -0
  55. package/dist/renderer/src/index.d.ts.map +1 -0
  56. package/dist/renderer/src/theme/design-tokens.d.ts +3 -0
  57. package/dist/renderer/src/theme/design-tokens.d.ts.map +1 -0
  58. package/dist/renderer/src/theme/provide.d.ts +11 -0
  59. package/dist/renderer/src/theme/provide.d.ts.map +1 -0
  60. package/dist/renderer/src/theme/tokens.d.ts +9 -0
  61. package/dist/renderer/src/theme/tokens.d.ts.map +1 -0
  62. package/package.json +40 -0
package/dist/index.js ADDED
@@ -0,0 +1,880 @@
1
+ import { inject as h, defineComponent as _, computed as i, openBlock as d, createBlock as k, resolveDynamicComponent as Y, normalizeClass as T, withCtx as J, createTextVNode as X, toDisplayString as $, createElementBlock as m, createElementVNode as g, normalizeStyle as B, renderSlot as P, createCommentVNode as C, ref as E, Fragment as U, renderList as L, provide as w, watch as Z, onBeforeUnmount as ee, createVNode as te, Teleport as ne, withModifiers as ae, unref as H, resolveComponent as oe, toRef as se, onUnmounted as re } from "vue";
2
+ import { isDynamicValue as S, resolvePath as x, resolveLiteral as I, executeFunction as R, setPath as V, isTemplateChildList as ce, getByPointer as ue, SurfaceManager as W, parseMessage as le } from "@nine1ie/a2ui-vue-core";
3
+ const O = Symbol("a2ui:surface"), F = Symbol("a2ui:registry"), D = Symbol("a2ui:dataModel");
4
+ function ie() {
5
+ const t = h(O), e = h(F), o = h(D);
6
+ if (!t || !e || !o)
7
+ throw new Error("[A2UI] useSurface() must be used within a SurfaceRenderer");
8
+ return { surface: t, registry: e, dataModel: o };
9
+ }
10
+ const pe = /* @__PURE__ */ _({
11
+ __name: "Text",
12
+ props: {
13
+ componentDef: {},
14
+ scope: {}
15
+ },
16
+ setup(t) {
17
+ const e = t, o = h(D), u = i(() => {
18
+ const s = e.componentDef.text;
19
+ return s ? S(s) ? "path" in s && s.path ? x(s.path, o.value, e.scope) : I(s) : String(s) : "";
20
+ }), a = i(() => {
21
+ const s = e.componentDef.usageHint;
22
+ return s ? s.startsWith("h") && !isNaN(Number(s[1])) ? s : s === "caption" ? "small" : "p" : "p";
23
+ });
24
+ return (s, l) => (d(), k(Y(a.value), {
25
+ class: T(["a2-text", `a2-text--${t.componentDef.usageHint ?? "body"}`])
26
+ }, {
27
+ default: J(() => [
28
+ X($(u.value), 1)
29
+ ]),
30
+ _: 1
31
+ }, 8, ["class"]));
32
+ }
33
+ }), b = (t, e) => {
34
+ const o = t.__vccOpts || t;
35
+ for (const [u, a] of e)
36
+ o[u] = a;
37
+ return o;
38
+ }, de = /* @__PURE__ */ b(pe, [["__scopeId", "data-v-72d838cd"]]), fe = { class: "a2-image-frame" }, me = ["src", "alt"], ve = {
39
+ key: 1,
40
+ class: "a2-image-empty"
41
+ }, _e = /* @__PURE__ */ _({
42
+ __name: "Image",
43
+ props: {
44
+ componentDef: {},
45
+ scope: {}
46
+ },
47
+ setup(t) {
48
+ const e = t, o = h(D);
49
+ function u(n) {
50
+ return n ? S(n) ? "path" in n && n.path ? x(n.path, o.value, e.scope) : I(n) : n : "";
51
+ }
52
+ const a = i(() => u(e.componentDef.url)), s = i(() => u(e.componentDef.alt) ?? ""), l = i(() => !!String(a.value ?? "").trim());
53
+ return (n, c) => (d(), m("div", fe, [
54
+ l.value ? (d(), m("img", {
55
+ key: 0,
56
+ class: "a2-image",
57
+ src: a.value,
58
+ alt: s.value,
59
+ loading: "lazy"
60
+ }, null, 8, me)) : (d(), m("div", ve, [...c[0] || (c[0] = [
61
+ g("span", { class: "a2-image-empty-icon" }, "◌", -1),
62
+ g("span", { class: "a2-image-empty-text" }, "Image unavailable", -1)
63
+ ])]))
64
+ ]));
65
+ }
66
+ }), he = /* @__PURE__ */ b(_e, [["__scopeId", "data-v-657be5eb"]]), be = ["data-icon", "aria-label"], ge = /* @__PURE__ */ _({
67
+ __name: "Icon",
68
+ props: {
69
+ componentDef: {},
70
+ scope: {}
71
+ },
72
+ setup(t) {
73
+ const e = t, o = h(D), u = i(() => {
74
+ const a = e.componentDef.icon;
75
+ return a ? S(a) ? "path" in a && a.path ? x(a.path, o.value, e.scope) : I(a) : String(a) : "";
76
+ });
77
+ return (a, s) => (d(), m("span", {
78
+ class: "a2-icon",
79
+ "data-icon": u.value,
80
+ role: "img",
81
+ "aria-label": u.value
82
+ }, $(u.value), 9, be));
83
+ }
84
+ }), xe = /* @__PURE__ */ b(ge, [["__scopeId", "data-v-9dbd16ec"]]), ye = {
85
+ class: "a2-divider",
86
+ "aria-orientation": "horizontal"
87
+ }, De = /* @__PURE__ */ _({
88
+ __name: "Divider",
89
+ props: {
90
+ componentDef: {}
91
+ },
92
+ setup(t) {
93
+ return (e, o) => (d(), m("hr", ye));
94
+ }
95
+ }), Se = /* @__PURE__ */ b(De, [["__scopeId", "data-v-bf27125a"]]), Ie = { class: "a2-video-shell" }, $e = ["src"], Ce = {
96
+ key: 1,
97
+ class: "a2-video-empty"
98
+ }, Me = /* @__PURE__ */ _({
99
+ __name: "Video",
100
+ props: {
101
+ componentDef: {},
102
+ scope: {}
103
+ },
104
+ setup(t) {
105
+ const e = t, o = h(D), u = i(() => {
106
+ const s = e.componentDef.url;
107
+ return s ? S(s) ? "path" in s && s.path ? x(s.path, o.value, e.scope) : I(s) : String(s) : "";
108
+ }), a = i(() => !!u.value.trim());
109
+ return (s, l) => (d(), m("div", Ie, [
110
+ a.value ? (d(), m("video", {
111
+ key: 0,
112
+ class: "a2-video",
113
+ controls: "",
114
+ src: u.value
115
+ }, null, 8, $e)) : (d(), m("div", Ce, [...l[0] || (l[0] = [
116
+ g("span", { class: "a2-video-empty-icon" }, "▶", -1),
117
+ g("span", { class: "a2-video-empty-text" }, "No video source", -1)
118
+ ])]))
119
+ ]));
120
+ }
121
+ }), ke = /* @__PURE__ */ b(Me, [["__scopeId", "data-v-d0aec5d0"]]), we = { class: "a2-audio-shell" }, Ae = ["src"], Te = {
122
+ key: 1,
123
+ class: "a2-audio-empty"
124
+ }, Re = /* @__PURE__ */ _({
125
+ __name: "AudioPlayer",
126
+ props: {
127
+ componentDef: {},
128
+ scope: {}
129
+ },
130
+ setup(t) {
131
+ const e = t, o = h(D), u = i(() => {
132
+ const s = e.componentDef.url;
133
+ return s ? S(s) ? "path" in s && s.path ? x(s.path, o.value, e.scope) : I(s) : String(s) : "";
134
+ }), a = i(() => !!u.value.trim());
135
+ return (s, l) => (d(), m("div", we, [
136
+ a.value ? (d(), m("audio", {
137
+ key: 0,
138
+ class: "a2-audio",
139
+ controls: "",
140
+ src: u.value
141
+ }, null, 8, Ae)) : (d(), m("div", Te, [...l[0] || (l[0] = [
142
+ g("span", { class: "a2-audio-empty-icon" }, "♫", -1),
143
+ g("span", { class: "a2-audio-empty-text" }, "No audio source", -1)
144
+ ])]))
145
+ ]));
146
+ }
147
+ }), Ne = /* @__PURE__ */ b(Re, [["__scopeId", "data-v-51bf1ff0"]]), Be = /* @__PURE__ */ _({
148
+ __name: "Row",
149
+ props: {
150
+ componentDef: {}
151
+ },
152
+ setup(t) {
153
+ const e = t, o = i(() => e.componentDef.alignment ?? "start"), u = i(() => ({
154
+ start: "flex-start",
155
+ center: "center",
156
+ end: "flex-end",
157
+ "space-between": "space-between",
158
+ "space-around": "space-around"
159
+ })[o.value] ?? "flex-start");
160
+ return (a, s) => (d(), m("div", {
161
+ class: "a2-row",
162
+ style: B({ justifyContent: u.value })
163
+ }, [
164
+ P(a.$slots, "default", {}, void 0, !0)
165
+ ], 4));
166
+ }
167
+ }), Ee = /* @__PURE__ */ b(Be, [["__scopeId", "data-v-8dc59252"]]), Ve = /* @__PURE__ */ _({
168
+ __name: "Column",
169
+ props: {
170
+ componentDef: {}
171
+ },
172
+ setup(t) {
173
+ const e = t, o = i(() => e.componentDef.alignment ?? "start"), u = i(() => ({
174
+ start: "flex-start",
175
+ center: "center",
176
+ end: "flex-end",
177
+ "space-between": "stretch",
178
+ "space-around": "stretch"
179
+ })[o.value] ?? "flex-start");
180
+ return (a, s) => (d(), m("div", {
181
+ class: "a2-column",
182
+ style: B({ alignItems: u.value })
183
+ }, [
184
+ P(a.$slots, "default", {}, void 0, !0)
185
+ ], 4));
186
+ }
187
+ }), Ue = /* @__PURE__ */ b(Ve, [["__scopeId", "data-v-b9114ac3"]]), Le = { class: "a2-list" }, ze = /* @__PURE__ */ _({
188
+ __name: "List",
189
+ props: {
190
+ componentDef: {}
191
+ },
192
+ setup(t) {
193
+ return (e, o) => (d(), m("div", Le, [
194
+ P(e.$slots, "default", {}, void 0, !0)
195
+ ]));
196
+ }
197
+ }), Pe = /* @__PURE__ */ b(ze, [["__scopeId", "data-v-eb613bdc"]]), Oe = { class: "a2-card" }, Fe = /* @__PURE__ */ _({
198
+ __name: "Card",
199
+ props: {
200
+ componentDef: {},
201
+ scope: {}
202
+ },
203
+ setup(t) {
204
+ return (e, o) => (d(), m("div", Oe, [
205
+ t.componentDef.child ? (d(), k(N, {
206
+ key: 0,
207
+ "component-id": t.componentDef.child,
208
+ scope: t.scope
209
+ }, null, 8, ["component-id", "scope"])) : C("", !0)
210
+ ]));
211
+ }
212
+ }), Ke = /* @__PURE__ */ b(Fe, [["__scopeId", "data-v-af74bfb0"]]), je = { class: "a2-tabs" }, Ye = { class: "a2-tabs-header" }, Je = ["onClick"], He = { class: "a2-tabs-content" }, We = /* @__PURE__ */ _({
213
+ __name: "Tabs",
214
+ props: {
215
+ componentDef: {},
216
+ scope: {}
217
+ },
218
+ setup(t) {
219
+ const e = t, o = E(0), u = i(() => e.componentDef.tabs ?? []), a = i(() => u.value[o.value]);
220
+ return (s, l) => {
221
+ var n;
222
+ return d(), m("div", je, [
223
+ g("div", Ye, [
224
+ (d(!0), m(U, null, L(u.value, (c, f) => (d(), m("button", {
225
+ key: f,
226
+ class: T(["a2-tabs-tab", { "a2-tabs-tab--active": f === o.value }]),
227
+ onClick: (r) => o.value = f
228
+ }, $(c.title), 11, Je))), 128))
229
+ ]),
230
+ g("div", He, [
231
+ (n = a.value) != null && n.child ? (d(), k(N, {
232
+ key: 0,
233
+ "component-id": a.value.child,
234
+ scope: t.scope
235
+ }, null, 8, ["component-id", "scope"])) : C("", !0)
236
+ ])
237
+ ]);
238
+ };
239
+ }
240
+ }), Ge = /* @__PURE__ */ b(We, [["__scopeId", "data-v-2d1df1f8"]]), qe = {
241
+ primaryColor: "#6366f1"
242
+ };
243
+ function K(t) {
244
+ return { ...qe, ...t };
245
+ }
246
+ function G(t) {
247
+ const e = t.primaryColor, o = Qe(e, -10), u = z(e, 0.15);
248
+ return {
249
+ // ─── Typography ───
250
+ "--a2-font-family": t.fontFamily ?? "'IBM Plex Sans', 'Avenir Next', 'Segoe UI', sans-serif",
251
+ "--a2-line-height": "1.5",
252
+ "--a2-font-size-xs": "0.75rem",
253
+ // 12px
254
+ "--a2-font-size-sm": "0.8125rem",
255
+ // 13px
256
+ "--a2-font-size-base": "0.875rem",
257
+ // 14px
258
+ "--a2-font-size-lg": "1rem",
259
+ // 16px
260
+ "--a2-font-size-xl": "1.125rem",
261
+ // 18px
262
+ "--a2-font-size-2xl": "1.25rem",
263
+ // 20px
264
+ "--a2-font-size-3xl": "1.5rem",
265
+ // 24px
266
+ "--a2-font-size-4xl": "2rem",
267
+ // 32px
268
+ "--a2-font-weight-normal": "400",
269
+ "--a2-font-weight-medium": "500",
270
+ "--a2-font-weight-semibold": "600",
271
+ "--a2-font-weight-bold": "700",
272
+ // ─── Colors: Primary ───
273
+ "--a2-color-primary": e,
274
+ "--a2-color-primary-hover": o,
275
+ "--a2-color-primary-focus": u,
276
+ // ─── Colors: Semantic ───
277
+ "--a2-color-error": t.errorColor ?? "#ef4444",
278
+ "--a2-color-error-focus": z(t.errorColor ?? "#ef4444", 0.15),
279
+ // ─── Colors: Text ───
280
+ "--a2-text-primary": "#1e293b",
281
+ "--a2-text-secondary": "#475569",
282
+ "--a2-text-muted": "#94a3b8",
283
+ "--a2-text-inverse": "#ffffff",
284
+ "--a2-text-disabled": "#cbd5e1",
285
+ // ─── Colors: Background ───
286
+ "--a2-bg-page": "#f8fafc",
287
+ "--a2-bg-surface": "#ffffff",
288
+ "--a2-bg-elevated": "#ffffff",
289
+ "--a2-bg-muted": "#f1f5f9",
290
+ "--a2-bg-subtle": "#f8f7fc",
291
+ "--a2-bg-tint": z(e, 0.08),
292
+ "--a2-bg-hover": "#f1f5f9",
293
+ "--a2-bg-overlay": "rgba(0, 0, 0, 0.5)",
294
+ // ─── Border ───
295
+ "--a2-border-default": "#e2e8f0",
296
+ "--a2-border-strong": "#cbd5e1",
297
+ "--a2-border-focus": e,
298
+ // ─── Border Radius ───
299
+ "--a2-radius-sm": "4px",
300
+ "--a2-radius-base": "8px",
301
+ "--a2-radius-lg": "12px",
302
+ "--a2-radius-xl": "18px",
303
+ "--a2-radius-full": "9999px",
304
+ // ─── Shadows ───
305
+ "--a2-shadow-sm": "0 1px 2px rgba(0, 0, 0, 0.05)",
306
+ "--a2-shadow-base": "0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06)",
307
+ "--a2-shadow-card": "0 10px 30px rgba(15, 23, 42, 0.06)",
308
+ "--a2-shadow-panel": "0 18px 42px rgba(57, 45, 101, 0.08)",
309
+ "--a2-shadow-lg": "0 10px 25px rgba(0, 0, 0, 0.15)",
310
+ "--a2-shadow-xl": "0 20px 50px rgba(0, 0, 0, 0.25)",
311
+ "--a2-shadow-focus": `0 0 0 3px ${u}`,
312
+ // ─── Spacing ───
313
+ "--a2-space-1": "4px",
314
+ "--a2-space-2": "8px",
315
+ "--a2-space-3": "12px",
316
+ "--a2-space-4": "16px",
317
+ "--a2-space-5": "20px",
318
+ "--a2-space-6": "24px",
319
+ "--a2-space-7": "28px",
320
+ "--a2-space-8": "32px",
321
+ // ─── Transition ───
322
+ "--a2-transition-fast": "150ms ease",
323
+ "--a2-transition-base": "200ms ease"
324
+ };
325
+ }
326
+ function z(t, e) {
327
+ const o = parseInt(t.slice(1, 3), 16), u = parseInt(t.slice(3, 5), 16), a = parseInt(t.slice(5, 7), 16);
328
+ return `rgba(${o}, ${u}, ${a}, ${e})`;
329
+ }
330
+ function Qe(t, e) {
331
+ const o = Math.min(255, Math.max(0, parseInt(t.slice(1, 3), 16) + e)), u = Math.min(255, Math.max(0, parseInt(t.slice(3, 5), 16) + e)), a = Math.min(255, Math.max(0, parseInt(t.slice(5, 7), 16) + e));
332
+ return `#${o.toString(16).padStart(2, "0")}${u.toString(16).padStart(2, "0")}${a.toString(16).padStart(2, "0")}`;
333
+ }
334
+ const q = Symbol("a2ui:theme"), Q = Symbol("a2ui:cssVars");
335
+ function Xe(t) {
336
+ const e = i(() => K(t)), o = i(() => G(e.value));
337
+ return w(q, e), w(Q, o), { tokens: e, cssVars: o };
338
+ }
339
+ function Ot() {
340
+ return h(q) ?? i(() => K());
341
+ }
342
+ function Ze() {
343
+ return h(Q) ?? i(() => G(K()));
344
+ }
345
+ const et = { class: "a2-modal-wrapper" }, tt = { class: "a2-modal-content" }, nt = /* @__PURE__ */ _({
346
+ __name: "Modal",
347
+ props: {
348
+ componentDef: {},
349
+ scope: {}
350
+ },
351
+ setup(t) {
352
+ const e = E(!1), o = Ze();
353
+ function u() {
354
+ e.value = !0;
355
+ }
356
+ function a() {
357
+ e.value = !1;
358
+ }
359
+ function s(n) {
360
+ (n.key === "Enter" || n.key === " ") && (n.preventDefault(), u());
361
+ }
362
+ function l(n) {
363
+ n.key === "Escape" && a();
364
+ }
365
+ return Z(e, (n) => {
366
+ n ? window.addEventListener("keydown", l) : window.removeEventListener("keydown", l);
367
+ }), ee(() => {
368
+ window.removeEventListener("keydown", l);
369
+ }), (n, c) => (d(), m("div", et, [
370
+ t.componentDef.trigger ? (d(), m("div", {
371
+ key: 0,
372
+ class: "a2-modal-trigger",
373
+ role: "button",
374
+ tabindex: "0",
375
+ onClick: u,
376
+ onKeydown: s
377
+ }, [
378
+ te(N, {
379
+ "component-id": t.componentDef.trigger,
380
+ scope: t.scope
381
+ }, null, 8, ["component-id", "scope"])
382
+ ], 32)) : C("", !0),
383
+ (d(), k(ne, { to: "body" }, [
384
+ e.value ? (d(), m("div", {
385
+ key: 0,
386
+ class: "a2-modal-overlay",
387
+ style: B(H(o)),
388
+ onClick: ae(a, ["self"])
389
+ }, [
390
+ g("div", tt, [
391
+ g("button", {
392
+ class: "a2-modal-close",
393
+ type: "button",
394
+ onClick: a
395
+ }, " Close "),
396
+ t.componentDef.child ? (d(), k(N, {
397
+ key: 0,
398
+ "component-id": t.componentDef.child,
399
+ scope: t.scope
400
+ }, null, 8, ["component-id", "scope"])) : C("", !0)
401
+ ])
402
+ ], 4)) : C("", !0)
403
+ ]))
404
+ ]));
405
+ }
406
+ }), at = /* @__PURE__ */ b(nt, [["__scopeId", "data-v-ff424ab9"]]), ot = ["disabled"], st = /* @__PURE__ */ _({
407
+ __name: "Button",
408
+ props: {
409
+ componentDef: {},
410
+ scope: {}
411
+ },
412
+ setup(t) {
413
+ const e = t, o = h(D), u = h(O), a = h("a2ui:surfaceManager"), s = i(() => {
414
+ const r = e.componentDef.label;
415
+ return r ? S(r) ? "path" in r && r.path ? x(r.path, o.value, e.scope) : I(r) : String(r) : "";
416
+ }), l = i(() => e.componentDef.variant ?? "default"), n = i(() => {
417
+ const r = e.componentDef.checks;
418
+ return r != null && r.length ? r.every((p) => R({ call: p.call, args: p.args }, o.value, e.scope) === !0) : !0;
419
+ });
420
+ function c(r) {
421
+ return S(r) ? "path" in r && r.path ? x(r.path, o.value, e.scope) : "functionCall" in r && r.functionCall ? R(r.functionCall, o.value, e.scope) : I(r) : r;
422
+ }
423
+ function f() {
424
+ if (!n.value) return;
425
+ const r = e.componentDef.action;
426
+ if (r) {
427
+ if ("event" in r && r.event) {
428
+ const p = {};
429
+ if (r.event.context)
430
+ for (const [M, A] of Object.entries(r.event.context))
431
+ p[M] = c(A);
432
+ const v = {
433
+ name: r.event.name,
434
+ surfaceId: (u == null ? void 0 : u.value.id) ?? "",
435
+ sourceComponentId: e.componentDef.id,
436
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
437
+ context: p
438
+ };
439
+ a == null || a.dispatchAction(v);
440
+ }
441
+ "functionCall" in r && r.functionCall && R(r.functionCall, o.value, e.scope);
442
+ }
443
+ }
444
+ return (r, p) => (d(), m("button", {
445
+ class: T(["a2-button", [
446
+ `a2-button--${l.value}`,
447
+ { "a2-button--disabled": !n.value }
448
+ ]]),
449
+ type: "button",
450
+ disabled: !n.value,
451
+ onClick: f
452
+ }, $(s.value), 11, ot));
453
+ }
454
+ }), rt = /* @__PURE__ */ b(st, [["__scopeId", "data-v-2753f350"]]), ct = { class: "a2-text-field" }, ut = {
455
+ key: 0,
456
+ class: "a2-text-field-label"
457
+ }, lt = ["value", "placeholder"], it = {
458
+ key: 1,
459
+ class: "a2-text-field-error"
460
+ }, pt = /* @__PURE__ */ _({
461
+ __name: "TextField",
462
+ props: {
463
+ componentDef: {},
464
+ scope: {}
465
+ },
466
+ setup(t) {
467
+ const e = t, o = h(D), u = i(() => {
468
+ const p = e.componentDef.label;
469
+ return p ? S(p) ? "path" in p && p.path ? x(p.path, o.value, e.scope) : I(p) : String(p) : "";
470
+ }), a = i(() => {
471
+ const p = e.componentDef.placeholder;
472
+ return p ? S(p) ? I(p) ?? "" : String(p) : "";
473
+ }), s = i(() => {
474
+ var p;
475
+ return (p = e.componentDef.value) == null ? void 0 : p.path;
476
+ }), l = i({
477
+ get: () => s.value ? x(s.value, o.value, e.scope) ?? "" : "",
478
+ set: (p) => {
479
+ s.value && V(s.value, o.value, p, e.scope);
480
+ }
481
+ }), n = E(""), c = i(() => e.componentDef.checks ?? []);
482
+ function f() {
483
+ for (const p of c.value)
484
+ if (R(
485
+ { call: p.call, args: { value: l.value, ...p.args } },
486
+ o.value,
487
+ e.scope
488
+ ) !== !0)
489
+ return n.value = p.message ?? "Validation failed", !1;
490
+ return n.value = "", !0;
491
+ }
492
+ function r(p) {
493
+ const v = p.target;
494
+ l.value = v.value, f();
495
+ }
496
+ return (p, v) => (d(), m("div", ct, [
497
+ u.value ? (d(), m("label", ut, $(u.value), 1)) : C("", !0),
498
+ g("input", {
499
+ class: T(["a2-text-field-input", { "a2-text-field-input--error": n.value }]),
500
+ type: "text",
501
+ value: l.value,
502
+ placeholder: a.value,
503
+ onInput: r,
504
+ onBlur: f
505
+ }, null, 42, lt),
506
+ n.value ? (d(), m("p", it, $(n.value), 1)) : C("", !0)
507
+ ]));
508
+ }
509
+ }), dt = /* @__PURE__ */ b(pt, [["__scopeId", "data-v-e71a98e2"]]), ft = ["checked"], mt = {
510
+ key: 0,
511
+ class: "a2-checkbox-label"
512
+ }, vt = /* @__PURE__ */ _({
513
+ __name: "CheckBox",
514
+ props: {
515
+ componentDef: {},
516
+ scope: {}
517
+ },
518
+ setup(t) {
519
+ const e = t, o = h(D), u = i(() => {
520
+ const n = e.componentDef.label;
521
+ return n ? S(n) ? "path" in n && n.path ? x(n.path, o.value, e.scope) : I(n) : String(n) : "";
522
+ }), a = i(() => !!u.value.trim()), s = i(() => {
523
+ var n;
524
+ return (n = e.componentDef.value) == null ? void 0 : n.path;
525
+ }), l = i({
526
+ get: () => s.value ? !!x(s.value, o.value, e.scope) : !1,
527
+ set: (n) => {
528
+ s.value && V(s.value, o.value, n, e.scope);
529
+ }
530
+ });
531
+ return (n, c) => (d(), m("label", {
532
+ class: T(["a2-checkbox", { "a2-checkbox--compact": !a.value }])
533
+ }, [
534
+ g("input", {
535
+ class: "a2-checkbox-input",
536
+ type: "checkbox",
537
+ checked: l.value,
538
+ onChange: c[0] || (c[0] = (f) => l.value = f.target.checked)
539
+ }, null, 40, ft),
540
+ c[1] || (c[1] = g("span", {
541
+ class: "a2-checkbox-box",
542
+ "aria-hidden": "true"
543
+ }, null, -1)),
544
+ a.value ? (d(), m("span", mt, $(u.value), 1)) : C("", !0)
545
+ ], 2));
546
+ }
547
+ }), _t = /* @__PURE__ */ b(vt, [["__scopeId", "data-v-b50f43e3"]]), ht = { class: "a2-choice-picker" }, bt = ["onClick"], gt = /* @__PURE__ */ _({
548
+ __name: "ChoicePicker",
549
+ props: {
550
+ componentDef: {},
551
+ scope: {}
552
+ },
553
+ setup(t) {
554
+ const e = t, o = h(D), u = i(() => e.componentDef.options ?? []), a = i(() => e.componentDef.multi ?? !1), s = i(() => {
555
+ var f;
556
+ return (f = e.componentDef.value) == null ? void 0 : f.path;
557
+ }), l = i({
558
+ get: () => s.value ? x(s.value, o.value, e.scope) ?? (a.value ? [] : "") : a.value ? [] : "",
559
+ set: (f) => {
560
+ s.value && V(s.value, o.value, f, e.scope);
561
+ }
562
+ });
563
+ function n(f) {
564
+ return a.value ? Array.isArray(l.value) && l.value.includes(f) : l.value === f;
565
+ }
566
+ function c(f) {
567
+ if (a.value) {
568
+ const r = Array.isArray(l.value) ? [...l.value] : [], p = r.indexOf(f);
569
+ p >= 0 ? r.splice(p, 1) : r.push(f), l.value = r;
570
+ } else
571
+ l.value = f;
572
+ }
573
+ return (f, r) => (d(), m("div", ht, [
574
+ (d(!0), m(U, null, L(u.value, (p) => (d(), m("button", {
575
+ key: p.value,
576
+ type: "button",
577
+ class: T(["a2-choice-option", { "a2-choice-option--selected": n(p.value) }]),
578
+ onClick: (v) => c(p.value)
579
+ }, $(p.label), 11, bt))), 128))
580
+ ]));
581
+ }
582
+ }), xt = /* @__PURE__ */ b(gt, [["__scopeId", "data-v-6065c210"]]), yt = ["min", "max", "step", "value"], Dt = { class: "a2-slider-value" }, St = /* @__PURE__ */ _({
583
+ __name: "Slider",
584
+ props: {
585
+ componentDef: {},
586
+ scope: {}
587
+ },
588
+ setup(t) {
589
+ const e = t, o = h(D);
590
+ function u(r, p) {
591
+ return r ? S(r) ? "path" in r && r.path ? Number(x(r.path, o.value, e.scope)) || p : Number(I(r)) || p : Number(r) || p : p;
592
+ }
593
+ const a = i(() => u(e.componentDef.min, 0)), s = i(() => u(e.componentDef.max, 100)), l = i(() => u(e.componentDef.step, 1)), n = i(() => {
594
+ var r;
595
+ return (r = e.componentDef.value) == null ? void 0 : r.path;
596
+ }), c = i({
597
+ get: () => n.value && Number(x(n.value, o.value, e.scope)) || a.value,
598
+ set: (r) => {
599
+ n.value && V(n.value, o.value, r, e.scope);
600
+ }
601
+ }), f = i(() => {
602
+ const r = s.value - a.value;
603
+ return r <= 0 ? 0 : (c.value - a.value) / r * 100;
604
+ });
605
+ return (r, p) => (d(), m("div", {
606
+ class: "a2-slider",
607
+ style: B({ "--a2-slider-progress": `${f.value}%` })
608
+ }, [
609
+ g("input", {
610
+ type: "range",
611
+ min: a.value,
612
+ max: s.value,
613
+ step: l.value,
614
+ value: c.value,
615
+ class: "a2-slider-input",
616
+ onInput: p[0] || (p[0] = (v) => c.value = Number(v.target.value))
617
+ }, null, 40, yt),
618
+ g("span", Dt, $(c.value), 1)
619
+ ], 4));
620
+ }
621
+ }), It = /* @__PURE__ */ b(St, [["__scopeId", "data-v-8f2c7993"]]), $t = { class: "a2-datetime" }, Ct = {
622
+ key: 0,
623
+ class: "a2-datetime-label"
624
+ }, Mt = ["type", "value"], kt = /* @__PURE__ */ _({
625
+ __name: "DateTimeInput",
626
+ props: {
627
+ componentDef: {},
628
+ scope: {}
629
+ },
630
+ setup(t) {
631
+ const e = t, o = h(D), u = i(() => {
632
+ const c = e.componentDef.label;
633
+ return c ? S(c) ? "path" in c && c.path ? x(c.path, o.value, e.scope) : I(c) : String(c) : "";
634
+ }), a = i(() => e.componentDef.mode ?? "date"), s = i(() => ({ date: "date", time: "time", datetime: "datetime-local" })[a.value] ?? "date"), l = i(() => {
635
+ var c;
636
+ return (c = e.componentDef.value) == null ? void 0 : c.path;
637
+ }), n = i({
638
+ get: () => l.value ? x(l.value, o.value, e.scope) ?? "" : "",
639
+ set: (c) => {
640
+ l.value && V(l.value, o.value, c, e.scope);
641
+ }
642
+ });
643
+ return (c, f) => (d(), m("div", $t, [
644
+ u.value ? (d(), m("label", Ct, $(u.value), 1)) : C("", !0),
645
+ g("input", {
646
+ type: s.value,
647
+ value: n.value,
648
+ class: "a2-datetime-input",
649
+ onInput: f[0] || (f[0] = (r) => n.value = r.target.value)
650
+ }, null, 40, Mt)
651
+ ]));
652
+ }
653
+ }), wt = /* @__PURE__ */ b(kt, [["__scopeId", "data-v-cf5e5e7b"]]), j = /* @__PURE__ */ new Map(), At = {
654
+ Text: de,
655
+ Image: he,
656
+ Icon: xe,
657
+ Divider: Se,
658
+ Video: ke,
659
+ AudioPlayer: Ne,
660
+ Row: Ee,
661
+ Column: Ue,
662
+ List: Pe,
663
+ Card: Ke,
664
+ Tabs: Ge,
665
+ Modal: at,
666
+ Button: rt,
667
+ TextField: dt,
668
+ CheckBox: _t,
669
+ ChoicePicker: xt,
670
+ Slider: It,
671
+ DateTimeInput: wt
672
+ };
673
+ for (const [t, e] of Object.entries(At))
674
+ j.set(t, e);
675
+ function Ft(t, e) {
676
+ j.set(t, e);
677
+ }
678
+ function Tt(t) {
679
+ return j.get(t);
680
+ }
681
+ const N = /* @__PURE__ */ _({
682
+ __name: "ComponentResolver",
683
+ props: {
684
+ componentId: {},
685
+ scope: {}
686
+ },
687
+ setup(t) {
688
+ const e = t, { registry: o, dataModel: u } = ie(), a = i(() => o.value.getComponent(e.componentId)), s = i(() => a.value ? Tt(a.value.component) : null), l = i(() => {
689
+ if (!a.value) return [];
690
+ const n = a.value.children;
691
+ if (!n) return [];
692
+ if (ce(n)) {
693
+ const c = ue(u.value, n.template.dataBinding);
694
+ return Array.isArray(c) ? c.map((f, r) => ({
695
+ key: `${n.template.componentId}__${r}`,
696
+ componentId: n.template.componentId,
697
+ scope: {
698
+ currentItem: f,
699
+ index: r,
700
+ parent: e.scope
701
+ }
702
+ })) : [];
703
+ }
704
+ return (n.explicitList ?? []).map((c) => ({
705
+ key: c,
706
+ componentId: c,
707
+ scope: e.scope
708
+ }));
709
+ });
710
+ return (n, c) => {
711
+ const f = oe("ComponentResolver", !0);
712
+ return s.value && a.value ? (d(), k(Y(s.value), {
713
+ key: 0,
714
+ "component-def": a.value,
715
+ scope: t.scope
716
+ }, {
717
+ default: J(() => [
718
+ (d(!0), m(U, null, L(l.value, (r) => (d(), k(f, {
719
+ key: r.key,
720
+ "component-id": r.componentId,
721
+ scope: r.scope
722
+ }, null, 8, ["component-id", "scope"]))), 128))
723
+ ]),
724
+ _: 1
725
+ }, 8, ["component-def", "scope"])) : C("", !0);
726
+ };
727
+ }
728
+ }), Rt = ["data-surface-id"], Nt = { class: "a2ui-surface-meta" }, Bt = { class: "a2ui-surface-badge" }, Et = {
729
+ key: 0,
730
+ class: "a2ui-surface-agent"
731
+ }, Vt = {
732
+ key: 1,
733
+ class: "a2ui-surface-placeholder"
734
+ }, Ut = /* @__PURE__ */ _({
735
+ __name: "SurfaceRenderer",
736
+ props: {
737
+ surface: {}
738
+ },
739
+ setup(t) {
740
+ const e = t, o = se(e, "surface"), u = i(() => e.surface._version), a = i(() => (u.value, e.surface.dataModel)), s = i(() => (u.value, e.surface.componentRegistry));
741
+ w(O, o), w(F, s), w(D, a);
742
+ const l = i(() => s.value.hasComponent("root"));
743
+ return (n, c) => {
744
+ var f;
745
+ return d(), m("div", {
746
+ class: "a2ui-surface",
747
+ "data-surface-id": t.surface.id
748
+ }, [
749
+ g("div", Nt, [
750
+ g("span", Bt, $(t.surface.id), 1),
751
+ (f = t.surface.theme) != null && f.agentDisplayName ? (d(), m("span", Et, $(t.surface.theme.agentDisplayName), 1)) : C("", !0)
752
+ ]),
753
+ l.value ? (d(), k(N, {
754
+ key: 0,
755
+ "component-id": "root"
756
+ })) : (d(), m("div", Vt, " Waiting for root component... "))
757
+ ], 8, Rt);
758
+ };
759
+ }
760
+ }), Lt = /* @__PURE__ */ b(Ut, [["__scopeId", "data-v-f641b31a"]]), Kt = /* @__PURE__ */ _({
761
+ __name: "A2UIRenderer",
762
+ props: {
763
+ theme: {}
764
+ },
765
+ emits: ["action"],
766
+ setup(t, { expose: e, emit: o }) {
767
+ const u = t, a = o, { cssVars: s } = Xe(u.theme), l = new W(), n = E(new Map(l.getAllSurfaces().map((v) => [v.id, v])));
768
+ l.onAction((v) => {
769
+ a("action", v);
770
+ }), w("a2ui:surfaceManager", l);
771
+ function c(v) {
772
+ var M, A;
773
+ if (v.createSurface && l.createSurface(v.createSurface), (M = v.updateComponents) != null && M.surfaceId) {
774
+ const y = l.getSurface(v.updateComponents.surfaceId);
775
+ y == null || y.componentRegistry.updateComponents(v.updateComponents.components), y && y._version++;
776
+ }
777
+ if ((A = v.updateDataModel) != null && A.surfaceId) {
778
+ l.updateDataModel(
779
+ v.updateDataModel.surfaceId,
780
+ v.updateDataModel.path,
781
+ v.updateDataModel.value
782
+ );
783
+ const y = l.getSurface(v.updateDataModel.surfaceId);
784
+ y && y._version++;
785
+ }
786
+ v.deleteSurface && l.deleteSurface(v.deleteSurface.surfaceId), n.value = new Map(l.getAllSurfaces().map((y) => [y.id, y]));
787
+ }
788
+ function f(v) {
789
+ try {
790
+ c(JSON.parse(v));
791
+ } catch (M) {
792
+ console.error("[A2UI] Parse error:", M);
793
+ }
794
+ }
795
+ function r(v) {
796
+ v.split(`
797
+ `).filter((M) => M.trim()).forEach(f);
798
+ }
799
+ function p() {
800
+ l.clear(), n.value = /* @__PURE__ */ new Map();
801
+ }
802
+ return e({ processMessage: c, processJSON: f, processJSONStream: r, reset: p }), (v, M) => (d(), m("div", {
803
+ class: "a2ui-renderer",
804
+ style: B(H(s))
805
+ }, [
806
+ (d(!0), m(U, null, L(n.value, ([A, y]) => (d(), k(Lt, {
807
+ key: A + "-" + y._version,
808
+ surface: y
809
+ }, null, 8, ["surface"]))), 128))
810
+ ], 4));
811
+ }
812
+ });
813
+ function jt(t) {
814
+ const e = new W(), o = E(/* @__PURE__ */ new Map());
815
+ t != null && t.onAction && e.onAction(t.onAction), w("a2ui:surfaceManager", e);
816
+ function u(n) {
817
+ if (n.createSurface && (e.createSurface(n.createSurface), o.value = new Map(e.getAllSurfaces().map((c) => [c.id, c]))), n.updateComponents && n.updateComponents.surfaceId) {
818
+ const c = e.getSurface(n.updateComponents.surfaceId);
819
+ c && (c.componentRegistry.updateComponents(n.updateComponents.components), o.value = new Map(e.getAllSurfaces().map((f) => [f.id, f])));
820
+ }
821
+ n.updateDataModel && n.updateDataModel.surfaceId && (e.updateDataModel(
822
+ n.updateDataModel.surfaceId,
823
+ n.updateDataModel.path,
824
+ n.updateDataModel.value
825
+ ), o.value = new Map(e.getAllSurfaces().map((c) => [c.id, c]))), n.deleteSurface && (e.deleteSurface(n.deleteSurface.surfaceId), o.value = new Map(e.getAllSurfaces().map((c) => [c.id, c])));
826
+ }
827
+ function a(n) {
828
+ try {
829
+ const c = le(n);
830
+ u(c);
831
+ } catch (c) {
832
+ console.error("[A2UI] Parse error:", c);
833
+ }
834
+ }
835
+ function s(n) {
836
+ const c = n.split(`
837
+ `).filter((f) => f.trim());
838
+ for (const f of c)
839
+ a(f);
840
+ }
841
+ function l() {
842
+ for (const n of e.getAllSurfaces())
843
+ e.deleteSurface(n.id);
844
+ o.value = /* @__PURE__ */ new Map();
845
+ }
846
+ return re(l), {
847
+ surfaces: o,
848
+ surfaceManager: e,
849
+ processMessage: u,
850
+ processJSON: a,
851
+ processJSONStream: s,
852
+ destroy: l
853
+ };
854
+ }
855
+ function Yt() {
856
+ const t = h(D), e = h(F);
857
+ if (!t || !e)
858
+ throw new Error("[A2UI] useDataModel() must be used within a SurfaceRenderer");
859
+ function o(a, s) {
860
+ return S(a) ? "path" in a && a.path ? x(a.path, t.value, s) : "functionCall" in a && a.functionCall ? R(a.functionCall, t.value, s) : I(a) : a;
861
+ }
862
+ function u(a, s) {
863
+ return i(() => o(a, s));
864
+ }
865
+ return { dataModel: t, resolve: o, reactiveResolve: u };
866
+ }
867
+ export {
868
+ Kt as A2UIRenderer,
869
+ N as ComponentResolver,
870
+ Lt as SurfaceRenderer,
871
+ G as generateCSSVariables,
872
+ Tt as getComponentType,
873
+ Xe as provideTheme,
874
+ Ft as registerComponent,
875
+ jt as useA2UI,
876
+ Ze as useCSSVars,
877
+ Yt as useDataModel,
878
+ ie as useSurface,
879
+ Ot as useTheme
880
+ };