@copilotkit/shared 2.0.0-rc.31 → 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,209 @@
1
+ import { TEXT_COLORS, TEXT_SIZES, TITLE_SIZES, WEIGHTS } from "./tokens.mjs";
2
+ import { CHILDREN_SLOT, sizeValue, weightProp } from "./layout.mjs";
3
+ import { z } from "zod";
4
+
5
+ //#region src/generative-ui/standard/text.ts
6
+ const colorProp = z.string().optional().describe(`One of ${TEXT_COLORS.join("|")} or a CSS color`);
7
+ const fontWeight = z.enum(WEIGHTS).optional();
8
+ const textAlign = z.enum([
9
+ "start",
10
+ "center",
11
+ "end"
12
+ ]).optional();
13
+ const typographyProps = {
14
+ color: colorProp,
15
+ fontWeight,
16
+ textAlign,
17
+ italic: z.boolean().optional(),
18
+ truncate: z.boolean().optional(),
19
+ maxLines: z.number().optional(),
20
+ tabularNums: z.boolean().optional(),
21
+ width: sizeValue.optional()
22
+ };
23
+ const typographySchema = z.object(typographyProps);
24
+ const titleSchema = z.object({
25
+ ...typographyProps,
26
+ text: z.string().describe("Heading text"),
27
+ size: z.enum(TITLE_SIZES).optional().describe("Default \"md\""),
28
+ strong: z.boolean().optional().describe("Default true")
29
+ });
30
+ const textSchema = z.object({
31
+ ...typographyProps,
32
+ weight: weightProp,
33
+ text: z.union([z.string(), z.number()]).optional().describe("Text with inline markdown. A bound number shows as text"),
34
+ size: z.enum(TEXT_SIZES).optional().describe("Default \"md\""),
35
+ fontSize: sizeValue.optional().describe("Pixels when a number. Wins over size"),
36
+ lineHeight: z.union([z.number(), z.string()]).optional().describe("A unitless ratio, or CSS"),
37
+ minLines: z.number().optional().describe("Reserves the height of this many lines"),
38
+ strong: z.boolean().optional().describe("Default false"),
39
+ underline: z.boolean().optional(),
40
+ lineThrough: z.boolean().optional(),
41
+ inline: z.boolean().optional(),
42
+ preserveWhitespace: z.boolean().optional(),
43
+ highlight: z.union([z.enum([
44
+ "green",
45
+ "orange",
46
+ "pink"
47
+ ]), z.boolean()]).optional()
48
+ });
49
+ const CAPTION_SIZES = [
50
+ "sm",
51
+ "md",
52
+ "lg"
53
+ ];
54
+ const captionSchema = z.object({
55
+ text: z.union([z.string(), z.number()]).describe("Caption text"),
56
+ color: colorProp,
57
+ size: z.enum(CAPTION_SIZES).optional().describe("Default \"lg\""),
58
+ fontWeight: fontWeight.describe("Default \"normal\""),
59
+ textAlign,
60
+ truncate: z.boolean().optional(),
61
+ maxLines: z.number().optional()
62
+ });
63
+ const labelSchema = z.object({
64
+ text: z.union([z.string(), z.number()]).describe("Label text"),
65
+ htmlFor: z.string().optional(),
66
+ color: colorProp,
67
+ size: z.enum(TEXT_SIZES).optional().describe("Default \"sm\""),
68
+ fontWeight: fontWeight.describe("Default \"medium\""),
69
+ textAlign,
70
+ truncate: z.boolean().optional(),
71
+ width: sizeValue.optional()
72
+ });
73
+ const boldSchema = z.object({
74
+ text: z.string(),
75
+ fontWeight
76
+ });
77
+ const inlineTextSchema = z.object({ text: z.string() });
78
+ const blockquoteSchema = z.object({ text: z.string().describe("The quoted text, with inline markdown") });
79
+ const BADGE_SIZES = [
80
+ "sm",
81
+ "md",
82
+ "lg"
83
+ ];
84
+ const badgeSchema = z.object({
85
+ label: z.string().describe("Badge text"),
86
+ color: z.enum([
87
+ "secondary",
88
+ "success",
89
+ "danger",
90
+ "warning",
91
+ "info",
92
+ "discovery"
93
+ ]).optional().describe("Default \"secondary\""),
94
+ size: z.enum(BADGE_SIZES).optional().describe("Default \"md\""),
95
+ pill: z.boolean().optional().describe("Default true"),
96
+ variant: z.enum([
97
+ "soft",
98
+ "solid",
99
+ "outline"
100
+ ]).optional().describe("Default \"soft\""),
101
+ fontWeight: fontWeight.describe("Default \"medium\""),
102
+ maxWidth: sizeValue.optional(),
103
+ padding: sizeValue.optional()
104
+ });
105
+ const codeSchema = z.object({
106
+ text: z.string().describe("Source code"),
107
+ language: z.string().optional()
108
+ });
109
+ const markdownSchema = z.object({
110
+ text: z.string().describe("Markdown source"),
111
+ streaming: z.boolean().optional().describe("Default false")
112
+ });
113
+ const mathSchema = z.object({
114
+ value: z.string().describe("TeX source"),
115
+ block: z.boolean().optional().describe("Default false")
116
+ });
117
+ const shimmerSchema = z.object({
118
+ ...typographyProps,
119
+ text: z.string(),
120
+ size: z.enum(TEXT_SIZES).optional().describe("Default \"md\""),
121
+ lineThrough: z.boolean().optional()
122
+ });
123
+ const linkSchema = z.object({
124
+ text: z.string().describe("Link text"),
125
+ href: z.string().describe("URL"),
126
+ title: z.string().optional()
127
+ });
128
+ /**
129
+ * The standard text components, without their framework components.
130
+ *
131
+ * - Text has a "multiple" `children` slot. The children render inline
132
+ * after the text.
133
+ * - Tooltip has two "single" slots: `trigger` and `content`.
134
+ * - Link is a plain link. It opens http, https and mailto URLs only.
135
+ */
136
+ const textDeclarations = {
137
+ Title: {
138
+ description: "A heading in a Card or next to another component; a heading alone is markdown. Size \"2xl\" at most once per surface, \"lg\" for sections. \"sm\" is an h4, \"md\"/\"lg\" an h3 (default \"md\"), \"xl\" and up an h2. Bold unless strong is false.",
139
+ props: titleSchema
140
+ },
141
+ Text: {
142
+ description: "Body text in a Card or next to another component; a paragraph alone is markdown outside the fence. Color \"default\" or \"secondary\". `text` takes inline markdown (**bold**, *italic*, ~~strike~~, ++underline++, `code`, [link](url)). `children` ids render inline after it, e.g. a Badge.",
143
+ props: textSchema,
144
+ slots: CHILDREN_SLOT
145
+ },
146
+ Caption: {
147
+ description: "Small secondary text: a hint under a control, or a label in a Row. `text` can have inline markdown.",
148
+ props: captionSchema
149
+ },
150
+ Label: {
151
+ description: "The label of a form field.",
152
+ props: labelSchema
153
+ },
154
+ Bold: {
155
+ description: "Bold inline text.",
156
+ props: boldSchema
157
+ },
158
+ Italic: {
159
+ description: "Italic inline text.",
160
+ props: inlineTextSchema
161
+ },
162
+ Underline: {
163
+ description: "Underlined inline text.",
164
+ props: inlineTextSchema
165
+ },
166
+ Strikethrough: {
167
+ description: "Struck-through inline text.",
168
+ props: inlineTextSchema
169
+ },
170
+ Badge: {
171
+ description: "A small status pill. Use the colors success, danger and warning only to show a status, not for decoration.",
172
+ props: badgeSchema
173
+ },
174
+ Blockquote: {
175
+ description: "A block quotation with a line on the left. `text` can have inline markdown.",
176
+ props: blockquoteSchema
177
+ },
178
+ Code: {
179
+ description: "A block of code in a monospace font.",
180
+ props: codeSchema
181
+ },
182
+ Markdown: {
183
+ description: "A block of GitHub-flavored markdown. Use it only next to other components, for example in a table cell or next to a chart. Markdown alone goes outside the fence.",
184
+ props: markdownSchema
185
+ },
186
+ Math: {
187
+ description: "A TeX math formula, typeset with KaTeX. Set block to true for a centered formula on its own line.",
188
+ props: mathSchema
189
+ },
190
+ ShimmerText: {
191
+ description: "Text with a moving shimmer. It shows that something is loading or pending.",
192
+ props: shimmerSchema
193
+ },
194
+ Link: {
195
+ description: "A link. Only http, https and mailto URLs work. It opens in a new tab.",
196
+ props: linkSchema
197
+ },
198
+ Tooltip: {
199
+ description: "Shows `content` when the user points at or focuses `trigger`. `trigger`: one child id, a Text, Icon or Badge (not a Button or Link). `content`: one child id of short text, no links or buttons.",
200
+ slots: {
201
+ trigger: "single",
202
+ content: "single"
203
+ }
204
+ }
205
+ };
206
+
207
+ //#endregion
208
+ export { BADGE_SIZES, CAPTION_SIZES, badgeSchema, blockquoteSchema, boldSchema, captionSchema, codeSchema, inlineTextSchema, labelSchema, linkSchema, markdownSchema, mathSchema, shimmerSchema, textDeclarations, textSchema, titleSchema, typographySchema };
209
+ //# sourceMappingURL=text.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text.mjs","names":[],"sources":["../../../src/generative-ui/standard/text.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { CHILDREN_SLOT, sizeValue, weightProp } from \"./layout\";\nimport { TEXT_COLORS, TEXT_SIZES, TITLE_SIZES, WEIGHTS } from \"./tokens\";\n\n// ---- Schemas ----\n\nconst colorProp = z\n .string()\n .optional()\n .describe(`One of ${TEXT_COLORS.join(\"|\")} or a CSS color`);\nconst fontWeight = z.enum(WEIGHTS).optional();\nconst textAlign = z.enum([\"start\", \"center\", \"end\"]).optional();\n\nconst typographyProps = {\n color: colorProp,\n fontWeight,\n textAlign,\n italic: z.boolean().optional(),\n truncate: z.boolean().optional(),\n maxLines: z.number().optional(),\n tabularNums: z.boolean().optional(),\n width: sizeValue.optional(),\n};\n\nexport const typographySchema = z.object(typographyProps);\nexport const titleSchema = z.object({\n ...typographyProps,\n text: z.string().describe(\"Heading text\"),\n size: z.enum(TITLE_SIZES).optional().describe('Default \"md\"'),\n strong: z.boolean().optional().describe(\"Default true\"),\n});\nexport const textSchema = z.object({\n ...typographyProps,\n weight: weightProp,\n text: z\n .union([z.string(), z.number()])\n .optional()\n .describe(\"Text with inline markdown. A bound number shows as text\"),\n size: z.enum(TEXT_SIZES).optional().describe('Default \"md\"'),\n fontSize: sizeValue\n .optional()\n .describe(\"Pixels when a number. Wins over size\"),\n lineHeight: z\n .union([z.number(), z.string()])\n .optional()\n .describe(\"A unitless ratio, or CSS\"),\n minLines: z\n .number()\n .optional()\n .describe(\"Reserves the height of this many lines\"),\n strong: z.boolean().optional().describe(\"Default false\"),\n underline: z.boolean().optional(),\n lineThrough: z.boolean().optional(),\n inline: z.boolean().optional(),\n preserveWhitespace: z.boolean().optional(),\n highlight: z\n .union([z.enum([\"green\", \"orange\", \"pink\"]), z.boolean()])\n .optional(),\n});\nexport const CAPTION_SIZES = [\"sm\", \"md\", \"lg\"] as const;\nexport const captionSchema = z.object({\n text: z.union([z.string(), z.number()]).describe(\"Caption text\"),\n color: colorProp,\n size: z.enum(CAPTION_SIZES).optional().describe('Default \"lg\"'),\n fontWeight: fontWeight.describe('Default \"normal\"'),\n textAlign,\n truncate: z.boolean().optional(),\n maxLines: z.number().optional(),\n});\nexport const labelSchema = z.object({\n text: z.union([z.string(), z.number()]).describe(\"Label text\"),\n htmlFor: z.string().optional(),\n color: colorProp,\n size: z.enum(TEXT_SIZES).optional().describe('Default \"sm\"'),\n fontWeight: fontWeight.describe('Default \"medium\"'),\n textAlign,\n truncate: z.boolean().optional(),\n width: sizeValue.optional(),\n});\nexport const boldSchema = z.object({ text: z.string(), fontWeight });\nexport const inlineTextSchema = z.object({ text: z.string() });\nexport const blockquoteSchema = z.object({\n text: z.string().describe(\"The quoted text, with inline markdown\"),\n});\nexport const BADGE_SIZES = [\"sm\", \"md\", \"lg\"] as const;\nexport const badgeSchema = z.object({\n label: z.string().describe(\"Badge text\"),\n color: z\n .enum([\"secondary\", \"success\", \"danger\", \"warning\", \"info\", \"discovery\"])\n .optional()\n .describe('Default \"secondary\"'),\n size: z.enum(BADGE_SIZES).optional().describe('Default \"md\"'),\n pill: z.boolean().optional().describe(\"Default true\"),\n variant: z\n .enum([\"soft\", \"solid\", \"outline\"])\n .optional()\n .describe('Default \"soft\"'),\n fontWeight: fontWeight.describe('Default \"medium\"'),\n maxWidth: sizeValue.optional(),\n padding: sizeValue.optional(),\n});\nexport const codeSchema = z.object({\n text: z.string().describe(\"Source code\"),\n language: z.string().optional(),\n});\nexport const markdownSchema = z.object({\n text: z.string().describe(\"Markdown source\"),\n streaming: z.boolean().optional().describe(\"Default false\"),\n});\nexport const mathSchema = z.object({\n value: z.string().describe(\"TeX source\"),\n block: z.boolean().optional().describe(\"Default false\"),\n});\nexport const shimmerSchema = z.object({\n ...typographyProps,\n text: z.string(),\n size: z.enum(TEXT_SIZES).optional().describe('Default \"md\"'),\n lineThrough: z.boolean().optional(),\n});\nexport const linkSchema = z.object({\n text: z.string().describe(\"Link text\"),\n href: z.string().describe(\"URL\"),\n title: z.string().optional(),\n});\n\n/**\n * The standard text components, without their framework components.\n *\n * - Text has a \"multiple\" `children` slot. The children render inline\n * after the text.\n * - Tooltip has two \"single\" slots: `trigger` and `content`.\n * - Link is a plain link. It opens http, https and mailto URLs only.\n */\nexport const textDeclarations = {\n Title: {\n description:\n 'A heading in a Card or next to another component; a heading alone is markdown. Size \"2xl\" at most once per surface, \"lg\" for sections. \"sm\" is an h4, \"md\"/\"lg\" an h3 (default \"md\"), \"xl\" and up an h2. Bold unless strong is false.',\n props: titleSchema,\n },\n Text: {\n description:\n 'Body text in a Card or next to another component; a paragraph alone is markdown outside the fence. Color \"default\" or \"secondary\". `text` takes inline markdown (**bold**, *italic*, ~~strike~~, ++underline++, `code`, [link](url)). `children` ids render inline after it, e.g. a Badge.',\n props: textSchema,\n slots: CHILDREN_SLOT,\n },\n Caption: {\n description:\n \"Small secondary text: a hint under a control, or a label in a Row. `text` can have inline markdown.\",\n props: captionSchema,\n },\n Label: {\n description: \"The label of a form field.\",\n props: labelSchema,\n },\n Bold: {\n description: \"Bold inline text.\",\n props: boldSchema,\n },\n Italic: {\n description: \"Italic inline text.\",\n props: inlineTextSchema,\n },\n Underline: {\n description: \"Underlined inline text.\",\n props: inlineTextSchema,\n },\n Strikethrough: {\n description: \"Struck-through inline text.\",\n props: inlineTextSchema,\n },\n Badge: {\n description:\n \"A small status pill. Use the colors success, danger and warning only to show a status, not for decoration.\",\n props: badgeSchema,\n },\n Blockquote: {\n description:\n \"A block quotation with a line on the left. `text` can have inline markdown.\",\n props: blockquoteSchema,\n },\n Code: {\n description: \"A block of code in a monospace font.\",\n props: codeSchema,\n },\n Markdown: {\n description:\n \"A block of GitHub-flavored markdown. Use it only next to other components, for example in a table cell or next to a chart. Markdown alone goes outside the fence.\",\n props: markdownSchema,\n },\n Math: {\n description:\n \"A TeX math formula, typeset with KaTeX. Set block to true for a centered formula on its own line.\",\n props: mathSchema,\n },\n ShimmerText: {\n description:\n \"Text with a moving shimmer. It shows that something is loading or pending.\",\n props: shimmerSchema,\n },\n Link: {\n description:\n \"A link. Only http, https and mailto URLs work. It opens in a new tab.\",\n props: linkSchema,\n },\n Tooltip: {\n description:\n \"Shows `content` when the user points at or focuses `trigger`. `trigger`: one child id, a Text, Icon or Badge (not a Button or Link). `content`: one child id of short text, no links or buttons.\",\n slots: { trigger: \"single\", content: \"single\" } as const,\n },\n};\n"],"mappings":";;;;;AAMA,MAAM,YAAY,EACf,QAAQ,CACR,UAAU,CACV,SAAS,UAAU,YAAY,KAAK,IAAI,CAAC,iBAAiB;AAC7D,MAAM,aAAa,EAAE,KAAK,QAAQ,CAAC,UAAU;AAC7C,MAAM,YAAY,EAAE,KAAK;CAAC;CAAS;CAAU;CAAM,CAAC,CAAC,UAAU;AAE/D,MAAM,kBAAkB;CACtB,OAAO;CACP;CACA;CACA,QAAQ,EAAE,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eAAe;EACb,aAAa;EACb,OAAO;EACR;CACD,OAAO;EACL,aACE;EACF,OAAO;EACR;CACD,YAAY;EACV,aACE;EACF,OAAO;EACR;CACD,MAAM;EACJ,aAAa;EACb,OAAO;EACR;CACD,UAAU;EACR,aACE;EACF,OAAO;EACR;CACD,MAAM;EACJ,aACE;EACF,OAAO;EACR;CACD,aAAa;EACX,aACE;EACF,OAAO;EACR;CACD,MAAM;EACJ,aACE;EACF,OAAO;EACR;CACD,SAAS;EACP,aACE;EACF,OAAO;GAAE,SAAS;GAAU,SAAS;GAAU;EAChD;CACF"}
@@ -0,0 +1,115 @@
1
+
2
+ //#region src/generative-ui/standard/theme.ts
3
+ /**
4
+ * The built-in dark values. The light values are the fallbacks in the
5
+ * components, so a surface is light when no variable is set.
6
+ */
7
+ const DARK_THEME = {
8
+ "--a2ui-color-text-default": "#ececec",
9
+ "--a2ui-color-text-prose": "#ececec",
10
+ "--a2ui-color-text-primary": "#ececec",
11
+ "--a2ui-color-text-emphasis": "#fff",
12
+ "--a2ui-color-text-secondary": "#b4b4b4",
13
+ "--a2ui-color-text-tertiary": "#8e8e8e",
14
+ "--a2ui-color-text-success": "#4fd1a5",
15
+ "--a2ui-color-text-info": "#6cb6ff",
16
+ "--a2ui-color-text-warning": "#e3b341",
17
+ "--a2ui-color-text-caution": "#e3b341",
18
+ "--a2ui-color-text-danger": "#ff7b72",
19
+ "--a2ui-color-text-discovery": "#bc9cff",
20
+ "--a2ui-color-surface": "#1f1f1f",
21
+ "--a2ui-color-surface-secondary": "#2a2a2a",
22
+ "--a2ui-color-surface-tertiary": "#3a3a3a",
23
+ "--a2ui-color-surface-elevated": "#262626",
24
+ "--a2ui-color-surface-elevated-secondary": "#2f2f2f",
25
+ "--a2ui-color-surface-inverted": "#f2f2f2",
26
+ "--a2ui-color-surface-soft": "#232323",
27
+ "--a2ui-color-info": "rgba(80, 160, 255, 0.14)",
28
+ "--a2ui-color-warning": "rgba(240, 180, 60, 0.14)",
29
+ "--a2ui-color-caution": "rgba(240, 180, 60, 0.14)",
30
+ "--a2ui-color-success": "rgba(60, 200, 150, 0.14)",
31
+ "--a2ui-color-danger": "rgba(255, 110, 100, 0.14)",
32
+ "--a2ui-color-discovery": "rgba(170, 130, 255, 0.14)",
33
+ "--a2ui-color-info-soft": "rgba(80, 160, 255, 0.08)",
34
+ "--a2ui-color-warning-soft": "rgba(240, 180, 60, 0.08)",
35
+ "--a2ui-color-caution-soft": "rgba(240, 180, 60, 0.08)",
36
+ "--a2ui-color-success-soft": "rgba(60, 200, 150, 0.08)",
37
+ "--a2ui-color-danger-soft": "rgba(255, 110, 100, 0.08)",
38
+ "--a2ui-color-discovery-soft": "rgba(170, 130, 255, 0.08)",
39
+ "--a2ui-color-info-solid": "#3b8eea",
40
+ "--a2ui-color-warning-solid": "#c99a2e",
41
+ "--a2ui-color-caution-solid": "#c99a2e",
42
+ "--a2ui-color-success-solid": "#2fae86",
43
+ "--a2ui-color-danger-solid": "#e5534b",
44
+ "--a2ui-color-discovery-solid": "#9a6ff0",
45
+ "--a2ui-color-border-default": "rgba(255, 255, 255, 0.12)",
46
+ "--a2ui-color-border-subtle": "rgba(255, 255, 255, 0.06)",
47
+ "--a2ui-color-border-strong": "#4a4a4a",
48
+ "--a2ui-color-border-info": "#2f5f8f",
49
+ "--a2ui-color-border-warning": "#6b5420",
50
+ "--a2ui-color-border-caution": "#6b5420",
51
+ "--a2ui-color-border-success": "#1f5f4b",
52
+ "--a2ui-color-border-danger": "#7a2f2b",
53
+ "--a2ui-color-border-discovery": "#4f3a80",
54
+ "--a2ui-color-border-control": "rgba(255, 255, 255, 0.2)",
55
+ "--a2ui-color-accent": "#f2f2f2",
56
+ "--a2ui-color-on-accent": "#0d0d0d",
57
+ "--a2ui-color-panel": "#262626",
58
+ "--a2ui-color-control": "#2f2f2f",
59
+ "--a2ui-color-focus": "#3b9bff",
60
+ "--a2ui-color-shimmer": "rgba(255, 255, 255, 0.12)",
61
+ "--a2ui-color-chart-cursor": "rgba(255, 255, 255, 0.06)",
62
+ "--a2ui-color-slider-track": "rgba(255, 255, 255, 0.1)",
63
+ "--a2ui-color-badge-secondary": "rgba(255, 255, 255, 0.08)",
64
+ "--a2ui-color-highlight-green": "#1d4a37",
65
+ "--a2ui-color-highlight-orange": "#4d3418",
66
+ "--a2ui-color-highlight-pink": "#4d2338",
67
+ "--a2ui-shadow-xs": "0 1px 2px rgba(0, 0, 0, 0.5)",
68
+ "--a2ui-shadow-sm": "0 1px 3px rgba(0, 0, 0, 0.5)",
69
+ "--a2ui-shadow-soft": "0 1px 3px rgba(0, 0, 0, 0.3)",
70
+ "--a2ui-shadow-md": "0 4px 12px rgba(0, 0, 0, 0.4)"
71
+ };
72
+ const VARIABLE_NAME = /^--a2ui-[a-z0-9-]+$/;
73
+ const UNSAFE_VALUE = /[{};<>]/;
74
+ /** Matches the `dark` class on an ancestor of a surface, or on the surface. */
75
+ const DARK = ":where(.dark)";
76
+ /** The default dark values, as a rule that any theme rule beats. */
77
+ const DARK_THEME_CSS = `:where(.dark .a2ui-surface,.a2ui-surface.dark){${declarations(DARK_THEME)}}`;
78
+ function declarations(values) {
79
+ return Object.entries(values ?? {}).filter(([name, value]) => VARIABLE_NAME.test(name) && typeof value === "string" && !UNSAFE_VALUE.test(value)).map(([name, value]) => `${name}:${value}`).join(";");
80
+ }
81
+ /** A short, stable id for a stylesheet. */
82
+ function hashOf(text) {
83
+ let hash = 5381;
84
+ for (let index = 0; index < text.length; index++) hash = hash * 33 ^ text.charCodeAt(index);
85
+ return `t${(hash >>> 0).toString(36)}`;
86
+ }
87
+ /**
88
+ * The stylesheet of a theme: its values on the surfaces that carry its id,
89
+ * then its dark values in dark mode. `undefined` when the theme sets no
90
+ * variable. Values that could break out of the rule are left out.
91
+ *
92
+ * @example
93
+ * ```ts
94
+ * themeStyleSheet({ "--a2ui-color-accent": "red" });
95
+ * // { id: "t…", css: '.a2ui-surface[data-a2ui-theme="t…"]{--a2ui-color-accent:red}' }
96
+ * ```
97
+ */
98
+ function themeStyleSheet(theme) {
99
+ const { dark, ...base } = theme ?? {};
100
+ const both = declarations(base);
101
+ const darkOnly = declarations(dark);
102
+ if (!both && !darkOnly) return void 0;
103
+ const id = hashOf(`${both}|${darkOnly}`);
104
+ const self = `.a2ui-surface[data-a2ui-theme="${id}"]`;
105
+ return {
106
+ id,
107
+ css: [both && `${self}{${both}}`, darkOnly && `${DARK} ${self},${self}${DARK}{${darkOnly}}`].filter(Boolean).join("")
108
+ };
109
+ }
110
+
111
+ //#endregion
112
+ exports.DARK_THEME = DARK_THEME;
113
+ exports.DARK_THEME_CSS = DARK_THEME_CSS;
114
+ exports.themeStyleSheet = themeStyleSheet;
115
+ //# sourceMappingURL=theme.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme.cjs","names":[],"sources":["../../../src/generative-ui/standard/theme.ts"],"sourcesContent":["import type { BACKGROUNDS, BORDER_COLORS, RADII, TEXT_COLORS } from \"./tokens\";\n\ntype TextColor = (typeof TEXT_COLORS)[number];\ntype BorderColor = (typeof BORDER_COLORS)[number];\ntype Background = (typeof BACKGROUNDS)[number];\ntype Radius = Exclude<(typeof RADII)[number], \"full\">;\ntype Tint = \"info\" | \"warning\" | \"caution\" | \"success\" | \"danger\" | \"discovery\";\ntype ChartSeries = 1 | 2 | 3 | 4 | 5 | 6;\n\n/** Every CSS variable that the standard components read. */\nexport type GenerativeUIThemeVariable =\n | `--a2ui-color-text-${TextColor}`\n | `--a2ui-color-${Background}`\n | `--a2ui-color-border-${BorderColor}`\n | `--a2ui-color-${Tint}-soft`\n | `--a2ui-radius-${Radius}`\n | `--a2ui-chart-${ChartSeries}`\n | \"--a2ui-color-accent\"\n | \"--a2ui-color-on-accent\"\n | \"--a2ui-color-panel\"\n | \"--a2ui-color-control\"\n | \"--a2ui-color-focus\"\n | \"--a2ui-color-shimmer\"\n | \"--a2ui-color-chart-cursor\"\n | \"--a2ui-color-slider-track\"\n | \"--a2ui-color-badge-secondary\"\n | \"--a2ui-color-border-control\"\n | \"--a2ui-color-highlight-green\"\n | \"--a2ui-color-highlight-orange\"\n | \"--a2ui-color-highlight-pink\"\n | \"--a2ui-color-backdrop\"\n | \"--a2ui-color-overlay\"\n | \"--a2ui-color-rating\"\n | \"--a2ui-shadow-xs\"\n | \"--a2ui-shadow-sm\"\n | \"--a2ui-shadow-soft\"\n | \"--a2ui-shadow-md\"\n | \"--a2ui-font-family\"\n | \"--a2ui-heading-margin\"\n | \"--a2ui-block-margin\";\n\n/** Values for the theme variables. A name that is not one is a type error. */\nexport type GenerativeUIThemeVariables = {\n [Variable in GenerativeUIThemeVariable]?: string;\n};\n\n/** The values of one color scheme, plus the map style of that scheme. */\nexport type GenerativeUIThemeValues = GenerativeUIThemeVariables & {\n /** A MapLibre style URL for the Map component. */\n mapStyle?: string;\n};\n\n/**\n * The look of generated UI. Values at the top level apply in light and in\n * dark mode. Values in `dark` replace them in dark mode. Dark mode is on\n * when an ancestor of the surface has the `dark` class, like the CopilotKit\n * chat.\n *\n * @example\n * ```ts\n * const theme: GenerativeUITheme = {\n * \"--a2ui-color-accent\": \"#d97706\",\n * \"--a2ui-font-family\": \"Inter, sans-serif\",\n * dark: { \"--a2ui-color-panel\": \"#1f2937\" },\n * };\n * ```\n */\nexport type GenerativeUITheme = GenerativeUIThemeValues & {\n dark?: GenerativeUIThemeValues;\n};\n\n/**\n * The built-in dark values. The light values are the fallbacks in the\n * components, so a surface is light when no variable is set.\n */\nexport const DARK_THEME: GenerativeUIThemeVariables = {\n \"--a2ui-color-text-default\": \"#ececec\",\n \"--a2ui-color-text-prose\": \"#ececec\",\n \"--a2ui-color-text-primary\": \"#ececec\",\n \"--a2ui-color-text-emphasis\": \"#fff\",\n \"--a2ui-color-text-secondary\": \"#b4b4b4\",\n \"--a2ui-color-text-tertiary\": \"#8e8e8e\",\n \"--a2ui-color-text-success\": \"#4fd1a5\",\n \"--a2ui-color-text-info\": \"#6cb6ff\",\n \"--a2ui-color-text-warning\": \"#e3b341\",\n \"--a2ui-color-text-caution\": \"#e3b341\",\n \"--a2ui-color-text-danger\": \"#ff7b72\",\n \"--a2ui-color-text-discovery\": \"#bc9cff\",\n \"--a2ui-color-surface\": \"#1f1f1f\",\n \"--a2ui-color-surface-secondary\": \"#2a2a2a\",\n \"--a2ui-color-surface-tertiary\": \"#3a3a3a\",\n \"--a2ui-color-surface-elevated\": \"#262626\",\n \"--a2ui-color-surface-elevated-secondary\": \"#2f2f2f\",\n \"--a2ui-color-surface-inverted\": \"#f2f2f2\",\n \"--a2ui-color-surface-soft\": \"#232323\",\n \"--a2ui-color-info\": \"rgba(80, 160, 255, 0.14)\",\n \"--a2ui-color-warning\": \"rgba(240, 180, 60, 0.14)\",\n \"--a2ui-color-caution\": \"rgba(240, 180, 60, 0.14)\",\n \"--a2ui-color-success\": \"rgba(60, 200, 150, 0.14)\",\n \"--a2ui-color-danger\": \"rgba(255, 110, 100, 0.14)\",\n \"--a2ui-color-discovery\": \"rgba(170, 130, 255, 0.14)\",\n \"--a2ui-color-info-soft\": \"rgba(80, 160, 255, 0.08)\",\n \"--a2ui-color-warning-soft\": \"rgba(240, 180, 60, 0.08)\",\n \"--a2ui-color-caution-soft\": \"rgba(240, 180, 60, 0.08)\",\n \"--a2ui-color-success-soft\": \"rgba(60, 200, 150, 0.08)\",\n \"--a2ui-color-danger-soft\": \"rgba(255, 110, 100, 0.08)\",\n \"--a2ui-color-discovery-soft\": \"rgba(170, 130, 255, 0.08)\",\n \"--a2ui-color-info-solid\": \"#3b8eea\",\n \"--a2ui-color-warning-solid\": \"#c99a2e\",\n \"--a2ui-color-caution-solid\": \"#c99a2e\",\n \"--a2ui-color-success-solid\": \"#2fae86\",\n \"--a2ui-color-danger-solid\": \"#e5534b\",\n \"--a2ui-color-discovery-solid\": \"#9a6ff0\",\n \"--a2ui-color-border-default\": \"rgba(255, 255, 255, 0.12)\",\n \"--a2ui-color-border-subtle\": \"rgba(255, 255, 255, 0.06)\",\n \"--a2ui-color-border-strong\": \"#4a4a4a\",\n \"--a2ui-color-border-info\": \"#2f5f8f\",\n \"--a2ui-color-border-warning\": \"#6b5420\",\n \"--a2ui-color-border-caution\": \"#6b5420\",\n \"--a2ui-color-border-success\": \"#1f5f4b\",\n \"--a2ui-color-border-danger\": \"#7a2f2b\",\n \"--a2ui-color-border-discovery\": \"#4f3a80\",\n \"--a2ui-color-border-control\": \"rgba(255, 255, 255, 0.2)\",\n \"--a2ui-color-accent\": \"#f2f2f2\",\n \"--a2ui-color-on-accent\": \"#0d0d0d\",\n \"--a2ui-color-panel\": \"#262626\",\n \"--a2ui-color-control\": \"#2f2f2f\",\n \"--a2ui-color-focus\": \"#3b9bff\",\n \"--a2ui-color-shimmer\": \"rgba(255, 255, 255, 0.12)\",\n \"--a2ui-color-chart-cursor\": \"rgba(255, 255, 255, 0.06)\",\n \"--a2ui-color-slider-track\": \"rgba(255, 255, 255, 0.1)\",\n \"--a2ui-color-badge-secondary\": \"rgba(255, 255, 255, 0.08)\",\n \"--a2ui-color-highlight-green\": \"#1d4a37\",\n \"--a2ui-color-highlight-orange\": \"#4d3418\",\n \"--a2ui-color-highlight-pink\": \"#4d2338\",\n \"--a2ui-shadow-xs\": \"0 1px 2px rgba(0, 0, 0, 0.5)\",\n \"--a2ui-shadow-sm\": \"0 1px 3px rgba(0, 0, 0, 0.5)\",\n \"--a2ui-shadow-soft\": \"0 1px 3px rgba(0, 0, 0, 0.3)\",\n \"--a2ui-shadow-md\": \"0 4px 12px rgba(0, 0, 0, 0.4)\",\n};\n\nconst VARIABLE_NAME = /^--a2ui-[a-z0-9-]+$/;\n// A value goes into a stylesheet, so it must not be able to end the rule or\n// the element.\nconst UNSAFE_VALUE = /[{};<>]/;\n\n/** Matches the `dark` class on an ancestor of a surface, or on the surface. */\nconst DARK = \":where(.dark)\";\n\n/** The default dark values, as a rule that any theme rule beats. */\nexport const DARK_THEME_CSS = `:where(.dark .a2ui-surface,.a2ui-surface.dark){${declarations(DARK_THEME)}}`;\n\nfunction declarations(values: GenerativeUIThemeValues | undefined) {\n return Object.entries(values ?? {})\n .filter(\n ([name, value]) =>\n VARIABLE_NAME.test(name) &&\n typeof value === \"string\" &&\n !UNSAFE_VALUE.test(value),\n )\n .map(([name, value]) => `${name}:${value}`)\n .join(\";\");\n}\n\n/** A short, stable id for a stylesheet. */\nfunction hashOf(text: string) {\n let hash = 5381;\n for (let index = 0; index < text.length; index++) {\n hash = (hash * 33) ^ text.charCodeAt(index);\n }\n return `t${(hash >>> 0).toString(36)}`;\n}\n\n/**\n * The stylesheet of a theme: its values on the surfaces that carry its id,\n * then its dark values in dark mode. `undefined` when the theme sets no\n * variable. Values that could break out of the rule are left out.\n *\n * @example\n * ```ts\n * themeStyleSheet({ \"--a2ui-color-accent\": \"red\" });\n * // { id: \"t…\", css: '.a2ui-surface[data-a2ui-theme=\"t…\"]{--a2ui-color-accent:red}' }\n * ```\n */\nexport function themeStyleSheet(theme: GenerativeUITheme | undefined) {\n const { dark, ...base } = theme ?? {};\n const both = declarations(base);\n const darkOnly = declarations(dark);\n if (!both && !darkOnly) return undefined;\n const id = hashOf(`${both}|${darkOnly}`);\n // The class makes these rules win over an app rule on `.a2ui-surface`.\n const self = `.a2ui-surface[data-a2ui-theme=\"${id}\"]`;\n const rules = [\n both && `${self}{${both}}`,\n darkOnly && `${DARK} ${self},${self}${DARK}{${darkOnly}}`,\n ].filter(Boolean);\n return { id, css: rules.join(\"\") };\n}\n"],"mappings":";;;;;;AA2EA,MAAa,aAAyC;CACpD,6BAA6B;CAC7B,2BAA2B;CAC3B,6BAA6B;CAC7B,8BAA8B;CAC9B,+BAA+B;CAC/B,8BAA8B;CAC9B,6BAA6B;CAC7B,0BAA0B;CAC1B,6BAA6B;CAC7B,6BAA6B;CAC7B,4BAA4B;CAC5B,+BAA+B;CAC/B,wBAAwB;CACxB,kCAAkC;CAClC,iCAAiC;CACjC,iCAAiC;CACjC,2CAA2C;CAC3C,iCAAiC;CACjC,6BAA6B;CAC7B,qBAAqB;CACrB,wBAA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,EAAE,MAAM,GAAG,SAAS,SAAS,EAAE;CACrC,MAAM,OAAO,aAAa,KAAK;CAC/B,MAAM,WAAW,aAAa,KAAK;AACnC,KAAI,CAAC,QAAQ,CAAC,SAAU,QAAO;CAC/B,MAAM,KAAK,OAAO,GAAG,KAAK,GAAG,WAAW;CAExC,MAAM,OAAO,kCAAkC,GAAG;AAKlD,QAAO;EAAE;EAAI,KAJC,CACZ,QAAQ,GAAG,KAAK,GAAG,KAAK,IACxB,YAAY,GAAG,KAAK,GAAG,KAAK,GAAG,OAAO,KAAK,GAAG,SAAS,GACxD,CAAC,OAAO,QAAQ,CACO,KAAK,GAAG;EAAE"}
@@ -0,0 +1,60 @@
1
+ import { BACKGROUNDS, BORDER_COLORS, RADII, TEXT_COLORS } from "./tokens.cjs";
2
+
3
+ //#region src/generative-ui/standard/theme.d.ts
4
+ type TextColor = (typeof TEXT_COLORS)[number];
5
+ type BorderColor = (typeof BORDER_COLORS)[number];
6
+ type Background = (typeof BACKGROUNDS)[number];
7
+ type Radius = Exclude<(typeof RADII)[number], "full">;
8
+ type Tint = "info" | "warning" | "caution" | "success" | "danger" | "discovery";
9
+ type ChartSeries = 1 | 2 | 3 | 4 | 5 | 6;
10
+ /** Every CSS variable that the standard components read. */
11
+ type GenerativeUIThemeVariable = `--a2ui-color-text-${TextColor}` | `--a2ui-color-${Background}` | `--a2ui-color-border-${BorderColor}` | `--a2ui-color-${Tint}-soft` | `--a2ui-radius-${Radius}` | `--a2ui-chart-${ChartSeries}` | "--a2ui-color-accent" | "--a2ui-color-on-accent" | "--a2ui-color-panel" | "--a2ui-color-control" | "--a2ui-color-focus" | "--a2ui-color-shimmer" | "--a2ui-color-chart-cursor" | "--a2ui-color-slider-track" | "--a2ui-color-badge-secondary" | "--a2ui-color-border-control" | "--a2ui-color-highlight-green" | "--a2ui-color-highlight-orange" | "--a2ui-color-highlight-pink" | "--a2ui-color-backdrop" | "--a2ui-color-overlay" | "--a2ui-color-rating" | "--a2ui-shadow-xs" | "--a2ui-shadow-sm" | "--a2ui-shadow-soft" | "--a2ui-shadow-md" | "--a2ui-font-family" | "--a2ui-heading-margin" | "--a2ui-block-margin";
12
+ /** Values for the theme variables. A name that is not one is a type error. */
13
+ type GenerativeUIThemeVariables = { [Variable in GenerativeUIThemeVariable]?: string };
14
+ /** The values of one color scheme, plus the map style of that scheme. */
15
+ type GenerativeUIThemeValues = GenerativeUIThemeVariables & {
16
+ /** A MapLibre style URL for the Map component. */mapStyle?: string;
17
+ };
18
+ /**
19
+ * The look of generated UI. Values at the top level apply in light and in
20
+ * dark mode. Values in `dark` replace them in dark mode. Dark mode is on
21
+ * when an ancestor of the surface has the `dark` class, like the CopilotKit
22
+ * chat.
23
+ *
24
+ * @example
25
+ * ```ts
26
+ * const theme: GenerativeUITheme = {
27
+ * "--a2ui-color-accent": "#d97706",
28
+ * "--a2ui-font-family": "Inter, sans-serif",
29
+ * dark: { "--a2ui-color-panel": "#1f2937" },
30
+ * };
31
+ * ```
32
+ */
33
+ type GenerativeUITheme = GenerativeUIThemeValues & {
34
+ dark?: GenerativeUIThemeValues;
35
+ };
36
+ /**
37
+ * The built-in dark values. The light values are the fallbacks in the
38
+ * components, so a surface is light when no variable is set.
39
+ */
40
+ declare const DARK_THEME: GenerativeUIThemeVariables;
41
+ /** The default dark values, as a rule that any theme rule beats. */
42
+ declare const DARK_THEME_CSS: string;
43
+ /**
44
+ * The stylesheet of a theme: its values on the surfaces that carry its id,
45
+ * then its dark values in dark mode. `undefined` when the theme sets no
46
+ * variable. Values that could break out of the rule are left out.
47
+ *
48
+ * @example
49
+ * ```ts
50
+ * themeStyleSheet({ "--a2ui-color-accent": "red" });
51
+ * // { id: "t…", css: '.a2ui-surface[data-a2ui-theme="t…"]{--a2ui-color-accent:red}' }
52
+ * ```
53
+ */
54
+ declare function themeStyleSheet(theme: GenerativeUITheme | undefined): {
55
+ id: string;
56
+ css: string;
57
+ } | undefined;
58
+ //#endregion
59
+ export { DARK_THEME, DARK_THEME_CSS, GenerativeUITheme, GenerativeUIThemeValues, GenerativeUIThemeVariable, GenerativeUIThemeVariables, themeStyleSheet };
60
+ //# sourceMappingURL=theme.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme.d.cts","names":[],"sources":["../../../src/generative-ui/standard/theme.ts"],"mappings":";;;KAEK,SAAA,WAAoB,WAAA;AAAA,KACpB,WAAA,WAAsB,aAAA;AAAA,KACtB,UAAA,WAAqB,WAAA;AAAA,KACrB,MAAA,GAAS,OAAA,SAAgB,KAAA;AAAA,KACzB,IAAA;AAAA,KACA,WAAA;;KAGO,yBAAA,wBACa,SAAA,qBACL,UAAA,4BACO,WAAA,qBACP,IAAA,2BACC,MAAA,qBACD,WAAA;;KA0BR,0BAAA,kBACG,yBAAA;AAxCyB;AAAA,KA4C5B,uBAAA,GAA0B,0BAAA;oDAEpC,QAAA;AAAA;AA7CmC;;;;;AACF;;;;;AAC1B;;;;;AAF4B,KA+DzB,iBAAA,GAAoB,uBAAA;EAC9B,IAAA,GAAO,uBAAA;AAAA;;;;;cAOI,UAAA,EAAY,0BAAA;;cA2EZ,cAAA;;;;;;;;;;AA5Gb;;iBA8IgB,eAAA,CAAgB,KAAA,EAAO,iBAAA"}
@@ -0,0 +1,60 @@
1
+ import { BACKGROUNDS, BORDER_COLORS, RADII, TEXT_COLORS } from "./tokens.mjs";
2
+
3
+ //#region src/generative-ui/standard/theme.d.ts
4
+ type TextColor = (typeof TEXT_COLORS)[number];
5
+ type BorderColor = (typeof BORDER_COLORS)[number];
6
+ type Background = (typeof BACKGROUNDS)[number];
7
+ type Radius = Exclude<(typeof RADII)[number], "full">;
8
+ type Tint = "info" | "warning" | "caution" | "success" | "danger" | "discovery";
9
+ type ChartSeries = 1 | 2 | 3 | 4 | 5 | 6;
10
+ /** Every CSS variable that the standard components read. */
11
+ type GenerativeUIThemeVariable = `--a2ui-color-text-${TextColor}` | `--a2ui-color-${Background}` | `--a2ui-color-border-${BorderColor}` | `--a2ui-color-${Tint}-soft` | `--a2ui-radius-${Radius}` | `--a2ui-chart-${ChartSeries}` | "--a2ui-color-accent" | "--a2ui-color-on-accent" | "--a2ui-color-panel" | "--a2ui-color-control" | "--a2ui-color-focus" | "--a2ui-color-shimmer" | "--a2ui-color-chart-cursor" | "--a2ui-color-slider-track" | "--a2ui-color-badge-secondary" | "--a2ui-color-border-control" | "--a2ui-color-highlight-green" | "--a2ui-color-highlight-orange" | "--a2ui-color-highlight-pink" | "--a2ui-color-backdrop" | "--a2ui-color-overlay" | "--a2ui-color-rating" | "--a2ui-shadow-xs" | "--a2ui-shadow-sm" | "--a2ui-shadow-soft" | "--a2ui-shadow-md" | "--a2ui-font-family" | "--a2ui-heading-margin" | "--a2ui-block-margin";
12
+ /** Values for the theme variables. A name that is not one is a type error. */
13
+ type GenerativeUIThemeVariables = { [Variable in GenerativeUIThemeVariable]?: string };
14
+ /** The values of one color scheme, plus the map style of that scheme. */
15
+ type GenerativeUIThemeValues = GenerativeUIThemeVariables & {
16
+ /** A MapLibre style URL for the Map component. */mapStyle?: string;
17
+ };
18
+ /**
19
+ * The look of generated UI. Values at the top level apply in light and in
20
+ * dark mode. Values in `dark` replace them in dark mode. Dark mode is on
21
+ * when an ancestor of the surface has the `dark` class, like the CopilotKit
22
+ * chat.
23
+ *
24
+ * @example
25
+ * ```ts
26
+ * const theme: GenerativeUITheme = {
27
+ * "--a2ui-color-accent": "#d97706",
28
+ * "--a2ui-font-family": "Inter, sans-serif",
29
+ * dark: { "--a2ui-color-panel": "#1f2937" },
30
+ * };
31
+ * ```
32
+ */
33
+ type GenerativeUITheme = GenerativeUIThemeValues & {
34
+ dark?: GenerativeUIThemeValues;
35
+ };
36
+ /**
37
+ * The built-in dark values. The light values are the fallbacks in the
38
+ * components, so a surface is light when no variable is set.
39
+ */
40
+ declare const DARK_THEME: GenerativeUIThemeVariables;
41
+ /** The default dark values, as a rule that any theme rule beats. */
42
+ declare const DARK_THEME_CSS: string;
43
+ /**
44
+ * The stylesheet of a theme: its values on the surfaces that carry its id,
45
+ * then its dark values in dark mode. `undefined` when the theme sets no
46
+ * variable. Values that could break out of the rule are left out.
47
+ *
48
+ * @example
49
+ * ```ts
50
+ * themeStyleSheet({ "--a2ui-color-accent": "red" });
51
+ * // { id: "t…", css: '.a2ui-surface[data-a2ui-theme="t…"]{--a2ui-color-accent:red}' }
52
+ * ```
53
+ */
54
+ declare function themeStyleSheet(theme: GenerativeUITheme | undefined): {
55
+ id: string;
56
+ css: string;
57
+ } | undefined;
58
+ //#endregion
59
+ export { DARK_THEME, DARK_THEME_CSS, GenerativeUITheme, GenerativeUIThemeValues, GenerativeUIThemeVariable, GenerativeUIThemeVariables, themeStyleSheet };
60
+ //# sourceMappingURL=theme.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme.d.mts","names":[],"sources":["../../../src/generative-ui/standard/theme.ts"],"mappings":";;;KAEK,SAAA,WAAoB,WAAA;AAAA,KACpB,WAAA,WAAsB,aAAA;AAAA,KACtB,UAAA,WAAqB,WAAA;AAAA,KACrB,MAAA,GAAS,OAAA,SAAgB,KAAA;AAAA,KACzB,IAAA;AAAA,KACA,WAAA;;KAGO,yBAAA,wBACa,SAAA,qBACL,UAAA,4BACO,WAAA,qBACP,IAAA,2BACC,MAAA,qBACD,WAAA;;KA0BR,0BAAA,kBACG,yBAAA;AAxCyB;AAAA,KA4C5B,uBAAA,GAA0B,0BAAA;oDAEpC,QAAA;AAAA;AA7CmC;;;;;AACF;;;;;AAC1B;;;;;AAF4B,KA+DzB,iBAAA,GAAoB,uBAAA;EAC9B,IAAA,GAAO,uBAAA;AAAA;;;;;cAOI,UAAA,EAAY,0BAAA;;cA2EZ,cAAA;;;;;;;;;;AA5Gb;;iBA8IgB,eAAA,CAAgB,KAAA,EAAO,iBAAA"}
@@ -0,0 +1,112 @@
1
+ //#region src/generative-ui/standard/theme.ts
2
+ /**
3
+ * The built-in dark values. The light values are the fallbacks in the
4
+ * components, so a surface is light when no variable is set.
5
+ */
6
+ const DARK_THEME = {
7
+ "--a2ui-color-text-default": "#ececec",
8
+ "--a2ui-color-text-prose": "#ececec",
9
+ "--a2ui-color-text-primary": "#ececec",
10
+ "--a2ui-color-text-emphasis": "#fff",
11
+ "--a2ui-color-text-secondary": "#b4b4b4",
12
+ "--a2ui-color-text-tertiary": "#8e8e8e",
13
+ "--a2ui-color-text-success": "#4fd1a5",
14
+ "--a2ui-color-text-info": "#6cb6ff",
15
+ "--a2ui-color-text-warning": "#e3b341",
16
+ "--a2ui-color-text-caution": "#e3b341",
17
+ "--a2ui-color-text-danger": "#ff7b72",
18
+ "--a2ui-color-text-discovery": "#bc9cff",
19
+ "--a2ui-color-surface": "#1f1f1f",
20
+ "--a2ui-color-surface-secondary": "#2a2a2a",
21
+ "--a2ui-color-surface-tertiary": "#3a3a3a",
22
+ "--a2ui-color-surface-elevated": "#262626",
23
+ "--a2ui-color-surface-elevated-secondary": "#2f2f2f",
24
+ "--a2ui-color-surface-inverted": "#f2f2f2",
25
+ "--a2ui-color-surface-soft": "#232323",
26
+ "--a2ui-color-info": "rgba(80, 160, 255, 0.14)",
27
+ "--a2ui-color-warning": "rgba(240, 180, 60, 0.14)",
28
+ "--a2ui-color-caution": "rgba(240, 180, 60, 0.14)",
29
+ "--a2ui-color-success": "rgba(60, 200, 150, 0.14)",
30
+ "--a2ui-color-danger": "rgba(255, 110, 100, 0.14)",
31
+ "--a2ui-color-discovery": "rgba(170, 130, 255, 0.14)",
32
+ "--a2ui-color-info-soft": "rgba(80, 160, 255, 0.08)",
33
+ "--a2ui-color-warning-soft": "rgba(240, 180, 60, 0.08)",
34
+ "--a2ui-color-caution-soft": "rgba(240, 180, 60, 0.08)",
35
+ "--a2ui-color-success-soft": "rgba(60, 200, 150, 0.08)",
36
+ "--a2ui-color-danger-soft": "rgba(255, 110, 100, 0.08)",
37
+ "--a2ui-color-discovery-soft": "rgba(170, 130, 255, 0.08)",
38
+ "--a2ui-color-info-solid": "#3b8eea",
39
+ "--a2ui-color-warning-solid": "#c99a2e",
40
+ "--a2ui-color-caution-solid": "#c99a2e",
41
+ "--a2ui-color-success-solid": "#2fae86",
42
+ "--a2ui-color-danger-solid": "#e5534b",
43
+ "--a2ui-color-discovery-solid": "#9a6ff0",
44
+ "--a2ui-color-border-default": "rgba(255, 255, 255, 0.12)",
45
+ "--a2ui-color-border-subtle": "rgba(255, 255, 255, 0.06)",
46
+ "--a2ui-color-border-strong": "#4a4a4a",
47
+ "--a2ui-color-border-info": "#2f5f8f",
48
+ "--a2ui-color-border-warning": "#6b5420",
49
+ "--a2ui-color-border-caution": "#6b5420",
50
+ "--a2ui-color-border-success": "#1f5f4b",
51
+ "--a2ui-color-border-danger": "#7a2f2b",
52
+ "--a2ui-color-border-discovery": "#4f3a80",
53
+ "--a2ui-color-border-control": "rgba(255, 255, 255, 0.2)",
54
+ "--a2ui-color-accent": "#f2f2f2",
55
+ "--a2ui-color-on-accent": "#0d0d0d",
56
+ "--a2ui-color-panel": "#262626",
57
+ "--a2ui-color-control": "#2f2f2f",
58
+ "--a2ui-color-focus": "#3b9bff",
59
+ "--a2ui-color-shimmer": "rgba(255, 255, 255, 0.12)",
60
+ "--a2ui-color-chart-cursor": "rgba(255, 255, 255, 0.06)",
61
+ "--a2ui-color-slider-track": "rgba(255, 255, 255, 0.1)",
62
+ "--a2ui-color-badge-secondary": "rgba(255, 255, 255, 0.08)",
63
+ "--a2ui-color-highlight-green": "#1d4a37",
64
+ "--a2ui-color-highlight-orange": "#4d3418",
65
+ "--a2ui-color-highlight-pink": "#4d2338",
66
+ "--a2ui-shadow-xs": "0 1px 2px rgba(0, 0, 0, 0.5)",
67
+ "--a2ui-shadow-sm": "0 1px 3px rgba(0, 0, 0, 0.5)",
68
+ "--a2ui-shadow-soft": "0 1px 3px rgba(0, 0, 0, 0.3)",
69
+ "--a2ui-shadow-md": "0 4px 12px rgba(0, 0, 0, 0.4)"
70
+ };
71
+ const VARIABLE_NAME = /^--a2ui-[a-z0-9-]+$/;
72
+ const UNSAFE_VALUE = /[{};<>]/;
73
+ /** Matches the `dark` class on an ancestor of a surface, or on the surface. */
74
+ const DARK = ":where(.dark)";
75
+ /** The default dark values, as a rule that any theme rule beats. */
76
+ const DARK_THEME_CSS = `:where(.dark .a2ui-surface,.a2ui-surface.dark){${declarations(DARK_THEME)}}`;
77
+ function declarations(values) {
78
+ return Object.entries(values ?? {}).filter(([name, value]) => VARIABLE_NAME.test(name) && typeof value === "string" && !UNSAFE_VALUE.test(value)).map(([name, value]) => `${name}:${value}`).join(";");
79
+ }
80
+ /** A short, stable id for a stylesheet. */
81
+ function hashOf(text) {
82
+ let hash = 5381;
83
+ for (let index = 0; index < text.length; index++) hash = hash * 33 ^ text.charCodeAt(index);
84
+ return `t${(hash >>> 0).toString(36)}`;
85
+ }
86
+ /**
87
+ * The stylesheet of a theme: its values on the surfaces that carry its id,
88
+ * then its dark values in dark mode. `undefined` when the theme sets no
89
+ * variable. Values that could break out of the rule are left out.
90
+ *
91
+ * @example
92
+ * ```ts
93
+ * themeStyleSheet({ "--a2ui-color-accent": "red" });
94
+ * // { id: "t…", css: '.a2ui-surface[data-a2ui-theme="t…"]{--a2ui-color-accent:red}' }
95
+ * ```
96
+ */
97
+ function themeStyleSheet(theme) {
98
+ const { dark, ...base } = theme ?? {};
99
+ const both = declarations(base);
100
+ const darkOnly = declarations(dark);
101
+ if (!both && !darkOnly) return void 0;
102
+ const id = hashOf(`${both}|${darkOnly}`);
103
+ const self = `.a2ui-surface[data-a2ui-theme="${id}"]`;
104
+ return {
105
+ id,
106
+ css: [both && `${self}{${both}}`, darkOnly && `${DARK} ${self},${self}${DARK}{${darkOnly}}`].filter(Boolean).join("")
107
+ };
108
+ }
109
+
110
+ //#endregion
111
+ export { DARK_THEME, DARK_THEME_CSS, themeStyleSheet };
112
+ //# sourceMappingURL=theme.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme.mjs","names":[],"sources":["../../../src/generative-ui/standard/theme.ts"],"sourcesContent":["import type { BACKGROUNDS, BORDER_COLORS, RADII, TEXT_COLORS } from \"./tokens\";\n\ntype TextColor = (typeof TEXT_COLORS)[number];\ntype BorderColor = (typeof BORDER_COLORS)[number];\ntype Background = (typeof BACKGROUNDS)[number];\ntype Radius = Exclude<(typeof RADII)[number], \"full\">;\ntype Tint = \"info\" | \"warning\" | \"caution\" | \"success\" | \"danger\" | \"discovery\";\ntype ChartSeries = 1 | 2 | 3 | 4 | 5 | 6;\n\n/** Every CSS variable that the standard components read. */\nexport type GenerativeUIThemeVariable =\n | `--a2ui-color-text-${TextColor}`\n | `--a2ui-color-${Background}`\n | `--a2ui-color-border-${BorderColor}`\n | `--a2ui-color-${Tint}-soft`\n | `--a2ui-radius-${Radius}`\n | `--a2ui-chart-${ChartSeries}`\n | \"--a2ui-color-accent\"\n | \"--a2ui-color-on-accent\"\n | \"--a2ui-color-panel\"\n | \"--a2ui-color-control\"\n | \"--a2ui-color-focus\"\n | \"--a2ui-color-shimmer\"\n | \"--a2ui-color-chart-cursor\"\n | \"--a2ui-color-slider-track\"\n | \"--a2ui-color-badge-secondary\"\n | \"--a2ui-color-border-control\"\n | \"--a2ui-color-highlight-green\"\n | \"--a2ui-color-highlight-orange\"\n | \"--a2ui-color-highlight-pink\"\n | \"--a2ui-color-backdrop\"\n | \"--a2ui-color-overlay\"\n | \"--a2ui-color-rating\"\n | \"--a2ui-shadow-xs\"\n | \"--a2ui-shadow-sm\"\n | \"--a2ui-shadow-soft\"\n | \"--a2ui-shadow-md\"\n | \"--a2ui-font-family\"\n | \"--a2ui-heading-margin\"\n | \"--a2ui-block-margin\";\n\n/** Values for the theme variables. A name that is not one is a type error. */\nexport type GenerativeUIThemeVariables = {\n [Variable in GenerativeUIThemeVariable]?: string;\n};\n\n/** The values of one color scheme, plus the map style of that scheme. */\nexport type GenerativeUIThemeValues = GenerativeUIThemeVariables & {\n /** A MapLibre style URL for the Map component. */\n mapStyle?: string;\n};\n\n/**\n * The look of generated UI. Values at the top level apply in light and in\n * dark mode. Values in `dark` replace them in dark mode. Dark mode is on\n * when an ancestor of the surface has the `dark` class, like the CopilotKit\n * chat.\n *\n * @example\n * ```ts\n * const theme: GenerativeUITheme = {\n * \"--a2ui-color-accent\": \"#d97706\",\n * \"--a2ui-font-family\": \"Inter, sans-serif\",\n * dark: { \"--a2ui-color-panel\": \"#1f2937\" },\n * };\n * ```\n */\nexport type GenerativeUITheme = GenerativeUIThemeValues & {\n dark?: GenerativeUIThemeValues;\n};\n\n/**\n * The built-in dark values. The light values are the fallbacks in the\n * components, so a surface is light when no variable is set.\n */\nexport const DARK_THEME: GenerativeUIThemeVariables = {\n \"--a2ui-color-text-default\": \"#ececec\",\n \"--a2ui-color-text-prose\": \"#ececec\",\n \"--a2ui-color-text-primary\": \"#ececec\",\n \"--a2ui-color-text-emphasis\": \"#fff\",\n \"--a2ui-color-text-secondary\": \"#b4b4b4\",\n \"--a2ui-color-text-tertiary\": \"#8e8e8e\",\n \"--a2ui-color-text-success\": \"#4fd1a5\",\n \"--a2ui-color-text-info\": \"#6cb6ff\",\n \"--a2ui-color-text-warning\": \"#e3b341\",\n \"--a2ui-color-text-caution\": \"#e3b341\",\n \"--a2ui-color-text-danger\": \"#ff7b72\",\n \"--a2ui-color-text-discovery\": \"#bc9cff\",\n \"--a2ui-color-surface\": \"#1f1f1f\",\n \"--a2ui-color-surface-secondary\": \"#2a2a2a\",\n \"--a2ui-color-surface-tertiary\": \"#3a3a3a\",\n \"--a2ui-color-surface-elevated\": \"#262626\",\n \"--a2ui-color-surface-elevated-secondary\": \"#2f2f2f\",\n \"--a2ui-color-surface-inverted\": \"#f2f2f2\",\n \"--a2ui-color-surface-soft\": \"#232323\",\n \"--a2ui-color-info\": \"rgba(80, 160, 255, 0.14)\",\n \"--a2ui-color-warning\": \"rgba(240, 180, 60, 0.14)\",\n \"--a2ui-color-caution\": \"rgba(240, 180, 60, 0.14)\",\n \"--a2ui-color-success\": \"rgba(60, 200, 150, 0.14)\",\n \"--a2ui-color-danger\": \"rgba(255, 110, 100, 0.14)\",\n \"--a2ui-color-discovery\": \"rgba(170, 130, 255, 0.14)\",\n \"--a2ui-color-info-soft\": \"rgba(80, 160, 255, 0.08)\",\n \"--a2ui-color-warning-soft\": \"rgba(240, 180, 60, 0.08)\",\n \"--a2ui-color-caution-soft\": \"rgba(240, 180, 60, 0.08)\",\n \"--a2ui-color-success-soft\": \"rgba(60, 200, 150, 0.08)\",\n \"--a2ui-color-danger-soft\": \"rgba(255, 110, 100, 0.08)\",\n \"--a2ui-color-discovery-soft\": \"rgba(170, 130, 255, 0.08)\",\n \"--a2ui-color-info-solid\": \"#3b8eea\",\n \"--a2ui-color-warning-solid\": \"#c99a2e\",\n \"--a2ui-color-caution-solid\": \"#c99a2e\",\n \"--a2ui-color-success-solid\": \"#2fae86\",\n \"--a2ui-color-danger-solid\": \"#e5534b\",\n \"--a2ui-color-discovery-solid\": \"#9a6ff0\",\n \"--a2ui-color-border-default\": \"rgba(255, 255, 255, 0.12)\",\n \"--a2ui-color-border-subtle\": \"rgba(255, 255, 255, 0.06)\",\n \"--a2ui-color-border-strong\": \"#4a4a4a\",\n \"--a2ui-color-border-info\": \"#2f5f8f\",\n \"--a2ui-color-border-warning\": \"#6b5420\",\n \"--a2ui-color-border-caution\": \"#6b5420\",\n \"--a2ui-color-border-success\": \"#1f5f4b\",\n \"--a2ui-color-border-danger\": \"#7a2f2b\",\n \"--a2ui-color-border-discovery\": \"#4f3a80\",\n \"--a2ui-color-border-control\": \"rgba(255, 255, 255, 0.2)\",\n \"--a2ui-color-accent\": \"#f2f2f2\",\n \"--a2ui-color-on-accent\": \"#0d0d0d\",\n \"--a2ui-color-panel\": \"#262626\",\n \"--a2ui-color-control\": \"#2f2f2f\",\n \"--a2ui-color-focus\": \"#3b9bff\",\n \"--a2ui-color-shimmer\": \"rgba(255, 255, 255, 0.12)\",\n \"--a2ui-color-chart-cursor\": \"rgba(255, 255, 255, 0.06)\",\n \"--a2ui-color-slider-track\": \"rgba(255, 255, 255, 0.1)\",\n \"--a2ui-color-badge-secondary\": \"rgba(255, 255, 255, 0.08)\",\n \"--a2ui-color-highlight-green\": \"#1d4a37\",\n \"--a2ui-color-highlight-orange\": \"#4d3418\",\n \"--a2ui-color-highlight-pink\": \"#4d2338\",\n \"--a2ui-shadow-xs\": \"0 1px 2px rgba(0, 0, 0, 0.5)\",\n \"--a2ui-shadow-sm\": \"0 1px 3px rgba(0, 0, 0, 0.5)\",\n \"--a2ui-shadow-soft\": \"0 1px 3px rgba(0, 0, 0, 0.3)\",\n \"--a2ui-shadow-md\": \"0 4px 12px rgba(0, 0, 0, 0.4)\",\n};\n\nconst VARIABLE_NAME = /^--a2ui-[a-z0-9-]+$/;\n// A value goes into a stylesheet, so it must not be able to end the rule or\n// the element.\nconst UNSAFE_VALUE = /[{};<>]/;\n\n/** Matches the `dark` class on an ancestor of a surface, or on the surface. */\nconst DARK = \":where(.dark)\";\n\n/** The default dark values, as a rule that any theme rule beats. */\nexport const DARK_THEME_CSS = `:where(.dark .a2ui-surface,.a2ui-surface.dark){${declarations(DARK_THEME)}}`;\n\nfunction declarations(values: GenerativeUIThemeValues | undefined) {\n return Object.entries(values ?? {})\n .filter(\n ([name, value]) =>\n VARIABLE_NAME.test(name) &&\n typeof value === \"string\" &&\n !UNSAFE_VALUE.test(value),\n )\n .map(([name, value]) => `${name}:${value}`)\n .join(\";\");\n}\n\n/** A short, stable id for a stylesheet. */\nfunction hashOf(text: string) {\n let hash = 5381;\n for (let index = 0; index < text.length; index++) {\n hash = (hash * 33) ^ text.charCodeAt(index);\n }\n return `t${(hash >>> 0).toString(36)}`;\n}\n\n/**\n * The stylesheet of a theme: its values on the surfaces that carry its id,\n * then its dark values in dark mode. `undefined` when the theme sets no\n * variable. Values that could break out of the rule are left out.\n *\n * @example\n * ```ts\n * themeStyleSheet({ \"--a2ui-color-accent\": \"red\" });\n * // { id: \"t…\", css: '.a2ui-surface[data-a2ui-theme=\"t…\"]{--a2ui-color-accent:red}' }\n * ```\n */\nexport function themeStyleSheet(theme: GenerativeUITheme | undefined) {\n const { dark, ...base } = theme ?? {};\n const both = declarations(base);\n const darkOnly = declarations(dark);\n if (!both && !darkOnly) return undefined;\n const id = hashOf(`${both}|${darkOnly}`);\n // The class makes these rules win over an app rule on `.a2ui-surface`.\n const self = `.a2ui-surface[data-a2ui-theme=\"${id}\"]`;\n const rules = [\n both && `${self}{${both}}`,\n darkOnly && `${DARK} ${self},${self}${DARK}{${darkOnly}}`,\n ].filter(Boolean);\n return { id, css: rules.join(\"\") };\n}\n"],"mappings":";;;;;AA2EA,MAAa,aAAyC;CACpD,6BAA6B;CAC7B,2BAA2B;CAC3B,6BAA6B;CAC7B,8BAA8B;CAC9B,+BAA+B;CAC/B,8BAA8B;CAC9B,6BAA6B;CAC7B,0BAA0B;CAC1B,6BAA6B;CAC7B,6BAA6B;CAC7B,4BAA4B;CAC5B,+BAA+B;CAC/B,wBAAwB;CACxB,kCAAkC;CAClC,iCAAiC;CACjC,iCAAiC;CACjC,2CAA2C;CAC3C,iCAAiC;CACjC,6BAA6B;CAC7B,qBAAqB;CACrB,wBAAwB;CACxB,wBAAwB;CACxB,wBAAwB;CACxB,uBAAuB;CACvB,0BAA0B;CAC1B,0BAA0B;CAC1B,6BAA6B;CAC7B,6BAA6B;CAC7B,6BAA6B;CAC7B,4BAA4B;CAC5B,+BAA+B;CAC/B,2BAA2B;CAC3B,8BAA8B;CAC9B,8BAA8B;CAC9B,8BAA8B;CAC9B,6BAA6B;CAC7B,gCAAgC;CAChC,+BAA+B;CAC/B,8BAA8B;CAC9B,8BAA8B;CAC9B,4BAA4B;CAC5B,+BAA+B;CAC/B,+BAA+B;CAC/B,+BAA+B;CAC/B,8BAA8B;CAC9B,iCAAiC;CACjC,+BAA+B;CAC/B,uBAAuB;CACvB,0BAA0B;CAC1B,sBAAsB;CACtB,wBAAwB;CACxB,sBAAsB;CACtB,wBAAwB;CACxB,6BAA6B;CAC7B,6BAA6B;CAC7B,gCAAgC;CAChC,gCAAgC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