@assistant-ui/react-generative-ui 0.0.24 → 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 (338) hide show
  1. package/README.md +2 -0
  2. package/dist/a2ui.d.ts +1 -4
  3. package/dist/a2ui.d.ts.map +1 -1
  4. package/dist/a2ui.js +1 -4
  5. package/dist/index.d.ts +1 -2
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +1 -10
  8. package/dist/index.server.d.ts +1 -2
  9. package/dist/index.server.d.ts.map +1 -1
  10. package/dist/index.server.js +1 -10
  11. package/dist/ir.d.ts +1 -111
  12. package/dist/ir.d.ts.map +1 -1
  13. package/dist/ir.js +1 -175
  14. package/dist/slack.d.ts +1 -4
  15. package/dist/slack.d.ts.map +1 -1
  16. package/dist/slack.js +1 -4
  17. package/dist/teams.d.ts +1 -4
  18. package/dist/teams.d.ts.map +1 -1
  19. package/dist/teams.js +1 -4
  20. package/package.json +4 -5
  21. package/src/a2ui.ts +1 -22
  22. package/src/index.server.ts +1 -2
  23. package/src/index.test.ts +75 -0
  24. package/src/index.ts +1 -2
  25. package/src/ir.ts +1 -279
  26. package/src/slack.ts +1 -39
  27. package/src/teams.ts +1 -35
  28. package/dist/JSONGenerativeUI.client.d.ts +0 -28
  29. package/dist/JSONGenerativeUI.client.d.ts.map +0 -1
  30. package/dist/JSONGenerativeUI.client.js +0 -101
  31. package/dist/JSONGenerativeUI.client.js.map +0 -1
  32. package/dist/JSONGenerativeUI.server.d.ts +0 -21
  33. package/dist/JSONGenerativeUI.server.d.ts.map +0 -1
  34. package/dist/JSONGenerativeUI.server.js +0 -32
  35. package/dist/JSONGenerativeUI.server.js.map +0 -1
  36. package/dist/JSONGenerativeUI.shared.d.ts +0 -63
  37. package/dist/JSONGenerativeUI.shared.d.ts.map +0 -1
  38. package/dist/JSONGenerativeUI.shared.js +0 -31
  39. package/dist/JSONGenerativeUI.shared.js.map +0 -1
  40. package/dist/RadioGroupScope.d.ts +0 -6
  41. package/dist/RadioGroupScope.d.ts.map +0 -1
  42. package/dist/RadioGroupScope.js +0 -25
  43. package/dist/RadioGroupScope.js.map +0 -1
  44. package/dist/a2ui/BindingContext.d.ts +0 -11
  45. package/dist/a2ui/BindingContext.d.ts.map +0 -1
  46. package/dist/a2ui/BindingContext.js +0 -12
  47. package/dist/a2ui/BindingContext.js.map +0 -1
  48. package/dist/a2ui/PresentRenderer.d.ts +0 -11
  49. package/dist/a2ui/PresentRenderer.d.ts.map +0 -1
  50. package/dist/a2ui/PresentRenderer.js +0 -39
  51. package/dist/a2ui/PresentRenderer.js.map +0 -1
  52. package/dist/a2ui/convert.d.ts +0 -15
  53. package/dist/a2ui/convert.d.ts.map +0 -1
  54. package/dist/a2ui/convert.js +0 -728
  55. package/dist/a2ui/convert.js.map +0 -1
  56. package/dist/a2ui/dataModel.d.ts +0 -9
  57. package/dist/a2ui/dataModel.d.ts.map +0 -1
  58. package/dist/a2ui/dataModel.js +0 -44
  59. package/dist/a2ui/dataModel.js.map +0 -1
  60. package/dist/a2ui/reducer.d.ts +0 -8
  61. package/dist/a2ui/reducer.d.ts.map +0 -1
  62. package/dist/a2ui/reducer.js +0 -242
  63. package/dist/a2ui/reducer.js.map +0 -1
  64. package/dist/a2ui/snapshot.d.ts +0 -3
  65. package/dist/a2ui/snapshot.d.ts.map +0 -1
  66. package/dist/a2ui/snapshot.js +0 -33
  67. package/dist/a2ui/snapshot.js.map +0 -1
  68. package/dist/a2ui/types.d.ts +0 -88
  69. package/dist/a2ui/types.d.ts.map +0 -1
  70. package/dist/a2ui/types.js +0 -6
  71. package/dist/a2ui/types.js.map +0 -1
  72. package/dist/a2ui/valueFunctions.d.ts +0 -16
  73. package/dist/a2ui/valueFunctions.d.ts.map +0 -1
  74. package/dist/a2ui/valueFunctions.js +0 -332
  75. package/dist/a2ui/valueFunctions.js.map +0 -1
  76. package/dist/actionRegistry.d.ts +0 -29
  77. package/dist/actionRegistry.d.ts.map +0 -1
  78. package/dist/actionRegistry.js +0 -41
  79. package/dist/actionRegistry.js.map +0 -1
  80. package/dist/answeredValues.d.ts +0 -16
  81. package/dist/answeredValues.d.ts.map +0 -1
  82. package/dist/answeredValues.js +0 -37
  83. package/dist/answeredValues.js.map +0 -1
  84. package/dist/buildPresentParameters.d.ts +0 -21
  85. package/dist/buildPresentParameters.d.ts.map +0 -1
  86. package/dist/buildPresentParameters.js +0 -95
  87. package/dist/buildPresentParameters.js.map +0 -1
  88. package/dist/constants.d.ts +0 -15
  89. package/dist/constants.d.ts.map +0 -1
  90. package/dist/constants.js +0 -19
  91. package/dist/constants.js.map +0 -1
  92. package/dist/convert/boundSpec.d.ts +0 -48
  93. package/dist/convert/boundSpec.d.ts.map +0 -1
  94. package/dist/convert/boundSpec.js +0 -108
  95. package/dist/convert/boundSpec.js.map +0 -1
  96. package/dist/convert/copyBounded.d.ts +0 -25
  97. package/dist/convert/copyBounded.d.ts.map +0 -1
  98. package/dist/convert/copyBounded.js +0 -38
  99. package/dist/convert/copyBounded.js.map +0 -1
  100. package/dist/convert/isElement.d.ts +0 -3
  101. package/dist/convert/isElement.d.ts.map +0 -1
  102. package/dist/convert/isElement.js +0 -6
  103. package/dist/convert/isElement.js.map +0 -1
  104. package/dist/convert/takeRun.d.ts +0 -6
  105. package/dist/convert/takeRun.d.ts.map +0 -1
  106. package/dist/convert/takeRun.js +0 -20
  107. package/dist/convert/takeRun.js.map +0 -1
  108. package/dist/defineGenerativeComponents.d.ts +0 -29
  109. package/dist/defineGenerativeComponents.d.ts.map +0 -1
  110. package/dist/defineGenerativeComponents.js +0 -34
  111. package/dist/defineGenerativeComponents.js.map +0 -1
  112. package/dist/fieldReferences.d.ts +0 -9
  113. package/dist/fieldReferences.d.ts.map +0 -1
  114. package/dist/fieldReferences.js +0 -53
  115. package/dist/fieldReferences.js.map +0 -1
  116. package/dist/generativeUIToJSX.d.ts +0 -18
  117. package/dist/generativeUIToJSX.d.ts.map +0 -1
  118. package/dist/generativeUIToJSX.js +0 -76
  119. package/dist/generativeUIToJSX.js.map +0 -1
  120. package/dist/index.shared.d.ts +0 -15
  121. package/dist/index.shared.d.ts.map +0 -1
  122. package/dist/index.shared.js +0 -9
  123. package/dist/ir.js.map +0 -1
  124. package/dist/renderGenerativeUI.d.ts +0 -14
  125. package/dist/renderGenerativeUI.d.ts.map +0 -1
  126. package/dist/renderGenerativeUI.js +0 -83
  127. package/dist/renderGenerativeUI.js.map +0 -1
  128. package/dist/scopeSchema.d.ts +0 -6
  129. package/dist/scopeSchema.d.ts.map +0 -1
  130. package/dist/scopeSchema.js +0 -56
  131. package/dist/scopeSchema.js.map +0 -1
  132. package/dist/slack/constants.d.ts +0 -93
  133. package/dist/slack/constants.d.ts.map +0 -1
  134. package/dist/slack/constants.js +0 -146
  135. package/dist/slack/constants.js.map +0 -1
  136. package/dist/slack/decodeBlockAction.d.ts +0 -10
  137. package/dist/slack/decodeBlockAction.d.ts.map +0 -1
  138. package/dist/slack/decodeBlockAction.js +0 -129
  139. package/dist/slack/decodeBlockAction.js.map +0 -1
  140. package/dist/slack/fromSlackBlocks.d.ts +0 -27
  141. package/dist/slack/fromSlackBlocks.d.ts.map +0 -1
  142. package/dist/slack/fromSlackBlocks.js +0 -483
  143. package/dist/slack/fromSlackBlocks.js.map +0 -1
  144. package/dist/slack/toSlackBlocks.d.ts +0 -4
  145. package/dist/slack/toSlackBlocks.d.ts.map +0 -1
  146. package/dist/slack/toSlackBlocks.js +0 -901
  147. package/dist/slack/toSlackBlocks.js.map +0 -1
  148. package/dist/slack/types.d.ts +0 -204
  149. package/dist/slack/types.d.ts.map +0 -1
  150. package/dist/slack/types.js +0 -0
  151. package/dist/teams/constants.d.ts +0 -34
  152. package/dist/teams/constants.d.ts.map +0 -1
  153. package/dist/teams/constants.js +0 -68
  154. package/dist/teams/constants.js.map +0 -1
  155. package/dist/teams/decodeSubmitData.d.ts +0 -26
  156. package/dist/teams/decodeSubmitData.d.ts.map +0 -1
  157. package/dist/teams/decodeSubmitData.js +0 -70
  158. package/dist/teams/decodeSubmitData.js.map +0 -1
  159. package/dist/teams/temporalId.d.ts +0 -5
  160. package/dist/teams/temporalId.d.ts.map +0 -1
  161. package/dist/teams/temporalId.js +0 -28
  162. package/dist/teams/temporalId.js.map +0 -1
  163. package/dist/teams/toAdaptiveCard.d.ts +0 -45
  164. package/dist/teams/toAdaptiveCard.d.ts.map +0 -1
  165. package/dist/teams/toAdaptiveCard.js +0 -642
  166. package/dist/teams/toAdaptiveCard.js.map +0 -1
  167. package/dist/teams/toTeamsAttachments.d.ts +0 -10
  168. package/dist/teams/toTeamsAttachments.d.ts.map +0 -1
  169. package/dist/teams/toTeamsAttachments.js +0 -99
  170. package/dist/teams/toTeamsAttachments.js.map +0 -1
  171. package/dist/teams/types.d.ts +0 -224
  172. package/dist/teams/types.d.ts.map +0 -1
  173. package/dist/teams/types.js +0 -0
  174. package/dist/temporal.d.ts +0 -33
  175. package/dist/temporal.d.ts.map +0 -1
  176. package/dist/temporal.js +0 -153
  177. package/dist/temporal.js.map +0 -1
  178. package/dist/types.d.ts +0 -99
  179. package/dist/types.d.ts.map +0 -1
  180. package/dist/types.js +0 -0
  181. package/dist/vocabulary/alert.d.ts +0 -32
  182. package/dist/vocabulary/alert.d.ts.map +0 -1
  183. package/dist/vocabulary/alert.js +0 -160
  184. package/dist/vocabulary/alert.js.map +0 -1
  185. package/dist/vocabulary/collectFormValues.d.ts +0 -23
  186. package/dist/vocabulary/collectFormValues.d.ts.map +0 -1
  187. package/dist/vocabulary/collectFormValues.js +0 -44
  188. package/dist/vocabulary/collectFormValues.js.map +0 -1
  189. package/dist/vocabulary/data.d.ts +0 -66
  190. package/dist/vocabulary/data.d.ts.map +0 -1
  191. package/dist/vocabulary/data.js +0 -503
  192. package/dist/vocabulary/data.js.map +0 -1
  193. package/dist/vocabulary/dispatch.d.ts +0 -9
  194. package/dist/vocabulary/dispatch.d.ts.map +0 -1
  195. package/dist/vocabulary/dispatch.js +0 -50
  196. package/dist/vocabulary/dispatch.js.map +0 -1
  197. package/dist/vocabulary/fact.d.ts +0 -19
  198. package/dist/vocabulary/fact.d.ts.map +0 -1
  199. package/dist/vocabulary/fact.js +0 -51
  200. package/dist/vocabulary/fact.js.map +0 -1
  201. package/dist/vocabulary/form.d.ts +0 -11
  202. package/dist/vocabulary/form.d.ts.map +0 -1
  203. package/dist/vocabulary/form.js +0 -23
  204. package/dist/vocabulary/form.js.map +0 -1
  205. package/dist/vocabulary/formatValue.d.ts +0 -7
  206. package/dist/vocabulary/formatValue.d.ts.map +0 -1
  207. package/dist/vocabulary/formatValue.js +0 -76
  208. package/dist/vocabulary/formatValue.js.map +0 -1
  209. package/dist/vocabulary/icon.d.ts +0 -41
  210. package/dist/vocabulary/icon.d.ts.map +0 -1
  211. package/dist/vocabulary/icon.js +0 -272
  212. package/dist/vocabulary/icon.js.map +0 -1
  213. package/dist/vocabulary/index.d.ts +0 -12
  214. package/dist/vocabulary/index.d.ts.map +0 -1
  215. package/dist/vocabulary/index.js +0 -36
  216. package/dist/vocabulary/index.js.map +0 -1
  217. package/dist/vocabulary/interactive.d.ts +0 -230
  218. package/dist/vocabulary/interactive.d.ts.map +0 -1
  219. package/dist/vocabulary/interactive.js +0 -584
  220. package/dist/vocabulary/interactive.js.map +0 -1
  221. package/dist/vocabulary/layout.d.ts +0 -79
  222. package/dist/vocabulary/layout.d.ts.map +0 -1
  223. package/dist/vocabulary/layout.js +0 -139
  224. package/dist/vocabulary/layout.js.map +0 -1
  225. package/dist/vocabulary/list.d.ts +0 -14
  226. package/dist/vocabulary/list.d.ts.map +0 -1
  227. package/dist/vocabulary/list.js +0 -50
  228. package/dist/vocabulary/list.js.map +0 -1
  229. package/dist/vocabulary/media.d.ts +0 -25
  230. package/dist/vocabulary/media.d.ts.map +0 -1
  231. package/dist/vocabulary/media.js +0 -42
  232. package/dist/vocabulary/media.js.map +0 -1
  233. package/dist/vocabulary/text.d.ts +0 -57
  234. package/dist/vocabulary/text.d.ts.map +0 -1
  235. package/dist/vocabulary/text.js +0 -49
  236. package/dist/vocabulary/text.js.map +0 -1
  237. package/dist/vocabulary/toTextContent.d.ts +0 -2
  238. package/dist/vocabulary/toTextContent.d.ts.map +0 -1
  239. package/dist/vocabulary/toTextContent.js +0 -6
  240. package/dist/vocabulary/toTextContent.js.map +0 -1
  241. package/src/JSONGenerativeUI.client.tsx +0 -168
  242. package/src/JSONGenerativeUI.server.tsx +0 -39
  243. package/src/JSONGenerativeUI.shared.ts +0 -90
  244. package/src/JSONGenerativeUI.test.tsx +0 -1298
  245. package/src/RadioGroupScope.server.test.tsx +0 -24
  246. package/src/RadioGroupScope.tsx +0 -34
  247. package/src/a2ui/BindingContext.ts +0 -26
  248. package/src/a2ui/PresentRenderer.tsx +0 -83
  249. package/src/a2ui/convert.test.ts +0 -2923
  250. package/src/a2ui/convert.ts +0 -1207
  251. package/src/a2ui/dataModel.ts +0 -69
  252. package/src/a2ui/reducer.test.ts +0 -422
  253. package/src/a2ui/reducer.ts +0 -363
  254. package/src/a2ui/snapshot.test.ts +0 -52
  255. package/src/a2ui/snapshot.ts +0 -52
  256. package/src/a2ui/types.ts +0 -114
  257. package/src/a2ui/valueFunctions.test.ts +0 -271
  258. package/src/a2ui/valueFunctions.ts +0 -523
  259. package/src/actionRegistry.test.ts +0 -90
  260. package/src/actionRegistry.ts +0 -88
  261. package/src/answeredValues.test.ts +0 -33
  262. package/src/answeredValues.tsx +0 -70
  263. package/src/buildPresentParameters.test.ts +0 -246
  264. package/src/buildPresentParameters.ts +0 -130
  265. package/src/constants.ts +0 -17
  266. package/src/convert/boundSpec.test.ts +0 -192
  267. package/src/convert/boundSpec.ts +0 -134
  268. package/src/convert/copyBounded.test.ts +0 -131
  269. package/src/convert/copyBounded.ts +0 -38
  270. package/src/convert/isElement.ts +0 -6
  271. package/src/convert/takeRun.test.ts +0 -64
  272. package/src/convert/takeRun.ts +0 -19
  273. package/src/defineGenerativeComponents.ts +0 -38
  274. package/src/fieldReferences.test.ts +0 -66
  275. package/src/fieldReferences.ts +0 -83
  276. package/src/generativeUIToJSX.test.ts +0 -268
  277. package/src/generativeUIToJSX.ts +0 -152
  278. package/src/index.server.test.ts +0 -106
  279. package/src/index.shared.ts +0 -61
  280. package/src/ir.test.ts +0 -203
  281. package/src/renderGenerativeUI.test.tsx +0 -373
  282. package/src/renderGenerativeUI.tsx +0 -165
  283. package/src/scopeSchema.test.ts +0 -72
  284. package/src/scopeSchema.ts +0 -71
  285. package/src/slack/a2uiSlack.test.ts +0 -198
  286. package/src/slack/constants.ts +0 -194
  287. package/src/slack/datePicker.test.ts +0 -612
  288. package/src/slack/decodeBlockAction.test.ts +0 -233
  289. package/src/slack/decodeBlockAction.ts +0 -232
  290. package/src/slack/fromSlackBlocks.test.ts +0 -1465
  291. package/src/slack/fromSlackBlocks.ts +0 -789
  292. package/src/slack/toSlackBlocks.test.ts +0 -3065
  293. package/src/slack/toSlackBlocks.ts +0 -1818
  294. package/src/slack/types.ts +0 -264
  295. package/src/teams/constants.ts +0 -93
  296. package/src/teams/decodeSubmitData.test.ts +0 -397
  297. package/src/teams/decodeSubmitData.ts +0 -110
  298. package/src/teams/temporal.test.ts +0 -766
  299. package/src/teams/temporalId.ts +0 -56
  300. package/src/teams/toAdaptiveCard.test.ts +0 -1897
  301. package/src/teams/toAdaptiveCard.ts +0 -1057
  302. package/src/teams/toTeamsAttachments.test.ts +0 -74
  303. package/src/teams/toTeamsAttachments.ts +0 -133
  304. package/src/teams/types.ts +0 -266
  305. package/src/temporal.test.ts +0 -337
  306. package/src/temporal.ts +0 -263
  307. package/src/types.ts +0 -119
  308. package/src/vocabulary/alert.test.tsx +0 -427
  309. package/src/vocabulary/alert.tsx +0 -217
  310. package/src/vocabulary/collectFormValues.test.ts +0 -389
  311. package/src/vocabulary/collectFormValues.ts +0 -116
  312. package/src/vocabulary/data.test.tsx +0 -858
  313. package/src/vocabulary/data.tsx +0 -819
  314. package/src/vocabulary/datepicker.dom.test.tsx +0 -1457
  315. package/src/vocabulary/dispatch.ts +0 -83
  316. package/src/vocabulary/fact.test.tsx +0 -94
  317. package/src/vocabulary/fact.tsx +0 -54
  318. package/src/vocabulary/form.test.tsx +0 -113
  319. package/src/vocabulary/form.tsx +0 -39
  320. package/src/vocabulary/formatValue.test.ts +0 -72
  321. package/src/vocabulary/formatValue.ts +0 -127
  322. package/src/vocabulary/icon.test.tsx +0 -64
  323. package/src/vocabulary/icon.tsx +0 -174
  324. package/src/vocabulary/index.test.ts +0 -65
  325. package/src/vocabulary/index.ts +0 -33
  326. package/src/vocabulary/interactive.dispatch.test.tsx +0 -454
  327. package/src/vocabulary/interactive.dom.test.tsx +0 -1747
  328. package/src/vocabulary/interactive.test.tsx +0 -377
  329. package/src/vocabulary/interactive.tsx +0 -1109
  330. package/src/vocabulary/layout.test.tsx +0 -323
  331. package/src/vocabulary/layout.tsx +0 -247
  332. package/src/vocabulary/list.test.tsx +0 -222
  333. package/src/vocabulary/list.tsx +0 -50
  334. package/src/vocabulary/media.test.tsx +0 -85
  335. package/src/vocabulary/media.tsx +0 -56
  336. package/src/vocabulary/text.test.tsx +0 -102
  337. package/src/vocabulary/text.tsx +0 -60
  338. package/src/vocabulary/toTextContent.ts +0 -2
@@ -1,9 +0,0 @@
1
- import type { Action } from "../ir.js";
2
- import type { GenerativeUIDispatch } from "../types.js";
3
- import type { A2uiBinding } from "../a2ui/BindingContext.js";
4
- export declare const actionAttr: (a: Action | undefined) => string | undefined;
5
- /**
6
- * Fires `$action` through `$dispatch` when both are present, merging a runtime value into the payload under the reserved `$input` key (not `value`) so the user's input never clobbers a model-supplied `value` field. Each `{ "$field": name }` inside `$action` first resolves to the current value of the control with that `name` in the vocabulary form or generative UI root nearest to `source`, collected the way a `Form` collects it; a reference whose control is missing or holds no value resolves to its `fallback`, or is dropped without one. No-op when no registry is wired. The returned promise from an async handler is caught and re-thrown on a microtask so rejections surface rather than going unhandled.
7
- */
8
- export declare const fire: ($action: Action | undefined, $dispatch: GenerativeUIDispatch | undefined, input?: unknown, source?: Element, bindings?: ReadonlyMap<string, A2uiBinding>) => void;
9
- //# sourceMappingURL=dispatch.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dispatch.d.ts","sourceRoot":"","sources":["../../src/vocabulary/dispatch.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,iBAAc;AACpC,OAAO,KAAK,EAAE,oBAAoB,EAAE,oBAAiB;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,kCAA+B;AAQ1D,eAAO,MAAM,UAAU,GAAI,GAAG,MAAM,GAAG,SAAS,KAAG,MAAM,GAAG,SACzB,CAAC;AA8CpC;;GAEG;AACH,eAAO,MAAM,IAAI,GACf,SAAS,MAAM,GAAG,SAAS,EAC3B,WAAW,oBAAoB,GAAG,SAAS,EAC3C,QAAQ,OAAO,EACf,SAAS,OAAO,EAChB,WAAW,WAAW,CAAC,MAAM,EAAE,WAAW,CAAC,SAgB5C,CAAC"}
@@ -1,50 +0,0 @@
1
- import { hasFieldReference, resolveFieldReferences } from "../fieldReferences.js";
2
- import "../constants.js";
3
- import { equalData } from "../a2ui/dataModel.js";
4
- import { collectFormValues } from "./collectFormValues.js";
5
- //#region src/vocabulary/dispatch.ts
6
- const actionAttr = (a) => a ? JSON.stringify(a) : void 0;
7
- const fieldValues = (source, bindings) => {
8
- const scope = source.closest("form[data-aui], [data-aui=\"root\"]");
9
- if (!scope) return {};
10
- const root = scope.closest("[data-aui=\"root\"]");
11
- const controls = Array.from(scope.querySelectorAll("input, select, textarea")).filter((control) => control.closest("[data-aui=\"root\"]") === root);
12
- const values = collectFormValues(controls);
13
- if (!bindings) return values;
14
- const groups = /* @__PURE__ */ new Map();
15
- for (const control of controls) {
16
- const name = control.getAttribute("data-aui-field-name") ?? control.name;
17
- if (!bindings.has(name)) continue;
18
- const field = groups.get(name) ?? /* @__PURE__ */ new Map();
19
- groups.set(name, field);
20
- const group = control.type === "radio" || control.hasAttribute("data-aui-checkbox-group") ? control.closest("fieldset") ?? control : control;
21
- const elements = field.get(group) ?? [];
22
- elements.push(control);
23
- field.set(group, elements);
24
- }
25
- for (const [name, field] of groups) {
26
- const candidates = [...field.values()].map((elements) => collectFormValues(elements)[name]).filter((value) => value !== void 0);
27
- if (candidates.length > 0) values[name] = candidates.find((value) => !equalData(value, bindings.get(name).value)) ?? candidates[0];
28
- }
29
- return values;
30
- };
31
- /**
32
- * Fires `$action` through `$dispatch` when both are present, merging a runtime value into the payload under the reserved `$input` key (not `value`) so the user's input never clobbers a model-supplied `value` field. Each `{ "$field": name }` inside `$action` first resolves to the current value of the control with that `name` in the vocabulary form or generative UI root nearest to `source`, collected the way a `Form` collects it; a reference whose control is missing or holds no value resolves to its `fallback`, or is dropped without one. No-op when no registry is wired. The returned promise from an async handler is caught and re-thrown on a microtask so rejections surface rather than going unhandled.
33
- */
34
- const fire = ($action, $dispatch, input, source, bindings) => {
35
- if (!$action || !$dispatch) return;
36
- const action = source && hasFieldReference($action) ? resolveFieldReferences($action, fieldValues(source, bindings)) : $action;
37
- const payload = input === void 0 ? action : {
38
- ...action,
39
- $input: input
40
- };
41
- Promise.resolve($dispatch(payload)).catch((error) => {
42
- queueMicrotask(() => {
43
- throw error;
44
- });
45
- });
46
- };
47
- //#endregion
48
- export { actionAttr, fire };
49
-
50
- //# sourceMappingURL=dispatch.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dispatch.js","names":[],"sources":["../../src/vocabulary/dispatch.ts"],"sourcesContent":["import { hasFieldReference, resolveFieldReferences } from \"../fieldReferences\";\nimport type { Action } from \"../ir\";\nimport type { GenerativeUIDispatch } from \"../types\";\nimport type { A2uiBinding } from \"../a2ui/BindingContext\";\nimport { equalData } from \"../a2ui/dataModel\";\nimport { CHECKBOX_GROUP_ATTR, FIELD_NAME_ATTR } from \"../constants\";\nimport {\n collectFormValues,\n type FormControlElementLike,\n} from \"./collectFormValues\";\n\nexport const actionAttr = (a: Action | undefined): string | undefined =>\n a ? JSON.stringify(a) : undefined;\n\nconst fieldValues = (\n source: Element,\n bindings?: ReadonlyMap<string, A2uiBinding>,\n): Record<string, unknown> => {\n const scope = source.closest('form[data-aui], [data-aui=\"root\"]');\n if (!scope) return {};\n const root = scope.closest('[data-aui=\"root\"]');\n const controls = Array.from(\n scope.querySelectorAll<\n HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement\n >(\"input, select, textarea\"),\n ).filter((control) => control.closest('[data-aui=\"root\"]') === root);\n const values = collectFormValues(\n controls as ArrayLike<FormControlElementLike>,\n );\n if (!bindings) return values;\n const groups = new Map<string, Map<Element, FormControlElementLike[]>>();\n for (const control of controls) {\n const name = control.getAttribute(FIELD_NAME_ATTR) ?? control.name;\n if (!bindings.has(name)) continue;\n const field =\n groups.get(name) ?? new Map<Element, FormControlElementLike[]>();\n groups.set(name, field);\n const group =\n control.type === \"radio\" || control.hasAttribute(CHECKBOX_GROUP_ATTR)\n ? (control.closest(\"fieldset\") ?? control)\n : control;\n const elements = field.get(group) ?? [];\n elements.push(control);\n field.set(group, elements);\n }\n for (const [name, field] of groups) {\n const candidates = [...field.values()]\n .map((elements) => collectFormValues(elements)[name])\n .filter((value) => value !== undefined);\n if (candidates.length > 0)\n values[name] =\n candidates.find(\n (value) => !equalData(value, bindings.get(name)!.value),\n ) ?? candidates[0];\n }\n return values;\n};\n\n/**\n * Fires `$action` through `$dispatch` when both are present, merging a runtime value into the payload under the reserved `$input` key (not `value`) so the user's input never clobbers a model-supplied `value` field. Each `{ \"$field\": name }` inside `$action` first resolves to the current value of the control with that `name` in the vocabulary form or generative UI root nearest to `source`, collected the way a `Form` collects it; a reference whose control is missing or holds no value resolves to its `fallback`, or is dropped without one. No-op when no registry is wired. The returned promise from an async handler is caught and re-thrown on a microtask so rejections surface rather than going unhandled.\n */\nexport const fire = (\n $action: Action | undefined,\n $dispatch: GenerativeUIDispatch | undefined,\n input?: unknown,\n source?: Element,\n bindings?: ReadonlyMap<string, A2uiBinding>,\n) => {\n if (!$action || !$dispatch) return;\n const action =\n source && hasFieldReference($action)\n ? (resolveFieldReferences(\n $action,\n fieldValues(source, bindings),\n ) as Action)\n : $action;\n const payload = input === undefined ? action : { ...action, $input: input };\n void Promise.resolve($dispatch(payload)).catch((error) => {\n queueMicrotask(() => {\n throw error;\n });\n });\n};\n"],"mappings":";;;;;AAWA,MAAa,cAAc,MACzB,IAAI,KAAK,UAAU,CAAC,IAAI,KAAA;AAE1B,MAAM,eACJ,QACA,aAC4B;CAC5B,MAAM,QAAQ,OAAO,QAAQ,qCAAmC;CAChE,IAAI,CAAC,OAAO,OAAO,CAAC;CACpB,MAAM,OAAO,MAAM,QAAQ,qBAAmB;CAC9C,MAAM,WAAW,MAAM,KACrB,MAAM,iBAEJ,yBAAyB,CAC7B,CAAC,CAAC,QAAQ,YAAY,QAAQ,QAAQ,qBAAmB,MAAM,IAAI;CACnE,MAAM,SAAS,kBACb,QACF;CACA,IAAI,CAAC,UAAU,OAAO;CACtB,MAAM,yBAAS,IAAI,IAAoD;CACvE,KAAK,MAAM,WAAW,UAAU;EAC9B,MAAM,OAAO,QAAQ,aAAA,qBAA4B,KAAK,QAAQ;EAC9D,IAAI,CAAC,SAAS,IAAI,IAAI,GAAG;EACzB,MAAM,QACJ,OAAO,IAAI,IAAI,qBAAK,IAAI,IAAuC;EACjE,OAAO,IAAI,MAAM,KAAK;EACtB,MAAM,QACJ,QAAQ,SAAS,WAAW,QAAQ,aAAA,yBAAgC,IAC/D,QAAQ,QAAQ,UAAU,KAAK,UAChC;EACN,MAAM,WAAW,MAAM,IAAI,KAAK,KAAK,CAAC;EACtC,SAAS,KAAK,OAAO;EACrB,MAAM,IAAI,OAAO,QAAQ;CAC3B;CACA,KAAK,MAAM,CAAC,MAAM,UAAU,QAAQ;EAClC,MAAM,aAAa,CAAC,GAAG,MAAM,OAAO,CAAC,CAAC,CACnC,KAAK,aAAa,kBAAkB,QAAQ,CAAC,CAAC,KAAK,CAAC,CACpD,QAAQ,UAAU,UAAU,KAAA,CAAS;EACxC,IAAI,WAAW,SAAS,GACtB,OAAO,QACL,WAAW,MACR,UAAU,CAAC,UAAU,OAAO,SAAS,IAAI,IAAI,CAAC,CAAE,KAAK,CACxD,KAAK,WAAW;CACtB;CACA,OAAO;AACT;;;;AAKA,MAAa,QACX,SACA,WACA,OACA,QACA,aACG;CACH,IAAI,CAAC,WAAW,CAAC,WAAW;CAC5B,MAAM,SACJ,UAAU,kBAAkB,OAAO,IAC9B,uBACC,SACA,YAAY,QAAQ,QAAQ,CAC9B,IACA;CACN,MAAM,UAAU,UAAU,KAAA,IAAY,SAAS;EAAE,GAAG;EAAQ,QAAQ;CAAM;CAC1E,QAAa,QAAQ,UAAU,OAAO,CAAC,CAAC,CAAC,OAAO,UAAU;EACxD,qBAAqB;GACnB,MAAM;EACR,CAAC;CACH,CAAC;AACH"}
@@ -1,19 +0,0 @@
1
- import { z } from "zod";
2
- export declare const factVocabulary: {
3
- Fact: {
4
- description: string;
5
- properties: z.ZodObject<{
6
- label: z.ZodString;
7
- value: z.ZodString;
8
- delta: z.ZodOptional<z.ZodString>;
9
- trend: z.ZodOptional<z.ZodEnum<{
10
- flat: "flat";
11
- up: "up";
12
- down: "down";
13
- }>>;
14
- upIsGood: z.ZodOptional<z.ZodBoolean>;
15
- }, z.core.$strip>;
16
- render: ({ label, value, delta, trend, upIsGood, children }: any) => import("react").JSX.Element;
17
- };
18
- };
19
- //# sourceMappingURL=fact.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fact.d.ts","sourceRoot":"","sources":["../../src/vocabulary/fact.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAexB,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;CAsCI,CAAC"}
@@ -1,51 +0,0 @@
1
- import { toTextContent } from "./toTextContent.js";
2
- import { factTrend, formatFactDelta } from "./formatValue.js";
3
- import { jsx, jsxs } from "react/jsx-runtime";
4
- import { z } from "zod";
5
- //#region src/vocabulary/fact.tsx
6
- const factTone = (trend, upIsGood) => {
7
- if (trend === "flat") return "neutral";
8
- const positive = upIsGood !== false;
9
- return (trend === "up" ? positive : !positive) ? "good" : "bad";
10
- };
11
- const factVocabulary = { Fact: {
12
- description: "A label/value pair, rendered as a key followed by its value. Use for compact metadata.",
13
- properties: z.object({
14
- label: z.string().describe("The fact label (key)."),
15
- value: z.string().describe("The fact value."),
16
- delta: z.string().optional().describe("Change from before."),
17
- trend: z.enum([
18
- "up",
19
- "down",
20
- "flat"
21
- ]).optional().describe("Change direction."),
22
- upIsGood: z.boolean().optional().describe("Whether up is good.")
23
- }),
24
- render: ({ label, value, delta, trend, upIsGood, children }) => {
25
- const direction = factTrend(delta, trend);
26
- const tone = factTone(direction, upIsGood);
27
- return /* @__PURE__ */ jsxs("dl", {
28
- "data-aui": "fact",
29
- children: [/* @__PURE__ */ jsx("dt", {
30
- "data-aui": "fact-label",
31
- children: toTextContent(label)
32
- }), /* @__PURE__ */ jsxs("dd", {
33
- "data-aui": "fact-value",
34
- children: [
35
- toTextContent(value),
36
- typeof delta === "string" ? /* @__PURE__ */ jsx("span", {
37
- "data-aui": "fact-delta",
38
- "data-aui-trend": direction,
39
- "data-aui-tone": tone,
40
- children: formatFactDelta(delta, direction)
41
- }) : null,
42
- children
43
- ]
44
- })]
45
- });
46
- }
47
- } };
48
- //#endregion
49
- export { factVocabulary };
50
-
51
- //# sourceMappingURL=fact.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fact.js","names":[],"sources":["../../src/vocabulary/fact.tsx"],"sourcesContent":["import { z } from \"zod\";\nimport type { GenerativeUILibrary } from \"../types\";\nimport { factTrend, formatFactDelta } from \"./formatValue\";\nimport { toTextContent } from \"./toTextContent\";\n\nconst factTone = (\n trend: \"up\" | \"down\" | \"flat\",\n upIsGood: unknown,\n): \"good\" | \"bad\" | \"neutral\" => {\n if (trend === \"flat\") return \"neutral\";\n const positive = upIsGood !== false;\n const isGood = trend === \"up\" ? positive : !positive;\n return isGood ? \"good\" : \"bad\";\n};\n\nexport const factVocabulary = {\n Fact: {\n description:\n \"A label/value pair, rendered as a key followed by its value. Use for compact metadata.\",\n properties: z.object({\n label: z.string().describe(\"The fact label (key).\"),\n value: z.string().describe(\"The fact value.\"),\n delta: z.string().optional().describe(\"Change from before.\"),\n trend: z\n .enum([\"up\", \"down\", \"flat\"])\n .optional()\n .describe(\"Change direction.\"),\n upIsGood: z.boolean().optional().describe(\"Whether up is good.\"),\n }),\n render: ({ label, value, delta, trend, upIsGood, children }) => {\n const direction = factTrend(delta, trend);\n const tone = factTone(direction, upIsGood);\n\n return (\n <dl data-aui=\"fact\">\n <dt data-aui=\"fact-label\">{toTextContent(label)}</dt>\n <dd data-aui=\"fact-value\">\n {toTextContent(value)}\n {typeof delta === \"string\" ? (\n <span\n data-aui=\"fact-delta\"\n data-aui-trend={direction}\n data-aui-tone={tone}\n >\n {formatFactDelta(delta, direction)}\n </span>\n ) : null}\n {children}\n </dd>\n </dl>\n );\n },\n },\n} satisfies GenerativeUILibrary;\n"],"mappings":";;;;;AAKA,MAAM,YACJ,OACA,aAC+B;CAC/B,IAAI,UAAU,QAAQ,OAAO;CAC7B,MAAM,WAAW,aAAa;CAE9B,QADe,UAAU,OAAO,WAAW,CAAC,YAC5B,SAAS;AAC3B;AAEA,MAAa,iBAAiB,EAC5B,MAAM;CACJ,aACE;CACF,YAAY,EAAE,OAAO;EACnB,OAAO,EAAE,OAAO,CAAC,CAAC,SAAS,uBAAuB;EAClD,OAAO,EAAE,OAAO,CAAC,CAAC,SAAS,iBAAiB;EAC5C,OAAO,EAAE,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,qBAAqB;EAC3D,OAAO,EACJ,KAAK;GAAC;GAAM;GAAQ;EAAM,CAAC,CAAC,CAC5B,SAAS,CAAC,CACV,SAAS,mBAAmB;EAC/B,UAAU,EAAE,QAAQ,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,qBAAqB;CACjE,CAAC;CACD,SAAS,EAAE,OAAO,OAAO,OAAO,OAAO,UAAU,eAAe;EAC9D,MAAM,YAAY,UAAU,OAAO,KAAK;EACxC,MAAM,OAAO,SAAS,WAAW,QAAQ;EAEzC,OACE,qBAAC,MAAD;GAAI,YAAS;GAAb,UAAA,CACE,oBAAC,MAAD;IAAI,YAAS;IAAc,UAAA,cAAc,KAAK;GAAM,CAAA,GACpD,qBAAC,MAAD;IAAI,YAAS;IAAb,UAAA;KACG,cAAc,KAAK;KACnB,OAAO,UAAU,WAChB,oBAAC,QAAD;MACE,YAAS;MACT,kBAAgB;MAChB,iBAAe;MAEd,UAAA,gBAAgB,OAAO,SAAS;KAC7B,CAAA,IACJ;KACH;IACC;GACF,CAAA,CAAA;;CAER;AACF,EACF"}
@@ -1,11 +0,0 @@
1
- import { z } from "zod";
2
- export declare const formVocabulary: {
3
- Form: {
4
- description: string;
5
- properties: z.ZodObject<{
6
- gap: z.ZodOptional<z.ZodNumber>;
7
- }, z.core.$strip>;
8
- render: ({ gap, $action, $dispatch, children }: any) => import("react").JSX.Element;
9
- };
10
- };
11
- //# sourceMappingURL=form.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"form.d.ts","sourceRoot":"","sources":["../../src/vocabulary/form.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,eAAO,MAAM,cAAc;;;;;;;;CAiCI,CAAC"}
@@ -1,23 +0,0 @@
1
- import { collectFormValuesFromEvent } from "./collectFormValues.js";
2
- import { actionAttr, fire } from "./dispatch.js";
3
- import { jsx } from "react/jsx-runtime";
4
- import { z } from "zod";
5
- //#region src/vocabulary/form.tsx
6
- const formVocabulary = { Form: {
7
- description: "Wraps named child controls (Select/Input/Checkbox/RadioGroup/CheckboxGroup/DatePicker with a `name`). Carries `$action`; on submit it fires with every named control's value, keyed by `name`.",
8
- properties: z.object({ gap: z.number().min(0).max(8).optional().describe("Gap between children in 4px units. 0 to 8 is the supported range.") }),
9
- render: ({ gap, $action, $dispatch, children }) => /* @__PURE__ */ jsx("form", {
10
- "data-aui": "form",
11
- "data-aui-gap": gap,
12
- "data-aui-action": actionAttr($action),
13
- onSubmit: (event) => {
14
- event.preventDefault();
15
- fire($action, $dispatch, collectFormValuesFromEvent(event), event.currentTarget);
16
- },
17
- children
18
- })
19
- } };
20
- //#endregion
21
- export { formVocabulary };
22
-
23
- //# sourceMappingURL=form.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"form.js","names":[],"sources":["../../src/vocabulary/form.tsx"],"sourcesContent":["import { z } from \"zod\";\nimport type { GenerativeUILibrary } from \"../types\";\nimport { actionAttr, fire } from \"./dispatch\";\nimport { collectFormValuesFromEvent } from \"./collectFormValues\";\n\nexport const formVocabulary = {\n Form: {\n description:\n \"Wraps named child controls (Select/Input/Checkbox/RadioGroup/CheckboxGroup/DatePicker with a `name`). Carries `$action`; on submit it fires with every named control's value, keyed by `name`.\",\n properties: z.object({\n gap: z\n .number()\n .min(0)\n .max(8)\n .optional()\n .describe(\n \"Gap between children in 4px units. 0 to 8 is the supported range.\",\n ),\n }),\n render: ({ gap, $action, $dispatch, children }) => (\n <form\n data-aui=\"form\"\n data-aui-gap={gap}\n data-aui-action={actionAttr($action)}\n onSubmit={(event) => {\n event.preventDefault();\n fire(\n $action,\n $dispatch,\n collectFormValuesFromEvent(event),\n event.currentTarget,\n );\n }}\n >\n {children}\n </form>\n ),\n },\n} satisfies GenerativeUILibrary;\n"],"mappings":";;;;;AAKA,MAAa,iBAAiB,EAC5B,MAAM;CACJ,aACE;CACF,YAAY,EAAE,OAAO,EACnB,KAAK,EACF,OAAO,CAAC,CACR,IAAI,CAAC,CAAC,CACN,IAAI,CAAC,CAAC,CACN,SAAS,CAAC,CACV,SACC,mEACF,EACJ,CAAC;CACD,SAAS,EAAE,KAAK,SAAS,WAAW,eAClC,oBAAC,QAAD;EACE,YAAS;EACT,gBAAc;EACd,mBAAiB,WAAW,OAAO;EACnC,WAAW,UAAU;GACnB,MAAM,eAAe;GACrB,KACE,SACA,WACA,2BAA2B,KAAK,GAChC,MAAM,aACR;EACF;EAEC;CACG,CAAA;AAEV,EACF"}
@@ -1,7 +0,0 @@
1
- type FactTrend = "up" | "down" | "flat";
2
- export declare const factTrend: (delta: unknown, trend: unknown) => FactTrend;
3
- export declare const formatFactDelta: (delta: string, trend: FactTrend) => string;
4
- export declare const isNumericTableFormat: (format: unknown) => boolean;
5
- export declare const formatValue: (value: unknown, format: unknown) => string;
6
- export {};
7
- //# sourceMappingURL=formatValue.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"formatValue.d.ts","sourceRoot":"","sources":["../../src/vocabulary/formatValue.ts"],"names":[],"mappings":"AAWA,KAAK,SAAS,GAAG,IAAI,GAAG,MAAM,GAAG,MAAM,CAAC;AAsDxC,eAAO,MAAM,SAAS,GAAI,OAAO,OAAO,EAAE,OAAO,OAAO,KAAG,SAM1D,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,OAAO,MAAM,EAAE,OAAO,SAAS,KAAG,MASjE,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAI,QAAQ,OAAO,KAAG,OACN,CAAC;AAElD,eAAO,MAAM,WAAW,GAAI,OAAO,OAAO,EAAE,QAAQ,OAAO,KAAG,MAuC7D,CAAC"}
@@ -1,76 +0,0 @@
1
- //#region src/vocabulary/formatValue.ts
2
- const DATE_ONLY_PATTERN = /^\d{4}-\d{2}-\d{2}$/;
3
- const ISO_DATE_PATTERN = /^\d{4}-\d{2}-\d{2}(?:T\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:?\d{2})?)?$/;
4
- const toRawText = (value) => typeof value === "string" || typeof value === "number" || typeof value === "boolean" ? String(value) : "";
5
- const isTableFormat = (format) => format !== null && typeof format === "object" && "kind" in format && (format.kind === "number" || format.kind === "currency" || format.kind === "percent" || format.kind === "date");
6
- const fractionDigits = (decimals) => {
7
- if (typeof decimals !== "number" || !Number.isFinite(decimals)) return;
8
- return Math.min(20, Math.max(0, Math.trunc(decimals)));
9
- };
10
- const isCalendarDate = (value) => {
11
- const [year, month, day] = value.slice(0, 10).split("-").map(Number);
12
- if (year === void 0 || month === void 0 || day === void 0) return false;
13
- const daysInMonth = month === 2 ? year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0) ? 29 : 28 : [
14
- 4,
15
- 6,
16
- 9,
17
- 11
18
- ].includes(month) ? 30 : 31;
19
- return month >= 1 && month <= 12 && day >= 1 && day <= daysInMonth;
20
- };
21
- const dateFromValue = (value) => {
22
- if (typeof value === "number") {
23
- const date = new Date(value);
24
- return Number.isNaN(date.getTime()) ? void 0 : date;
25
- }
26
- if (typeof value !== "string" || !ISO_DATE_PATTERN.test(value)) return;
27
- if (!isCalendarDate(value)) return void 0;
28
- const date = new Date(value);
29
- return Number.isNaN(date.getTime()) ? void 0 : date;
30
- };
31
- const factTrend = (delta, trend) => {
32
- if (trend === "down" || trend === "flat" || trend === "up") return trend;
33
- if (typeof delta === "string" && /\d/.test(delta) && !/[1-9]/.test(delta)) return "flat";
34
- return typeof delta === "string" && /^[-\u2212]/.test(delta) ? "down" : "up";
35
- };
36
- const formatFactDelta = (delta, trend) => {
37
- return `${trend === "up" ? "↑" : trend === "down" ? "↓" : "→"} ${trend === "up" ? delta.replace(/^\+/, "") : trend === "down" ? delta.replace(/^[-\u2212]/, "") : delta}`;
38
- };
39
- const isNumericTableFormat = (format) => isTableFormat(format) && format.kind !== "date";
40
- const formatValue = (value, format) => {
41
- const raw = toRawText(value);
42
- try {
43
- if (!isTableFormat(format)) return raw;
44
- if (format.kind === "date") {
45
- const date = dateFromValue(value);
46
- return date === void 0 ? raw : new Intl.DateTimeFormat("en-US", {
47
- dateStyle: "medium",
48
- ...typeof value === "string" && DATE_ONLY_PATTERN.test(value) ? { timeZone: "UTC" } : {}
49
- }).format(date);
50
- }
51
- if (typeof value !== "number") return raw;
52
- const decimals = fractionDigits(format.decimals);
53
- const digitOptions = decimals === void 0 ? {} : {
54
- minimumFractionDigits: decimals,
55
- maximumFractionDigits: decimals
56
- };
57
- if (format.kind === "currency") {
58
- if (typeof format.currency !== "string") return raw;
59
- return new Intl.NumberFormat("en-US", {
60
- ...digitOptions,
61
- style: "currency",
62
- currency: format.currency
63
- }).format(value);
64
- }
65
- return new Intl.NumberFormat("en-US", {
66
- ...digitOptions,
67
- ...format.kind === "percent" ? { style: "percent" } : {}
68
- }).format(value);
69
- } catch {
70
- return raw;
71
- }
72
- };
73
- //#endregion
74
- export { factTrend, formatFactDelta, formatValue, isNumericTableFormat };
75
-
76
- //# sourceMappingURL=formatValue.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"formatValue.js","names":[],"sources":["../../src/vocabulary/formatValue.ts"],"sourcesContent":["type TableFormat = {\n kind: \"number\" | \"currency\" | \"percent\" | \"date\";\n currency?: string;\n decimals?: number;\n};\n\nconst DATE_ONLY_PATTERN = /^\\d{4}-\\d{2}-\\d{2}$/;\n\nconst ISO_DATE_PATTERN =\n /^\\d{4}-\\d{2}-\\d{2}(?:T\\d{2}:\\d{2}(?::\\d{2}(?:\\.\\d+)?)?(?:Z|[+-]\\d{2}:?\\d{2})?)?$/;\n\ntype FactTrend = \"up\" | \"down\" | \"flat\";\n\nconst toRawText = (value: unknown): string =>\n typeof value === \"string\" ||\n typeof value === \"number\" ||\n typeof value === \"boolean\"\n ? String(value)\n : \"\";\n\nconst isTableFormat = (format: unknown): format is TableFormat =>\n format !== null &&\n typeof format === \"object\" &&\n \"kind\" in format &&\n (format.kind === \"number\" ||\n format.kind === \"currency\" ||\n format.kind === \"percent\" ||\n format.kind === \"date\");\n\nconst fractionDigits = (decimals: unknown): number | undefined => {\n if (typeof decimals !== \"number\" || !Number.isFinite(decimals)) {\n return undefined;\n }\n return Math.min(20, Math.max(0, Math.trunc(decimals)));\n};\n\nconst isCalendarDate = (value: string): boolean => {\n const [year, month, day] = value.slice(0, 10).split(\"-\").map(Number);\n if (year === undefined || month === undefined || day === undefined) {\n return false;\n }\n const daysInMonth =\n month === 2\n ? year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0)\n ? 29\n : 28\n : [4, 6, 9, 11].includes(month)\n ? 30\n : 31;\n return month >= 1 && month <= 12 && day >= 1 && day <= daysInMonth;\n};\n\nconst dateFromValue = (value: unknown): Date | undefined => {\n if (typeof value === \"number\") {\n const date = new Date(value);\n return Number.isNaN(date.getTime()) ? undefined : date;\n }\n if (typeof value !== \"string\" || !ISO_DATE_PATTERN.test(value)) {\n return undefined;\n }\n if (!isCalendarDate(value)) return undefined;\n const date = new Date(value);\n return Number.isNaN(date.getTime()) ? undefined : date;\n};\n\nexport const factTrend = (delta: unknown, trend: unknown): FactTrend => {\n if (trend === \"down\" || trend === \"flat\" || trend === \"up\") return trend;\n if (typeof delta === \"string\" && /\\d/.test(delta) && !/[1-9]/.test(delta)) {\n return \"flat\";\n }\n return typeof delta === \"string\" && /^[-\\u2212]/.test(delta) ? \"down\" : \"up\";\n};\n\nexport const formatFactDelta = (delta: string, trend: FactTrend): string => {\n const arrow = trend === \"up\" ? \"↑\" : trend === \"down\" ? \"↓\" : \"→\";\n const text =\n trend === \"up\"\n ? delta.replace(/^\\+/, \"\")\n : trend === \"down\"\n ? delta.replace(/^[-\\u2212]/, \"\")\n : delta;\n return `${arrow} ${text}`;\n};\n\nexport const isNumericTableFormat = (format: unknown): boolean =>\n isTableFormat(format) && format.kind !== \"date\";\n\nexport const formatValue = (value: unknown, format: unknown): string => {\n const raw = toRawText(value);\n try {\n if (!isTableFormat(format)) return raw;\n\n if (format.kind === \"date\") {\n const date = dateFromValue(value);\n return date === undefined\n ? raw\n : new Intl.DateTimeFormat(\"en-US\", {\n dateStyle: \"medium\",\n ...(typeof value === \"string\" && DATE_ONLY_PATTERN.test(value)\n ? { timeZone: \"UTC\" }\n : {}),\n }).format(date);\n }\n\n if (typeof value !== \"number\") return raw;\n\n const decimals = fractionDigits(format.decimals);\n const digitOptions =\n decimals === undefined\n ? {}\n : { minimumFractionDigits: decimals, maximumFractionDigits: decimals };\n if (format.kind === \"currency\") {\n if (typeof format.currency !== \"string\") return raw;\n return new Intl.NumberFormat(\"en-US\", {\n ...digitOptions,\n style: \"currency\",\n currency: format.currency,\n }).format(value);\n }\n return new Intl.NumberFormat(\"en-US\", {\n ...digitOptions,\n ...(format.kind === \"percent\" ? { style: \"percent\" } : {}),\n }).format(value);\n } catch {\n return raw;\n }\n};\n"],"mappings":"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"}
@@ -1,41 +0,0 @@
1
- import { z } from "zod";
2
- export declare const iconVocabulary: {
3
- Icon: {
4
- description: string;
5
- properties: z.ZodObject<{
6
- name: z.ZodEnum<{
7
- search: "search";
8
- sun: "sun";
9
- moon: "moon";
10
- cloud: "cloud";
11
- rain: "rain";
12
- snow: "snow";
13
- wind: "wind";
14
- play: "play";
15
- pause: "pause";
16
- check: "check";
17
- x: "x";
18
- star: "star";
19
- heart: "heart";
20
- "arrow-right": "arrow-right";
21
- "arrow-up-right": "arrow-up-right";
22
- "chevron-right": "chevron-right";
23
- calendar: "calendar";
24
- clock: "clock";
25
- "map-pin": "map-pin";
26
- plane: "plane";
27
- truck: "truck";
28
- "credit-card": "credit-card";
29
- user: "user";
30
- bell: "bell";
31
- }>;
32
- size: z.ZodOptional<z.ZodEnum<{
33
- sm: "sm";
34
- md: "md";
35
- lg: "lg";
36
- }>>;
37
- }, z.core.$strip>;
38
- render: ({ name, size }: any) => import("react").JSX.Element | null;
39
- };
40
- };
41
- //# sourceMappingURL=icon.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"icon.d.ts","sourceRoot":"","sources":["../../src/vocabulary/icon.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAwIxB,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoCI,CAAC"}
@@ -1,272 +0,0 @@
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