@copilotkit/shared 2.0.0-rc.30 → 2.0.0-rc.32

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 (231) hide show
  1. package/README.md +1 -1
  2. package/dist/generative-ui/catalog/catalog-export.cjs +329 -0
  3. package/dist/generative-ui/catalog/catalog-export.cjs.map +1 -0
  4. package/dist/generative-ui/catalog/catalog-export.d.cts +92 -0
  5. package/dist/generative-ui/catalog/catalog-export.d.cts.map +1 -0
  6. package/dist/generative-ui/catalog/catalog-export.d.mts +92 -0
  7. package/dist/generative-ui/catalog/catalog-export.d.mts.map +1 -0
  8. package/dist/generative-ui/catalog/catalog-export.mjs +328 -0
  9. package/dist/generative-ui/catalog/catalog-export.mjs.map +1 -0
  10. package/dist/generative-ui/catalog/catalog.cjs +315 -0
  11. package/dist/generative-ui/catalog/catalog.cjs.map +1 -0
  12. package/dist/generative-ui/catalog/catalog.d.cts +407 -0
  13. package/dist/generative-ui/catalog/catalog.d.cts.map +1 -0
  14. package/dist/generative-ui/catalog/catalog.d.mts +407 -0
  15. package/dist/generative-ui/catalog/catalog.d.mts.map +1 -0
  16. package/dist/generative-ui/catalog/catalog.mjs +312 -0
  17. package/dist/generative-ui/catalog/catalog.mjs.map +1 -0
  18. package/dist/generative-ui/catalog/errors.cjs +13 -0
  19. package/dist/generative-ui/catalog/errors.cjs.map +1 -0
  20. package/dist/generative-ui/catalog/errors.d.cts +46 -0
  21. package/dist/generative-ui/catalog/errors.d.cts.map +1 -0
  22. package/dist/generative-ui/catalog/errors.d.mts +46 -0
  23. package/dist/generative-ui/catalog/errors.d.mts.map +1 -0
  24. package/dist/generative-ui/catalog/errors.mjs +12 -0
  25. package/dist/generative-ui/catalog/errors.mjs.map +1 -0
  26. package/dist/generative-ui/catalog/index.d.mts +6 -0
  27. package/dist/generative-ui/catalog/json-schema.cjs +16 -0
  28. package/dist/generative-ui/catalog/json-schema.cjs.map +1 -0
  29. package/dist/generative-ui/catalog/json-schema.d.cts +12 -0
  30. package/dist/generative-ui/catalog/json-schema.d.cts.map +1 -0
  31. package/dist/generative-ui/catalog/json-schema.d.mts +12 -0
  32. package/dist/generative-ui/catalog/json-schema.d.mts.map +1 -0
  33. package/dist/generative-ui/catalog/json-schema.mjs +16 -0
  34. package/dist/generative-ui/catalog/json-schema.mjs.map +1 -0
  35. package/dist/generative-ui/catalog/refs.cjs +21 -0
  36. package/dist/generative-ui/catalog/refs.cjs.map +1 -0
  37. package/dist/generative-ui/catalog/refs.d.cts +55 -0
  38. package/dist/generative-ui/catalog/refs.d.cts.map +1 -0
  39. package/dist/generative-ui/catalog/refs.d.mts +55 -0
  40. package/dist/generative-ui/catalog/refs.d.mts.map +1 -0
  41. package/dist/generative-ui/catalog/refs.mjs +18 -0
  42. package/dist/generative-ui/catalog/refs.mjs.map +1 -0
  43. package/dist/generative-ui/catalog/schema.cjs +74 -0
  44. package/dist/generative-ui/catalog/schema.cjs.map +1 -0
  45. package/dist/generative-ui/catalog/schema.d.cts +43 -0
  46. package/dist/generative-ui/catalog/schema.d.cts.map +1 -0
  47. package/dist/generative-ui/catalog/schema.d.mts +43 -0
  48. package/dist/generative-ui/catalog/schema.d.mts.map +1 -0
  49. package/dist/generative-ui/catalog/schema.mjs +68 -0
  50. package/dist/generative-ui/catalog/schema.mjs.map +1 -0
  51. package/dist/generative-ui/index.cjs +247 -0
  52. package/dist/generative-ui/index.d.cts +33 -0
  53. package/dist/generative-ui/index.d.mts +35 -0
  54. package/dist/generative-ui/index.mjs +34 -0
  55. package/dist/generative-ui/is-record.cjs +6 -1
  56. package/dist/generative-ui/is-record.cjs.map +1 -1
  57. package/dist/generative-ui/is-record.d.cts +6 -0
  58. package/dist/generative-ui/is-record.d.cts.map +1 -0
  59. package/dist/generative-ui/is-record.d.mts +6 -0
  60. package/dist/generative-ui/is-record.d.mts.map +1 -0
  61. package/dist/generative-ui/is-record.mjs +6 -2
  62. package/dist/generative-ui/is-record.mjs.map +1 -1
  63. package/dist/generative-ui/standard/chart.cjs +56 -0
  64. package/dist/generative-ui/standard/chart.cjs.map +1 -0
  65. package/dist/generative-ui/standard/chart.d.cts +62 -0
  66. package/dist/generative-ui/standard/chart.d.cts.map +1 -0
  67. package/dist/generative-ui/standard/chart.d.mts +62 -0
  68. package/dist/generative-ui/standard/chart.d.mts.map +1 -0
  69. package/dist/generative-ui/standard/chart.mjs +54 -0
  70. package/dist/generative-ui/standard/chart.mjs.map +1 -0
  71. package/dist/generative-ui/standard/checks.cjs +74 -0
  72. package/dist/generative-ui/standard/checks.cjs.map +1 -0
  73. package/dist/generative-ui/standard/checks.d.cts +56 -0
  74. package/dist/generative-ui/standard/checks.d.cts.map +1 -0
  75. package/dist/generative-ui/standard/checks.d.mts +56 -0
  76. package/dist/generative-ui/standard/checks.d.mts.map +1 -0
  77. package/dist/generative-ui/standard/checks.mjs +71 -0
  78. package/dist/generative-ui/standard/checks.mjs.map +1 -0
  79. package/dist/generative-ui/standard/components.cjs +23 -0
  80. package/dist/generative-ui/standard/components.cjs.map +1 -0
  81. package/dist/generative-ui/standard/components.d.cts +24 -0
  82. package/dist/generative-ui/standard/components.d.cts.map +1 -0
  83. package/dist/generative-ui/standard/components.d.mts +24 -0
  84. package/dist/generative-ui/standard/components.d.mts.map +1 -0
  85. package/dist/generative-ui/standard/components.mjs +22 -0
  86. package/dist/generative-ui/standard/components.mjs.map +1 -0
  87. package/dist/generative-ui/standard/composites.cjs +143 -0
  88. package/dist/generative-ui/standard/composites.cjs.map +1 -0
  89. package/dist/generative-ui/standard/composites.d.cts +233 -0
  90. package/dist/generative-ui/standard/composites.d.cts.map +1 -0
  91. package/dist/generative-ui/standard/composites.d.mts +233 -0
  92. package/dist/generative-ui/standard/composites.d.mts.map +1 -0
  93. package/dist/generative-ui/standard/composites.mjs +132 -0
  94. package/dist/generative-ui/standard/composites.mjs.map +1 -0
  95. package/dist/generative-ui/standard/data.cjs +176 -0
  96. package/dist/generative-ui/standard/data.cjs.map +1 -0
  97. package/dist/generative-ui/standard/data.d.cts +365 -0
  98. package/dist/generative-ui/standard/data.d.cts.map +1 -0
  99. package/dist/generative-ui/standard/data.d.mts +365 -0
  100. package/dist/generative-ui/standard/data.d.mts.map +1 -0
  101. package/dist/generative-ui/standard/data.mjs +167 -0
  102. package/dist/generative-ui/standard/data.mjs.map +1 -0
  103. package/dist/generative-ui/standard/declarations.cjs +40 -0
  104. package/dist/generative-ui/standard/declarations.cjs.map +1 -0
  105. package/dist/generative-ui/standard/declarations.d.cts +2570 -0
  106. package/dist/generative-ui/standard/declarations.d.cts.map +1 -0
  107. package/dist/generative-ui/standard/declarations.d.mts +2571 -0
  108. package/dist/generative-ui/standard/declarations.d.mts.map +1 -0
  109. package/dist/generative-ui/standard/declarations.mjs +39 -0
  110. package/dist/generative-ui/standard/declarations.mjs.map +1 -0
  111. package/dist/generative-ui/standard/feedback.cjs +97 -0
  112. package/dist/generative-ui/standard/feedback.cjs.map +1 -0
  113. package/dist/generative-ui/standard/feedback.d.cts +133 -0
  114. package/dist/generative-ui/standard/feedback.d.cts.map +1 -0
  115. package/dist/generative-ui/standard/feedback.d.mts +133 -0
  116. package/dist/generative-ui/standard/feedback.d.mts.map +1 -0
  117. package/dist/generative-ui/standard/feedback.mjs +90 -0
  118. package/dist/generative-ui/standard/feedback.mjs.map +1 -0
  119. package/dist/generative-ui/standard/index.d.mts +16 -0
  120. package/dist/generative-ui/standard/inputs.cjs +333 -0
  121. package/dist/generative-ui/standard/inputs.cjs.map +1 -0
  122. package/dist/generative-ui/standard/inputs.d.cts +1128 -0
  123. package/dist/generative-ui/standard/inputs.d.cts.map +1 -0
  124. package/dist/generative-ui/standard/inputs.d.mts +1128 -0
  125. package/dist/generative-ui/standard/inputs.d.mts.map +1 -0
  126. package/dist/generative-ui/standard/inputs.mjs +318 -0
  127. package/dist/generative-ui/standard/inputs.mjs.map +1 -0
  128. package/dist/generative-ui/standard/layout.cjs +289 -0
  129. package/dist/generative-ui/standard/layout.cjs.map +1 -0
  130. package/dist/generative-ui/standard/layout.d.cts +1974 -0
  131. package/dist/generative-ui/standard/layout.d.cts.map +1 -0
  132. package/dist/generative-ui/standard/layout.d.mts +1975 -0
  133. package/dist/generative-ui/standard/layout.d.mts.map +1 -0
  134. package/dist/generative-ui/standard/layout.mjs +269 -0
  135. package/dist/generative-ui/standard/layout.mjs.map +1 -0
  136. package/dist/generative-ui/standard/map.cjs +27 -0
  137. package/dist/generative-ui/standard/map.cjs.map +1 -0
  138. package/dist/generative-ui/standard/map.d.cts +31 -0
  139. package/dist/generative-ui/standard/map.d.cts.map +1 -0
  140. package/dist/generative-ui/standard/map.d.mts +31 -0
  141. package/dist/generative-ui/standard/map.d.mts.map +1 -0
  142. package/dist/generative-ui/standard/map.mjs +25 -0
  143. package/dist/generative-ui/standard/map.mjs.map +1 -0
  144. package/dist/generative-ui/standard/media.cjs +215 -0
  145. package/dist/generative-ui/standard/media.cjs.map +1 -0
  146. package/dist/generative-ui/standard/media.d.cts +396 -0
  147. package/dist/generative-ui/standard/media.d.cts.map +1 -0
  148. package/dist/generative-ui/standard/media.d.mts +396 -0
  149. package/dist/generative-ui/standard/media.d.mts.map +1 -0
  150. package/dist/generative-ui/standard/media.mjs +205 -0
  151. package/dist/generative-ui/standard/media.mjs.map +1 -0
  152. package/dist/generative-ui/standard/parameter-order.cjs +231 -0
  153. package/dist/generative-ui/standard/parameter-order.cjs.map +1 -0
  154. package/dist/generative-ui/standard/parameter-order.d.cts +84 -0
  155. package/dist/generative-ui/standard/parameter-order.d.cts.map +1 -0
  156. package/dist/generative-ui/standard/parameter-order.d.mts +84 -0
  157. package/dist/generative-ui/standard/parameter-order.d.mts.map +1 -0
  158. package/dist/generative-ui/standard/parameter-order.mjs +230 -0
  159. package/dist/generative-ui/standard/parameter-order.mjs.map +1 -0
  160. package/dist/generative-ui/standard/styles.cjs +62 -0
  161. package/dist/generative-ui/standard/styles.cjs.map +1 -0
  162. package/dist/generative-ui/standard/styles.d.cts +17 -0
  163. package/dist/generative-ui/standard/styles.d.cts.map +1 -0
  164. package/dist/generative-ui/standard/styles.d.mts +17 -0
  165. package/dist/generative-ui/standard/styles.d.mts.map +1 -0
  166. package/dist/generative-ui/standard/styles.mjs +60 -0
  167. package/dist/generative-ui/standard/styles.mjs.map +1 -0
  168. package/dist/generative-ui/standard/text.cjs +226 -0
  169. package/dist/generative-ui/standard/text.cjs.map +1 -0
  170. package/dist/generative-ui/standard/text.d.cts +522 -0
  171. package/dist/generative-ui/standard/text.d.cts.map +1 -0
  172. package/dist/generative-ui/standard/text.d.mts +522 -0
  173. package/dist/generative-ui/standard/text.d.mts.map +1 -0
  174. package/dist/generative-ui/standard/text.mjs +209 -0
  175. package/dist/generative-ui/standard/text.mjs.map +1 -0
  176. package/dist/generative-ui/standard/theme.cjs +115 -0
  177. package/dist/generative-ui/standard/theme.cjs.map +1 -0
  178. package/dist/generative-ui/standard/theme.d.cts +60 -0
  179. package/dist/generative-ui/standard/theme.d.cts.map +1 -0
  180. package/dist/generative-ui/standard/theme.d.mts +60 -0
  181. package/dist/generative-ui/standard/theme.d.mts.map +1 -0
  182. package/dist/generative-ui/standard/theme.mjs +112 -0
  183. package/dist/generative-ui/standard/theme.mjs.map +1 -0
  184. package/dist/generative-ui/standard/tokens.cjs +336 -0
  185. package/dist/generative-ui/standard/tokens.cjs.map +1 -0
  186. package/dist/generative-ui/standard/tokens.d.cts +76 -0
  187. package/dist/generative-ui/standard/tokens.d.cts.map +1 -0
  188. package/dist/generative-ui/standard/tokens.d.mts +76 -0
  189. package/dist/generative-ui/standard/tokens.d.mts.map +1 -0
  190. package/dist/generative-ui/standard/tokens.mjs +305 -0
  191. package/dist/generative-ui/standard/tokens.mjs.map +1 -0
  192. package/dist/index.cjs.map +1 -1
  193. package/dist/index.d.cts +10 -10
  194. package/dist/index.d.mts +10 -10
  195. package/dist/index.mjs.map +1 -1
  196. package/dist/index.umd.js +2 -2
  197. package/dist/index.umd.js.map +1 -1
  198. package/dist/package.cjs +1 -1
  199. package/dist/package.mjs +1 -1
  200. package/package.json +7 -3
  201. package/src/generative-ui/base.ts +9 -0
  202. package/src/generative-ui/catalog/catalog-export.ts +478 -0
  203. package/src/generative-ui/catalog/catalog.ts +1167 -0
  204. package/src/generative-ui/catalog/errors.ts +102 -0
  205. package/src/generative-ui/catalog/index.ts +6 -0
  206. package/src/generative-ui/catalog/json-schema.ts +14 -0
  207. package/src/generative-ui/catalog/refs.ts +87 -0
  208. package/src/generative-ui/catalog/schema.ts +107 -0
  209. package/src/generative-ui/index.ts +7 -0
  210. package/src/generative-ui/is-record.ts +6 -1
  211. package/src/generative-ui/standard/__tests__/theme.test.ts +61 -0
  212. package/src/generative-ui/standard/__tests__/tokens.test.ts +139 -0
  213. package/src/generative-ui/standard/chart.ts +79 -0
  214. package/src/generative-ui/standard/checks.ts +98 -0
  215. package/src/generative-ui/standard/components.ts +35 -0
  216. package/src/generative-ui/standard/composites.ts +158 -0
  217. package/src/generative-ui/standard/data.ts +213 -0
  218. package/src/generative-ui/standard/declarations.ts +57 -0
  219. package/src/generative-ui/standard/feedback.ts +105 -0
  220. package/src/generative-ui/standard/index.ts +19 -0
  221. package/src/generative-ui/standard/inputs.ts +423 -0
  222. package/src/generative-ui/standard/layout.ts +312 -0
  223. package/src/generative-ui/standard/map.ts +32 -0
  224. package/src/generative-ui/standard/media.ts +265 -0
  225. package/src/generative-ui/standard/parameter-order.ts +155 -0
  226. package/src/generative-ui/standard/styles.ts +79 -0
  227. package/src/generative-ui/standard/text.ts +210 -0
  228. package/src/generative-ui/standard/theme.ts +198 -0
  229. package/src/generative-ui/standard/tokens.ts +317 -0
  230. package/src/index.ts +1 -1
  231. package/tsdown.config.ts +1 -1
@@ -0,0 +1,62 @@
1
+ import { z } from "zod";
2
+
3
+ //#region src/generative-ui/standard/chart.d.ts
4
+ declare const chartSeries: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
5
+ key: z.ZodString;
6
+ label: z.ZodOptional<z.ZodString>;
7
+ color: z.ZodOptional<z.ZodString>;
8
+ }, z.core.$strip>]>;
9
+ type ChartSeries = z.output<typeof chartSeries>;
10
+ declare const chartSchema: z.ZodObject<{
11
+ chartType: z.ZodOptional<z.ZodEnum<{
12
+ bar: "bar";
13
+ line: "line";
14
+ area: "area";
15
+ scatter: "scatter";
16
+ pie: "pie";
17
+ donut: "donut";
18
+ }>>;
19
+ data: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
20
+ xKey: z.ZodOptional<z.ZodString>;
21
+ series: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
22
+ key: z.ZodString;
23
+ label: z.ZodOptional<z.ZodString>;
24
+ color: z.ZodOptional<z.ZodString>;
25
+ }, z.core.$strip>]>>>;
26
+ stacked: z.ZodOptional<z.ZodBoolean>;
27
+ layout: z.ZodOptional<z.ZodEnum<{
28
+ horizontal: "horizontal";
29
+ vertical: "vertical";
30
+ }>>;
31
+ yAxis: z.ZodOptional<z.ZodObject<{
32
+ label: z.ZodOptional<z.ZodString>;
33
+ min: z.ZodOptional<z.ZodNumber>;
34
+ max: z.ZodOptional<z.ZodNumber>;
35
+ width: z.ZodOptional<z.ZodNumber>;
36
+ }, z.core.$strip>>;
37
+ showDots: z.ZodOptional<z.ZodBoolean>;
38
+ barRadius: z.ZodOptional<z.ZodNumber>;
39
+ innerRadius: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
40
+ outerRadius: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
41
+ startAngle: z.ZodOptional<z.ZodNumber>;
42
+ endAngle: z.ZodOptional<z.ZodNumber>;
43
+ cornerRadius: z.ZodOptional<z.ZodNumber>;
44
+ paddingAngle: z.ZodOptional<z.ZodNumber>;
45
+ showLabelLines: z.ZodOptional<z.ZodBoolean>;
46
+ height: z.ZodOptional<z.ZodNumber>;
47
+ showLegend: z.ZodOptional<z.ZodBoolean>;
48
+ showGrid: z.ZodOptional<z.ZodBoolean>;
49
+ showTooltip: z.ZodOptional<z.ZodBoolean>;
50
+ showValueLabels: z.ZodOptional<z.ZodBoolean>;
51
+ format: z.ZodOptional<z.ZodEnum<{
52
+ number: "number";
53
+ currency: "currency";
54
+ percent: "percent";
55
+ }>>;
56
+ currency: z.ZodOptional<z.ZodString>;
57
+ title: z.ZodOptional<z.ZodString>;
58
+ }, z.core.$strip>;
59
+ type ChartProps = z.output<typeof chartSchema>;
60
+ //#endregion
61
+ export { ChartProps, ChartSeries, chartSchema, chartSeries };
62
+ //# sourceMappingURL=chart.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chart.d.mts","names":[],"sources":["../../../src/generative-ui/standard/chart.ts"],"mappings":";;;cAIa,WAAA,EAAW,CAAA,CAAA,QAAA,WAAA,CAAA,CAAA,SAAA,EAAA,CAAA,CAAA,SAAA;;;;;KAQZ,WAAA,GAAc,CAAA,CAAE,MAAA,QAAc,WAAA;AAAA,cAE7B,WAAA,EAAW,CAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAgEZ,UAAA,GAAa,CAAA,CAAE,MAAA,QAAc,WAAA"}
@@ -0,0 +1,54 @@
1
+ import { z } from "zod";
2
+
3
+ //#region src/generative-ui/standard/chart.ts
4
+ const chartSeries = z.union([z.string(), z.object({
5
+ key: z.string(),
6
+ label: z.string().optional(),
7
+ color: z.string().optional().describe("A text color token or a CSS color")
8
+ })]);
9
+ const chartSchema = z.object({
10
+ chartType: z.enum([
11
+ "bar",
12
+ "line",
13
+ "area",
14
+ "scatter",
15
+ "pie",
16
+ "donut"
17
+ ]).optional().describe("Default \"bar\""),
18
+ data: z.array(z.record(z.string(), z.unknown())).optional(),
19
+ xKey: z.string().optional().describe("The field of the category axis"),
20
+ series: z.array(chartSeries).optional().describe("Default: every number field except xKey"),
21
+ stacked: z.boolean().optional(),
22
+ layout: z.enum(["vertical", "horizontal"]).optional().describe("\"horizontal\" draws the bars from left to right. Default \"vertical\""),
23
+ yAxis: z.object({
24
+ label: z.string().optional(),
25
+ min: z.number().optional(),
26
+ max: z.number().optional(),
27
+ width: z.number().optional().describe("Pixels")
28
+ }).optional().describe("Example: {label: \"Revenue (USD)\", min: 0, max: 100}. In a horizontal chart it is the horizontal axis, and width sets the category axis width"),
29
+ showDots: z.boolean().optional().describe("Point markers on a line or area"),
30
+ barRadius: z.number().optional().describe("The corner radius of a bar, in pixels"),
31
+ innerRadius: z.union([z.number(), z.string()]).optional().describe("Pie and donut"),
32
+ outerRadius: z.union([z.number(), z.string()]).optional().describe("Pie and donut"),
33
+ startAngle: z.number().optional().describe("Pie and donut. Default 90"),
34
+ endAngle: z.number().optional().describe("Pie and donut. Default -270"),
35
+ cornerRadius: z.number().optional().describe("The corners of a slice"),
36
+ paddingAngle: z.number().optional().describe("The gap between slices"),
37
+ showLabelLines: z.boolean().optional().describe("Leader lines of the slice labels. Default true"),
38
+ height: z.number().optional().describe("Pixels. Default 240"),
39
+ showLegend: z.boolean().optional().describe("Default true"),
40
+ showGrid: z.boolean().optional().describe("Default true"),
41
+ showTooltip: z.boolean().optional().describe("Default true"),
42
+ showValueLabels: z.boolean().optional(),
43
+ format: z.enum([
44
+ "number",
45
+ "currency",
46
+ "percent"
47
+ ]).optional().describe("With \"percent\", data values and axis min/max are fractions: 0.4 shows as 40%; for 0% to 10%, use min: 0 and max: 0.1."),
48
+ currency: z.string().optional().describe("ISO code. Default \"USD\""),
49
+ title: z.string().optional()
50
+ });
51
+
52
+ //#endregion
53
+ export { chartSchema, chartSeries };
54
+ //# sourceMappingURL=chart.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chart.mjs","names":[],"sources":["../../../src/generative-ui/standard/chart.ts"],"sourcesContent":["import { z } from \"zod\";\n\n// ---- Schema ----\n\nexport const chartSeries = z.union([\n z.string(),\n z.object({\n key: z.string(),\n label: z.string().optional(),\n color: z.string().optional().describe(\"A text color token or a CSS color\"),\n }),\n]);\nexport type ChartSeries = z.output<typeof chartSeries>;\n\nexport const chartSchema = z.object({\n chartType: z\n .enum([\"bar\", \"line\", \"area\", \"scatter\", \"pie\", \"donut\"])\n .optional()\n .describe('Default \"bar\"'),\n data: z.array(z.record(z.string(), z.unknown())).optional(),\n xKey: z.string().optional().describe(\"The field of the category axis\"),\n series: z\n .array(chartSeries)\n .optional()\n .describe(\"Default: every number field except xKey\"),\n stacked: z.boolean().optional(),\n layout: z\n .enum([\"vertical\", \"horizontal\"])\n .optional()\n .describe(\n '\"horizontal\" draws the bars from left to right. Default \"vertical\"',\n ),\n yAxis: z\n .object({\n label: z.string().optional(),\n min: z.number().optional(),\n max: z.number().optional(),\n width: z.number().optional().describe(\"Pixels\"),\n })\n .optional()\n .describe(\n 'Example: {label: \"Revenue (USD)\", min: 0, max: 100}. In a horizontal chart it is the horizontal axis, and width sets the category axis width',\n ),\n showDots: z.boolean().optional().describe(\"Point markers on a line or area\"),\n barRadius: z\n .number()\n .optional()\n .describe(\"The corner radius of a bar, in pixels\"),\n innerRadius: z\n .union([z.number(), z.string()])\n .optional()\n .describe(\"Pie and donut\"),\n outerRadius: z\n .union([z.number(), z.string()])\n .optional()\n .describe(\"Pie and donut\"),\n startAngle: z.number().optional().describe(\"Pie and donut. Default 90\"),\n endAngle: z.number().optional().describe(\"Pie and donut. Default -270\"),\n cornerRadius: z.number().optional().describe(\"The corners of a slice\"),\n paddingAngle: z.number().optional().describe(\"The gap between slices\"),\n showLabelLines: z\n .boolean()\n .optional()\n .describe(\"Leader lines of the slice labels. Default true\"),\n height: z.number().optional().describe(\"Pixels. Default 240\"),\n showLegend: z.boolean().optional().describe(\"Default true\"),\n showGrid: z.boolean().optional().describe(\"Default true\"),\n showTooltip: z.boolean().optional().describe(\"Default true\"),\n showValueLabels: z.boolean().optional(),\n format: z\n .enum([\"number\", \"currency\", \"percent\"])\n .optional()\n .describe(\n 'With \"percent\", data values and axis min/max are fractions: 0.4 shows as 40%; for 0% to 10%, use min: 0 and max: 0.1.',\n ),\n currency: z.string().optional().describe('ISO code. Default \"USD\"'),\n title: z.string().optional(),\n});\nexport type ChartProps = z.output<typeof chartSchema>;\n"],"mappings":";;;AAIA,MAAa,cAAc,EAAE,MAAM,CACjC,EAAE,QAAQ,EACV,EAAE,OAAO;CACP,KAAK,EAAE,QAAQ;CACf,OAAO,EAAE,QAAQ,CAAC,UAAU;CAC5B,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,SAAS,oCAAoC;CAC3E,CAAC,CACH,CAAC;AAGF,MAAa,cAAc,EAAE,OAAO;CAClC,WAAW,EACR,KAAK;EAAC;EAAO;EAAQ;EAAQ;EAAW;EAAO;EAAQ,CAAC,CACxD,UAAU,CACV,SAAS,kBAAgB;CAC5B,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,SAAS,CAAC,CAAC,CAAC,UAAU;CAC3D,MAAM,EAAE,QAAQ,CAAC,UAAU,CAAC,SAAS,iCAAiC;CACtE,QAAQ,EACL,MAAM,YAAY,CAClB,UAAU,CACV,SAAS,0CAA0C;CACtD,SAAS,EAAE,SAAS,CAAC,UAAU;CAC/B,QAAQ,EACL,KAAK,CAAC,YAAY,aAAa,CAAC,CAChC,UAAU,CACV,SACC,yEACD;CACH,OAAO,EACJ,OAAO;EACN,OAAO,EAAE,QAAQ,CAAC,UAAU;EAC5B,KAAK,EAAE,QAAQ,CAAC,UAAU;EAC1B,KAAK,EAAE,QAAQ,CAAC,UAAU;EAC1B,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,SAAS,SAAS;EAChD,CAAC,CACD,UAAU,CACV,SACC,iJACD;CACH,UAAU,EAAE,SAAS,CAAC,UAAU,CAAC,SAAS,kCAAkC;CAC5E,WAAW,EACR,QAAQ,CACR,UAAU,CACV,SAAS,wCAAwC;CACpD,aAAa,EACV,MAAM,CAAC,EAAE,QAAQ,EAAE,EAAE,QAAQ,CAAC,CAAC,CAC/B,UAAU,CACV,SAAS,gBAAgB;CAC5B,aAAa,EACV,MAAM,CAAC,EAAE,QAAQ,EAAE,EAAE,QAAQ,CAAC,CAAC,CAC/B,UAAU,CACV,SAAS,gBAAgB;CAC5B,YAAY,EAAE,QAAQ,CAAC,UAAU,CAAC,SAAS,4BAA4B;CACvE,UAAU,EAAE,QAAQ,CAAC,UAAU,CAAC,SAAS,8BAA8B;CACvE,cAAc,EAAE,QAAQ,CAAC,UAAU,CAAC,SAAS,yBAAyB;CACtE,cAAc,EAAE,QAAQ,CAAC,UAAU,CAAC,SAAS,yBAAyB;CACtE,gBAAgB,EACb,SAAS,CACT,UAAU,CACV,SAAS,iDAAiD;CAC7D,QAAQ,EAAE,QAAQ,CAAC,UAAU,CAAC,SAAS,sBAAsB;CAC7D,YAAY,EAAE,SAAS,CAAC,UAAU,CAAC,SAAS,eAAe;CAC3D,UAAU,EAAE,SAAS,CAAC,UAAU,CAAC,SAAS,eAAe;CACzD,aAAa,EAAE,SAAS,CAAC,UAAU,CAAC,SAAS,eAAe;CAC5D,iBAAiB,EAAE,SAAS,CAAC,UAAU;CACvC,QAAQ,EACL,KAAK;EAAC;EAAU;EAAY;EAAU,CAAC,CACvC,UAAU,CACV,SACC,0HACD;CACH,UAAU,EAAE,QAAQ,CAAC,UAAU,CAAC,SAAS,4BAA0B;CACnE,OAAO,EAAE,QAAQ,CAAC,UAAU;CAC7B,CAAC"}
@@ -0,0 +1,74 @@
1
+ const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
2
+ const require_tokens = require('./tokens.cjs');
3
+ let zod = require("zod");
4
+
5
+ //#region src/generative-ui/standard/checks.ts
6
+ /**
7
+ * The `checks` of the A2UI 1.0 `Checkable` components. The model writes
8
+ * each condition as a validator call or a boolean binding:
9
+ * `{ "condition": { "@call": "email", "args": { "value": { "@path": "/form/email" } } }, "message": "..." }`.
10
+ * The engine resolves the condition before the component renders, so a
11
+ * component sees a boolean or a `ValidationResult`.
12
+ */
13
+ const severity = zod.z.enum([
14
+ "error",
15
+ "warning",
16
+ "info"
17
+ ]);
18
+ const validationResult = zod.z.object({
19
+ valid: zod.z.boolean(),
20
+ message: zod.z.string().optional(),
21
+ code: zod.z.string().optional(),
22
+ severity: severity.optional()
23
+ }).loose();
24
+ const checksProp = zod.z.array(zod.z.object({
25
+ condition: zod.z.union([zod.z.boolean(), validationResult]).optional().describe("A validator call, for example {\"@call\":\"required\",\"args\":{\"value\":{\"@path\":\"/x\"}}}, or a boolean binding"),
26
+ message: zod.z.string().optional().describe("Shown when the check fails, instead of the default message")
27
+ })).optional().describe("Validation rules. The control shows the first failed one");
28
+ /**
29
+ * The failed check to show, or `undefined` when every check passes: the
30
+ * first error, or the first warning or info when no check is an error, so
31
+ * a warning never hides an error that comes after it. A condition that is
32
+ * not known yet (undefined) passes. A `false` condition is an error with
33
+ * the check's message. The check's message also wins over the message of
34
+ * a validator result: the built-in validators always have one, and the
35
+ * check is where the model puts its own wording.
36
+ */
37
+ function firstFailedCheck(checks) {
38
+ let first;
39
+ for (const check of checks ?? []) {
40
+ const { condition } = check;
41
+ if (condition === void 0 || condition === null) continue;
42
+ let failed;
43
+ if (typeof condition === "boolean") {
44
+ if (condition) continue;
45
+ failed = {
46
+ message: check.message ?? "Invalid value",
47
+ severity: "error"
48
+ };
49
+ } else {
50
+ if (condition.valid) continue;
51
+ failed = {
52
+ message: check.message ?? condition.message ?? "Invalid value",
53
+ severity: condition.severity ?? "error",
54
+ ...condition.code === void 0 ? {} : { code: condition.code }
55
+ };
56
+ }
57
+ if (failed.severity === "error") return failed;
58
+ first ??= failed;
59
+ }
60
+ return first;
61
+ }
62
+ /** The style of a check message, by its severity. */
63
+ function checkMessageStyle(severity) {
64
+ return {
65
+ ...require_tokens.textFont("sm"),
66
+ color: require_tokens.textColor(severity === "error" ? "danger" : severity === "warning" ? "warning" : "secondary")
67
+ };
68
+ }
69
+
70
+ //#endregion
71
+ exports.checkMessageStyle = checkMessageStyle;
72
+ exports.checksProp = checksProp;
73
+ exports.firstFailedCheck = firstFailedCheck;
74
+ //# sourceMappingURL=checks.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checks.cjs","names":["z","textFont","textColor"],"sources":["../../../src/generative-ui/standard/checks.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { textColor, textFont } from \"./tokens\";\n\n/**\n * The `checks` of the A2UI 1.0 `Checkable` components. The model writes\n * each condition as a validator call or a boolean binding:\n * `{ \"condition\": { \"@call\": \"email\", \"args\": { \"value\": { \"@path\": \"/form/email\" } } }, \"message\": \"...\" }`.\n * The engine resolves the condition before the component renders, so a\n * component sees a boolean or a `ValidationResult`.\n */\n\nconst severity = z.enum([\"error\", \"warning\", \"info\"]);\n\nconst validationResult = z\n .object({\n valid: z.boolean(),\n message: z.string().optional(),\n code: z.string().optional(),\n severity: severity.optional(),\n })\n .loose();\n\n/** The first failed check of a control, as the control shows it. */\nexport interface FailedCheck {\n message: string;\n /** `\"error\"` when the result named none. Only an error blocks. */\n severity: z.output<typeof severity>;\n /** The `code` of the validation result, when it had one. */\n code?: string;\n}\n\nexport const checksProp = z\n .array(\n z.object({\n condition: z\n .union([z.boolean(), validationResult])\n .optional()\n .describe(\n 'A validator call, for example {\"@call\":\"required\",\"args\":{\"value\":{\"@path\":\"/x\"}}}, or a boolean binding',\n ),\n message: z\n .string()\n .optional()\n .describe(\"Shown when the check fails, instead of the default message\"),\n }),\n )\n .optional()\n .describe(\"Validation rules. The control shows the first failed one\");\n\nexport type ResolvedChecks = z.output<typeof checksProp>;\n\n/**\n * The failed check to show, or `undefined` when every check passes: the\n * first error, or the first warning or info when no check is an error, so\n * a warning never hides an error that comes after it. A condition that is\n * not known yet (undefined) passes. A `false` condition is an error with\n * the check's message. The check's message also wins over the message of\n * a validator result: the built-in validators always have one, and the\n * check is where the model puts its own wording.\n */\nexport function firstFailedCheck(\n checks: ResolvedChecks,\n): FailedCheck | undefined {\n let first: FailedCheck | undefined;\n for (const check of checks ?? []) {\n const { condition } = check;\n if (condition === undefined || condition === null) continue;\n let failed: FailedCheck;\n if (typeof condition === \"boolean\") {\n if (condition) continue;\n failed = { message: check.message ?? \"Invalid value\", severity: \"error\" };\n } else {\n if (condition.valid) continue;\n failed = {\n message: check.message ?? condition.message ?? \"Invalid value\",\n severity: condition.severity ?? \"error\",\n ...(condition.code === undefined ? {} : { code: condition.code }),\n };\n }\n if (failed.severity === \"error\") return failed;\n first ??= failed;\n }\n return first;\n}\n\n/** The style of a check message, by its severity. */\nexport function checkMessageStyle(severity: FailedCheck[\"severity\"]) {\n return {\n ...textFont(\"sm\"),\n color: textColor(\n severity === \"error\"\n ? \"danger\"\n : severity === \"warning\"\n ? \"warning\"\n : \"secondary\",\n ),\n };\n}\n"],"mappings":";;;;;;;;;;;;AAWA,MAAM,WAAWA,MAAE,KAAK;CAAC;CAAS;CAAW;CAAO,CAAC;AAErD,MAAM,mBAAmBA,MACtB,OAAO;CACN,OAAOA,MAAE,SAAS;CAClB,SAASA,MAAE,QAAQ,CAAC,UAAU;CAC9B,MAAMA,MAAE,QAAQ,CAAC,UAAU;CAC3B,UAAU,SAAS,UAAU;CAC9B,CAAC,CACD,OAAO;AAWV,MAAa,aAAaA,MACvB,MACCA,MAAE,OAAO;CACP,WAAWA,MACR,MAAM,CAACA,MAAE,SAAS,EAAE,iBAAiB,CAAC,CACtC,UAAU,CACV,SACC,uHACD;CACH,SAASA,MACN,QAAQ,CACR,UAAU,CACV,SAAS,6DAA6D;CAC1E,CAAC,CACH,CACA,UAAU,CACV,SAAS,2DAA2D;;;;;;;;;;AAavE,SAAgB,iBACd,QACyB;CACzB,IAAI;AACJ,MAAK,MAAM,SAAS,UAAU,EAAE,EAAE;EAChC,MAAM,EAAE,cAAc;AACtB,MAAI,cAAc,UAAa,cAAc,KAAM;EACnD,IAAI;AACJ,MAAI,OAAO,cAAc,WAAW;AAClC,OAAI,UAAW;AACf,YAAS;IAAE,SAAS,MAAM,WAAW;IAAiB,UAAU;IAAS;SACpE;AACL,OAAI,UAAU,MAAO;AACrB,YAAS;IACP,SAAS,MAAM,WAAW,UAAU,WAAW;IAC/C,UAAU,UAAU,YAAY;IAChC,GAAI,UAAU,SAAS,SAAY,EAAE,GAAG,EAAE,MAAM,UAAU,MAAM;IACjE;;AAEH,MAAI,OAAO,aAAa,QAAS,QAAO;AACxC,YAAU;;AAEZ,QAAO;;;AAIT,SAAgB,kBAAkB,UAAmC;AACnE,QAAO;EACL,GAAGC,wBAAS,KAAK;EACjB,OAAOC,yBACL,aAAa,UACT,WACA,aAAa,YACX,YACA,YACP;EACF"}
@@ -0,0 +1,56 @@
1
+ import { z } from "zod";
2
+
3
+ //#region src/generative-ui/standard/checks.d.ts
4
+ /**
5
+ * The `checks` of the A2UI 1.0 `Checkable` components. The model writes
6
+ * each condition as a validator call or a boolean binding:
7
+ * `{ "condition": { "@call": "email", "args": { "value": { "@path": "/form/email" } } }, "message": "..." }`.
8
+ * The engine resolves the condition before the component renders, so a
9
+ * component sees a boolean or a `ValidationResult`.
10
+ */
11
+ declare const severity: z.ZodEnum<{
12
+ info: "info";
13
+ warning: "warning";
14
+ error: "error";
15
+ }>;
16
+ /** The first failed check of a control, as the control shows it. */
17
+ interface FailedCheck {
18
+ message: string;
19
+ /** `"error"` when the result named none. Only an error blocks. */
20
+ severity: z.output<typeof severity>;
21
+ /** The `code` of the validation result, when it had one. */
22
+ code?: string;
23
+ }
24
+ declare const checksProp: z.ZodOptional<z.ZodArray<z.ZodObject<{
25
+ condition: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodObject<{
26
+ valid: z.ZodBoolean;
27
+ message: z.ZodOptional<z.ZodString>;
28
+ code: z.ZodOptional<z.ZodString>;
29
+ severity: z.ZodOptional<z.ZodEnum<{
30
+ info: "info";
31
+ warning: "warning";
32
+ error: "error";
33
+ }>>;
34
+ }, z.core.$loose>]>>;
35
+ message: z.ZodOptional<z.ZodString>;
36
+ }, z.core.$strip>>>;
37
+ type ResolvedChecks = z.output<typeof checksProp>;
38
+ /**
39
+ * The failed check to show, or `undefined` when every check passes: the
40
+ * first error, or the first warning or info when no check is an error, so
41
+ * a warning never hides an error that comes after it. A condition that is
42
+ * not known yet (undefined) passes. A `false` condition is an error with
43
+ * the check's message. The check's message also wins over the message of
44
+ * a validator result: the built-in validators always have one, and the
45
+ * check is where the model puts its own wording.
46
+ */
47
+ declare function firstFailedCheck(checks: ResolvedChecks): FailedCheck | undefined;
48
+ /** The style of a check message, by its severity. */
49
+ declare function checkMessageStyle(severity: FailedCheck["severity"]): {
50
+ color: string | undefined;
51
+ fontSize: string;
52
+ lineHeight: number;
53
+ };
54
+ //#endregion
55
+ export { FailedCheck, ResolvedChecks, checkMessageStyle, checksProp, firstFailedCheck };
56
+ //# sourceMappingURL=checks.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checks.d.cts","names":[],"sources":["../../../src/generative-ui/standard/checks.ts"],"mappings":";;;;;AAAwB;;;;;cAWlB,QAAA,EAAQ,CAAA,CAAA,OAAA;;;;;;UAYG,WAAA;EACf,OAAA;;EAEA,QAAA,EAAU,CAAA,CAAE,MAAA,QAAc,QAAA;EAF1B;EAIA,IAAA;AAAA;AAAA,cAGW,UAAA,EAAU,CAAA,CAAA,WAAA,CAAA,CAAA,CAAA,QAAA,CAAA,CAAA,CAAA,SAAA;;;;;;;;;;;;;KAkBX,cAAA,GAAiB,CAAA,CAAE,MAAA,QAAc,UAAA;;;;;;;;;;iBAW7B,gBAAA,CACd,MAAA,EAAQ,cAAA,GACP,WAAA;;iBAwBa,iBAAA,CAAkB,QAAA,EAAU,WAAA"}
@@ -0,0 +1,56 @@
1
+ import { z } from "zod";
2
+
3
+ //#region src/generative-ui/standard/checks.d.ts
4
+ /**
5
+ * The `checks` of the A2UI 1.0 `Checkable` components. The model writes
6
+ * each condition as a validator call or a boolean binding:
7
+ * `{ "condition": { "@call": "email", "args": { "value": { "@path": "/form/email" } } }, "message": "..." }`.
8
+ * The engine resolves the condition before the component renders, so a
9
+ * component sees a boolean or a `ValidationResult`.
10
+ */
11
+ declare const severity: z.ZodEnum<{
12
+ info: "info";
13
+ warning: "warning";
14
+ error: "error";
15
+ }>;
16
+ /** The first failed check of a control, as the control shows it. */
17
+ interface FailedCheck {
18
+ message: string;
19
+ /** `"error"` when the result named none. Only an error blocks. */
20
+ severity: z.output<typeof severity>;
21
+ /** The `code` of the validation result, when it had one. */
22
+ code?: string;
23
+ }
24
+ declare const checksProp: z.ZodOptional<z.ZodArray<z.ZodObject<{
25
+ condition: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodObject<{
26
+ valid: z.ZodBoolean;
27
+ message: z.ZodOptional<z.ZodString>;
28
+ code: z.ZodOptional<z.ZodString>;
29
+ severity: z.ZodOptional<z.ZodEnum<{
30
+ info: "info";
31
+ warning: "warning";
32
+ error: "error";
33
+ }>>;
34
+ }, z.core.$loose>]>>;
35
+ message: z.ZodOptional<z.ZodString>;
36
+ }, z.core.$strip>>>;
37
+ type ResolvedChecks = z.output<typeof checksProp>;
38
+ /**
39
+ * The failed check to show, or `undefined` when every check passes: the
40
+ * first error, or the first warning or info when no check is an error, so
41
+ * a warning never hides an error that comes after it. A condition that is
42
+ * not known yet (undefined) passes. A `false` condition is an error with
43
+ * the check's message. The check's message also wins over the message of
44
+ * a validator result: the built-in validators always have one, and the
45
+ * check is where the model puts its own wording.
46
+ */
47
+ declare function firstFailedCheck(checks: ResolvedChecks): FailedCheck | undefined;
48
+ /** The style of a check message, by its severity. */
49
+ declare function checkMessageStyle(severity: FailedCheck["severity"]): {
50
+ color: string | undefined;
51
+ fontSize: string;
52
+ lineHeight: number;
53
+ };
54
+ //#endregion
55
+ export { FailedCheck, ResolvedChecks, checkMessageStyle, checksProp, firstFailedCheck };
56
+ //# sourceMappingURL=checks.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checks.d.mts","names":[],"sources":["../../../src/generative-ui/standard/checks.ts"],"mappings":";;;;;AAAwB;;;;;cAWlB,QAAA,EAAQ,CAAA,CAAA,OAAA;;;;;;UAYG,WAAA;EACf,OAAA;;EAEA,QAAA,EAAU,CAAA,CAAE,MAAA,QAAc,QAAA;EAF1B;EAIA,IAAA;AAAA;AAAA,cAGW,UAAA,EAAU,CAAA,CAAA,WAAA,CAAA,CAAA,CAAA,QAAA,CAAA,CAAA,CAAA,SAAA;;;;;;;;;;;;;KAkBX,cAAA,GAAiB,CAAA,CAAE,MAAA,QAAc,UAAA;;;;;;;;;;iBAW7B,gBAAA,CACd,MAAA,EAAQ,cAAA,GACP,WAAA;;iBAwBa,iBAAA,CAAkB,QAAA,EAAU,WAAA"}
@@ -0,0 +1,71 @@
1
+ import { textColor, textFont } from "./tokens.mjs";
2
+ import { z } from "zod";
3
+
4
+ //#region src/generative-ui/standard/checks.ts
5
+ /**
6
+ * The `checks` of the A2UI 1.0 `Checkable` components. The model writes
7
+ * each condition as a validator call or a boolean binding:
8
+ * `{ "condition": { "@call": "email", "args": { "value": { "@path": "/form/email" } } }, "message": "..." }`.
9
+ * The engine resolves the condition before the component renders, so a
10
+ * component sees a boolean or a `ValidationResult`.
11
+ */
12
+ const severity = z.enum([
13
+ "error",
14
+ "warning",
15
+ "info"
16
+ ]);
17
+ const validationResult = z.object({
18
+ valid: z.boolean(),
19
+ message: z.string().optional(),
20
+ code: z.string().optional(),
21
+ severity: severity.optional()
22
+ }).loose();
23
+ const checksProp = z.array(z.object({
24
+ condition: z.union([z.boolean(), validationResult]).optional().describe("A validator call, for example {\"@call\":\"required\",\"args\":{\"value\":{\"@path\":\"/x\"}}}, or a boolean binding"),
25
+ message: z.string().optional().describe("Shown when the check fails, instead of the default message")
26
+ })).optional().describe("Validation rules. The control shows the first failed one");
27
+ /**
28
+ * The failed check to show, or `undefined` when every check passes: the
29
+ * first error, or the first warning or info when no check is an error, so
30
+ * a warning never hides an error that comes after it. A condition that is
31
+ * not known yet (undefined) passes. A `false` condition is an error with
32
+ * the check's message. The check's message also wins over the message of
33
+ * a validator result: the built-in validators always have one, and the
34
+ * check is where the model puts its own wording.
35
+ */
36
+ function firstFailedCheck(checks) {
37
+ let first;
38
+ for (const check of checks ?? []) {
39
+ const { condition } = check;
40
+ if (condition === void 0 || condition === null) continue;
41
+ let failed;
42
+ if (typeof condition === "boolean") {
43
+ if (condition) continue;
44
+ failed = {
45
+ message: check.message ?? "Invalid value",
46
+ severity: "error"
47
+ };
48
+ } else {
49
+ if (condition.valid) continue;
50
+ failed = {
51
+ message: check.message ?? condition.message ?? "Invalid value",
52
+ severity: condition.severity ?? "error",
53
+ ...condition.code === void 0 ? {} : { code: condition.code }
54
+ };
55
+ }
56
+ if (failed.severity === "error") return failed;
57
+ first ??= failed;
58
+ }
59
+ return first;
60
+ }
61
+ /** The style of a check message, by its severity. */
62
+ function checkMessageStyle(severity) {
63
+ return {
64
+ ...textFont("sm"),
65
+ color: textColor(severity === "error" ? "danger" : severity === "warning" ? "warning" : "secondary")
66
+ };
67
+ }
68
+
69
+ //#endregion
70
+ export { checkMessageStyle, checksProp, firstFailedCheck };
71
+ //# sourceMappingURL=checks.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checks.mjs","names":[],"sources":["../../../src/generative-ui/standard/checks.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { textColor, textFont } from \"./tokens\";\n\n/**\n * The `checks` of the A2UI 1.0 `Checkable` components. The model writes\n * each condition as a validator call or a boolean binding:\n * `{ \"condition\": { \"@call\": \"email\", \"args\": { \"value\": { \"@path\": \"/form/email\" } } }, \"message\": \"...\" }`.\n * The engine resolves the condition before the component renders, so a\n * component sees a boolean or a `ValidationResult`.\n */\n\nconst severity = z.enum([\"error\", \"warning\", \"info\"]);\n\nconst validationResult = z\n .object({\n valid: z.boolean(),\n message: z.string().optional(),\n code: z.string().optional(),\n severity: severity.optional(),\n })\n .loose();\n\n/** The first failed check of a control, as the control shows it. */\nexport interface FailedCheck {\n message: string;\n /** `\"error\"` when the result named none. Only an error blocks. */\n severity: z.output<typeof severity>;\n /** The `code` of the validation result, when it had one. */\n code?: string;\n}\n\nexport const checksProp = z\n .array(\n z.object({\n condition: z\n .union([z.boolean(), validationResult])\n .optional()\n .describe(\n 'A validator call, for example {\"@call\":\"required\",\"args\":{\"value\":{\"@path\":\"/x\"}}}, or a boolean binding',\n ),\n message: z\n .string()\n .optional()\n .describe(\"Shown when the check fails, instead of the default message\"),\n }),\n )\n .optional()\n .describe(\"Validation rules. The control shows the first failed one\");\n\nexport type ResolvedChecks = z.output<typeof checksProp>;\n\n/**\n * The failed check to show, or `undefined` when every check passes: the\n * first error, or the first warning or info when no check is an error, so\n * a warning never hides an error that comes after it. A condition that is\n * not known yet (undefined) passes. A `false` condition is an error with\n * the check's message. The check's message also wins over the message of\n * a validator result: the built-in validators always have one, and the\n * check is where the model puts its own wording.\n */\nexport function firstFailedCheck(\n checks: ResolvedChecks,\n): FailedCheck | undefined {\n let first: FailedCheck | undefined;\n for (const check of checks ?? []) {\n const { condition } = check;\n if (condition === undefined || condition === null) continue;\n let failed: FailedCheck;\n if (typeof condition === \"boolean\") {\n if (condition) continue;\n failed = { message: check.message ?? \"Invalid value\", severity: \"error\" };\n } else {\n if (condition.valid) continue;\n failed = {\n message: check.message ?? condition.message ?? \"Invalid value\",\n severity: condition.severity ?? \"error\",\n ...(condition.code === undefined ? {} : { code: condition.code }),\n };\n }\n if (failed.severity === \"error\") return failed;\n first ??= failed;\n }\n return first;\n}\n\n/** The style of a check message, by its severity. */\nexport function checkMessageStyle(severity: FailedCheck[\"severity\"]) {\n return {\n ...textFont(\"sm\"),\n color: textColor(\n severity === \"error\"\n ? \"danger\"\n : severity === \"warning\"\n ? \"warning\"\n : \"secondary\",\n ),\n };\n}\n"],"mappings":";;;;;;;;;;;AAWA,MAAM,WAAW,EAAE,KAAK;CAAC;CAAS;CAAW;CAAO,CAAC;AAErD,MAAM,mBAAmB,EACtB,OAAO;CACN,OAAO,EAAE,SAAS;CAClB,SAAS,EAAE,QAAQ,CAAC,UAAU;CAC9B,MAAM,EAAE,QAAQ,CAAC,UAAU;CAC3B,UAAU,SAAS,UAAU;CAC9B,CAAC,CACD,OAAO;AAWV,MAAa,aAAa,EACvB,MACC,EAAE,OAAO;CACP,WAAW,EACR,MAAM,CAAC,EAAE,SAAS,EAAE,iBAAiB,CAAC,CACtC,UAAU,CACV,SACC,uHACD;CACH,SAAS,EACN,QAAQ,CACR,UAAU,CACV,SAAS,6DAA6D;CAC1E,CAAC,CACH,CACA,UAAU,CACV,SAAS,2DAA2D;;;;;;;;;;AAavE,SAAgB,iBACd,QACyB;CACzB,IAAI;AACJ,MAAK,MAAM,SAAS,UAAU,EAAE,EAAE;EAChC,MAAM,EAAE,cAAc;AACtB,MAAI,cAAc,UAAa,cAAc,KAAM;EACnD,IAAI;AACJ,MAAI,OAAO,cAAc,WAAW;AAClC,OAAI,UAAW;AACf,YAAS;IAAE,SAAS,MAAM,WAAW;IAAiB,UAAU;IAAS;SACpE;AACL,OAAI,UAAU,MAAO;AACrB,YAAS;IACP,SAAS,MAAM,WAAW,UAAU,WAAW;IAC/C,UAAU,UAAU,YAAY;IAChC,GAAI,UAAU,SAAS,SAAY,EAAE,GAAG,EAAE,MAAM,UAAU,MAAM;IACjE;;AAEH,MAAI,OAAO,aAAa,QAAS,QAAO;AACxC,YAAU;;AAEZ,QAAO;;;AAIT,SAAgB,kBAAkB,UAAmC;AACnE,QAAO;EACL,GAAG,SAAS,KAAK;EACjB,OAAO,UACL,aAAa,UACT,WACA,aAAa,YACX,YACA,YACP;EACF"}
@@ -0,0 +1,23 @@
1
+
2
+ //#region src/generative-ui/standard/components.ts
3
+ /**
4
+ * The definitions of `createGenerativeUI`: each declaration with the
5
+ * component of the same name.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * const layoutComponents = withComponents(layoutDeclarations, { Box, Column });
10
+ * ```
11
+ */
12
+ function withComponents(declarations, components) {
13
+ const definitions = {};
14
+ for (const name of Object.keys(declarations)) definitions[name] = {
15
+ ...declarations[name],
16
+ component: components[name]
17
+ };
18
+ return definitions;
19
+ }
20
+
21
+ //#endregion
22
+ exports.withComponents = withComponents;
23
+ //# sourceMappingURL=components.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"components.cjs","names":[],"sources":["../../../src/generative-ui/standard/components.ts"],"sourcesContent":["import type { GenerativeUIComponentDefinition } from \"../catalog/catalog\";\n\n/**\n * A standard component without its framework component: what the model\n * sees (description, props, events, slots) and how the engine treats it.\n * Each framework adds its own component with `withComponents`.\n */\nexport type GenerativeUIComponentDeclaration = Omit<\n GenerativeUIComponentDefinition,\n \"component\"\n>;\n\n/**\n * The definitions of `createGenerativeUI`: each declaration with the\n * component of the same name.\n *\n * @example\n * ```ts\n * const layoutComponents = withComponents(layoutDeclarations, { Box, Column });\n * ```\n */\nexport function withComponents<\n Declarations extends Record<string, GenerativeUIComponentDeclaration>,\n Components extends { [Name in keyof Declarations]: unknown },\n>(declarations: Declarations, components: Components) {\n const definitions: Record<string, unknown> = {};\n for (const name of Object.keys(declarations)) {\n definitions[name] = { ...declarations[name], component: components[name] };\n }\n return definitions as {\n [Name in keyof Declarations]: Declarations[Name] & {\n component: Components[Name];\n };\n };\n}\n"],"mappings":";;;;;;;;;;;AAqBA,SAAgB,eAGd,cAA4B,YAAwB;CACpD,MAAM,cAAuC,EAAE;AAC/C,MAAK,MAAM,QAAQ,OAAO,KAAK,aAAa,CAC1C,aAAY,QAAQ;EAAE,GAAG,aAAa;EAAO,WAAW,WAAW;EAAO;AAE5E,QAAO"}
@@ -0,0 +1,24 @@
1
+ import { GenerativeUIComponentDefinition } from "../catalog/catalog.cjs";
2
+
3
+ //#region src/generative-ui/standard/components.d.ts
4
+ /**
5
+ * A standard component without its framework component: what the model
6
+ * sees (description, props, events, slots) and how the engine treats it.
7
+ * Each framework adds its own component with `withComponents`.
8
+ */
9
+ type GenerativeUIComponentDeclaration = Omit<GenerativeUIComponentDefinition, "component">;
10
+ /**
11
+ * The definitions of `createGenerativeUI`: each declaration with the
12
+ * component of the same name.
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * const layoutComponents = withComponents(layoutDeclarations, { Box, Column });
17
+ * ```
18
+ */
19
+ declare function withComponents<Declarations extends Record<string, GenerativeUIComponentDeclaration>, Components extends { [Name in keyof Declarations]: unknown }>(declarations: Declarations, components: Components): { [Name in keyof Declarations]: Declarations[Name] & {
20
+ component: Components[Name];
21
+ } };
22
+ //#endregion
23
+ export { GenerativeUIComponentDeclaration, withComponents };
24
+ //# sourceMappingURL=components.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"components.d.cts","names":[],"sources":["../../../src/generative-ui/standard/components.ts"],"mappings":";;;;;AAOA;;;KAAY,gCAAA,GAAmC,IAAA,CAC7C,+BAAA;;AAaF;;;;;;;;iBAAgB,cAAA,sBACO,MAAA,SAAe,gCAAA,uCACA,YAAA,aAAA,CACpC,YAAA,EAAc,YAAA,EAAc,UAAA,EAAY,UAAA,oBAMvB,YAAA,GAAe,YAAA,CAAa,IAAA;EACzC,SAAA,EAAW,UAAA,CAAW,IAAA;AAAA"}
@@ -0,0 +1,24 @@
1
+ import { GenerativeUIComponentDefinition } from "../catalog/catalog.mjs";
2
+
3
+ //#region src/generative-ui/standard/components.d.ts
4
+ /**
5
+ * A standard component without its framework component: what the model
6
+ * sees (description, props, events, slots) and how the engine treats it.
7
+ * Each framework adds its own component with `withComponents`.
8
+ */
9
+ type GenerativeUIComponentDeclaration = Omit<GenerativeUIComponentDefinition, "component">;
10
+ /**
11
+ * The definitions of `createGenerativeUI`: each declaration with the
12
+ * component of the same name.
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * const layoutComponents = withComponents(layoutDeclarations, { Box, Column });
17
+ * ```
18
+ */
19
+ declare function withComponents<Declarations extends Record<string, GenerativeUIComponentDeclaration>, Components extends { [Name in keyof Declarations]: unknown }>(declarations: Declarations, components: Components): { [Name in keyof Declarations]: Declarations[Name] & {
20
+ component: Components[Name];
21
+ } };
22
+ //#endregion
23
+ export { GenerativeUIComponentDeclaration, withComponents };
24
+ //# sourceMappingURL=components.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"components.d.mts","names":[],"sources":["../../../src/generative-ui/standard/components.ts"],"mappings":";;;;;AAOA;;;KAAY,gCAAA,GAAmC,IAAA,CAC7C,+BAAA;;AAaF;;;;;;;;iBAAgB,cAAA,sBACO,MAAA,SAAe,gCAAA,uCACA,YAAA,aAAA,CACpC,YAAA,EAAc,YAAA,EAAc,UAAA,EAAY,UAAA,oBAMvB,YAAA,GAAe,YAAA,CAAa,IAAA;EACzC,SAAA,EAAW,UAAA,CAAW,IAAA;AAAA"}
@@ -0,0 +1,22 @@
1
+ //#region src/generative-ui/standard/components.ts
2
+ /**
3
+ * The definitions of `createGenerativeUI`: each declaration with the
4
+ * component of the same name.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * const layoutComponents = withComponents(layoutDeclarations, { Box, Column });
9
+ * ```
10
+ */
11
+ function withComponents(declarations, components) {
12
+ const definitions = {};
13
+ for (const name of Object.keys(declarations)) definitions[name] = {
14
+ ...declarations[name],
15
+ component: components[name]
16
+ };
17
+ return definitions;
18
+ }
19
+
20
+ //#endregion
21
+ export { withComponents };
22
+ //# sourceMappingURL=components.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"components.mjs","names":[],"sources":["../../../src/generative-ui/standard/components.ts"],"sourcesContent":["import type { GenerativeUIComponentDefinition } from \"../catalog/catalog\";\n\n/**\n * A standard component without its framework component: what the model\n * sees (description, props, events, slots) and how the engine treats it.\n * Each framework adds its own component with `withComponents`.\n */\nexport type GenerativeUIComponentDeclaration = Omit<\n GenerativeUIComponentDefinition,\n \"component\"\n>;\n\n/**\n * The definitions of `createGenerativeUI`: each declaration with the\n * component of the same name.\n *\n * @example\n * ```ts\n * const layoutComponents = withComponents(layoutDeclarations, { Box, Column });\n * ```\n */\nexport function withComponents<\n Declarations extends Record<string, GenerativeUIComponentDeclaration>,\n Components extends { [Name in keyof Declarations]: unknown },\n>(declarations: Declarations, components: Components) {\n const definitions: Record<string, unknown> = {};\n for (const name of Object.keys(declarations)) {\n definitions[name] = { ...declarations[name], component: components[name] };\n }\n return definitions as {\n [Name in keyof Declarations]: Declarations[Name] & {\n component: Components[Name];\n };\n };\n}\n"],"mappings":";;;;;;;;;;AAqBA,SAAgB,eAGd,cAA4B,YAAwB;CACpD,MAAM,cAAuC,EAAE;AAC/C,MAAK,MAAM,QAAQ,OAAO,KAAK,aAAa,CAC1C,aAAY,QAAQ;EAAE,GAAG,aAAa;EAAO,WAAW,WAAW;EAAO;AAE5E,QAAO"}