@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,46 @@
1
+ import { cva } from "class-variance-authority";
2
+ const assistantMessageVariants = cva('group/message flex flex-col items-start gap-4 px-8 [&>[data-slot=chain-of-thought]]:mb-8 [&>[data-slot=approval-card]]:mb-8 [&>[data-slot=approval-card]]:self-stretch [&>[data-slot=message-actions]]:-ms-4');
3
+ const assistantMessageContentVariants = cva('self-stretch break-words text-sm leading-base text-text-primary [&_:is(h1,h2,h3,h4,h5,h6)]:font-sans-display [&_:is(h1,h2,h3,h4,h5,h6)]:text-base [&_:is(h1,h2,h3,h4,h5,h6)]:font-medium [&>*+*]:mt-8 [&>:is(h1,h2,h3,h4,h5,h6)+*]:mt-4 [&_ul]:list-disc [&_ol]:list-decimal [&_:is(ul,ol)]:ps-21 [&_li]:leading-sm [&_li+li]:mt-4');
4
+ const assistantMessageLoaderVariants = cva('flex items-start gap-6 self-stretch text-xs leading-xs text-text-secondary');
5
+ const assistantMessageErrorVariants = cva('flex items-start gap-8 self-stretch text-sm text-text-danger [&>:nth-child(n+3)]:-my-2');
6
+ const assistantMessageMarkdownBlockquoteVariants = cva('border-s-2 border-border-primary ps-12 text-text-secondary [&>*+*]:mt-8');
7
+ const assistantMessageMarkdownListVariants = cva('ps-18', {
8
+ variants: {
9
+ ordered: {
10
+ true: 'list-decimal',
11
+ false: 'list-disc'
12
+ }
13
+ },
14
+ defaultVariants: {
15
+ ordered: false
16
+ }
17
+ });
18
+ const assistantMessageMarkdownTaskItemVariants = cva('flex list-none items-start gap-8');
19
+ const assistantMessageMarkdownCellVariants = cva('', {
20
+ variants: {
21
+ align: {
22
+ left: 'text-left',
23
+ center: 'text-center',
24
+ right: 'text-right'
25
+ }
26
+ },
27
+ defaultVariants: {
28
+ align: 'right'
29
+ }
30
+ });
31
+ const assistantMessageMarkdownInlineCodeVariants = cva('max-w-full wrap-anywhere', {
32
+ variants: {
33
+ muted: {
34
+ true: 'text-text-secondary',
35
+ false: ''
36
+ }
37
+ },
38
+ defaultVariants: {
39
+ muted: false
40
+ }
41
+ });
42
+ const assistantMessageMarkdownLinkVariants = cva('inline rounded-2 focus-visible:ring-3 focus-visible:ring-focus-primary');
43
+ const assistantMessageMarkdownCodeBlockVariants = cva('[li>&]:mt-4');
44
+ const assistantMessageMarkdownTableVariants = cva('overflow-x-auto');
45
+ const assistantMessageMarkdownTableGridVariants = cva('w-full border-separate border-spacing-0 [&>tbody>tr:last-child>td]:border-b-0');
46
+ export { assistantMessageContentVariants, assistantMessageErrorVariants, assistantMessageLoaderVariants, assistantMessageMarkdownBlockquoteVariants, assistantMessageMarkdownCellVariants, assistantMessageMarkdownCodeBlockVariants, assistantMessageMarkdownInlineCodeVariants, assistantMessageMarkdownLinkVariants, assistantMessageMarkdownListVariants, assistantMessageMarkdownTableGridVariants, assistantMessageMarkdownTableVariants, assistantMessageMarkdownTaskItemVariants, assistantMessageVariants };
@@ -0,0 +1,9 @@
1
+ export { AssistantMessage, type AssistantMessageProps } from './AssistantMessage.js';
2
+ export { AssistantMessageContent, type AssistantMessageContentProps, } from './AssistantMessageContent.js';
3
+ export { AssistantMessageError, type AssistantMessageErrorProps } from './AssistantMessageError.js';
4
+ export { AssistantMessageLoader, type AssistantMessageLoaderProps } from './AssistantMessageLoader.js';
5
+ export { AssistantMessageMarkdown, type AssistantMessageMarkdownComponents, type AssistantMessageMarkdownProps, type AssistantMessageMarkdownVariant, } from './AssistantMessageMarkdown.js';
6
+ export { AssistantMessageMarkdownCodeBlock, type AssistantMessageMarkdownCodeBlockProps, } from './AssistantMessageMarkdownCodeBlock.js';
7
+ export { AssistantMessageMarkdownInlineCode, type AssistantMessageMarkdownInlineCodeProps, } from './AssistantMessageMarkdownInlineCode.js';
8
+ export { AssistantMessageMarkdownLink, type AssistantMessageMarkdownLinkProps, } from './AssistantMessageMarkdownLink.js';
9
+ export { AssistantMessageMarkdownTable, type AssistantMessageMarkdownTableProps, } from './AssistantMessageMarkdownTable.js';
@@ -0,0 +1,9 @@
1
+ export { AssistantMessage } from "./AssistantMessage.js";
2
+ export { AssistantMessageContent } from "./AssistantMessageContent.js";
3
+ export { AssistantMessageError } from "./AssistantMessageError.js";
4
+ export { AssistantMessageLoader } from "./AssistantMessageLoader.js";
5
+ export { AssistantMessageMarkdown } from "./AssistantMessageMarkdown.js";
6
+ export { AssistantMessageMarkdownCodeBlock } from "./AssistantMessageMarkdownCodeBlock.js";
7
+ export { AssistantMessageMarkdownInlineCode } from "./AssistantMessageMarkdownInlineCode.js";
8
+ export { AssistantMessageMarkdownLink } from "./AssistantMessageMarkdownLink.js";
9
+ export { AssistantMessageMarkdownTable } from "./AssistantMessageMarkdownTable.js";
@@ -0,0 +1,20 @@
1
+ import { type MarkedToken, type Token } from 'marked';
2
+ export declare const asTokens: (tokens: Token[] | undefined) => MarkedToken[];
3
+ /**
4
+ * The top-level blocks of untrusted GFM. While `streaming`, only the last block can be unfinished, so only it is
5
+ * repaired (remend counts markers across its whole input: run on the full text, one stray `*` in a finished
6
+ * block leaks a closer into every later frame), and a tail that would flash — a half-typed table header, a fence
7
+ * with no code yet — is held back.
8
+ */
9
+ export declare const lexMarkdown: (text: string, streaming: boolean) => MarkedToken[];
10
+ /** The closing fence has arrived (indented code has none and is always closed). */
11
+ export declare const isClosedFence: (raw: string) => boolean;
12
+ /**
13
+ * http(s), mailto and relative URLs pass; javascript:, data:, vbscript:, file:, blob: and anything unparsable
14
+ * don't. The WHATWG parser is the browser's own, so case, whitespace and control-character tricks resolve the
15
+ * same way here. Never entity-decode an href: React writes attributes verbatim, so `javascript:x` stays
16
+ * a harmless relative path.
17
+ */
18
+ export declare const safeHref: (href: string | null | undefined) => string | undefined;
19
+ /** marked decodes numeric entities but keeps these named ones in text tokens. Text nodes only. */
20
+ export declare const decodeEntities: (s: string) => string;
@@ -0,0 +1,51 @@
1
+ import { Lexer } from "marked";
2
+ import remend from "remend";
3
+ const asTokens = (tokens)=>tokens ?? [];
4
+ const lexBlocks = (src)=>asTokens(Lexer.lex(src, {
5
+ gfm: true
6
+ })).filter((t)=>'space' !== t.type && 'def' !== t.type);
7
+ const DANGLING = /(^|\s)(?:(?:[*+-]|\d+[.)])\s+\[[ xX]?\]?|[*_~`#>+-]+|\d+[.)])\s*$/;
8
+ const FENCE_LINE = /(^|\n) {0,3}(?:`{3,}|~{3,})\s*$/;
9
+ const REMEND = {
10
+ linkMode: 'text-only',
11
+ katex: false,
12
+ htmlTags: false,
13
+ italic: false
14
+ };
15
+ const isHalfTable = (t)=>'paragraph' === t.type && /^ {0,3}\|/.test(t.raw) && t.raw.split('\n').slice(1).every((line)=>/^[\s|:-]*$/.test(line));
16
+ const lexMarkdown = (text, streaming)=>{
17
+ if (!streaming) return lexBlocks(text);
18
+ const blocks = lexBlocks(FENCE_LINE.test(text) ? text : text.replace(DANGLING, '$1'));
19
+ const tail = blocks.pop();
20
+ if (tail) blocks.push(...'code' === tail.type || 'html' === tail.type ? [
21
+ tail
22
+ ] : lexBlocks(remend(tail.raw, REMEND)));
23
+ const last = blocks[blocks.length - 1];
24
+ if (last && (isHalfTable(last) || 'code' === last.type && !last.text)) blocks.pop();
25
+ return blocks;
26
+ };
27
+ const isClosedFence = (raw)=>{
28
+ const open = /^ {0,3}(`{3,}|~{3,})/.exec(raw)?.[1];
29
+ if (!open) return true;
30
+ const lines = raw.trimEnd().split('\n');
31
+ const close = lines.length > 1 ? /^ {0,3}(`{3,}|~{3,})[ \t]*$/.exec(lines[lines.length - 1] ?? '')?.[1] : void 0;
32
+ return !!close && close[0] === open[0] && close.length >= open.length;
33
+ };
34
+ const BASE = 'https://base.invalid';
35
+ const safeHref = (href)=>{
36
+ if (!href) return;
37
+ try {
38
+ return /^(?:https?|mailto):$/.test(new URL(href, BASE).protocol) ? href : void 0;
39
+ } catch {
40
+ return;
41
+ }
42
+ };
43
+ const ENTITIES = {
44
+ amp: '&',
45
+ lt: '<',
46
+ gt: '>',
47
+ quot: '"',
48
+ nbsp: ' '
49
+ };
50
+ const decodeEntities = (s)=>s.replace(/&(amp|lt|gt|quot|nbsp);/g, (m, name)=>ENTITIES[name] ?? m);
51
+ export { asTokens, decodeEntities, isClosedFence, lexMarkdown, safeHref };
@@ -0,0 +1,10 @@
1
+ import type { FC, OlHTMLAttributes, Ref } from 'react';
2
+ import { type TestableProps } from '../../utils/testId.js';
3
+ export interface ChainOfThoughtProps extends OlHTMLAttributes<HTMLOListElement>, TestableProps {
4
+ ref?: Ref<HTMLOListElement>;
5
+ }
6
+ /**
7
+ * Read-only log of an agent's steps. Children must be `ChainOfThoughtStep`s —
8
+ * each `<li>` a direct child, so the last step drops its connector.
9
+ */
10
+ export declare const ChainOfThought: FC<ChainOfThoughtProps>;
@@ -0,0 +1,66 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { c } from "react/compiler-runtime";
3
+ import { cn } from "../../utils/cn.js";
4
+ import { TestIdProvider, useTestId } from "../../utils/testId.js";
5
+ import { chainOfThoughtVariants } from "./classes.js";
6
+ const ChainOfThought = (t0)=>{
7
+ const $ = c(17);
8
+ let children;
9
+ let className;
10
+ let props;
11
+ let ref;
12
+ let testIdProp;
13
+ if ($[0] !== t0) {
14
+ ({ ref, className, children, "data-testid": testIdProp, ...props } = t0);
15
+ $[0] = t0;
16
+ $[1] = children;
17
+ $[2] = className;
18
+ $[3] = props;
19
+ $[4] = ref;
20
+ $[5] = testIdProp;
21
+ } else {
22
+ children = $[1];
23
+ className = $[2];
24
+ props = $[3];
25
+ ref = $[4];
26
+ testIdProp = $[5];
27
+ }
28
+ const testId = useTestId("chain-of-thought", testIdProp);
29
+ let t1;
30
+ if ($[6] !== className) {
31
+ t1 = cn(chainOfThoughtVariants(), className);
32
+ $[6] = className;
33
+ $[7] = t1;
34
+ } else t1 = $[7];
35
+ let t2;
36
+ if ($[8] !== children || $[9] !== testId) {
37
+ t2 = /*#__PURE__*/ jsx(TestIdProvider, {
38
+ value: testId,
39
+ children: children
40
+ });
41
+ $[8] = children;
42
+ $[9] = testId;
43
+ $[10] = t2;
44
+ } else t2 = $[10];
45
+ let t3;
46
+ if ($[11] !== props || $[12] !== ref || $[13] !== t1 || $[14] !== t2 || $[15] !== testId) {
47
+ t3 = /*#__PURE__*/ jsx("ol", {
48
+ ...props,
49
+ ref: ref,
50
+ "data-slot": "chain-of-thought",
51
+ "data-testid": testId,
52
+ role: "list",
53
+ className: t1,
54
+ children: t2
55
+ });
56
+ $[11] = props;
57
+ $[12] = ref;
58
+ $[13] = t1;
59
+ $[14] = t2;
60
+ $[15] = testId;
61
+ $[16] = t3;
62
+ } else t3 = $[16];
63
+ return t3;
64
+ };
65
+ ChainOfThought.displayName = "ChainOfThought";
66
+ export { ChainOfThought };
@@ -0,0 +1,31 @@
1
+ import { type FC, type HTMLAttributes, type ReactNode, type Ref } from 'react';
2
+ import { type TestableProps } from '../../utils/testId.js';
3
+ export interface ChainOfThoughtStepProps extends Omit<HTMLAttributes<HTMLElement>, 'children'>, TestableProps {
4
+ /**
5
+ * `...rest`, `ref`, `className` and `data-testid` land on the ROW — a `<button>` when the
6
+ * step has children, a `<div>` otherwise.
7
+ */
8
+ ref?: Ref<HTMLElement>;
9
+ /** Row text: 'Searched for ABC', 'Working...', 'Thought for 5s', 'Worked for 3m 45s'. */
10
+ label: ReactNode;
11
+ /** 16px type icon. Default `<CircleDashed />`. `null` = Figma "Simple" row (no icon cell, no connector). */
12
+ icon?: ReactNode;
13
+ /** Right-aligned mono slot = Figma "Simple-result". */
14
+ metric?: ReactNode;
15
+ /**
16
+ * `'running'` shimmers the label (Figma "Working"). `'error'` tints the label and icon danger
17
+ * (not in Figma yet; pending design review) and prefixes a visually hidden "Error:" for screen
18
+ * readers; still word the label so it reads as a failure ('get_attacks failed'). Default `'done'`.
19
+ * Reflected in the `li`'s `data-status`. A step that mounts as `'running'` gets `data-entered`
20
+ * and animates in (and fades its shimmer out on `'done'`); one mounted `'done'` renders static.
21
+ */
22
+ status?: 'running' | 'done' | 'error';
23
+ /** Controlled open state of the nested content. */
24
+ open?: boolean;
25
+ /** Initial open state when uncontrolled. Default `false`. */
26
+ defaultOpen?: boolean;
27
+ onOpenChange?: (open: boolean) => void;
28
+ /** Nested content (a nested `ChainOfThought`, text, inline code). Its presence makes the row a collapsible trigger. */
29
+ children?: ReactNode;
30
+ }
31
+ export declare const ChainOfThoughtStep: FC<ChainOfThoughtStepProps>;
@@ -0,0 +1,312 @@
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import { c } from "react/compiler-runtime";
3
+ import { useId, useState } from "react";
4
+ import { ChevronDown, CircleDashed } from "../../icons/index.js";
5
+ import { Collapse } from "../../utils/Collapse.js";
6
+ import { cn } from "../../utils/cn.js";
7
+ import { TestIdProvider, useTestId } from "../../utils/testId.js";
8
+ import { chainOfThoughtBodyVariants, chainOfThoughtIconVariants, chainOfThoughtLabelVariants, chainOfThoughtLineVariants, chainOfThoughtMetricVariants, chainOfThoughtRowVariants, chainOfThoughtStepVariants } from "./classes.js";
9
+ const DEFAULT_ICON = /*#__PURE__*/ jsx(CircleDashed, {});
10
+ const ChainOfThoughtStep = (t0)=>{
11
+ const $ = c(81);
12
+ let children;
13
+ let className;
14
+ let label;
15
+ let metric;
16
+ let onClick;
17
+ let onOpenChange;
18
+ let open;
19
+ let props;
20
+ let ref;
21
+ let t1;
22
+ let t2;
23
+ let t3;
24
+ let testIdProp;
25
+ if ($[0] !== t0) {
26
+ ({ ref, label, icon: t1, metric, status: t2, open, defaultOpen: t3, onOpenChange, children, className, onClick, "data-testid": testIdProp, ...props } = t0);
27
+ $[0] = t0;
28
+ $[1] = children;
29
+ $[2] = className;
30
+ $[3] = label;
31
+ $[4] = metric;
32
+ $[5] = onClick;
33
+ $[6] = onOpenChange;
34
+ $[7] = open;
35
+ $[8] = props;
36
+ $[9] = ref;
37
+ $[10] = t1;
38
+ $[11] = t2;
39
+ $[12] = t3;
40
+ $[13] = testIdProp;
41
+ } else {
42
+ children = $[1];
43
+ className = $[2];
44
+ label = $[3];
45
+ metric = $[4];
46
+ onClick = $[5];
47
+ onOpenChange = $[6];
48
+ open = $[7];
49
+ props = $[8];
50
+ ref = $[9];
51
+ t1 = $[10];
52
+ t2 = $[11];
53
+ t3 = $[12];
54
+ testIdProp = $[13];
55
+ }
56
+ const icon = void 0 === t1 ? DEFAULT_ICON : t1;
57
+ const status = void 0 === t2 ? "done" : t2;
58
+ const defaultOpen = void 0 === t3 ? false : t3;
59
+ const testId = useTestId("step", testIdProp);
60
+ const contentId = useId();
61
+ const [internalOpen, setInternalOpen] = useState(defaultOpen);
62
+ const [entered] = useState("running" === status);
63
+ const [settled, setSettled] = useState(false);
64
+ const labelEntered = entered && !(settled && "done" === status);
65
+ let t4;
66
+ if ($[14] !== status) {
67
+ t4 = (event)=>{
68
+ if ("done" === status && event.target === event.currentTarget && event.propertyName.endsWith("text-fill-color")) setSettled(true);
69
+ };
70
+ $[14] = status;
71
+ $[15] = t4;
72
+ } else t4 = $[15];
73
+ const handleLabelTransitionEnd = t4;
74
+ const isOpen = open ?? internalOpen;
75
+ const collapsible = null != children && false !== children;
76
+ const hasIcon = null !== icon;
77
+ let t5;
78
+ if ($[16] !== isOpen || $[17] !== onClick || $[18] !== onOpenChange || $[19] !== open) {
79
+ t5 = (event_0)=>{
80
+ onClick?.(event_0);
81
+ if (event_0.defaultPrevented) return;
82
+ if (void 0 === open) setInternalOpen(!isOpen);
83
+ onOpenChange?.(!isOpen);
84
+ };
85
+ $[16] = isOpen;
86
+ $[17] = onClick;
87
+ $[18] = onOpenChange;
88
+ $[19] = open;
89
+ $[20] = t5;
90
+ } else t5 = $[20];
91
+ const handleClick = t5;
92
+ const showTypeIcon = hasIcon && !(collapsible && isOpen);
93
+ let t6;
94
+ if ($[21] !== collapsible || $[22] !== icon || $[23] !== isOpen || $[24] !== showTypeIcon || $[25] !== status || $[26] !== testId) {
95
+ t6 = (showTypeIcon || collapsible) && /*#__PURE__*/ jsxs("span", {
96
+ className: cn(chainOfThoughtIconVariants({
97
+ status
98
+ })),
99
+ "data-testid": testId && `${testId}--icon`,
100
+ children: [
101
+ showTypeIcon && /*#__PURE__*/ jsx("span", {
102
+ className: cn("inline-flex", collapsible && "group-hover/row:hidden group-focus-visible/row:hidden"),
103
+ children: icon
104
+ }),
105
+ collapsible && /*#__PURE__*/ jsx("span", {
106
+ className: cn("inline-flex transition-transform motion-reduce:transition-none", !isOpen && "-rotate-90", showTypeIcon && "hidden group-hover/row:inline-flex group-focus-visible/row:inline-flex"),
107
+ children: /*#__PURE__*/ jsx(ChevronDown, {})
108
+ })
109
+ ]
110
+ });
111
+ $[21] = collapsible;
112
+ $[22] = icon;
113
+ $[23] = isOpen;
114
+ $[24] = showTypeIcon;
115
+ $[25] = status;
116
+ $[26] = testId;
117
+ $[27] = t6;
118
+ } else t6 = $[27];
119
+ const iconCell = t6;
120
+ let t7;
121
+ if ($[28] !== status) {
122
+ t7 = "error" === status && /*#__PURE__*/ jsx("span", {
123
+ className: "sr-only",
124
+ children: "Error: "
125
+ });
126
+ $[28] = status;
127
+ $[29] = t7;
128
+ } else t7 = $[29];
129
+ let t8;
130
+ if ($[30] !== labelEntered || $[31] !== status) {
131
+ t8 = chainOfThoughtLabelVariants({
132
+ status,
133
+ entered: labelEntered
134
+ });
135
+ $[30] = labelEntered;
136
+ $[31] = status;
137
+ $[32] = t8;
138
+ } else t8 = $[32];
139
+ const t9 = labelEntered ? handleLabelTransitionEnd : void 0;
140
+ let t10;
141
+ if ($[33] !== label || $[34] !== t8 || $[35] !== t9) {
142
+ t10 = /*#__PURE__*/ jsx("span", {
143
+ className: t8,
144
+ onTransitionEnd: t9,
145
+ children: label
146
+ });
147
+ $[33] = label;
148
+ $[34] = t8;
149
+ $[35] = t9;
150
+ $[36] = t10;
151
+ } else t10 = $[36];
152
+ let t11;
153
+ if ($[37] !== metric) {
154
+ t11 = null != metric && /*#__PURE__*/ jsx("span", {
155
+ className: chainOfThoughtMetricVariants(),
156
+ children: metric
157
+ });
158
+ $[37] = metric;
159
+ $[38] = t11;
160
+ } else t11 = $[38];
161
+ let t12;
162
+ if ($[39] !== iconCell || $[40] !== t10 || $[41] !== t11 || $[42] !== t7) {
163
+ t12 = /*#__PURE__*/ jsxs(Fragment, {
164
+ children: [
165
+ iconCell,
166
+ t7,
167
+ t10,
168
+ t11
169
+ ]
170
+ });
171
+ $[39] = iconCell;
172
+ $[40] = t10;
173
+ $[41] = t11;
174
+ $[42] = t7;
175
+ $[43] = t12;
176
+ } else t12 = $[43];
177
+ const rowContent = t12;
178
+ const t13 = ref;
179
+ let t14;
180
+ if ($[44] !== className || $[45] !== collapsible) {
181
+ t14 = cn(chainOfThoughtRowVariants({
182
+ interactive: collapsible
183
+ }), className);
184
+ $[44] = className;
185
+ $[45] = collapsible;
186
+ $[46] = t14;
187
+ } else t14 = $[46];
188
+ let t15;
189
+ if ($[47] !== props || $[48] !== t13 || $[49] !== t14 || $[50] !== testId) {
190
+ t15 = {
191
+ ...props,
192
+ ref: t13,
193
+ "data-slot": "chain-of-thought-step-row",
194
+ "data-testid": testId,
195
+ className: t14
196
+ };
197
+ $[47] = props;
198
+ $[48] = t13;
199
+ $[49] = t14;
200
+ $[50] = testId;
201
+ $[51] = t15;
202
+ } else t15 = $[51];
203
+ const rowProps = t15;
204
+ const t16 = entered || void 0;
205
+ const t17 = collapsible && isOpen ? "open" : "closed";
206
+ const t18 = !hasIcon;
207
+ let t19;
208
+ if ($[52] !== entered || $[53] !== t18) {
209
+ t19 = chainOfThoughtStepVariants({
210
+ simple: t18,
211
+ entered
212
+ });
213
+ $[52] = entered;
214
+ $[53] = t18;
215
+ $[54] = t19;
216
+ } else t19 = $[54];
217
+ let t20;
218
+ if ($[55] !== collapsible || $[56] !== contentId || $[57] !== handleClick || $[58] !== isOpen || $[59] !== onClick || $[60] !== rowContent || $[61] !== rowProps) {
219
+ t20 = collapsible ? /*#__PURE__*/ jsx("button", {
220
+ ...rowProps,
221
+ type: "button",
222
+ "aria-expanded": isOpen,
223
+ "aria-controls": contentId,
224
+ onClick: handleClick,
225
+ children: rowContent
226
+ }) : /*#__PURE__*/ jsx("div", {
227
+ ...rowProps,
228
+ onClick: onClick,
229
+ children: rowContent
230
+ });
231
+ $[55] = collapsible;
232
+ $[56] = contentId;
233
+ $[57] = handleClick;
234
+ $[58] = isOpen;
235
+ $[59] = onClick;
236
+ $[60] = rowContent;
237
+ $[61] = rowProps;
238
+ $[62] = t20;
239
+ } else t20 = $[62];
240
+ let t21;
241
+ if ($[63] !== entered || $[64] !== showTypeIcon || $[65] !== testId) {
242
+ t21 = showTypeIcon && /*#__PURE__*/ jsx("span", {
243
+ "aria-hidden": true,
244
+ "data-slot": "chain-of-thought-connector",
245
+ "data-testid": testId && `${testId}--connector`,
246
+ className: cn(chainOfThoughtLineVariants({
247
+ entered
248
+ }), "h-20")
249
+ });
250
+ $[63] = entered;
251
+ $[64] = showTypeIcon;
252
+ $[65] = testId;
253
+ $[66] = t21;
254
+ } else t21 = $[66];
255
+ let t22;
256
+ if ($[67] !== children || $[68] !== collapsible || $[69] !== contentId || $[70] !== isOpen || $[71] !== testId) {
257
+ t22 = collapsible && /*#__PURE__*/ jsx(Collapse, {
258
+ id: contentId,
259
+ open: isOpen,
260
+ inertWhenClosed: true,
261
+ "data-slot": "chain-of-thought-step-content",
262
+ children: /*#__PURE__*/ jsxs("div", {
263
+ className: "flex",
264
+ children: [
265
+ /*#__PURE__*/ jsx("span", {
266
+ "aria-hidden": true,
267
+ className: chainOfThoughtLineVariants()
268
+ }),
269
+ /*#__PURE__*/ jsx("div", {
270
+ className: chainOfThoughtBodyVariants(),
271
+ children: /*#__PURE__*/ jsx(TestIdProvider, {
272
+ value: testId,
273
+ children: children
274
+ })
275
+ })
276
+ ]
277
+ })
278
+ });
279
+ $[67] = children;
280
+ $[68] = collapsible;
281
+ $[69] = contentId;
282
+ $[70] = isOpen;
283
+ $[71] = testId;
284
+ $[72] = t22;
285
+ } else t22 = $[72];
286
+ let t23;
287
+ if ($[73] !== status || $[74] !== t16 || $[75] !== t17 || $[76] !== t19 || $[77] !== t20 || $[78] !== t21 || $[79] !== t22) {
288
+ t23 = /*#__PURE__*/ jsxs("li", {
289
+ "data-slot": "chain-of-thought-step",
290
+ "data-status": status,
291
+ "data-entered": t16,
292
+ "data-state": t17,
293
+ className: t19,
294
+ children: [
295
+ t20,
296
+ t21,
297
+ t22
298
+ ]
299
+ });
300
+ $[73] = status;
301
+ $[74] = t16;
302
+ $[75] = t17;
303
+ $[76] = t19;
304
+ $[77] = t20;
305
+ $[78] = t21;
306
+ $[79] = t22;
307
+ $[80] = t23;
308
+ } else t23 = $[80];
309
+ return t23;
310
+ };
311
+ ChainOfThoughtStep.displayName = "ChainOfThoughtStep";
312
+ export { ChainOfThoughtStep };
@@ -0,0 +1,20 @@
1
+ export declare const chainOfThoughtVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
2
+ export declare const chainOfThoughtStepVariants: (props?: ({
3
+ simple?: boolean | null | undefined;
4
+ entered?: boolean | null | undefined;
5
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
6
+ export declare const chainOfThoughtRowVariants: (props?: ({
7
+ interactive?: boolean | null | undefined;
8
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
9
+ export declare const chainOfThoughtIconVariants: (props?: ({
10
+ status?: "done" | "error" | "running" | null | undefined;
11
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
12
+ export declare const chainOfThoughtLabelVariants: (props?: ({
13
+ status?: "done" | "error" | "running" | null | undefined;
14
+ entered?: boolean | null | undefined;
15
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
16
+ export declare const chainOfThoughtMetricVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
17
+ export declare const chainOfThoughtLineVariants: (props?: ({
18
+ entered?: boolean | null | undefined;
19
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
20
+ export declare const chainOfThoughtBodyVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
@@ -0,0 +1,84 @@
1
+ import { cva } from "class-variance-authority";
2
+ const chainOfThoughtVariants = cva('flex w-full list-none flex-col self-stretch text-xs leading-xs text-text-secondary');
3
+ const chainOfThoughtStepVariants = cva('flex flex-col [&:last-child>[data-slot=chain-of-thought-connector]]:hidden', {
4
+ variants: {
5
+ simple: {
6
+ true: 'not-first:mt-16',
7
+ false: ''
8
+ },
9
+ entered: {
10
+ true: 'motion-safe:transition-[opacity,translate] motion-safe:duration-200 motion-safe:ease-out motion-safe:starting:translate-y-4 motion-safe:starting:opacity-0',
11
+ false: ''
12
+ }
13
+ },
14
+ defaultVariants: {
15
+ simple: false,
16
+ entered: false
17
+ }
18
+ });
19
+ const chainOfThoughtRowVariants = cva('group/row flex w-full items-start gap-6 text-left', {
20
+ variants: {
21
+ interactive: {
22
+ true: 'cursor-pointer rounded-4 outline-none focus-visible:ring-3 focus-visible:ring-focus-primary',
23
+ false: ''
24
+ }
25
+ },
26
+ defaultVariants: {
27
+ interactive: false
28
+ }
29
+ });
30
+ const chainOfThoughtIconVariants = cva('flex size-16 shrink-0 items-center justify-center text-icon-secondary [&_svg]:icon-md', {
31
+ variants: {
32
+ status: {
33
+ running: '',
34
+ done: '',
35
+ error: 'text-icon-danger'
36
+ }
37
+ },
38
+ defaultVariants: {
39
+ status: 'done'
40
+ }
41
+ });
42
+ const chainOfThoughtLabelVariants = cva('min-w-0 flex-1', {
43
+ variants: {
44
+ status: {
45
+ running: 'shimmer-text',
46
+ done: '',
47
+ error: 'text-text-danger'
48
+ },
49
+ entered: {
50
+ true: 'motion-safe:transition-[-webkit-text-fill-color,color] motion-safe:duration-200 motion-safe:ease-out',
51
+ false: ''
52
+ }
53
+ },
54
+ compoundVariants: [
55
+ {
56
+ entered: true,
57
+ status: 'running',
58
+ class: 'motion-safe:not-forced-colors:[-webkit-text-fill-color:transparent]'
59
+ },
60
+ {
61
+ entered: true,
62
+ status: 'done',
63
+ class: 'shimmer-text [animation-play-state:paused] motion-safe:not-forced-colors:[-webkit-text-fill-color:var(--color-text-secondary)]'
64
+ }
65
+ ],
66
+ defaultVariants: {
67
+ status: 'done',
68
+ entered: false
69
+ }
70
+ });
71
+ const chainOfThoughtMetricVariants = cva("ms-auto shrink-0 text-right font-mono [font-feature-settings:'liga'_0]");
72
+ const chainOfThoughtLineVariants = cva('flex w-16 shrink-0 justify-center py-2 before:w-px before:bg-border-primary', {
73
+ variants: {
74
+ entered: {
75
+ true: 'motion-safe:origin-top motion-safe:transition-[scale] motion-safe:duration-200 motion-safe:ease-out motion-safe:starting:scale-y-0',
76
+ false: ''
77
+ }
78
+ },
79
+ defaultVariants: {
80
+ entered: false
81
+ }
82
+ });
83
+ const chainOfThoughtBodyVariants = cva('flex min-w-0 flex-1 flex-col gap-16 py-12 pl-6 pe-3 [&_ul]:list-disc [&_ul]:ps-18 [&_:is(h1,h2,h3,h4)]:font-medium');
84
+ export { chainOfThoughtBodyVariants, chainOfThoughtIconVariants, chainOfThoughtLabelVariants, chainOfThoughtLineVariants, chainOfThoughtMetricVariants, chainOfThoughtRowVariants, chainOfThoughtStepVariants, chainOfThoughtVariants };
@@ -0,0 +1,2 @@
1
+ export { ChainOfThought, type ChainOfThoughtProps } from './ChainOfThought.js';
2
+ export { ChainOfThoughtStep, type ChainOfThoughtStepProps } from './ChainOfThoughtStep.js';
@@ -0,0 +1,2 @@
1
+ export { ChainOfThought } from "./ChainOfThought.js";
2
+ export { ChainOfThoughtStep } from "./ChainOfThoughtStep.js";