@assistant-ui/react-generative-ui 0.0.7 → 0.0.9

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 (181) hide show
  1. package/dist/JSONGenerativeUI.client.d.ts +0 -1
  2. package/dist/JSONGenerativeUI.client.d.ts.map +1 -1
  3. package/dist/JSONGenerativeUI.server.d.ts +0 -1
  4. package/dist/JSONGenerativeUI.server.d.ts.map +1 -1
  5. package/dist/JSONGenerativeUI.shared.d.ts +0 -1
  6. package/dist/JSONGenerativeUI.shared.d.ts.map +1 -1
  7. package/dist/actionRegistry.d.ts +2 -11
  8. package/dist/actionRegistry.d.ts.map +1 -1
  9. package/dist/actionRegistry.js.map +1 -1
  10. package/dist/buildPresentParameters.d.ts +5 -5
  11. package/dist/buildPresentParameters.d.ts.map +1 -1
  12. package/dist/buildPresentParameters.js +10 -5
  13. package/dist/buildPresentParameters.js.map +1 -1
  14. package/dist/constants.d.ts.map +1 -1
  15. package/dist/defineGenerativeComponents.d.ts +0 -1
  16. package/dist/defineGenerativeComponents.d.ts.map +1 -1
  17. package/dist/generativeUIToJSX.d.ts +15 -10
  18. package/dist/generativeUIToJSX.d.ts.map +1 -1
  19. package/dist/generativeUIToJSX.js +47 -17
  20. package/dist/generativeUIToJSX.js.map +1 -1
  21. package/dist/index.d.ts +4 -3
  22. package/dist/index.js +2 -2
  23. package/dist/index.server.d.ts +4 -3
  24. package/dist/index.server.js +2 -2
  25. package/dist/index.shared.d.ts +3 -3
  26. package/dist/index.shared.js +2 -2
  27. package/dist/ir.d.ts +6 -6
  28. package/dist/ir.d.ts.map +1 -1
  29. package/dist/ir.js +27 -1
  30. package/dist/ir.js.map +1 -1
  31. package/dist/node_modules/.pnpm/@types_json-schema@7.0.15/node_modules/@types/json-schema/index.d.ts +3 -3
  32. package/dist/node_modules/.pnpm/@types_json-schema@7.0.15/node_modules/@types/json-schema/index.d.ts.map +1 -1
  33. package/dist/renderGenerativeUI.d.ts +0 -1
  34. package/dist/renderGenerativeUI.d.ts.map +1 -1
  35. package/dist/slack/constants.d.ts +111 -0
  36. package/dist/slack/constants.d.ts.map +1 -0
  37. package/dist/slack/constants.js +162 -0
  38. package/dist/slack/constants.js.map +1 -0
  39. package/dist/slack/decodeBlockAction.d.ts +11 -0
  40. package/dist/slack/decodeBlockAction.d.ts.map +1 -0
  41. package/dist/slack/decodeBlockAction.js +40 -0
  42. package/dist/slack/decodeBlockAction.js.map +1 -0
  43. package/dist/slack/fromSlackBlocks.d.ts +30 -0
  44. package/dist/slack/fromSlackBlocks.d.ts.map +1 -0
  45. package/dist/slack/fromSlackBlocks.js +447 -0
  46. package/dist/slack/fromSlackBlocks.js.map +1 -0
  47. package/dist/slack/toSlackBlocks.d.ts +7 -0
  48. package/dist/slack/toSlackBlocks.d.ts.map +1 -0
  49. package/dist/slack/toSlackBlocks.js +649 -0
  50. package/dist/slack/toSlackBlocks.js.map +1 -0
  51. package/dist/slack/types.d.ts +178 -0
  52. package/dist/slack/types.d.ts.map +1 -0
  53. package/dist/slack/types.js +0 -0
  54. package/dist/slack.d.ts +5 -0
  55. package/dist/slack.js +4 -0
  56. package/dist/teams/boundSpec.d.ts +20 -0
  57. package/dist/teams/boundSpec.d.ts.map +1 -0
  58. package/dist/teams/boundSpec.js +67 -0
  59. package/dist/teams/boundSpec.js.map +1 -0
  60. package/dist/teams/constants.d.ts +57 -0
  61. package/dist/teams/constants.d.ts.map +1 -0
  62. package/dist/teams/constants.js +92 -0
  63. package/dist/teams/constants.js.map +1 -0
  64. package/dist/teams/decodeSubmitData.d.ts +25 -0
  65. package/dist/teams/decodeSubmitData.d.ts.map +1 -0
  66. package/dist/teams/decodeSubmitData.js +44 -0
  67. package/dist/teams/decodeSubmitData.js.map +1 -0
  68. package/dist/teams/toAdaptiveCard.d.ts +39 -0
  69. package/dist/teams/toAdaptiveCard.d.ts.map +1 -0
  70. package/dist/teams/toAdaptiveCard.js +496 -0
  71. package/dist/teams/toAdaptiveCard.js.map +1 -0
  72. package/dist/teams/toTeamsAttachments.d.ts +13 -0
  73. package/dist/teams/toTeamsAttachments.d.ts.map +1 -0
  74. package/dist/teams/toTeamsAttachments.js +95 -0
  75. package/dist/teams/toTeamsAttachments.js.map +1 -0
  76. package/dist/teams/types.d.ts +196 -0
  77. package/dist/teams/types.d.ts.map +1 -0
  78. package/dist/teams/types.js +0 -0
  79. package/dist/teams.d.ts +5 -0
  80. package/dist/teams.js +4 -0
  81. package/dist/types.d.ts +7 -4
  82. package/dist/types.d.ts.map +1 -1
  83. package/dist/vocabulary/alert.d.ts +6 -12
  84. package/dist/vocabulary/alert.d.ts.map +1 -1
  85. package/dist/vocabulary/alert.js +13 -4
  86. package/dist/vocabulary/alert.js.map +1 -1
  87. package/dist/vocabulary/collectFormValues.d.ts +23 -0
  88. package/dist/vocabulary/collectFormValues.d.ts.map +1 -0
  89. package/dist/vocabulary/collectFormValues.js +32 -0
  90. package/dist/vocabulary/collectFormValues.js.map +1 -0
  91. package/dist/vocabulary/data.d.ts +16 -17
  92. package/dist/vocabulary/data.d.ts.map +1 -1
  93. package/dist/vocabulary/data.js +244 -13
  94. package/dist/vocabulary/data.js.map +1 -1
  95. package/dist/vocabulary/dispatch.d.ts +11 -0
  96. package/dist/vocabulary/dispatch.d.ts.map +1 -0
  97. package/dist/vocabulary/dispatch.js +21 -0
  98. package/dist/vocabulary/dispatch.js.map +1 -0
  99. package/dist/vocabulary/fact.d.ts +1 -6
  100. package/dist/vocabulary/fact.d.ts.map +1 -1
  101. package/dist/vocabulary/fact.js.map +1 -1
  102. package/dist/vocabulary/form.d.ts +14 -0
  103. package/dist/vocabulary/form.d.ts.map +1 -0
  104. package/dist/vocabulary/form.js +23 -0
  105. package/dist/vocabulary/form.js.map +1 -0
  106. package/dist/vocabulary/icon.d.ts +44 -0
  107. package/dist/vocabulary/icon.d.ts.map +1 -0
  108. package/dist/vocabulary/icon.js +272 -0
  109. package/dist/vocabulary/icon.js.map +1 -0
  110. package/dist/vocabulary/index.d.ts +0 -1
  111. package/dist/vocabulary/index.d.ts.map +1 -1
  112. package/dist/vocabulary/index.js +7 -1
  113. package/dist/vocabulary/index.js.map +1 -1
  114. package/dist/vocabulary/interactive.d.ts +45 -33
  115. package/dist/vocabulary/interactive.d.ts.map +1 -1
  116. package/dist/vocabulary/interactive.js +78 -29
  117. package/dist/vocabulary/interactive.js.map +1 -1
  118. package/dist/vocabulary/layout.d.ts +27 -23
  119. package/dist/vocabulary/layout.d.ts.map +1 -1
  120. package/dist/vocabulary/layout.js +78 -14
  121. package/dist/vocabulary/layout.js.map +1 -1
  122. package/dist/vocabulary/list.d.ts +17 -0
  123. package/dist/vocabulary/list.d.ts.map +1 -0
  124. package/dist/vocabulary/list.js +48 -0
  125. package/dist/vocabulary/list.js.map +1 -0
  126. package/dist/vocabulary/media.d.ts +3 -9
  127. package/dist/vocabulary/media.d.ts.map +1 -1
  128. package/dist/vocabulary/media.js +17 -7
  129. package/dist/vocabulary/media.js.map +1 -1
  130. package/dist/vocabulary/text.d.ts +3 -17
  131. package/dist/vocabulary/text.d.ts.map +1 -1
  132. package/dist/vocabulary/text.js.map +1 -1
  133. package/package.json +15 -7
  134. package/src/actionRegistry.ts +2 -10
  135. package/src/buildPresentParameters.ts +15 -9
  136. package/src/generativeUIToJSX.test.ts +186 -0
  137. package/src/generativeUIToJSX.ts +112 -21
  138. package/src/index.shared.ts +3 -0
  139. package/src/ir.ts +31 -5
  140. package/src/renderGenerativeUI.test.tsx +16 -2
  141. package/src/slack/constants.ts +212 -0
  142. package/src/slack/decodeBlockAction.test.ts +135 -0
  143. package/src/slack/decodeBlockAction.ts +66 -0
  144. package/src/slack/fromSlackBlocks.test.ts +1145 -0
  145. package/src/slack/fromSlackBlocks.ts +709 -0
  146. package/src/slack/toSlackBlocks.test.ts +1936 -0
  147. package/src/slack/toSlackBlocks.ts +1319 -0
  148. package/src/slack/types.ts +230 -0
  149. package/src/slack.ts +37 -0
  150. package/src/teams/boundSpec.ts +102 -0
  151. package/src/teams/constants.ts +127 -0
  152. package/src/teams/decodeSubmitData.test.ts +148 -0
  153. package/src/teams/decodeSubmitData.ts +57 -0
  154. package/src/teams/toAdaptiveCard.test.ts +1410 -0
  155. package/src/teams/toAdaptiveCard.ts +762 -0
  156. package/src/teams/toTeamsAttachments.test.ts +29 -0
  157. package/src/teams/toTeamsAttachments.ts +137 -0
  158. package/src/teams/types.ts +237 -0
  159. package/src/teams.ts +34 -0
  160. package/src/vocabulary/alert.test.tsx +72 -2
  161. package/src/vocabulary/alert.tsx +24 -5
  162. package/src/vocabulary/collectFormValues.test.ts +127 -0
  163. package/src/vocabulary/collectFormValues.ts +58 -0
  164. package/src/vocabulary/data.test.tsx +503 -3
  165. package/src/vocabulary/data.tsx +426 -18
  166. package/src/vocabulary/dispatch.ts +22 -0
  167. package/src/vocabulary/form.test.tsx +112 -0
  168. package/src/vocabulary/form.tsx +34 -0
  169. package/src/vocabulary/icon.test.tsx +64 -0
  170. package/src/vocabulary/icon.tsx +174 -0
  171. package/src/vocabulary/index.test.ts +7 -0
  172. package/src/vocabulary/index.ts +6 -0
  173. package/src/vocabulary/interactive.dispatch.test.tsx +243 -1
  174. package/src/vocabulary/interactive.test.tsx +143 -3
  175. package/src/vocabulary/interactive.tsx +134 -30
  176. package/src/vocabulary/layout.test.tsx +231 -3
  177. package/src/vocabulary/layout.tsx +168 -15
  178. package/src/vocabulary/list.test.tsx +195 -0
  179. package/src/vocabulary/list.tsx +48 -0
  180. package/src/vocabulary/media.test.tsx +36 -4
  181. package/src/vocabulary/media.tsx +27 -8
@@ -0,0 +1,272 @@
1
+ import { ICON_NAMES } from "../ir.js";
2
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
+ import { z } from "zod";
4
+ //#region src/vocabulary/icon.tsx
5
+ const ICON_SIZE_TOKENS = [
6
+ "sm",
7
+ "md",
8
+ "lg"
9
+ ];
10
+ const ICON_SIZE_PX = {
11
+ sm: 14,
12
+ md: 16,
13
+ lg: 20
14
+ };
15
+ const ICON_GLYPHS = {
16
+ sun: /* @__PURE__ */ jsxs(Fragment, { children: [
17
+ /* @__PURE__ */ jsx("circle", {
18
+ cx: "12",
19
+ cy: "12",
20
+ r: "4.5"
21
+ }),
22
+ /* @__PURE__ */ jsx("line", {
23
+ x1: "12",
24
+ y1: "2",
25
+ x2: "12",
26
+ y2: "5"
27
+ }),
28
+ /* @__PURE__ */ jsx("line", {
29
+ x1: "12",
30
+ y1: "19",
31
+ x2: "12",
32
+ y2: "22"
33
+ }),
34
+ /* @__PURE__ */ jsx("line", {
35
+ x1: "2",
36
+ y1: "12",
37
+ x2: "5",
38
+ y2: "12"
39
+ }),
40
+ /* @__PURE__ */ jsx("line", {
41
+ x1: "19",
42
+ y1: "12",
43
+ x2: "22",
44
+ y2: "12"
45
+ }),
46
+ /* @__PURE__ */ jsx("line", {
47
+ x1: "5.5",
48
+ y1: "5.5",
49
+ x2: "7.5",
50
+ y2: "7.5"
51
+ }),
52
+ /* @__PURE__ */ jsx("line", {
53
+ x1: "16.5",
54
+ y1: "16.5",
55
+ x2: "18.5",
56
+ y2: "18.5"
57
+ }),
58
+ /* @__PURE__ */ jsx("line", {
59
+ x1: "18.5",
60
+ y1: "5.5",
61
+ x2: "16.5",
62
+ y2: "7.5"
63
+ }),
64
+ /* @__PURE__ */ jsx("line", {
65
+ x1: "7.5",
66
+ y1: "16.5",
67
+ x2: "5.5",
68
+ y2: "18.5"
69
+ })
70
+ ] }),
71
+ moon: /* @__PURE__ */ jsx("path", { d: "M19 13.5A8.5 8.5 0 1 1 10.5 4.5 6.8 6.8 0 0 0 19 13.5Z" }),
72
+ cloud: /* @__PURE__ */ jsx("path", { d: "M7 18a4 4 0 1 1 .5-8A5.5 5.5 0 0 1 17.5 11.5 3.5 3.5 0 0 1 17 18Z" }),
73
+ rain: /* @__PURE__ */ jsxs(Fragment, { children: [
74
+ /* @__PURE__ */ jsx("path", { d: "M6.5 13a3 3 0 1 1 .4-6A4.5 4.5 0 0 1 15.5 8.5 3 3 0 0 1 15 13Z" }),
75
+ /* @__PURE__ */ jsx("line", {
76
+ x1: "8",
77
+ y1: "15",
78
+ x2: "7",
79
+ y2: "18"
80
+ }),
81
+ /* @__PURE__ */ jsx("line", {
82
+ x1: "12",
83
+ y1: "15",
84
+ x2: "11",
85
+ y2: "18"
86
+ }),
87
+ /* @__PURE__ */ jsx("line", {
88
+ x1: "16",
89
+ y1: "15",
90
+ x2: "15",
91
+ y2: "18"
92
+ })
93
+ ] }),
94
+ snow: /* @__PURE__ */ jsxs(Fragment, { children: [
95
+ /* @__PURE__ */ jsx("path", { d: "M6.5 13a3 3 0 1 1 .4-6A4.5 4.5 0 0 1 15.5 8.5 3 3 0 0 1 15 13Z" }),
96
+ /* @__PURE__ */ jsx("circle", {
97
+ cx: "7.5",
98
+ cy: "17",
99
+ r: "0.75",
100
+ fill: "currentColor",
101
+ stroke: "none"
102
+ }),
103
+ /* @__PURE__ */ jsx("circle", {
104
+ cx: "12",
105
+ cy: "18",
106
+ r: "0.75",
107
+ fill: "currentColor",
108
+ stroke: "none"
109
+ }),
110
+ /* @__PURE__ */ jsx("circle", {
111
+ cx: "16.5",
112
+ cy: "17",
113
+ r: "0.75",
114
+ fill: "currentColor",
115
+ stroke: "none"
116
+ })
117
+ ] }),
118
+ wind: /* @__PURE__ */ jsxs(Fragment, { children: [
119
+ /* @__PURE__ */ jsx("path", { d: "M3 7.5h10.5a2.5 2.5 0 1 0-2-4" }),
120
+ /* @__PURE__ */ jsx("path", { d: "M3 12h14a2.5 2.5 0 1 1-2 4" }),
121
+ /* @__PURE__ */ jsx("path", { d: "M3 16.5h8" })
122
+ ] }),
123
+ play: /* @__PURE__ */ jsx("path", { d: "M7 4.5v15l13-7.5z" }),
124
+ pause: /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("line", {
125
+ x1: "8",
126
+ y1: "4",
127
+ x2: "8",
128
+ y2: "20"
129
+ }), /* @__PURE__ */ jsx("line", {
130
+ x1: "16",
131
+ y1: "4",
132
+ x2: "16",
133
+ y2: "20"
134
+ })] }),
135
+ check: /* @__PURE__ */ jsx("path", { d: "M4 12.5l5 5.5 11-12" }),
136
+ x: /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("line", {
137
+ x1: "5",
138
+ y1: "5",
139
+ x2: "19",
140
+ y2: "19"
141
+ }), /* @__PURE__ */ jsx("line", {
142
+ x1: "19",
143
+ y1: "5",
144
+ x2: "5",
145
+ y2: "19"
146
+ })] }),
147
+ star: /* @__PURE__ */ jsx("path", { d: "M12 2.5l2.6 5.9 6.4.6-4.8 4.3 1.4 6.3-5.6-3-5.6 3 1.4-6.3-4.8-4.3 6.4-.6z" }),
148
+ heart: /* @__PURE__ */ jsx("path", { d: "M12 20s-7.5-4.7-9.8-9.6C.6 6.8 3 3.3 6.6 3.3c2 0 3.7 1.1 5.4 3.3 1.7-2.2 3.4-3.3 5.4-3.3 3.6 0 6 3.5 4.4 7.1C19.5 15.3 12 20 12 20z" }),
149
+ "arrow-right": /* @__PURE__ */ jsx("path", { d: "M4 12h15M13 6l6 6-6 6" }),
150
+ "arrow-up-right": /* @__PURE__ */ jsx("path", { d: "M7 17L17 7M9 7h8v8" }),
151
+ "chevron-right": /* @__PURE__ */ jsx("path", { d: "M9 5l7 7-7 7" }),
152
+ calendar: /* @__PURE__ */ jsxs(Fragment, { children: [
153
+ /* @__PURE__ */ jsx("rect", {
154
+ x: "3.5",
155
+ y: "5",
156
+ width: "17",
157
+ height: "15",
158
+ rx: "2"
159
+ }),
160
+ /* @__PURE__ */ jsx("line", {
161
+ x1: "3.5",
162
+ y1: "9.5",
163
+ x2: "20.5",
164
+ y2: "9.5"
165
+ }),
166
+ /* @__PURE__ */ jsx("line", {
167
+ x1: "8",
168
+ y1: "3",
169
+ x2: "8",
170
+ y2: "7"
171
+ }),
172
+ /* @__PURE__ */ jsx("line", {
173
+ x1: "16",
174
+ y1: "3",
175
+ x2: "16",
176
+ y2: "7"
177
+ })
178
+ ] }),
179
+ clock: /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("circle", {
180
+ cx: "12",
181
+ cy: "12",
182
+ r: "8.5"
183
+ }), /* @__PURE__ */ jsx("path", { d: "M12 7.5V12l3.5 2" })] }),
184
+ "map-pin": /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("path", { d: "M12 21s7-6.7 7-12.2A7 7 0 1 0 5 8.8C5 14.3 12 21 12 21z" }), /* @__PURE__ */ jsx("circle", {
185
+ cx: "12",
186
+ cy: "8.8",
187
+ r: "2.3"
188
+ })] }),
189
+ plane: /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("path", { d: "M3 12l18-8-6 18-3-7-7-3z" }), /* @__PURE__ */ jsx("path", { d: "M12 15l3-3" })] }),
190
+ truck: /* @__PURE__ */ jsxs(Fragment, { children: [
191
+ /* @__PURE__ */ jsx("path", { d: "M2 8h11v9H2z" }),
192
+ /* @__PURE__ */ jsx("path", { d: "M13 11h4l3 3v3h-7z" }),
193
+ /* @__PURE__ */ jsx("circle", {
194
+ cx: "6",
195
+ cy: "19",
196
+ r: "1.8"
197
+ }),
198
+ /* @__PURE__ */ jsx("circle", {
199
+ cx: "17",
200
+ cy: "19",
201
+ r: "1.8"
202
+ })
203
+ ] }),
204
+ "credit-card": /* @__PURE__ */ jsxs(Fragment, { children: [
205
+ /* @__PURE__ */ jsx("rect", {
206
+ x: "2.5",
207
+ y: "5.5",
208
+ width: "19",
209
+ height: "13",
210
+ rx: "2"
211
+ }),
212
+ /* @__PURE__ */ jsx("line", {
213
+ x1: "2.5",
214
+ y1: "10",
215
+ x2: "21.5",
216
+ y2: "10"
217
+ }),
218
+ /* @__PURE__ */ jsx("line", {
219
+ x1: "6",
220
+ y1: "15",
221
+ x2: "10",
222
+ y2: "15"
223
+ })
224
+ ] }),
225
+ user: /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("circle", {
226
+ cx: "12",
227
+ cy: "8",
228
+ r: "3.6"
229
+ }), /* @__PURE__ */ jsx("path", { d: "M4.5 20.5a7.5 7.5 0 0 1 15 0" })] }),
230
+ search: /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("circle", {
231
+ cx: "10.5",
232
+ cy: "10.5",
233
+ r: "6.5"
234
+ }), /* @__PURE__ */ jsx("line", {
235
+ x1: "20",
236
+ y1: "20",
237
+ x2: "15.3",
238
+ y2: "15.3"
239
+ })] }),
240
+ bell: /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("path", { d: "M12 3a5.5 5.5 0 0 0-5.5 5.5c0 4.5-2 6-2 6h15s-2-1.5-2-6A5.5 5.5 0 0 0 12 3z" }), /* @__PURE__ */ jsx("path", { d: "M10 19a2 2 0 0 0 4 0" })] })
241
+ };
242
+ const iconVocabulary = { Icon: {
243
+ description: "A small line icon from the built-in set. `size` controls the rendered pixel size.",
244
+ properties: z.object({
245
+ name: z.enum(ICON_NAMES).describe("Which built-in icon to render."),
246
+ size: z.enum(ICON_SIZE_TOKENS).optional().describe("Icon size; defaults to `md` (16px).")
247
+ }),
248
+ render: ({ name, size }) => {
249
+ const glyph = ICON_GLYPHS[name];
250
+ if (!glyph) return null;
251
+ const px = ICON_SIZE_PX[size ?? "md"];
252
+ return /* @__PURE__ */ jsx("svg", {
253
+ "data-aui": "icon",
254
+ "data-aui-name": name,
255
+ "data-aui-size": size,
256
+ viewBox: "0 0 24 24",
257
+ width: px,
258
+ height: px,
259
+ fill: "none",
260
+ stroke: "currentColor",
261
+ strokeWidth: "2",
262
+ strokeLinecap: "round",
263
+ strokeLinejoin: "round",
264
+ "aria-hidden": "true",
265
+ children: glyph
266
+ });
267
+ }
268
+ } };
269
+ //#endregion
270
+ export { iconVocabulary };
271
+
272
+ //# sourceMappingURL=icon.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"icon.js","names":[],"sources":["../../src/vocabulary/icon.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport { z } from \"zod\";\nimport type { GenerativeUILibrary } from \"../types\";\nimport { ICON_NAMES } from \"../ir\";\n\nconst ICON_SIZE_TOKENS = [\"sm\", \"md\", \"lg\"] as const;\nconst ICON_SIZE_PX: Record<(typeof ICON_SIZE_TOKENS)[number], number> = {\n sm: 14,\n md: 16,\n lg: 20,\n};\n\nconst ICON_GLYPHS: Record<(typeof ICON_NAMES)[number], ReactNode> = {\n sun: (\n <>\n <circle cx=\"12\" cy=\"12\" r=\"4.5\" />\n <line x1=\"12\" y1=\"2\" x2=\"12\" y2=\"5\" />\n <line x1=\"12\" y1=\"19\" x2=\"12\" y2=\"22\" />\n <line x1=\"2\" y1=\"12\" x2=\"5\" y2=\"12\" />\n <line x1=\"19\" y1=\"12\" x2=\"22\" y2=\"12\" />\n <line x1=\"5.5\" y1=\"5.5\" x2=\"7.5\" y2=\"7.5\" />\n <line x1=\"16.5\" y1=\"16.5\" x2=\"18.5\" y2=\"18.5\" />\n <line x1=\"18.5\" y1=\"5.5\" x2=\"16.5\" y2=\"7.5\" />\n <line x1=\"7.5\" y1=\"16.5\" x2=\"5.5\" y2=\"18.5\" />\n </>\n ),\n moon: <path d=\"M19 13.5A8.5 8.5 0 1 1 10.5 4.5 6.8 6.8 0 0 0 19 13.5Z\" />,\n cloud: (\n <path d=\"M7 18a4 4 0 1 1 .5-8A5.5 5.5 0 0 1 17.5 11.5 3.5 3.5 0 0 1 17 18Z\" />\n ),\n rain: (\n <>\n <path d=\"M6.5 13a3 3 0 1 1 .4-6A4.5 4.5 0 0 1 15.5 8.5 3 3 0 0 1 15 13Z\" />\n <line x1=\"8\" y1=\"15\" x2=\"7\" y2=\"18\" />\n <line x1=\"12\" y1=\"15\" x2=\"11\" y2=\"18\" />\n <line x1=\"16\" y1=\"15\" x2=\"15\" y2=\"18\" />\n </>\n ),\n snow: (\n <>\n <path d=\"M6.5 13a3 3 0 1 1 .4-6A4.5 4.5 0 0 1 15.5 8.5 3 3 0 0 1 15 13Z\" />\n <circle cx=\"7.5\" cy=\"17\" r=\"0.75\" fill=\"currentColor\" stroke=\"none\" />\n <circle cx=\"12\" cy=\"18\" r=\"0.75\" fill=\"currentColor\" stroke=\"none\" />\n <circle cx=\"16.5\" cy=\"17\" r=\"0.75\" fill=\"currentColor\" stroke=\"none\" />\n </>\n ),\n wind: (\n <>\n <path d=\"M3 7.5h10.5a2.5 2.5 0 1 0-2-4\" />\n <path d=\"M3 12h14a2.5 2.5 0 1 1-2 4\" />\n <path d=\"M3 16.5h8\" />\n </>\n ),\n play: <path d=\"M7 4.5v15l13-7.5z\" />,\n pause: (\n <>\n <line x1=\"8\" y1=\"4\" x2=\"8\" y2=\"20\" />\n <line x1=\"16\" y1=\"4\" x2=\"16\" y2=\"20\" />\n </>\n ),\n check: <path d=\"M4 12.5l5 5.5 11-12\" />,\n x: (\n <>\n <line x1=\"5\" y1=\"5\" x2=\"19\" y2=\"19\" />\n <line x1=\"19\" y1=\"5\" x2=\"5\" y2=\"19\" />\n </>\n ),\n star: (\n <path d=\"M12 2.5l2.6 5.9 6.4.6-4.8 4.3 1.4 6.3-5.6-3-5.6 3 1.4-6.3-4.8-4.3 6.4-.6z\" />\n ),\n heart: (\n <path d=\"M12 20s-7.5-4.7-9.8-9.6C.6 6.8 3 3.3 6.6 3.3c2 0 3.7 1.1 5.4 3.3 1.7-2.2 3.4-3.3 5.4-3.3 3.6 0 6 3.5 4.4 7.1C19.5 15.3 12 20 12 20z\" />\n ),\n \"arrow-right\": <path d=\"M4 12h15M13 6l6 6-6 6\" />,\n \"arrow-up-right\": <path d=\"M7 17L17 7M9 7h8v8\" />,\n \"chevron-right\": <path d=\"M9 5l7 7-7 7\" />,\n calendar: (\n <>\n <rect x=\"3.5\" y=\"5\" width=\"17\" height=\"15\" rx=\"2\" />\n <line x1=\"3.5\" y1=\"9.5\" x2=\"20.5\" y2=\"9.5\" />\n <line x1=\"8\" y1=\"3\" x2=\"8\" y2=\"7\" />\n <line x1=\"16\" y1=\"3\" x2=\"16\" y2=\"7\" />\n </>\n ),\n clock: (\n <>\n <circle cx=\"12\" cy=\"12\" r=\"8.5\" />\n <path d=\"M12 7.5V12l3.5 2\" />\n </>\n ),\n \"map-pin\": (\n <>\n <path d=\"M12 21s7-6.7 7-12.2A7 7 0 1 0 5 8.8C5 14.3 12 21 12 21z\" />\n <circle cx=\"12\" cy=\"8.8\" r=\"2.3\" />\n </>\n ),\n plane: (\n <>\n <path d=\"M3 12l18-8-6 18-3-7-7-3z\" />\n <path d=\"M12 15l3-3\" />\n </>\n ),\n truck: (\n <>\n <path d=\"M2 8h11v9H2z\" />\n <path d=\"M13 11h4l3 3v3h-7z\" />\n <circle cx=\"6\" cy=\"19\" r=\"1.8\" />\n <circle cx=\"17\" cy=\"19\" r=\"1.8\" />\n </>\n ),\n \"credit-card\": (\n <>\n <rect x=\"2.5\" y=\"5.5\" width=\"19\" height=\"13\" rx=\"2\" />\n <line x1=\"2.5\" y1=\"10\" x2=\"21.5\" y2=\"10\" />\n <line x1=\"6\" y1=\"15\" x2=\"10\" y2=\"15\" />\n </>\n ),\n user: (\n <>\n <circle cx=\"12\" cy=\"8\" r=\"3.6\" />\n <path d=\"M4.5 20.5a7.5 7.5 0 0 1 15 0\" />\n </>\n ),\n search: (\n <>\n <circle cx=\"10.5\" cy=\"10.5\" r=\"6.5\" />\n <line x1=\"20\" y1=\"20\" x2=\"15.3\" y2=\"15.3\" />\n </>\n ),\n bell: (\n <>\n <path d=\"M12 3a5.5 5.5 0 0 0-5.5 5.5c0 4.5-2 6-2 6h15s-2-1.5-2-6A5.5 5.5 0 0 0 12 3z\" />\n <path d=\"M10 19a2 2 0 0 0 4 0\" />\n </>\n ),\n};\n\nexport const iconVocabulary = {\n Icon: {\n description:\n \"A small line icon from the built-in set. `size` controls the rendered pixel size.\",\n properties: z.object({\n name: z.enum(ICON_NAMES).describe(\"Which built-in icon to render.\"),\n size: z\n .enum(ICON_SIZE_TOKENS)\n .optional()\n .describe(\"Icon size; defaults to `md` (16px).\"),\n }),\n render: ({ name, size }) => {\n const glyph = ICON_GLYPHS[name as keyof typeof ICON_GLYPHS];\n if (!glyph) return null;\n const px = ICON_SIZE_PX[(size as keyof typeof ICON_SIZE_PX) ?? \"md\"];\n\n return (\n <svg\n data-aui=\"icon\"\n data-aui-name={name}\n data-aui-size={size}\n viewBox=\"0 0 24 24\"\n width={px}\n height={px}\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n >\n {glyph}\n </svg>\n );\n },\n },\n} satisfies GenerativeUILibrary;\n"],"mappings":";;;;AAKA,MAAM,mBAAmB;CAAC;CAAM;CAAM;AAAI;AAC1C,MAAM,eAAkE;CACtE,IAAI;CACJ,IAAI;CACJ,IAAI;AACN;AAEA,MAAM,cAA8D;CAClE,KACE,qBAAA,UAAA,EAAA,UAAA;EACE,oBAAC,UAAD;GAAQ,IAAG;GAAK,IAAG;GAAK,GAAE;EAAO,CAAA;EACjC,oBAAC,QAAD;GAAM,IAAG;GAAK,IAAG;GAAI,IAAG;GAAK,IAAG;EAAK,CAAA;EACrC,oBAAC,QAAD;GAAM,IAAG;GAAK,IAAG;GAAK,IAAG;GAAK,IAAG;EAAM,CAAA;EACvC,oBAAC,QAAD;GAAM,IAAG;GAAI,IAAG;GAAK,IAAG;GAAI,IAAG;EAAM,CAAA;EACrC,oBAAC,QAAD;GAAM,IAAG;GAAK,IAAG;GAAK,IAAG;GAAK,IAAG;EAAM,CAAA;EACvC,oBAAC,QAAD;GAAM,IAAG;GAAM,IAAG;GAAM,IAAG;GAAM,IAAG;EAAO,CAAA;EAC3C,oBAAC,QAAD;GAAM,IAAG;GAAO,IAAG;GAAO,IAAG;GAAO,IAAG;EAAQ,CAAA;EAC/C,oBAAC,QAAD;GAAM,IAAG;GAAO,IAAG;GAAM,IAAG;GAAO,IAAG;EAAO,CAAA;EAC7C,oBAAC,QAAD;GAAM,IAA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AA,CAAA;CAEJ,MACE,qBAAA,UAAA,EAAA,UAAA,CACE,oBAAC,QAAD,EAAM,GAAE,8EAA+E,CAAA,GACvF,oBAAC,QAAD,EAAM,GAAE,uBAAwB,CAAA,CAChC,EAAA,CAAA;AAEN;AAEA,MAAa,iBAAiB,EAC5B,MAAM;CACJ,aACE;CACF,YAAY,EAAE,OAAO;EACnB,MAAM,EAAE,KAAK,UAAU,CAAC,CAAC,SAAS,gCAAgC;EAClE,MAAM,EACH,KAAK,gBAAgB,CAAC,CACtB,SAAS,CAAC,CACV,SAAS,qCAAqC;CACnD,CAAC;CACD,SAAS,EAAE,MAAM,WAAW;EAC1B,MAAM,QAAQ,YAAY;EAC1B,IAAI,CAAC,OAAO,OAAO;EACnB,MAAM,KAAK,aAAc,QAAsC;EAE/D,OACE,oBAAC,OAAD;GACE,YAAS;GACT,iBAAe;GACf,iBAAe;GACf,SAAQ;GACR,OAAO;GACP,QAAQ;GACR,MAAK;GACL,QAAO;GACP,aAAY;GACZ,eAAc;GACd,gBAAe;GACf,eAAY;GAEX,UAAA;EACE,CAAA;CAET;AACF,EACF"}
@@ -1,5 +1,4 @@
1
1
  import { GenerativeUILibrary } from "../types.js";
2
-
3
2
  //#region src/vocabulary/index.d.ts
4
3
  /**
5
4
  * The closed generative-ui vocabulary the factory ships: a fixed set of
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/vocabulary/index.ts"],"mappings":";;;;;AAkBA;;;;AAQC;;;cARY,0BAAA,EAA4B,mBAQxC"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/vocabulary/index.ts"],"mappings":";;;;;;;;;;;cAqBa,4BAA4B"}
@@ -1,8 +1,11 @@
1
1
  import { alertVocabulary } from "./alert.js";
2
2
  import { dataVocabulary } from "./data.js";
3
3
  import { factVocabulary } from "./fact.js";
4
+ import { formVocabulary } from "./form.js";
5
+ import { iconVocabulary } from "./icon.js";
4
6
  import { interactiveVocabulary } from "./interactive.js";
5
7
  import { layoutVocabulary } from "./layout.js";
8
+ import { listVocabulary } from "./list.js";
6
9
  import { mediaVocabulary } from "./media.js";
7
10
  import { textVocabulary } from "./text.js";
8
11
  //#region src/vocabulary/index.ts
@@ -20,9 +23,12 @@ const defaultGenerativeUILibrary = {
20
23
  ...mediaVocabulary,
21
24
  ...factVocabulary,
22
25
  ...interactiveVocabulary,
26
+ ...formVocabulary,
23
27
  ...layoutVocabulary,
28
+ ...listVocabulary,
24
29
  ...dataVocabulary,
25
- ...alertVocabulary
30
+ ...alertVocabulary,
31
+ ...iconVocabulary
26
32
  };
27
33
  //#endregion
28
34
  export { defaultGenerativeUILibrary };
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../src/vocabulary/index.ts"],"sourcesContent":["import type { GenerativeUILibrary } from \"../types\";\nimport { alertVocabulary } from \"./alert\";\nimport { dataVocabulary } from \"./data\";\nimport { factVocabulary } from \"./fact\";\nimport { interactiveVocabulary } from \"./interactive\";\nimport { layoutVocabulary } from \"./layout\";\nimport { mediaVocabulary } from \"./media\";\nimport { textVocabulary } from \"./text\";\n\n/**\n * The closed generative-ui vocabulary the factory ships: a fixed set of\n * intrinsic components the model may render, each a zod `properties` schema\n * plus an unstyled structural `render` (semantic HTML with a `data-aui`\n * attribute naming the component, plus `data-aui-<prop>` hooks, for the host\n * to style). Users opt in by passing it to\n * `new JSONGenerativeUI({ library: defaultGenerativeUILibrary })`, and override\n * or extend entries with their own `defineGenerativeComponents`.\n */\nexport const defaultGenerativeUILibrary: GenerativeUILibrary = {\n ...textVocabulary,\n ...mediaVocabulary,\n ...factVocabulary,\n ...interactiveVocabulary,\n ...layoutVocabulary,\n ...dataVocabulary,\n ...alertVocabulary,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAkBA,MAAa,6BAAkD;CAC7D,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;AACL"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/vocabulary/index.ts"],"sourcesContent":["import type { GenerativeUILibrary } from \"../types\";\nimport { alertVocabulary } from \"./alert\";\nimport { dataVocabulary } from \"./data\";\nimport { factVocabulary } from \"./fact\";\nimport { formVocabulary } from \"./form\";\nimport { iconVocabulary } from \"./icon\";\nimport { interactiveVocabulary } from \"./interactive\";\nimport { layoutVocabulary } from \"./layout\";\nimport { listVocabulary } from \"./list\";\nimport { mediaVocabulary } from \"./media\";\nimport { textVocabulary } from \"./text\";\n\n/**\n * The closed generative-ui vocabulary the factory ships: a fixed set of\n * intrinsic components the model may render, each a zod `properties` schema\n * plus an unstyled structural `render` (semantic HTML with a `data-aui`\n * attribute naming the component, plus `data-aui-<prop>` hooks, for the host\n * to style). Users opt in by passing it to\n * `new JSONGenerativeUI({ library: defaultGenerativeUILibrary })`, and override\n * or extend entries with their own `defineGenerativeComponents`.\n */\nexport const defaultGenerativeUILibrary: GenerativeUILibrary = {\n ...textVocabulary,\n ...mediaVocabulary,\n ...factVocabulary,\n ...interactiveVocabulary,\n ...formVocabulary,\n ...layoutVocabulary,\n ...listVocabulary,\n ...dataVocabulary,\n ...alertVocabulary,\n ...iconVocabulary,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAqBA,MAAa,6BAAkD;CAC7D,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;AACL"}
@@ -1,6 +1,19 @@
1
+ import { Action } from "../ir.js";
2
+ import { GenerativeUIDispatch } from "../types.js";
1
3
  import { z } from "zod";
2
-
3
4
  //#region src/vocabulary/interactive.d.ts
5
+ type RadioGroupRenderProps = {
6
+ options: {
7
+ label: string;
8
+ value: string;
9
+ }[];
10
+ name?: string;
11
+ label?: string;
12
+ defaultValue?: string;
13
+ $action?: Action;
14
+ $dispatch?: GenerativeUIDispatch;
15
+ };
16
+ declare function RadioGroupRender({ options, name, label, defaultValue, $action, $dispatch }: RadioGroupRenderProps): import("react").JSX.Element;
4
17
  declare const interactiveVocabulary: {
5
18
  Button: {
6
19
  description: string;
@@ -8,21 +21,15 @@ declare const interactiveVocabulary: {
8
21
  label: z.ZodString;
9
22
  buttonStyle: z.ZodOptional<z.ZodEnum<{
10
23
  secondary: "secondary";
11
- danger: "danger";
12
24
  primary: "primary";
13
25
  outline: "outline";
14
26
  ghost: "ghost";
27
+ danger: "danger";
15
28
  }>>;
16
29
  block: z.ZodOptional<z.ZodBoolean>;
30
+ submit: z.ZodOptional<z.ZodBoolean>;
17
31
  }, z.core.$strip>;
18
- render: ({
19
- label,
20
- buttonStyle,
21
- block,
22
- $action,
23
- $dispatch,
24
- children
25
- }: any) => import("react").JSX.Element;
32
+ render: ({ label, buttonStyle, block, submit, $action, $dispatch, children }: any) => import("react").JSX.Element;
26
33
  };
27
34
  Select: {
28
35
  description: string;
@@ -33,15 +40,9 @@ declare const interactiveVocabulary: {
33
40
  }, z.core.$strip>>;
34
41
  placeholder: z.ZodOptional<z.ZodString>;
35
42
  label: z.ZodOptional<z.ZodString>;
43
+ name: z.ZodOptional<z.ZodString>;
36
44
  }, z.core.$strip>;
37
- render: ({
38
- options,
39
- placeholder,
40
- label,
41
- $action,
42
- $dispatch,
43
- children
44
- }: any) => import("react").JSX.Element;
45
+ render: ({ options, placeholder, label, name, $action, $dispatch, children }: any) => import("react").JSX.Element;
45
46
  };
46
47
  Input: {
47
48
  description: string;
@@ -49,14 +50,9 @@ declare const interactiveVocabulary: {
49
50
  placeholder: z.ZodOptional<z.ZodString>;
50
51
  multiline: z.ZodOptional<z.ZodBoolean>;
51
52
  label: z.ZodOptional<z.ZodString>;
53
+ name: z.ZodOptional<z.ZodString>;
52
54
  }, z.core.$strip>;
53
- render: ({
54
- placeholder,
55
- multiline,
56
- label,
57
- $action,
58
- $dispatch
59
- }: any) => import("react").JSX.Element;
55
+ render: ({ placeholder, multiline, label, name, $action, $dispatch }: any) => import("react").JSX.Element;
60
56
  };
61
57
  DatePicker: {
62
58
  description: string;
@@ -65,15 +61,31 @@ declare const interactiveVocabulary: {
65
61
  min: z.ZodOptional<z.ZodString>;
66
62
  max: z.ZodOptional<z.ZodString>;
67
63
  label: z.ZodOptional<z.ZodString>;
64
+ name: z.ZodOptional<z.ZodString>;
65
+ }, z.core.$strip>;
66
+ render: ({ value, min, max, label, name, $action, $dispatch }: any) => import("react").JSX.Element;
67
+ };
68
+ Checkbox: {
69
+ description: string;
70
+ properties: z.ZodObject<{
71
+ label: z.ZodString;
72
+ name: z.ZodOptional<z.ZodString>;
73
+ defaultChecked: z.ZodOptional<z.ZodBoolean>;
74
+ }, z.core.$strip>;
75
+ render: ({ label, name, defaultChecked, $action, $dispatch }: any) => import("react").JSX.Element;
76
+ };
77
+ RadioGroup: {
78
+ description: string;
79
+ properties: z.ZodObject<{
80
+ options: z.ZodArray<z.ZodObject<{
81
+ label: z.ZodString;
82
+ value: z.ZodString;
83
+ }, z.core.$strip>>;
84
+ name: z.ZodOptional<z.ZodString>;
85
+ label: z.ZodOptional<z.ZodString>;
86
+ defaultValue: z.ZodOptional<z.ZodString>;
68
87
  }, z.core.$strip>;
69
- render: ({
70
- value,
71
- min,
72
- max,
73
- label,
74
- $action,
75
- $dispatch
76
- }: any) => import("react").JSX.Element;
88
+ render: typeof RadioGroupRender;
77
89
  };
78
90
  };
79
91
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"interactive.d.ts","names":[],"sources":["../../src/vocabulary/interactive.tsx"],"mappings":";;;cAgCa,qBAAA"}
1
+ {"version":3,"file":"interactive.d.ts","names":[],"sources":["../../src/vocabulary/interactive.tsx"],"mappings":";;;;KAYK;EACH;IAAW;IAAe;;EAC1B;EACA;EACA;EACA,UAAU;EACV,YAAY;;iBAGL,mBACP,SACA,MACA,OACA,cACA,SACA,aACC,wCAAqB,IAAA;cA8BX"}
@@ -1,4 +1,6 @@
1
1
  import { BUTTON_STYLES } from "../ir.js";
2
+ import { actionAttr, fire } from "./dispatch.js";
3
+ import { useId } from "react";
2
4
  import { jsx, jsxs } from "react/jsx-runtime";
3
5
  import { z } from "zod";
4
6
  //#region src/vocabulary/interactive.tsx
@@ -6,38 +8,43 @@ const optionSchema = z.object({
6
8
  label: z.string(),
7
9
  value: z.string()
8
10
  });
9
- const actionAttr = (a) => a ? JSON.stringify(a) : void 0;
10
- /** Fires `$action` through `$dispatch` when both are present, merging a runtime
11
- * value into the payload under the reserved `$input` key (not `value`) so the
12
- * user's input never clobbers a model-supplied `value` field. No-op when no
13
- * registry is wired. The returned promise from an async handler is caught and
14
- * re-thrown on a microtask so rejections surface rather than going unhandled. */
15
- const fire = ($action, $dispatch, input) => {
16
- if (!$action || !$dispatch) return;
17
- const payload = input === void 0 ? $action : {
18
- ...$action,
19
- $input: input
20
- };
21
- Promise.resolve($dispatch(payload)).catch((error) => {
22
- queueMicrotask(() => {
23
- throw error;
24
- });
11
+ function RadioGroupRender({ options, name, label, defaultValue, $action, $dispatch }) {
12
+ const generatedName = useId();
13
+ const fieldName = name ?? generatedName;
14
+ const safeOptions = Array.isArray(options) ? options : [];
15
+ return /* @__PURE__ */ jsx("fieldset", {
16
+ "data-aui": "radiogroup",
17
+ "data-aui-action": actionAttr($action),
18
+ "aria-label": label,
19
+ children: safeOptions.map((option, i) => option && typeof option.label === "string" && typeof option.value === "string" ? /* @__PURE__ */ jsxs("label", {
20
+ "data-aui": "radiogroup-option",
21
+ children: [/* @__PURE__ */ jsx("input", {
22
+ type: "radio",
23
+ name: fieldName,
24
+ value: option.value,
25
+ defaultChecked: defaultValue === option.value,
26
+ onChange: () => fire($action, $dispatch, option.value)
27
+ }), option.label]
28
+ }, i) : null)
25
29
  });
26
- };
30
+ }
27
31
  const interactiveVocabulary = {
28
32
  Button: {
29
- description: "A clickable button. Carries `$action` describing the side effect or resume value.",
33
+ description: "A clickable button. Carries `$action` describing the side effect or resume value. Set `submit` to submit an ancestor Form/Card instead of firing `$action` on click.",
30
34
  properties: z.object({
31
35
  label: z.string().describe("Button label."),
32
36
  buttonStyle: z.enum(BUTTON_STYLES).optional().describe("Visual style."),
33
- block: z.boolean().optional().describe("Whether the button spans the full width.")
37
+ block: z.boolean().optional().describe("Whether the button spans the full width."),
38
+ submit: z.boolean().optional().describe("Render as a submit button for an ancestor Form/Card instead of a click button.")
34
39
  }),
35
- render: ({ label, buttonStyle, block, $action, $dispatch, children }) => /* @__PURE__ */ jsxs("button", {
40
+ render: ({ label, buttonStyle, block, submit, $action, $dispatch, children }) => /* @__PURE__ */ jsxs("button", {
41
+ type: submit ? "submit" : "button",
36
42
  "data-aui": "button",
37
43
  "data-aui-style": buttonStyle,
38
44
  "data-aui-block": block || void 0,
45
+ "data-aui-submit": submit || void 0,
39
46
  "data-aui-action": actionAttr($action),
40
- onClick: () => fire($action, $dispatch),
47
+ onClick: submit ? void 0 : () => fire($action, $dispatch),
41
48
  children: [label, children]
42
49
  })
43
50
  },
@@ -46,11 +53,13 @@ const interactiveVocabulary = {
46
53
  properties: z.object({
47
54
  options: z.array(optionSchema).describe("Selectable options."),
48
55
  placeholder: z.string().optional().describe("Placeholder shown when nothing is selected."),
49
- label: z.string().optional().describe("Accessible label for the control.")
56
+ label: z.string().optional().describe("Accessible label for the control."),
57
+ name: z.string().optional().describe("Field name used inside a Form.")
50
58
  }),
51
- render: ({ options, placeholder, label, $action, $dispatch, children }) => /* @__PURE__ */ jsxs("select", {
59
+ render: ({ options, placeholder, label, name, $action, $dispatch, children }) => /* @__PURE__ */ jsxs("select", {
52
60
  "data-aui": "select",
53
61
  "data-aui-action": actionAttr($action),
62
+ name,
54
63
  "aria-label": label,
55
64
  defaultValue: "",
56
65
  onChange: (e) => fire($action, $dispatch, e.currentTarget.value),
@@ -73,26 +82,33 @@ const interactiveVocabulary = {
73
82
  properties: z.object({
74
83
  placeholder: z.string().optional().describe("Placeholder text."),
75
84
  multiline: z.boolean().optional().describe("Render a textarea instead of a single-line input."),
76
- label: z.string().optional().describe("Accessible label for the control.")
85
+ label: z.string().optional().describe("Accessible label for the control."),
86
+ name: z.string().optional().describe("Field name used inside a Form.")
77
87
  }),
78
- render: ({ placeholder, multiline, label, $action, $dispatch }) => {
88
+ render: ({ placeholder, multiline, label, name, $action, $dispatch }) => {
79
89
  const submit = (v) => fire($action, $dispatch, v);
80
90
  return multiline ? /* @__PURE__ */ jsx("textarea", {
81
91
  "data-aui": "input",
82
92
  "data-aui-multiline": true,
83
93
  "data-aui-action": actionAttr($action),
94
+ name,
84
95
  "aria-label": label,
85
96
  placeholder,
86
97
  onKeyDown: (e) => {
87
- if (e.key === "Enter" && (e.ctrlKey || e.metaKey) && !e.nativeEvent.isComposing) submit(e.currentTarget.value);
98
+ if (e.key !== "Enter" || !(e.ctrlKey || e.metaKey) || e.nativeEvent.isComposing) return;
99
+ if (e.currentTarget.form) {
100
+ e.preventDefault();
101
+ HTMLFormElement.prototype.requestSubmit.call(e.currentTarget.form);
102
+ } else submit(e.currentTarget.value);
88
103
  }
89
104
  }) : /* @__PURE__ */ jsx("input", {
90
105
  "data-aui": "input",
91
106
  "data-aui-action": actionAttr($action),
107
+ name,
92
108
  "aria-label": label,
93
109
  placeholder,
94
110
  onKeyDown: (e) => {
95
- if (e.key === "Enter" && !e.nativeEvent.isComposing) submit(e.currentTarget.value);
111
+ if (e.key === "Enter" && !e.nativeEvent.isComposing && !e.currentTarget.form) submit(e.currentTarget.value);
96
112
  }
97
113
  });
98
114
  }
@@ -103,18 +119,51 @@ const interactiveVocabulary = {
103
119
  value: z.string().optional().describe("Initial date (YYYY-MM-DD)."),
104
120
  min: z.string().optional().describe("Minimum date (YYYY-MM-DD)."),
105
121
  max: z.string().optional().describe("Maximum date (YYYY-MM-DD)."),
106
- label: z.string().optional().describe("Accessible label for the control.")
122
+ label: z.string().optional().describe("Accessible label for the control."),
123
+ name: z.string().optional().describe("Field name used inside a Form.")
107
124
  }),
108
- render: ({ value, min, max, label, $action, $dispatch }) => /* @__PURE__ */ jsx("input", {
125
+ render: ({ value, min, max, label, name, $action, $dispatch }) => /* @__PURE__ */ jsx("input", {
109
126
  type: "date",
110
127
  "data-aui": "datepicker",
111
128
  "data-aui-action": actionAttr($action),
129
+ name,
112
130
  "aria-label": label,
113
131
  defaultValue: value,
114
132
  min,
115
133
  max,
116
134
  onChange: (e) => fire($action, $dispatch, e.currentTarget.value)
117
135
  })
136
+ },
137
+ Checkbox: {
138
+ description: "A checkbox with a label. Carries `$action` describing the on-change behavior.",
139
+ properties: z.object({
140
+ label: z.string().describe("Label text next to the checkbox."),
141
+ name: z.string().optional().describe("Field name used inside a Form."),
142
+ defaultChecked: z.boolean().optional().describe("Whether the checkbox starts checked.")
143
+ }),
144
+ render: ({ label, name, defaultChecked, $action, $dispatch }) => /* @__PURE__ */ jsxs("label", {
145
+ "data-aui": "checkbox",
146
+ children: [/* @__PURE__ */ jsx("input", {
147
+ type: "checkbox",
148
+ "data-aui-action": actionAttr($action),
149
+ name,
150
+ defaultChecked,
151
+ onChange: (e) => fire($action, $dispatch, e.currentTarget.checked)
152
+ }), /* @__PURE__ */ jsx("span", {
153
+ "data-aui": "checkbox-label",
154
+ children: label
155
+ })]
156
+ })
157
+ },
158
+ RadioGroup: {
159
+ description: "A group of mutually exclusive radio options. Carries `$action` describing the on-change behavior.",
160
+ properties: z.object({
161
+ options: z.array(optionSchema).describe("Selectable options."),
162
+ name: z.string().optional().describe("Field name used inside a Form."),
163
+ label: z.string().optional().describe("Accessible name for the group."),
164
+ defaultValue: z.string().optional().describe("Initially selected value.")
165
+ }),
166
+ render: RadioGroupRender
118
167
  }
119
168
  };
120
169
  //#endregion