@wallarm-org/design-system 3.2.0 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (169) hide show
  1. package/dist/components/AnimatedBackground/blur/BlurBackground.d.ts +6 -0
  2. package/dist/components/AnimatedBackground/blur/BlurBackground.js +176 -76
  3. package/dist/components/AnimatedBackground/blur/index.d.ts +1 -1
  4. package/dist/components/AnimatedBackground/index.d.ts +1 -1
  5. package/dist/components/ApprovalCard/ApprovalCard.d.ts +13 -0
  6. package/dist/components/ApprovalCard/ApprovalCard.js +249 -0
  7. package/dist/components/ApprovalCard/ApprovalCardActions.d.ts +6 -0
  8. package/dist/components/ApprovalCard/ApprovalCardActions.js +50 -0
  9. package/dist/components/ApprovalCard/ApprovalCardContent.d.ts +6 -0
  10. package/dist/components/ApprovalCard/ApprovalCardContent.js +50 -0
  11. package/dist/components/ApprovalCard/classes.d.ts +10 -0
  12. package/dist/components/ApprovalCard/classes.js +26 -0
  13. package/dist/components/ApprovalCard/index.d.ts +3 -0
  14. package/dist/components/ApprovalCard/index.js +3 -0
  15. package/dist/components/AssistantMessage/AssistantMessage.d.ts +12 -0
  16. package/dist/components/AssistantMessage/AssistantMessage.js +66 -0
  17. package/dist/components/AssistantMessage/AssistantMessageContent.d.ts +10 -0
  18. package/dist/components/AssistantMessage/AssistantMessageContent.js +50 -0
  19. package/dist/components/AssistantMessage/AssistantMessageError.d.ts +13 -0
  20. package/dist/components/AssistantMessage/AssistantMessageError.js +93 -0
  21. package/dist/components/AssistantMessage/AssistantMessageLoader.d.ts +13 -0
  22. package/dist/components/AssistantMessage/AssistantMessageLoader.js +88 -0
  23. package/dist/components/AssistantMessage/AssistantMessageMarkdown.d.ts +71 -0
  24. package/dist/components/AssistantMessage/AssistantMessageMarkdown.js +278 -0
  25. package/dist/components/AssistantMessage/AssistantMessageMarkdownCodeBlock.d.ts +17 -0
  26. package/dist/components/AssistantMessage/AssistantMessageMarkdownCodeBlock.js +94 -0
  27. package/dist/components/AssistantMessage/AssistantMessageMarkdownInlineCode.d.ts +10 -0
  28. package/dist/components/AssistantMessage/AssistantMessageMarkdownInlineCode.js +59 -0
  29. package/dist/components/AssistantMessage/AssistantMessageMarkdownLink.d.ts +14 -0
  30. package/dist/components/AssistantMessage/AssistantMessageMarkdownLink.js +65 -0
  31. package/dist/components/AssistantMessage/AssistantMessageMarkdownTable.d.ts +7 -0
  32. package/dist/components/AssistantMessage/AssistantMessageMarkdownTable.js +70 -0
  33. package/dist/components/AssistantMessage/classes.d.ts +38 -0
  34. package/dist/components/AssistantMessage/classes.js +46 -0
  35. package/dist/components/AssistantMessage/index.d.ts +9 -0
  36. package/dist/components/AssistantMessage/index.js +9 -0
  37. package/dist/components/AssistantMessage/lib/markdown.d.ts +20 -0
  38. package/dist/components/AssistantMessage/lib/markdown.js +51 -0
  39. package/dist/components/ChainOfThought/ChainOfThought.d.ts +10 -0
  40. package/dist/components/ChainOfThought/ChainOfThought.js +66 -0
  41. package/dist/components/ChainOfThought/ChainOfThoughtStep.d.ts +31 -0
  42. package/dist/components/ChainOfThought/ChainOfThoughtStep.js +312 -0
  43. package/dist/components/ChainOfThought/classes.d.ts +20 -0
  44. package/dist/components/ChainOfThought/classes.js +84 -0
  45. package/dist/components/ChainOfThought/index.d.ts +2 -0
  46. package/dist/components/ChainOfThought/index.js +2 -0
  47. package/dist/components/Chat/Chat.d.ts +12 -0
  48. package/dist/components/Chat/Chat.js +90 -0
  49. package/dist/components/Chat/ChatBody.d.ts +12 -0
  50. package/dist/components/Chat/ChatBody.js +52 -0
  51. package/dist/components/Chat/ChatFooter.d.ts +7 -0
  52. package/dist/components/Chat/ChatFooter.js +50 -0
  53. package/dist/components/Chat/ChatGreeting.d.ts +8 -0
  54. package/dist/components/Chat/ChatGreeting.js +94 -0
  55. package/dist/components/Chat/ChatHeader.d.ts +6 -0
  56. package/dist/components/Chat/ChatHeader.js +50 -0
  57. package/dist/components/Chat/ChatHeaderActions.d.ts +7 -0
  58. package/dist/components/Chat/ChatHeaderActions.js +50 -0
  59. package/dist/components/Chat/ChatHeaderTitle.d.ts +12 -0
  60. package/dist/components/Chat/ChatHeaderTitle.js +99 -0
  61. package/dist/components/Chat/ChatSuggestion.d.ts +7 -0
  62. package/dist/components/Chat/ChatSuggestion.js +56 -0
  63. package/dist/components/Chat/ChatSuggestions.d.ts +14 -0
  64. package/dist/components/Chat/ChatSuggestions.js +111 -0
  65. package/dist/components/Chat/ChatSuggestionsContext.d.ts +7 -0
  66. package/dist/components/Chat/ChatSuggestionsContext.js +7 -0
  67. package/dist/components/Chat/ChatTrigger.d.ts +13 -0
  68. package/dist/components/Chat/ChatTrigger.js +101 -0
  69. package/dist/components/Chat/classes.d.ts +17 -0
  70. package/dist/components/Chat/classes.js +44 -0
  71. package/dist/components/Chat/index.d.ts +10 -0
  72. package/dist/components/Chat/index.js +10 -0
  73. package/dist/components/ChatInput/ChatInput.d.ts +30 -0
  74. package/dist/components/ChatInput/ChatInput.js +230 -0
  75. package/dist/components/ChatInput/ChatInputContext.d.ts +11 -0
  76. package/dist/components/ChatInput/ChatInputContext.js +8 -0
  77. package/dist/components/ChatInput/ChatInputSubmit.d.ts +10 -0
  78. package/dist/components/ChatInput/ChatInputSubmit.js +175 -0
  79. package/dist/components/ChatInput/ChatInputTextarea.d.ts +6 -0
  80. package/dist/components/ChatInput/ChatInputTextarea.js +155 -0
  81. package/dist/components/ChatInput/classes.d.ts +9 -0
  82. package/dist/components/ChatInput/classes.js +22 -0
  83. package/dist/components/ChatInput/index.d.ts +3 -0
  84. package/dist/components/ChatInput/index.js +3 -0
  85. package/dist/components/ChatPermissions/ChatPermissions.d.ts +12 -0
  86. package/dist/components/ChatPermissions/ChatPermissions.js +66 -0
  87. package/dist/components/ChatPermissions/ChatPermissionsContent.d.ts +7 -0
  88. package/dist/components/ChatPermissions/ChatPermissionsContent.js +73 -0
  89. package/dist/components/ChatPermissions/ChatPermissionsContext.d.ts +7 -0
  90. package/dist/components/ChatPermissions/ChatPermissionsContext.js +8 -0
  91. package/dist/components/ChatPermissions/ChatPermissionsItem.d.ts +17 -0
  92. package/dist/components/ChatPermissions/ChatPermissionsItem.js +115 -0
  93. package/dist/components/ChatPermissions/ChatPermissionsTrigger.d.ts +6 -0
  94. package/dist/components/ChatPermissions/ChatPermissionsTrigger.js +110 -0
  95. package/dist/components/ChatPermissions/classes.d.ts +3 -0
  96. package/dist/components/ChatPermissions/classes.js +5 -0
  97. package/dist/components/ChatPermissions/index.d.ts +4 -0
  98. package/dist/components/ChatPermissions/index.js +4 -0
  99. package/dist/components/Conversation/Conversation.d.ts +19 -0
  100. package/dist/components/Conversation/Conversation.js +102 -0
  101. package/dist/components/Conversation/ConversationContent.d.ts +11 -0
  102. package/dist/components/Conversation/ConversationContent.js +103 -0
  103. package/dist/components/Conversation/ConversationContext.d.ts +14 -0
  104. package/dist/components/Conversation/ConversationContext.js +8 -0
  105. package/dist/components/Conversation/ConversationEmptyState.d.ts +15 -0
  106. package/dist/components/Conversation/ConversationEmptyState.js +70 -0
  107. package/dist/components/Conversation/ConversationScrollButton.d.ts +13 -0
  108. package/dist/components/Conversation/ConversationScrollButton.js +138 -0
  109. package/dist/components/Conversation/classes.d.ts +13 -0
  110. package/dist/components/Conversation/classes.js +8 -0
  111. package/dist/components/Conversation/index.d.ts +4 -0
  112. package/dist/components/Conversation/index.js +4 -0
  113. package/dist/components/Conversation/useStickToBottom.d.ts +9 -0
  114. package/dist/components/Conversation/useStickToBottom.js +203 -0
  115. package/dist/components/MessageActions/MessageAction.d.ts +18 -0
  116. package/dist/components/MessageActions/MessageAction.js +109 -0
  117. package/dist/components/MessageActions/MessageActions.d.ts +12 -0
  118. package/dist/components/MessageActions/MessageActions.js +74 -0
  119. package/dist/components/MessageActions/MessageTimestamp.d.ts +7 -0
  120. package/dist/components/MessageActions/MessageTimestamp.js +50 -0
  121. package/dist/components/MessageActions/classes.d.ts +5 -0
  122. package/dist/components/MessageActions/classes.js +15 -0
  123. package/dist/components/MessageActions/index.d.ts +3 -0
  124. package/dist/components/MessageActions/index.js +3 -0
  125. package/dist/components/Popover/PopoverContent.d.ts +2 -1
  126. package/dist/components/Popover/PopoverContent.js +42 -39
  127. package/dist/components/UserMessage/UserMessage.d.ts +10 -0
  128. package/dist/components/UserMessage/UserMessage.js +66 -0
  129. package/dist/components/UserMessage/UserMessageBubble.d.ts +16 -0
  130. package/dist/components/UserMessage/UserMessageBubble.js +175 -0
  131. package/dist/components/UserMessage/UserMessageContext.d.ts +9 -0
  132. package/dist/components/UserMessage/UserMessageContext.js +4 -0
  133. package/dist/components/UserMessage/UserMessageShowMore.d.ts +15 -0
  134. package/dist/components/UserMessage/UserMessageShowMore.js +87 -0
  135. package/dist/components/UserMessage/classes.d.ts +11 -0
  136. package/dist/components/UserMessage/classes.js +32 -0
  137. package/dist/components/UserMessage/index.d.ts +3 -0
  138. package/dist/components/UserMessage/index.js +3 -0
  139. package/dist/components/WallyAssistant/WallyAssistant.d.ts +56 -0
  140. package/dist/components/WallyAssistant/WallyAssistant.js +541 -0
  141. package/dist/components/WallyAssistant/index.d.ts +10 -0
  142. package/dist/components/WallyAssistant/index.js +8 -0
  143. package/dist/components/WallyAssistant/model/deriveChatState.d.ts +33 -0
  144. package/dist/components/WallyAssistant/model/deriveChatState.js +54 -0
  145. package/dist/components/WallyAssistant/model/labels.d.ts +43 -0
  146. package/dist/components/WallyAssistant/model/labels.js +33 -0
  147. package/dist/components/WallyAssistant/model/model.d.ts +184 -0
  148. package/dist/components/WallyAssistant/model/model.js +0 -0
  149. package/dist/components/WallyAssistant/views/ApprovalCardView.d.ts +20 -0
  150. package/dist/components/WallyAssistant/views/ApprovalCardView.js +274 -0
  151. package/dist/components/WallyAssistant/views/ChainOfThoughtView.d.ts +18 -0
  152. package/dist/components/WallyAssistant/views/ChainOfThoughtView.js +301 -0
  153. package/dist/components/WallyAssistant/views/ChatMessageView.d.ts +15 -0
  154. package/dist/components/WallyAssistant/views/ChatMessageView.js +372 -0
  155. package/dist/components/WallyAssistant/views/ChatPartView.d.ts +16 -0
  156. package/dist/components/WallyAssistant/views/ChatPartView.js +171 -0
  157. package/dist/components/WallyAssistant/views/ChatViewContext.d.ts +98 -0
  158. package/dist/components/WallyAssistant/views/ChatViewContext.js +44 -0
  159. package/dist/components/WallyAssistant/views/ChatViewProvider.d.ts +18 -0
  160. package/dist/components/WallyAssistant/views/ChatViewProvider.js +96 -0
  161. package/dist/components/WallyAssistant/views/stepIcons.d.ts +8 -0
  162. package/dist/components/WallyAssistant/views/stepIcons.js +47 -0
  163. package/dist/index.d.ts +10 -0
  164. package/dist/index.js +10 -0
  165. package/dist/metadata/components.json +30786 -15960
  166. package/dist/theme/components/animated-background.css +6 -1
  167. package/dist/theme/index.css +1 -0
  168. package/dist/theme/utilities/shimmer-text.css +27 -0
  169. package/package.json +3 -1
@@ -0,0 +1,301 @@
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import { c } from "react/compiler-runtime";
3
+ import { useState } from "react";
4
+ import { Activity, Brain } from "../../../icons/index.js";
5
+ import { useTestId } from "../../../utils/testId.js";
6
+ import { ChainOfThought, ChainOfThoughtStep } from "../../ChainOfThought/index.js";
7
+ import { useRenderEveryTime } from "../../Table/lib/useRenderEveryTime.js";
8
+ import { isLiveStep, isLiveStepStatus } from "../model/deriveChatState.js";
9
+ import { MarkdownView, useChatView } from "./ChatViewContext.js";
10
+ import { resolveStepIcon, stepVisualStatus } from "./stepIcons.js";
11
+ const StepList = ({ steps, ...props })=>steps.map((step, j)=>/*#__PURE__*/ jsx(StepView, {
12
+ ...props,
13
+ step: step,
14
+ slot: `step-${j}`
15
+ }, step.id));
16
+ const StepView = (t0)=>{
17
+ const $ = c(42);
18
+ const { step, message, slot, toggles, onToggle } = t0;
19
+ const { icons, renderStepContent } = useChatView();
20
+ const testId = useTestId(slot);
21
+ let t1;
22
+ if ($[0] !== step.status) {
23
+ t1 = isLiveStepStatus(step.status);
24
+ $[0] = step.status;
25
+ $[1] = t1;
26
+ } else t1 = $[1];
27
+ const ownLive = t1;
28
+ let t2;
29
+ if ($[2] !== message || $[3] !== ownLive || $[4] !== step.content || $[5] !== step.id) {
30
+ t2 = step.content ? /*#__PURE__*/ jsx(MarkdownView, {
31
+ text: step.content,
32
+ streaming: ownLive,
33
+ variant: "chain-of-thought",
34
+ messageId: message.id,
35
+ partId: step.id
36
+ }) : null;
37
+ $[2] = message;
38
+ $[3] = ownLive;
39
+ $[4] = step.content;
40
+ $[5] = step.id;
41
+ $[6] = t2;
42
+ } else t2 = $[6];
43
+ const body = t2;
44
+ let t3;
45
+ if ($[7] !== message || $[8] !== onToggle || $[9] !== step.steps || $[10] !== toggles) {
46
+ t3 = step.steps?.length ? /*#__PURE__*/ jsx(ChainOfThought, {
47
+ children: /*#__PURE__*/ jsx(StepList, {
48
+ steps: step.steps,
49
+ message: message,
50
+ toggles: toggles,
51
+ onToggle: onToggle
52
+ })
53
+ }) : null;
54
+ $[7] = message;
55
+ $[8] = onToggle;
56
+ $[9] = step.steps;
57
+ $[10] = toggles;
58
+ $[11] = t3;
59
+ } else t3 = $[11];
60
+ const nested = t3;
61
+ let t4;
62
+ if ($[12] !== body || $[13] !== nested) {
63
+ t4 = body || nested ? /*#__PURE__*/ jsxs(Fragment, {
64
+ children: [
65
+ body,
66
+ nested
67
+ ]
68
+ }) : null;
69
+ $[12] = body;
70
+ $[13] = nested;
71
+ $[14] = t4;
72
+ } else t4 = $[14];
73
+ const defaultNode = t4;
74
+ let t5;
75
+ if ($[15] !== defaultNode || $[16] !== message || $[17] !== renderStepContent || $[18] !== step) {
76
+ t5 = ()=>renderStepContent?.(step, {
77
+ message,
78
+ defaultRender: ()=>defaultNode
79
+ });
80
+ $[15] = defaultNode;
81
+ $[16] = message;
82
+ $[17] = renderStepContent;
83
+ $[18] = step;
84
+ $[19] = t5;
85
+ } else t5 = $[19];
86
+ const custom = useRenderEveryTime(t5);
87
+ const content = void 0 === custom ? defaultNode : custom;
88
+ const t6 = step.label;
89
+ let t7;
90
+ if ($[20] !== icons || $[21] !== step) {
91
+ t7 = resolveStepIcon(step, icons);
92
+ $[20] = icons;
93
+ $[21] = step;
94
+ $[22] = t7;
95
+ } else t7 = $[22];
96
+ const t8 = step.metric || void 0;
97
+ let t9;
98
+ if ($[23] !== step.status) {
99
+ t9 = stepVisualStatus(step.status);
100
+ $[23] = step.status;
101
+ $[24] = t9;
102
+ } else t9 = $[24];
103
+ let t10;
104
+ if ($[25] !== ownLive || $[26] !== step.id || $[27] !== step.kind || $[28] !== toggles) {
105
+ t10 = toggles.get(step.id) ?? ("reasoning" === step.kind && ownLive);
106
+ $[25] = ownLive;
107
+ $[26] = step.id;
108
+ $[27] = step.kind;
109
+ $[28] = toggles;
110
+ $[29] = t10;
111
+ } else t10 = $[29];
112
+ let t11;
113
+ if ($[30] !== onToggle || $[31] !== step.id) {
114
+ t11 = (open)=>onToggle(step.id, open);
115
+ $[30] = onToggle;
116
+ $[31] = step.id;
117
+ $[32] = t11;
118
+ } else t11 = $[32];
119
+ let t12;
120
+ if ($[33] !== content || $[34] !== step.label || $[35] !== t10 || $[36] !== t11 || $[37] !== t7 || $[38] !== t8 || $[39] !== t9 || $[40] !== testId) {
121
+ t12 = /*#__PURE__*/ jsx(ChainOfThoughtStep, {
122
+ "data-testid": testId,
123
+ label: t6,
124
+ icon: t7,
125
+ metric: t8,
126
+ status: t9,
127
+ open: t10,
128
+ onOpenChange: t11,
129
+ children: content
130
+ });
131
+ $[33] = content;
132
+ $[34] = step.label;
133
+ $[35] = t10;
134
+ $[36] = t11;
135
+ $[37] = t7;
136
+ $[38] = t8;
137
+ $[39] = t9;
138
+ $[40] = testId;
139
+ $[41] = t12;
140
+ } else t12 = $[41];
141
+ return t12;
142
+ };
143
+ const SlotStep = (t0)=>{
144
+ const $ = c(6);
145
+ let props;
146
+ let slot;
147
+ if ($[0] !== t0) {
148
+ ({ slot, ...props } = t0);
149
+ $[0] = t0;
150
+ $[1] = props;
151
+ $[2] = slot;
152
+ } else {
153
+ props = $[1];
154
+ slot = $[2];
155
+ }
156
+ const t1 = useTestId(slot);
157
+ let t2;
158
+ if ($[3] !== props || $[4] !== t1) {
159
+ t2 = /*#__PURE__*/ jsx(ChainOfThoughtStep, {
160
+ ...props,
161
+ "data-testid": t1
162
+ });
163
+ $[3] = props;
164
+ $[4] = t1;
165
+ $[5] = t2;
166
+ } else t2 = $[5];
167
+ return t2;
168
+ };
169
+ const ChainOfThoughtView = (t0)=>{
170
+ const $ = c(32);
171
+ let message;
172
+ let part;
173
+ let props;
174
+ let t1;
175
+ let t2;
176
+ if ($[0] !== t0) {
177
+ ({ part, message, active: t1, working: t2, ...props } = t0);
178
+ $[0] = t0;
179
+ $[1] = message;
180
+ $[2] = part;
181
+ $[3] = props;
182
+ $[4] = t1;
183
+ $[5] = t2;
184
+ } else {
185
+ message = $[1];
186
+ part = $[2];
187
+ props = $[3];
188
+ t1 = $[4];
189
+ t2 = $[5];
190
+ }
191
+ const active = void 0 === t1 ? false : t1;
192
+ const working = void 0 === t2 ? false : t2;
193
+ const { labels } = useChatView();
194
+ const [toggles, setToggles] = useState(_temp);
195
+ let t3;
196
+ if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
197
+ t3 = (id, open)=>setToggles((prev)=>new Map(prev).set(id, open));
198
+ $[6] = t3;
199
+ } else t3 = $[6];
200
+ const onToggle = t3;
201
+ const [summaryOpen, setSummaryOpen] = useState(false);
202
+ const folded = !!part.summary && !active && !part.steps.some(isLiveStep);
203
+ let t4;
204
+ if ($[7] !== message || $[8] !== part.steps || $[9] !== toggles) {
205
+ t4 = /*#__PURE__*/ jsx(StepList, {
206
+ steps: part.steps,
207
+ message: message,
208
+ toggles: toggles,
209
+ onToggle: onToggle
210
+ });
211
+ $[7] = message;
212
+ $[8] = part.steps;
213
+ $[9] = toggles;
214
+ $[10] = t4;
215
+ } else t4 = $[10];
216
+ const steps = t4;
217
+ if (folded) {
218
+ let t5;
219
+ if ($[11] !== part.steps) {
220
+ t5 = part.steps.every(_temp2);
221
+ $[11] = part.steps;
222
+ $[12] = t5;
223
+ } else t5 = $[12];
224
+ const reasoningOnly = t5;
225
+ let t6;
226
+ if ($[13] !== reasoningOnly) {
227
+ t6 = reasoningOnly ? /*#__PURE__*/ jsx(Brain, {}) : /*#__PURE__*/ jsx(Activity, {});
228
+ $[13] = reasoningOnly;
229
+ $[14] = t6;
230
+ } else t6 = $[14];
231
+ let t7;
232
+ if ($[15] !== steps) {
233
+ t7 = /*#__PURE__*/ jsx(ChainOfThought, {
234
+ children: steps
235
+ });
236
+ $[15] = steps;
237
+ $[16] = t7;
238
+ } else t7 = $[16];
239
+ let t8;
240
+ if ($[17] !== part.summary || $[18] !== summaryOpen || $[19] !== t6 || $[20] !== t7) {
241
+ t8 = /*#__PURE__*/ jsx(SlotStep, {
242
+ slot: "step-summary",
243
+ icon: t6,
244
+ label: part.summary,
245
+ open: summaryOpen,
246
+ onOpenChange: setSummaryOpen,
247
+ children: t7
248
+ });
249
+ $[17] = part.summary;
250
+ $[18] = summaryOpen;
251
+ $[19] = t6;
252
+ $[20] = t7;
253
+ $[21] = t8;
254
+ } else t8 = $[21];
255
+ let t9;
256
+ if ($[22] !== props || $[23] !== t8) {
257
+ t9 = /*#__PURE__*/ jsx(ChainOfThought, {
258
+ ...props,
259
+ children: t8
260
+ });
261
+ $[22] = props;
262
+ $[23] = t8;
263
+ $[24] = t9;
264
+ } else t9 = $[24];
265
+ return t9;
266
+ }
267
+ let t5;
268
+ if ($[25] !== labels || $[26] !== working) {
269
+ t5 = working && /*#__PURE__*/ jsx(SlotStep, {
270
+ slot: "step-working",
271
+ status: "running",
272
+ label: labels.working
273
+ });
274
+ $[25] = labels;
275
+ $[26] = working;
276
+ $[27] = t5;
277
+ } else t5 = $[27];
278
+ let t6;
279
+ if ($[28] !== props || $[29] !== steps || $[30] !== t5) {
280
+ t6 = /*#__PURE__*/ jsxs(ChainOfThought, {
281
+ ...props,
282
+ children: [
283
+ steps,
284
+ t5
285
+ ]
286
+ });
287
+ $[28] = props;
288
+ $[29] = steps;
289
+ $[30] = t5;
290
+ $[31] = t6;
291
+ } else t6 = $[31];
292
+ return t6;
293
+ };
294
+ ChainOfThoughtView.displayName = "ChainOfThoughtView";
295
+ function _temp() {
296
+ return new Map();
297
+ }
298
+ function _temp2(s) {
299
+ return "reasoning" === s.kind;
300
+ }
301
+ export { ChainOfThoughtView };
@@ -0,0 +1,15 @@
1
+ import type { FC } from 'react';
2
+ import type { ChatMessage } from '../model/model.js';
3
+ export interface ChatMessageViewProps {
4
+ message: ChatMessage;
5
+ /** Position in the rendered rows: drives the test id (`user-message-{index}` / `assistant-message-{index}`). */
6
+ index: number;
7
+ /** The last row: loader, streaming, docked approvals, always-visible actions. */
8
+ isLast: boolean;
9
+ }
10
+ /**
11
+ * One message row: `UserMessage` or `AssistantMessage`, each part through `ChatPartView` as a
12
+ * direct child (so the built part spacing applies), the loader while the reply has nothing to
13
+ * show yet, and the actions row once the turn is over.
14
+ */
15
+ export declare const ChatMessageView: FC<ChatMessageViewProps>;
@@ -0,0 +1,372 @@
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import { c } from "react/compiler-runtime";
3
+ import { ThumbsDown, ThumbsUp } from "../../../icons/index.js";
4
+ import { formatRelativeTime } from "../../../utils/formatDateTime.js";
5
+ import { useTestId } from "../../../utils/testId.js";
6
+ import { AssistantMessage, AssistantMessageLoader } from "../../AssistantMessage/index.js";
7
+ import { Copyable, CopyableIcon } from "../../Copyable/index.js";
8
+ import { useDateFormat } from "../../DateFormatProvider/index.js";
9
+ import { MessageAction, MessageActions, MessageTimestamp } from "../../MessageActions/index.js";
10
+ import { useRenderEveryTime } from "../../Table/lib/useRenderEveryTime.js";
11
+ import { UserMessage } from "../../UserMessage/index.js";
12
+ import { copyTextOf, getDockedApprovals, hasPendingApproval, isRunningStatus } from "../model/deriveChatState.js";
13
+ import { ChatPartView, isAbsentPart } from "./ChatPartView.js";
14
+ import { useChatView } from "./ChatViewContext.js";
15
+ const KNOWN_PARTS = new Set([
16
+ "text",
17
+ "chain-of-thought",
18
+ "approval",
19
+ "error"
20
+ ]);
21
+ const CopyAction = (t0)=>{
22
+ const $ = c(12);
23
+ const { message, text } = t0;
24
+ const { labels, handlers } = useChatView();
25
+ let t1;
26
+ if ($[0] !== handlers.current || $[1] !== message || $[2] !== text) {
27
+ t1 = ()=>handlers.current.onCopy?.(message, text);
28
+ $[0] = handlers.current;
29
+ $[1] = message;
30
+ $[2] = text;
31
+ $[3] = t1;
32
+ } else t1 = $[3];
33
+ const t2 = labels.copy;
34
+ const t3 = useTestId("copy");
35
+ let t4;
36
+ if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
37
+ t4 = /*#__PURE__*/ jsx(CopyableIcon, {});
38
+ $[4] = t4;
39
+ } else t4 = $[4];
40
+ let t5;
41
+ if ($[5] !== labels.copy || $[6] !== t3) {
42
+ t5 = /*#__PURE__*/ jsx(MessageAction, {
43
+ "aria-label": t2,
44
+ "data-testid": t3,
45
+ children: t4
46
+ });
47
+ $[5] = labels.copy;
48
+ $[6] = t3;
49
+ $[7] = t5;
50
+ } else t5 = $[7];
51
+ let t6;
52
+ if ($[8] !== t1 || $[9] !== t5 || $[10] !== text) {
53
+ t6 = /*#__PURE__*/ jsx(Copyable, {
54
+ text: text,
55
+ onCopied: t1,
56
+ children: t5
57
+ });
58
+ $[8] = t1;
59
+ $[9] = t5;
60
+ $[10] = text;
61
+ $[11] = t6;
62
+ } else t6 = $[11];
63
+ return t6;
64
+ };
65
+ const FeedbackAction = (t0)=>{
66
+ const $ = c(13);
67
+ const { message, value } = t0;
68
+ const { labels, handlers } = useChatView();
69
+ const positive = "positive" === value;
70
+ const pressed = message.feedback === value;
71
+ const t1 = positive ? labels.feedbackPositive : labels.feedbackNegative;
72
+ const t2 = useTestId(positive ? "like" : "dislike");
73
+ let t3;
74
+ if ($[0] !== handlers.current || $[1] !== message || $[2] !== pressed || $[3] !== value) {
75
+ t3 = ()=>handlers.current.onFeedback?.(message, pressed ? null : value);
76
+ $[0] = handlers.current;
77
+ $[1] = message;
78
+ $[2] = pressed;
79
+ $[3] = value;
80
+ $[4] = t3;
81
+ } else t3 = $[4];
82
+ let t4;
83
+ if ($[5] !== positive) {
84
+ t4 = positive ? /*#__PURE__*/ jsx(ThumbsUp, {}) : /*#__PURE__*/ jsx(ThumbsDown, {});
85
+ $[5] = positive;
86
+ $[6] = t4;
87
+ } else t4 = $[6];
88
+ let t5;
89
+ if ($[7] !== pressed || $[8] !== t1 || $[9] !== t2 || $[10] !== t3 || $[11] !== t4) {
90
+ t5 = /*#__PURE__*/ jsx(MessageAction, {
91
+ "aria-label": t1,
92
+ "aria-pressed": pressed,
93
+ "data-testid": t2,
94
+ onClick: t3,
95
+ children: t4
96
+ });
97
+ $[7] = pressed;
98
+ $[8] = t1;
99
+ $[9] = t2;
100
+ $[10] = t3;
101
+ $[11] = t4;
102
+ $[12] = t5;
103
+ } else t5 = $[12];
104
+ return t5;
105
+ };
106
+ const TimestampAction = (t0)=>{
107
+ const $ = c(7);
108
+ const { createdAt } = t0;
109
+ const { formatTimestamp } = useChatView();
110
+ const dateFormat = useDateFormat();
111
+ let t1;
112
+ if ($[0] !== createdAt || $[1] !== dateFormat || $[2] !== formatTimestamp) {
113
+ t1 = formatTimestamp ? formatTimestamp(createdAt) : formatRelativeTime(new Date(createdAt), new Date(), dateFormat);
114
+ $[0] = createdAt;
115
+ $[1] = dateFormat;
116
+ $[2] = formatTimestamp;
117
+ $[3] = t1;
118
+ } else t1 = $[3];
119
+ let t2;
120
+ if ($[4] !== createdAt || $[5] !== t1) {
121
+ t2 = /*#__PURE__*/ jsx(MessageTimestamp, {
122
+ dateTime: createdAt,
123
+ children: t1
124
+ });
125
+ $[4] = createdAt;
126
+ $[5] = t1;
127
+ $[6] = t2;
128
+ } else t2 = $[6];
129
+ return t2;
130
+ };
131
+ const ActionsRow = (t0)=>{
132
+ const $ = c(31);
133
+ const { message, visible } = t0;
134
+ const { labels, renderMessageActions, hasFeedback } = useChatView();
135
+ let t1;
136
+ if ($[0] !== message) {
137
+ t1 = copyTextOf(message);
138
+ $[0] = message;
139
+ $[1] = t1;
140
+ } else t1 = $[1];
141
+ const text = t1;
142
+ const assistant = "assistant" === message.role ? message : null;
143
+ let t2;
144
+ if ($[2] !== message || $[3] !== text) {
145
+ t2 = text ? /*#__PURE__*/ jsx(CopyAction, {
146
+ message: message,
147
+ text: text
148
+ }) : null;
149
+ $[2] = message;
150
+ $[3] = text;
151
+ $[4] = t2;
152
+ } else t2 = $[4];
153
+ const copy = t2;
154
+ let t3;
155
+ if ($[5] !== assistant || $[6] !== hasFeedback) {
156
+ t3 = assistant && hasFeedback ? /*#__PURE__*/ jsx(FeedbackAction, {
157
+ message: assistant,
158
+ value: "positive"
159
+ }) : null;
160
+ $[5] = assistant;
161
+ $[6] = hasFeedback;
162
+ $[7] = t3;
163
+ } else t3 = $[7];
164
+ const like = t3;
165
+ let t4;
166
+ if ($[8] !== assistant || $[9] !== hasFeedback) {
167
+ t4 = assistant && hasFeedback ? /*#__PURE__*/ jsx(FeedbackAction, {
168
+ message: assistant,
169
+ value: "negative"
170
+ }) : null;
171
+ $[8] = assistant;
172
+ $[9] = hasFeedback;
173
+ $[10] = t4;
174
+ } else t4 = $[10];
175
+ const dislike = t4;
176
+ let t5;
177
+ if ($[11] !== message.createdAt) {
178
+ t5 = message.createdAt ? /*#__PURE__*/ jsx(TimestampAction, {
179
+ createdAt: message.createdAt
180
+ }) : null;
181
+ $[11] = message.createdAt;
182
+ $[12] = t5;
183
+ } else t5 = $[12];
184
+ const timestamp = t5;
185
+ let t6;
186
+ if ($[13] !== copy || $[14] !== dislike || $[15] !== like || $[16] !== message || $[17] !== renderMessageActions || $[18] !== timestamp) {
187
+ t6 = ()=>renderMessageActions?.(message, {
188
+ copy,
189
+ like,
190
+ dislike,
191
+ timestamp
192
+ });
193
+ $[13] = copy;
194
+ $[14] = dislike;
195
+ $[15] = like;
196
+ $[16] = message;
197
+ $[17] = renderMessageActions;
198
+ $[18] = timestamp;
199
+ $[19] = t6;
200
+ } else t6 = $[19];
201
+ const custom = useRenderEveryTime(t6);
202
+ if (null === custom) return null;
203
+ let t7;
204
+ if ($[20] !== assistant || $[21] !== copy || $[22] !== custom || $[23] !== dislike || $[24] !== like || $[25] !== timestamp) {
205
+ t7 = void 0 !== custom ? custom : assistant ? /*#__PURE__*/ jsxs(Fragment, {
206
+ children: [
207
+ copy,
208
+ like,
209
+ dislike,
210
+ timestamp
211
+ ]
212
+ }) : /*#__PURE__*/ jsxs(Fragment, {
213
+ children: [
214
+ timestamp,
215
+ copy
216
+ ]
217
+ });
218
+ $[20] = assistant;
219
+ $[21] = copy;
220
+ $[22] = custom;
221
+ $[23] = dislike;
222
+ $[24] = like;
223
+ $[25] = timestamp;
224
+ $[26] = t7;
225
+ } else t7 = $[26];
226
+ let t8;
227
+ if ($[27] !== labels.messageActions || $[28] !== t7 || $[29] !== visible) {
228
+ t8 = /*#__PURE__*/ jsx(MessageActions, {
229
+ "aria-label": labels.messageActions,
230
+ visible: visible,
231
+ children: t7
232
+ });
233
+ $[27] = labels.messageActions;
234
+ $[28] = t7;
235
+ $[29] = visible;
236
+ $[30] = t8;
237
+ } else t8 = $[30];
238
+ return t8;
239
+ };
240
+ const ChatMessageView = (t0)=>{
241
+ const $ = c(39);
242
+ const { message, index, isLast } = t0;
243
+ const { status, labels, approvalPlacement, renderPart } = useChatView();
244
+ const testId = useTestId(`${message.role}-message-${index}`);
245
+ let rendersAny;
246
+ let showActions;
247
+ let t1;
248
+ if ($[0] !== approvalPlacement || $[1] !== isLast || $[2] !== message || $[3] !== renderPart || $[4] !== status) {
249
+ const docked = isLast && "docked" === approvalPlacement ? getDockedApprovals(message) : [];
250
+ const parts = message.parts.filter((p)=>!isAbsentPart(p) && !docked.includes(p));
251
+ let t2;
252
+ if ($[8] !== renderPart) {
253
+ t2 = (p_0)=>null != renderPart || KNOWN_PARTS.has(p_0.type);
254
+ $[8] = renderPart;
255
+ $[9] = t2;
256
+ } else t2 = $[9];
257
+ const renders = t2;
258
+ rendersAny = parts.some(renders);
259
+ showActions = parts.some((p_1)=>"approval" !== p_1.type && renders(p_1)) && !(isLast && (isRunningStatus(status) || hasPendingApproval(message)));
260
+ let t3;
261
+ if ($[10] !== isLast || $[11] !== message) {
262
+ t3 = (p_2)=>/*#__PURE__*/ jsx(ChatPartView, {
263
+ part: p_2,
264
+ message: message,
265
+ isLast: isLast
266
+ }, p_2.id);
267
+ $[10] = isLast;
268
+ $[11] = message;
269
+ $[12] = t3;
270
+ } else t3 = $[12];
271
+ t1 = parts.map(t3);
272
+ $[0] = approvalPlacement;
273
+ $[1] = isLast;
274
+ $[2] = message;
275
+ $[3] = renderPart;
276
+ $[4] = status;
277
+ $[5] = rendersAny;
278
+ $[6] = showActions;
279
+ $[7] = t1;
280
+ } else {
281
+ rendersAny = $[5];
282
+ showActions = $[6];
283
+ t1 = $[7];
284
+ }
285
+ const items = t1;
286
+ if ("user" === message.role) {
287
+ if (!rendersAny) return null;
288
+ let t2;
289
+ if ($[13] !== message || $[14] !== showActions) {
290
+ t2 = showActions && /*#__PURE__*/ jsx(ActionsRow, {
291
+ message: message,
292
+ visible: false
293
+ });
294
+ $[13] = message;
295
+ $[14] = showActions;
296
+ $[15] = t2;
297
+ } else t2 = $[15];
298
+ let t3;
299
+ if ($[16] !== items || $[17] !== labels.you || $[18] !== t2 || $[19] !== testId) {
300
+ t3 = /*#__PURE__*/ jsxs(UserMessage, {
301
+ "aria-label": labels.you,
302
+ "data-testid": testId,
303
+ children: [
304
+ items,
305
+ t2
306
+ ]
307
+ });
308
+ $[16] = items;
309
+ $[17] = labels.you;
310
+ $[18] = t2;
311
+ $[19] = testId;
312
+ $[20] = t3;
313
+ } else t3 = $[20];
314
+ return t3;
315
+ }
316
+ if ("assistant" !== message.role) return null;
317
+ let t2;
318
+ if ($[21] !== isLast || $[22] !== message || $[23] !== status) {
319
+ t2 = isLast && isRunningStatus(status) && !hasPendingApproval(message);
320
+ $[21] = isLast;
321
+ $[22] = message;
322
+ $[23] = status;
323
+ $[24] = t2;
324
+ } else t2 = $[24];
325
+ const busy = t2;
326
+ const loading = busy && !rendersAny;
327
+ if (!rendersAny && !loading) return null;
328
+ const t3 = busy || void 0;
329
+ let t4;
330
+ if ($[25] !== labels.working || $[26] !== loading) {
331
+ t4 = loading && /*#__PURE__*/ jsx(AssistantMessageLoader, {
332
+ children: labels.working
333
+ });
334
+ $[25] = labels.working;
335
+ $[26] = loading;
336
+ $[27] = t4;
337
+ } else t4 = $[27];
338
+ let t5;
339
+ if ($[28] !== isLast || $[29] !== message || $[30] !== showActions) {
340
+ t5 = showActions && /*#__PURE__*/ jsx(ActionsRow, {
341
+ message: message,
342
+ visible: isLast
343
+ });
344
+ $[28] = isLast;
345
+ $[29] = message;
346
+ $[30] = showActions;
347
+ $[31] = t5;
348
+ } else t5 = $[31];
349
+ let t6;
350
+ if ($[32] !== items || $[33] !== labels.assistant || $[34] !== t3 || $[35] !== t4 || $[36] !== t5 || $[37] !== testId) {
351
+ t6 = /*#__PURE__*/ jsxs(AssistantMessage, {
352
+ "aria-label": labels.assistant,
353
+ "aria-busy": t3,
354
+ "data-testid": testId,
355
+ children: [
356
+ t4,
357
+ items,
358
+ t5
359
+ ]
360
+ });
361
+ $[32] = items;
362
+ $[33] = labels.assistant;
363
+ $[34] = t3;
364
+ $[35] = t4;
365
+ $[36] = t5;
366
+ $[37] = testId;
367
+ $[38] = t6;
368
+ } else t6 = $[38];
369
+ return t6;
370
+ };
371
+ ChatMessageView.displayName = "ChatMessageView";
372
+ export { ChatMessageView };
@@ -0,0 +1,16 @@
1
+ import type { FC } from 'react';
2
+ import type { ChatMessage, ChatPart } from '../model/model.js';
3
+ export interface ChatPartViewProps {
4
+ part: ChatPart;
5
+ message: ChatMessage;
6
+ isLast: boolean;
7
+ /** 'docked' when you render a docked approval in your own footer. Default 'inline'. */
8
+ placement?: 'inline' | 'docked';
9
+ }
10
+ /** An empty text or an empty chain counts as absent (model header): it renders nothing. */
11
+ export declare const isAbsentPart: (p: ChatPart) => boolean;
12
+ /**
13
+ * One part with its default L1 rendering. `renderPart` runs first for every part (custom and
14
+ * unknown types included): `undefined` → the default, `null` → nothing, a node replaces it.
15
+ */
16
+ export declare const ChatPartView: FC<ChatPartViewProps>;