@mcp-b/react-components 0.1.1 → 0.1.2

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 (203) hide show
  1. package/dist/Button-QCM8ZKgR.d.ts +98 -0
  2. package/dist/CodeBlock-CttHhWcb.js +356 -0
  3. package/dist/CodeBlock-V6pgafSS.d.ts +174 -0
  4. package/dist/Select-CRsKCJ9x.d.ts +200 -0
  5. package/dist/class-names-9UtZwb0J.js +12 -0
  6. package/dist/components/Accordion.d.ts +81 -0
  7. package/dist/components/Accordion.js +97 -0
  8. package/dist/components/AgentConnection.d.ts +69 -0
  9. package/dist/components/AgentConnection.js +176 -0
  10. package/dist/components/AlertDialog.d.ts +148 -0
  11. package/dist/components/AlertDialog.js +141 -0
  12. package/dist/components/Artifact.d.ts +128 -0
  13. package/dist/components/Artifact.js +115 -0
  14. package/dist/components/Autocomplete.d.ts +186 -0
  15. package/dist/components/Autocomplete.js +186 -0
  16. package/dist/components/Avatar.d.ts +134 -0
  17. package/dist/components/Avatar.js +118 -0
  18. package/dist/components/Badge.d.ts +68 -0
  19. package/dist/components/Badge.js +108 -0
  20. package/dist/components/Button.d.ts +2 -0
  21. package/dist/components/Button.js +73 -0
  22. package/dist/components/Card.d.ts +87 -0
  23. package/dist/components/Card.js +81 -0
  24. package/dist/components/ChainOfThought.d.ts +153 -0
  25. package/dist/components/ChainOfThought.js +157 -0
  26. package/dist/components/Checkbox.d.ts +35 -0
  27. package/dist/components/Checkbox.js +47 -0
  28. package/dist/components/CheckboxGroup.d.ts +76 -0
  29. package/dist/components/CheckboxGroup.js +69 -0
  30. package/dist/components/CodeBlock.d.ts +2 -0
  31. package/dist/components/CodeBlock.js +2 -0
  32. package/dist/components/Collapsible.d.ts +127 -0
  33. package/dist/components/Collapsible.js +103 -0
  34. package/dist/components/Combobox.d.ts +177 -0
  35. package/dist/components/Combobox.js +179 -0
  36. package/dist/components/Commit.d.ts +265 -0
  37. package/dist/components/Commit.js +282 -0
  38. package/dist/components/Context.d.ts +129 -0
  39. package/dist/components/Context.js +309 -0
  40. package/dist/components/ContextMenu.d.ts +282 -0
  41. package/dist/components/ContextMenu.js +270 -0
  42. package/dist/components/Conversation.d.ts +166 -0
  43. package/dist/components/Conversation.js +202 -0
  44. package/dist/components/Dialog.d.ts +120 -0
  45. package/dist/components/Dialog.js +114 -0
  46. package/dist/components/EnvironmentVariables.d.ts +176 -0
  47. package/dist/components/EnvironmentVariables.js +221 -0
  48. package/dist/components/Field.d.ts +281 -0
  49. package/dist/components/Field.js +274 -0
  50. package/dist/components/Fieldset.d.ts +93 -0
  51. package/dist/components/Fieldset.js +81 -0
  52. package/dist/components/FileTree.d.ts +116 -0
  53. package/dist/components/FileTree.js +310 -0
  54. package/dist/components/Form.d.ts +94 -0
  55. package/dist/components/Form.js +88 -0
  56. package/dist/components/GithubMotionMark.d.ts +13 -0
  57. package/dist/components/GithubMotionMark.js +23 -0
  58. package/dist/components/Input.d.ts +33 -0
  59. package/dist/components/Input.js +27 -0
  60. package/dist/components/Label.d.ts +44 -0
  61. package/dist/components/Label.js +41 -0
  62. package/dist/components/Menu.d.ts +395 -0
  63. package/dist/components/Menu.js +338 -0
  64. package/dist/components/Menubar.d.ts +331 -0
  65. package/dist/components/Menubar.js +299 -0
  66. package/dist/components/Message.d.ts +216 -0
  67. package/dist/components/Message.js +245 -0
  68. package/dist/components/Meter.d.ts +151 -0
  69. package/dist/components/Meter.js +121 -0
  70. package/dist/components/ModelSelector.d.ts +198 -0
  71. package/dist/components/ModelSelector.js +306 -0
  72. package/dist/components/NaniteScene.d.ts +33 -0
  73. package/dist/components/NaniteScene.js +405 -0
  74. package/dist/components/NavigationMenu.d.ts +256 -0
  75. package/dist/components/NavigationMenu.js +228 -0
  76. package/dist/components/NumberField.d.ts +159 -0
  77. package/dist/components/NumberField.js +123 -0
  78. package/dist/components/Popover.d.ts +278 -0
  79. package/dist/components/Popover.js +245 -0
  80. package/dist/components/PreviewCard.d.ts +156 -0
  81. package/dist/components/PreviewCard.js +156 -0
  82. package/dist/components/PricingPage.d.ts +209 -0
  83. package/dist/components/PricingPage.js +506 -0
  84. package/dist/components/Progress.d.ts +58 -0
  85. package/dist/components/Progress.js +51 -0
  86. package/dist/components/PromptInput.d.ts +399 -0
  87. package/dist/components/PromptInput.js +737 -0
  88. package/dist/components/Queue.d.ts +241 -0
  89. package/dist/components/Queue.js +225 -0
  90. package/dist/components/RadioGroup.d.ts +78 -0
  91. package/dist/components/RadioGroup.js +72 -0
  92. package/dist/components/Reasoning.d.ts +88 -0
  93. package/dist/components/Reasoning.js +187 -0
  94. package/dist/components/ScrollArea.d.ts +160 -0
  95. package/dist/components/ScrollArea.js +145 -0
  96. package/dist/components/Select.d.ts +2 -0
  97. package/dist/components/Select.js +260 -0
  98. package/dist/components/Separator.d.ts +45 -0
  99. package/dist/components/Separator.js +40 -0
  100. package/dist/components/Shell.d.ts +163 -0
  101. package/dist/components/Shell.js +137 -0
  102. package/dist/components/Slider.d.ts +120 -0
  103. package/dist/components/Slider.js +115 -0
  104. package/dist/components/Sources.d.ts +91 -0
  105. package/dist/components/Sources.js +121 -0
  106. package/dist/components/Stepper.d.ts +190 -0
  107. package/dist/components/Stepper.js +315 -0
  108. package/dist/components/Switch.d.ts +57 -0
  109. package/dist/components/Switch.js +55 -0
  110. package/dist/components/Tabs.d.ts +84 -0
  111. package/dist/components/Tabs.js +78 -0
  112. package/dist/components/Task.d.ts +100 -0
  113. package/dist/components/Task.js +120 -0
  114. package/dist/components/Terminal.d.ts +118 -0
  115. package/dist/components/Terminal.js +234 -0
  116. package/dist/components/TestResults.d.ts +236 -0
  117. package/dist/components/TestResults.js +346 -0
  118. package/dist/components/Toast.d.ts +192 -0
  119. package/dist/components/Toast.js +163 -0
  120. package/dist/components/Toggle.d.ts +69 -0
  121. package/dist/components/Toggle.js +66 -0
  122. package/dist/components/ToggleGroup.d.ts +69 -0
  123. package/dist/components/ToggleGroup.js +99 -0
  124. package/dist/components/Tool.d.ts +119 -0
  125. package/dist/components/Tool.js +192 -0
  126. package/dist/components/Toolbar.d.ts +162 -0
  127. package/dist/components/Toolbar.js +126 -0
  128. package/dist/components/Tooltip.d.ts +81 -0
  129. package/dist/components/Tooltip.js +74 -0
  130. package/dist/components/WebPreview.d.ts +143 -0
  131. package/dist/components/WebPreview.js +280 -0
  132. package/dist/components/useStickToBottom.d.ts +30 -0
  133. package/dist/components/useStickToBottom.js +95 -0
  134. package/dist/copy-button-BIATcZWZ.d.ts +16 -0
  135. package/dist/copy-button-BNgclDrO.js +43 -0
  136. package/dist/icons-BsWc8g4E.js +221 -0
  137. package/dist/styles/accordion.css +10 -10
  138. package/dist/styles/agent-connection.css +18 -17
  139. package/dist/styles/alert-dialog.css +48 -29
  140. package/dist/styles/artifact.css +10 -10
  141. package/dist/styles/autocomplete.css +25 -24
  142. package/dist/styles/avatar.css +96 -6
  143. package/dist/styles/badge.css +78 -14
  144. package/dist/styles/base.css +9 -9
  145. package/dist/styles/button.css +57 -38
  146. package/dist/styles/card.css +57 -10
  147. package/dist/styles/chain-of-thought.css +47 -33
  148. package/dist/styles/checkbox.css +24 -10
  149. package/dist/styles/code-block.css +22 -15
  150. package/dist/styles/collapsible.css +14 -12
  151. package/dist/styles/combobox.css +26 -25
  152. package/dist/styles/commit.css +49 -24
  153. package/dist/styles/context-menu.css +70 -16
  154. package/dist/styles/context.css +15 -15
  155. package/dist/styles/conversation.css +12 -12
  156. package/dist/styles/dialog.css +52 -16
  157. package/dist/styles/environment-variables.css +19 -19
  158. package/dist/styles/field.css +184 -22
  159. package/dist/styles/fieldset.css +5 -4
  160. package/dist/styles/file-tree.css +17 -17
  161. package/dist/styles/index.css.d.ts +1 -0
  162. package/dist/styles/input.css +45 -11
  163. package/dist/styles/label.css +21 -4
  164. package/dist/styles/menu.css +55 -32
  165. package/dist/styles/menubar.css +80 -28
  166. package/dist/styles/message.css +22 -13
  167. package/dist/styles/meter.css +8 -8
  168. package/dist/styles/model-selector.css +33 -21
  169. package/dist/styles/navigation-menu.css +26 -24
  170. package/dist/styles/number-field.css +20 -18
  171. package/dist/styles/popover.css +38 -28
  172. package/dist/styles/preview-card.css +15 -13
  173. package/dist/styles/pricing-page.css +53 -53
  174. package/dist/styles/progress.css +7 -7
  175. package/dist/styles/prompt-input.css +73 -24
  176. package/dist/styles/queue.css +58 -32
  177. package/dist/styles/radio.css +26 -11
  178. package/dist/styles/reasoning.css +15 -11
  179. package/dist/styles/scroll-area.css +6 -6
  180. package/dist/styles/scrollbars.css +4 -4
  181. package/dist/styles/select.css +84 -25
  182. package/dist/styles/separator.css +1 -1
  183. package/dist/styles/shell.css +21 -20
  184. package/dist/styles/slider.css +35 -11
  185. package/dist/styles/sources.css +20 -20
  186. package/dist/styles/stepper.css +22 -22
  187. package/dist/styles/switch.css +29 -13
  188. package/dist/styles/tabs.css +23 -16
  189. package/dist/styles/task.css +27 -23
  190. package/dist/styles/terminal.css +16 -13
  191. package/dist/styles/test-results.css +79 -32
  192. package/dist/styles/toast.css +26 -25
  193. package/dist/styles/toggle-group.css +12 -12
  194. package/dist/styles/toggle.css +29 -11
  195. package/dist/styles/tool.css +54 -32
  196. package/dist/styles/toolbar.css +30 -28
  197. package/dist/styles/tooltip.css +10 -8
  198. package/dist/styles/web-preview.css +37 -21
  199. package/dist/utils/structured-code.d.ts +10 -0
  200. package/dist/utils/structured-code.js +81 -0
  201. package/package.json +16 -7
  202. package/dist/index.d.ts +0 -7236
  203. package/dist/index.js +0 -8945
@@ -0,0 +1,120 @@
1
+ import { S as SearchIcon, c as ChevronRightIcon, m as FileIcon } from "../icons-BsWc8g4E.js";
2
+ import { t as cx } from "../class-names-9UtZwb0J.js";
3
+ import { CollapsiblePanel, CollapsibleRoot, CollapsibleTrigger } from "./Collapsible.js";
4
+ import "react";
5
+ import { jsx, jsxs } from "react/jsx-runtime";
6
+ //#region src/components/Task.tsx
7
+ /**
8
+ * A collapsible task/workflow list. Compose with TaskTrigger, TaskContent,
9
+ * TaskItem, and TaskItemFile to show structured progress for a multi-step
10
+ * workflow like file edits. Adapted from Vercel AI Elements and restyled
11
+ * with Sigvelo CSS tokens.
12
+ *
13
+ * @example
14
+ * ```tsx
15
+ * <Task defaultOpen>
16
+ * <TaskTrigger title="Refactoring authentication module" />
17
+ * <TaskContent>
18
+ * <TaskItem>
19
+ * Updated <TaskItemFile name="auth.ts" /> to export the new interface
20
+ * </TaskItem>
21
+ * <TaskItem>
22
+ * Added tests in <TaskItemFile name="auth.test.ts" />
23
+ * </TaskItem>
24
+ * </TaskContent>
25
+ * </Task>
26
+ * ```
27
+ *
28
+ * @see {@link https://elements.ai-sdk.dev/components/task | AI Elements Task}
29
+ */
30
+ function Task({ className, defaultOpen = true, ref, ...props }) {
31
+ return /* @__PURE__ */ jsx(CollapsibleRoot, {
32
+ ref,
33
+ className: cx("task", className),
34
+ defaultOpen,
35
+ ...props,
36
+ unstyled: true
37
+ });
38
+ }
39
+ /**
40
+ * Clickable header that toggles the task content.
41
+ */
42
+ function TaskTrigger({ className, title, children, ref, ...props }) {
43
+ if (children !== void 0 && children !== null) return /* @__PURE__ */ jsx(CollapsibleTrigger, {
44
+ ref,
45
+ className: cx("task__trigger", className),
46
+ ...props,
47
+ unstyled: true,
48
+ children
49
+ });
50
+ return /* @__PURE__ */ jsxs(CollapsibleTrigger, {
51
+ ref,
52
+ className: cx("task__trigger", className),
53
+ ...props,
54
+ unstyled: true,
55
+ children: [
56
+ /* @__PURE__ */ jsx("span", {
57
+ className: "task__trigger-leading-icon",
58
+ "aria-hidden": "true",
59
+ children: /* @__PURE__ */ jsx(SearchIcon, {})
60
+ }),
61
+ /* @__PURE__ */ jsx("span", {
62
+ className: "task__trigger-title",
63
+ children: title
64
+ }),
65
+ /* @__PURE__ */ jsx("span", {
66
+ className: "task__trigger-icon",
67
+ "aria-hidden": "true",
68
+ children: /* @__PURE__ */ jsx(ChevronRightIcon, {})
69
+ })
70
+ ]
71
+ });
72
+ }
73
+ /**
74
+ * The collapsible panel containing TaskItem children.
75
+ */
76
+ function TaskContent({ className, children, ref, ...props }) {
77
+ return /* @__PURE__ */ jsx(CollapsiblePanel, {
78
+ ref,
79
+ className: cx("task__content", className),
80
+ ...props,
81
+ unstyled: true,
82
+ children: /* @__PURE__ */ jsx("ul", {
83
+ className: "task__list",
84
+ role: "list",
85
+ children
86
+ })
87
+ });
88
+ }
89
+ /**
90
+ * A single task row. Free-form content; compose with TaskItemFile to
91
+ * reference a file inline.
92
+ */
93
+ function TaskItem({ className, children, ref, ...props }) {
94
+ return /* @__PURE__ */ jsx("li", {
95
+ ref,
96
+ className: cx("task__item", className),
97
+ ...props,
98
+ children
99
+ });
100
+ }
101
+ /**
102
+ * Inline file reference badge used inside TaskItem content.
103
+ */
104
+ function TaskItemFile({ className, name, children, ref, ...props }) {
105
+ return /* @__PURE__ */ jsxs("span", {
106
+ ref,
107
+ className: cx("task__file", className),
108
+ ...props,
109
+ children: [/* @__PURE__ */ jsx("span", {
110
+ className: "task__file-icon",
111
+ "aria-hidden": "true",
112
+ children: /* @__PURE__ */ jsx(FileIcon, {})
113
+ }), /* @__PURE__ */ jsx("span", {
114
+ className: "task__file-name",
115
+ children: children ?? name
116
+ })]
117
+ });
118
+ }
119
+ //#endregion
120
+ export { Task, TaskContent, TaskItem, TaskItemFile, TaskTrigger };
@@ -0,0 +1,118 @@
1
+ import { r as ButtonProps } from "../Button-QCM8ZKgR.js";
2
+ import { t as CopyButtonProps } from "../copy-button-BIATcZWZ.js";
3
+ import * as React from "react";
4
+
5
+ //#region src/components/Terminal.d.ts
6
+ interface TerminalProps extends React.HTMLAttributes<HTMLDivElement> {
7
+ /** Terminal output; may include ANSI escape codes. */
8
+ output: string;
9
+ /** Whether output is actively streaming. Shows a blinking cursor. */
10
+ isStreaming?: boolean;
11
+ /** Whether to auto-scroll to bottom when output changes. */
12
+ autoScroll?: boolean;
13
+ /** Called when the clear button is pressed. */
14
+ onClear?: () => void;
15
+ }
16
+ /**
17
+ * A console output viewer with ANSI color support, auto-scroll, and a
18
+ * streaming cursor. Compose with TerminalHeader and TerminalContent.
19
+ *
20
+ * @example
21
+ * ```tsx
22
+ * <Terminal output={logs} isStreaming>
23
+ * <TerminalHeader>
24
+ * <TerminalTitle>build.log</TerminalTitle>
25
+ * <TerminalStatus status="running" />
26
+ * <TerminalActions>
27
+ * <TerminalCopyButton />
28
+ * <TerminalClearButton />
29
+ * </TerminalActions>
30
+ * </TerminalHeader>
31
+ * <TerminalContent />
32
+ * </Terminal>
33
+ * ```
34
+ */
35
+ declare function Terminal({
36
+ className,
37
+ output,
38
+ isStreaming,
39
+ autoScroll,
40
+ onClear,
41
+ children,
42
+ ref,
43
+ ...props
44
+ }: TerminalProps & {
45
+ ref?: React.Ref<HTMLDivElement>;
46
+ }): React.JSX.Element;
47
+ interface TerminalHeaderProps extends React.HTMLAttributes<HTMLDivElement> {}
48
+ declare function TerminalHeader({
49
+ className,
50
+ children,
51
+ ref,
52
+ ...props
53
+ }: TerminalHeaderProps & {
54
+ ref?: React.Ref<HTMLDivElement>;
55
+ }): React.JSX.Element;
56
+ interface TerminalTitleProps extends React.HTMLAttributes<HTMLSpanElement> {}
57
+ declare function TerminalTitle({
58
+ className,
59
+ children,
60
+ ref,
61
+ ...props
62
+ }: TerminalTitleProps & {
63
+ ref?: React.Ref<HTMLSpanElement>;
64
+ }): React.JSX.Element;
65
+ type TerminalStatusValue = "idle" | "running" | "success" | "error";
66
+ interface TerminalStatusProps extends Omit<React.HTMLAttributes<HTMLSpanElement>, "color"> {
67
+ status: TerminalStatusValue;
68
+ }
69
+ declare function TerminalStatus({
70
+ className,
71
+ status,
72
+ ref,
73
+ ...props
74
+ }: TerminalStatusProps & {
75
+ ref?: React.Ref<HTMLSpanElement>;
76
+ }): React.JSX.Element;
77
+ interface TerminalActionsProps extends React.HTMLAttributes<HTMLDivElement> {}
78
+ declare function TerminalActions({
79
+ className,
80
+ children,
81
+ ref,
82
+ ...props
83
+ }: TerminalActionsProps & {
84
+ ref?: React.Ref<HTMLDivElement>;
85
+ }): React.JSX.Element;
86
+ interface TerminalContentProps extends React.HTMLAttributes<HTMLDivElement> {}
87
+ declare function TerminalContent({
88
+ className,
89
+ ref,
90
+ ...props
91
+ }: TerminalContentProps & {
92
+ ref?: React.Ref<HTMLDivElement>;
93
+ }): React.JSX.Element;
94
+ interface TerminalCopyButtonProps extends Omit<CopyButtonProps, "text" | "label"> {
95
+ label?: string;
96
+ /** Milliseconds to show "Copied" before reverting. Default 2000. */
97
+ timeout?: number;
98
+ }
99
+ declare function TerminalCopyButton({
100
+ className,
101
+ label,
102
+ timeout,
103
+ onClick,
104
+ ...props
105
+ }: TerminalCopyButtonProps): React.JSX.Element;
106
+ interface TerminalClearButtonProps extends Omit<ButtonProps, "children" | "variant" | "size" | "color" | "className" | "onClick"> {
107
+ className?: string;
108
+ label?: string;
109
+ onClick?: React.MouseEventHandler<HTMLButtonElement>;
110
+ }
111
+ declare function TerminalClearButton({
112
+ className,
113
+ label,
114
+ onClick,
115
+ ...props
116
+ }: TerminalClearButtonProps): React.JSX.Element;
117
+ //#endregion
118
+ export { Terminal, TerminalActions, TerminalActionsProps, TerminalClearButton, TerminalClearButtonProps, TerminalContent, TerminalContentProps, TerminalCopyButton, TerminalCopyButtonProps, TerminalHeader, TerminalHeaderProps, TerminalProps, TerminalStatus, TerminalStatusProps, TerminalStatusValue, TerminalTitle, TerminalTitleProps };
@@ -0,0 +1,234 @@
1
+ import { O as XIcon, T as TerminalIcon } from "../icons-BsWc8g4E.js";
2
+ import { t as cx } from "../class-names-9UtZwb0J.js";
3
+ import { Button } from "./Button.js";
4
+ import { Tooltip, TooltipPopup, TooltipPortal, TooltipPositioner, TooltipTrigger } from "./Tooltip.js";
5
+ import { t as CopyButton } from "../copy-button-BNgclDrO.js";
6
+ import { Badge } from "./Badge.js";
7
+ import { ScrollArea } from "./ScrollArea.js";
8
+ import * as React from "react";
9
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
10
+ import Anser from "anser";
11
+ //#region src/components/_internal/ansi.ts
12
+ /**
13
+ * Maps Anser's standard 16-color RGB strings to CSS variables bound to the
14
+ * Sigvelo palette. Values come from anser's internal PALETTE. Any RGB triple
15
+ * not in this map falls through to a raw `rgb(...)` literal.
16
+ */
17
+ const STANDARD_COLOR_MAP = {
18
+ "0, 0, 0": "var(--sigvelo-color-neutral-300)",
19
+ "187, 0, 0": "var(--sigvelo-color-danger-300)",
20
+ "0, 187, 0": "var(--sigvelo-color-success-300)",
21
+ "187, 187, 0": "var(--sigvelo-color-warning-300)",
22
+ "0, 0, 187": "var(--sigvelo-color-primary-300)",
23
+ "187, 0, 187": "var(--sigvelo-color-primary-200)",
24
+ "0, 187, 187": "var(--sigvelo-color-primary-200)",
25
+ "255, 255, 255": "var(--sigvelo-color-neutral-100)",
26
+ "85, 85, 85": "var(--sigvelo-color-neutral-400)",
27
+ "255, 85, 85": "var(--sigvelo-color-danger-300)",
28
+ "85, 255, 85": "var(--sigvelo-color-success-300)",
29
+ "255, 255, 85": "var(--sigvelo-color-warning-300)",
30
+ "85, 85, 255": "var(--sigvelo-color-primary-300)",
31
+ "255, 85, 255": "var(--sigvelo-color-primary-200)",
32
+ "85, 255, 255": "var(--sigvelo-color-primary-200)",
33
+ "187, 187, 187": "var(--sigvelo-color-neutral-300)"
34
+ };
35
+ function toCss(raw) {
36
+ if (!raw) return void 0;
37
+ const mapped = STANDARD_COLOR_MAP[raw];
38
+ if (mapped) return mapped;
39
+ return `rgb(${raw})`;
40
+ }
41
+ /**
42
+ * Parses an ANSI-escaped string into an array of formatted segments.
43
+ *
44
+ * Empty segments (bare escape codes) are filtered out.
45
+ */
46
+ function parseAnsi(input) {
47
+ return Anser.ansiToJson(input, {
48
+ json: true,
49
+ remove_empty: true
50
+ }).filter((c) => c.content.length > 0).map((c) => ({
51
+ content: c.content,
52
+ fg: toCss(c.fg),
53
+ bg: toCss(c.bg),
54
+ bold: c.decorations?.includes("bold") ?? false,
55
+ italic: c.decorations?.includes("italic") ?? false,
56
+ underline: c.decorations?.includes("underline") ?? false,
57
+ strikethrough: c.decorations?.includes("strikethrough") ?? false,
58
+ dim: c.decorations?.includes("dim") ?? false
59
+ }));
60
+ }
61
+ //#endregion
62
+ //#region src/components/Terminal.tsx
63
+ const TerminalContext = React.createContext(null);
64
+ function useTerminalContext() {
65
+ const ctx = React.useContext(TerminalContext);
66
+ if (!ctx) throw new Error("Terminal subcomponents must be used inside <Terminal>.");
67
+ return ctx;
68
+ }
69
+ /**
70
+ * A console output viewer with ANSI color support, auto-scroll, and a
71
+ * streaming cursor. Compose with TerminalHeader and TerminalContent.
72
+ *
73
+ * @example
74
+ * ```tsx
75
+ * <Terminal output={logs} isStreaming>
76
+ * <TerminalHeader>
77
+ * <TerminalTitle>build.log</TerminalTitle>
78
+ * <TerminalStatus status="running" />
79
+ * <TerminalActions>
80
+ * <TerminalCopyButton />
81
+ * <TerminalClearButton />
82
+ * </TerminalActions>
83
+ * </TerminalHeader>
84
+ * <TerminalContent />
85
+ * </Terminal>
86
+ * ```
87
+ */
88
+ function Terminal({ className, output, isStreaming = false, autoScroll = true, onClear, children, ref, ...props }) {
89
+ const ctxValue = React.useMemo(() => ({
90
+ output,
91
+ isStreaming,
92
+ autoScroll,
93
+ onClear
94
+ }), [
95
+ output,
96
+ isStreaming,
97
+ autoScroll,
98
+ onClear
99
+ ]);
100
+ return /* @__PURE__ */ jsx(TerminalContext.Provider, {
101
+ value: ctxValue,
102
+ children: /* @__PURE__ */ jsx("div", {
103
+ ref,
104
+ className: cx("terminal", className),
105
+ "data-streaming": isStreaming ? "" : void 0,
106
+ ...props,
107
+ children: children ?? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs(TerminalHeader, { children: [/* @__PURE__ */ jsx(TerminalTitle, {}), /* @__PURE__ */ jsxs(TerminalActions, { children: [/* @__PURE__ */ jsx(TerminalCopyButton, {}), onClear ? /* @__PURE__ */ jsx(TerminalClearButton, {}) : null] })] }), /* @__PURE__ */ jsx(TerminalContent, {})] })
108
+ })
109
+ });
110
+ }
111
+ function TerminalHeader({ className, children, ref, ...props }) {
112
+ return /* @__PURE__ */ jsx("div", {
113
+ ref,
114
+ className: cx("terminal__header", className),
115
+ ...props,
116
+ children
117
+ });
118
+ }
119
+ function TerminalTitle({ className, children, ref, ...props }) {
120
+ return /* @__PURE__ */ jsxs("span", {
121
+ ref,
122
+ className: cx("terminal__title", className),
123
+ ...props,
124
+ children: [/* @__PURE__ */ jsx(TerminalIcon, { "aria-hidden": "true" }), children ?? "Terminal"]
125
+ });
126
+ }
127
+ const STATUS_COLOR = {
128
+ idle: "neutral",
129
+ running: "primary",
130
+ success: "success",
131
+ error: "destructive"
132
+ };
133
+ function TerminalStatus({ className, status, ref, ...props }) {
134
+ return /* @__PURE__ */ jsx(Badge, {
135
+ ...props,
136
+ ref,
137
+ color: STATUS_COLOR[status],
138
+ size: "sm",
139
+ className: cx("terminal__status", className),
140
+ children: status
141
+ });
142
+ }
143
+ function TerminalActions({ className, children, ref, ...props }) {
144
+ return /* @__PURE__ */ jsx("div", {
145
+ ref,
146
+ className: cx("terminal__actions", className),
147
+ ...props,
148
+ children
149
+ });
150
+ }
151
+ function TerminalContent({ className, ref, ...props }) {
152
+ const { output, isStreaming, autoScroll } = useTerminalContext();
153
+ const viewportRef = React.useRef(null);
154
+ const [stickToBottom, setStickToBottom] = React.useState(true);
155
+ const segments = React.useMemo(() => parseAnsi(output), [output]);
156
+ React.useEffect(() => {
157
+ if (!autoScroll || !stickToBottom) return;
158
+ const viewport = viewportRef.current;
159
+ if (!viewport) return;
160
+ viewport.scrollTop = viewport.scrollHeight;
161
+ }, [
162
+ output,
163
+ autoScroll,
164
+ stickToBottom
165
+ ]);
166
+ const handleScroll = (e) => {
167
+ const target = e.currentTarget;
168
+ setStickToBottom(target.scrollHeight - target.scrollTop - target.clientHeight < 8);
169
+ };
170
+ return /* @__PURE__ */ jsxs(ScrollArea.Root, {
171
+ ref,
172
+ className: cx("terminal__content", className),
173
+ ...props,
174
+ children: [/* @__PURE__ */ jsx(ScrollArea.Viewport, {
175
+ ref: viewportRef,
176
+ className: "terminal__content-viewport",
177
+ onScroll: handleScroll,
178
+ children: /* @__PURE__ */ jsxs("pre", {
179
+ className: "terminal__output",
180
+ children: [segments.map((seg, i) => /* @__PURE__ */ jsx("span", {
181
+ style: {
182
+ color: seg.fg,
183
+ backgroundColor: seg.bg,
184
+ fontWeight: seg.bold ? "bold" : void 0,
185
+ fontStyle: seg.italic ? "italic" : void 0,
186
+ textDecoration: seg.underline ? "underline" : seg.strikethrough ? "line-through" : void 0,
187
+ opacity: seg.dim ? .7 : void 0
188
+ },
189
+ children: seg.content
190
+ }, i)), isStreaming ? /* @__PURE__ */ jsx("span", {
191
+ className: "terminal__cursor",
192
+ "aria-hidden": "true"
193
+ }) : null]
194
+ })
195
+ }), /* @__PURE__ */ jsx(ScrollArea.Scrollbar, {
196
+ orientation: "vertical",
197
+ children: /* @__PURE__ */ jsx(ScrollArea.Thumb, {})
198
+ })]
199
+ });
200
+ }
201
+ function TerminalCopyButton({ className, label = "Copy output", timeout = 2e3, onClick, ...props }) {
202
+ const { output } = useTerminalContext();
203
+ const plain = React.useMemo(() => stripAnsi(output), [output]);
204
+ return /* @__PURE__ */ jsx(CopyButton, {
205
+ ...props,
206
+ text: plain,
207
+ label,
208
+ timeout,
209
+ className: cx("terminal__copy", className),
210
+ onClick
211
+ });
212
+ }
213
+ function TerminalClearButton({ className, label = "Clear terminal", onClick, ...props }) {
214
+ const { onClear } = useTerminalContext();
215
+ const handleClick = React.useCallback((e) => {
216
+ onClear?.();
217
+ onClick?.(e);
218
+ }, [onClear, onClick]);
219
+ return /* @__PURE__ */ jsxs(Tooltip, { children: [/* @__PURE__ */ jsx(TooltipTrigger, { render: /* @__PURE__ */ jsx(Button, {
220
+ variant: "ghost",
221
+ size: "icon",
222
+ "aria-label": label,
223
+ className: cx("terminal__clear", className),
224
+ ...props,
225
+ onClick: handleClick,
226
+ children: /* @__PURE__ */ jsx(XIcon, {})
227
+ }) }), /* @__PURE__ */ jsx(TooltipPortal, { children: /* @__PURE__ */ jsx(TooltipPositioner, { children: /* @__PURE__ */ jsx(TooltipPopup, { children: label }) }) })] });
228
+ }
229
+ const ANSI_REGEX = /\u001b\[[0-9;?]*[a-zA-Z]/g;
230
+ function stripAnsi(input) {
231
+ return input.replace(ANSI_REGEX, "");
232
+ }
233
+ //#endregion
234
+ export { Terminal, TerminalActions, TerminalClearButton, TerminalContent, TerminalCopyButton, TerminalHeader, TerminalStatus, TerminalTitle };
@@ -0,0 +1,236 @@
1
+ import { CollapsiblePanelProps, CollapsibleRootProps, CollapsibleTriggerProps } from "./Collapsible.js";
2
+ import * as React from "react";
3
+
4
+ //#region src/components/TestResults.d.ts
5
+ type TestStatusValue = "passed" | "failed" | "skipped" | "running";
6
+ interface TestSummary {
7
+ /** Number of passed tests. */
8
+ passed: number;
9
+ /** Number of failed tests. */
10
+ failed: number;
11
+ /** Number of skipped tests. */
12
+ skipped: number;
13
+ /** Total number of tests represented by the summary. */
14
+ total: number;
15
+ /** Total runtime in milliseconds. */
16
+ duration?: number;
17
+ }
18
+ interface TestResultsProps extends React.HTMLAttributes<HTMLDivElement> {
19
+ /** Aggregate test counts used by the summary and progress bar. */
20
+ summary?: TestSummary;
21
+ /** Additional class names for layout only; do not override status colors from apps. */
22
+ className?: string;
23
+ /** Optional custom report content; defaults to summary and empty content slots. */
24
+ children?: React.ReactNode;
25
+ }
26
+ /**
27
+ * Displays a test suite report with summary stats, progress bar, and
28
+ * collapsible per-suite results.
29
+ *
30
+ * Built internally for CI/test output in agent and developer workflows. Use it
31
+ * for structured test reports. Do not use it for generic status dashboards.
32
+ *
33
+ * Sigvelo changes: composes Collapsible, Badge, and Progress; maps status
34
+ * color and spacing to Sigvelo CSS tokens; opens failed suites by default.
35
+ *
36
+ * Suite triggers inherit Collapsible keyboard behavior. Error stacks should be
37
+ * text, not images. Add new statuses here before apps fork their own report UI.
38
+ *
39
+ * @example
40
+ * ```tsx
41
+ * <TestResults summary={{ passed: 10, failed: 1, skipped: 0, total: 11 }}>
42
+ * <TestSuite name="auth.test.ts" status="failed">
43
+ * <Test name="rejects bad tokens" status="failed">
44
+ * <TestError message="Expected 401, received 500" />
45
+ * </Test>
46
+ * </TestSuite>
47
+ * </TestResults>
48
+ * ```
49
+ */
50
+ declare function TestResults({
51
+ className,
52
+ summary,
53
+ children,
54
+ ref,
55
+ ...props
56
+ }: TestResultsProps & {
57
+ ref?: React.Ref<HTMLDivElement>;
58
+ }): React.JSX.Element;
59
+ interface TestResultsHeaderProps extends React.HTMLAttributes<HTMLDivElement> {}
60
+ declare function TestResultsHeader({
61
+ className,
62
+ children,
63
+ ref,
64
+ ...props
65
+ }: TestResultsHeaderProps & {
66
+ ref?: React.Ref<HTMLDivElement>;
67
+ }): React.JSX.Element;
68
+ interface TestResultsDurationProps extends React.HTMLAttributes<HTMLSpanElement> {}
69
+ declare function TestResultsDuration({
70
+ className,
71
+ children,
72
+ ref,
73
+ ...props
74
+ }: TestResultsDurationProps & {
75
+ ref?: React.Ref<HTMLSpanElement>;
76
+ }): React.JSX.Element | null;
77
+ interface TestResultsSummaryProps extends React.HTMLAttributes<HTMLDivElement> {}
78
+ declare function TestResultsSummary({
79
+ className,
80
+ children,
81
+ ref,
82
+ ...props
83
+ }: TestResultsSummaryProps & {
84
+ ref?: React.Ref<HTMLDivElement>;
85
+ }): React.JSX.Element | null;
86
+ interface TestResultsProgressProps extends React.HTMLAttributes<HTMLDivElement> {}
87
+ declare function TestResultsProgress({
88
+ className,
89
+ children,
90
+ ref,
91
+ ...props
92
+ }: TestResultsProgressProps & {
93
+ ref?: React.Ref<HTMLDivElement>;
94
+ }): React.JSX.Element | null;
95
+ interface TestResultsContentProps extends React.HTMLAttributes<HTMLDivElement> {}
96
+ declare function TestResultsContent({
97
+ className,
98
+ children,
99
+ ref,
100
+ ...props
101
+ }: TestResultsContentProps & {
102
+ ref?: React.Ref<HTMLDivElement>;
103
+ }): React.JSX.Element;
104
+ interface TestSuiteProps extends Omit<CollapsibleRootProps, "className" | "unstyled"> {
105
+ className?: string;
106
+ name: string;
107
+ status: TestStatusValue;
108
+ }
109
+ declare function TestSuite({
110
+ className,
111
+ name,
112
+ status,
113
+ defaultOpen,
114
+ children,
115
+ ref,
116
+ ...props
117
+ }: TestSuiteProps & {
118
+ ref?: React.Ref<HTMLDivElement>;
119
+ }): React.JSX.Element;
120
+ type TestSuiteNameProps = Omit<CollapsibleTriggerProps, "className" | "unstyled"> & {
121
+ className?: string;
122
+ };
123
+ declare function TestSuiteName({
124
+ className,
125
+ children,
126
+ ref,
127
+ ...props
128
+ }: TestSuiteNameProps & {
129
+ ref?: React.Ref<HTMLButtonElement>;
130
+ }): React.JSX.Element;
131
+ interface TestSuiteStatsProps extends React.HTMLAttributes<HTMLDivElement> {
132
+ passed?: number;
133
+ failed?: number;
134
+ skipped?: number;
135
+ }
136
+ declare function TestSuiteStats({
137
+ className,
138
+ passed,
139
+ failed,
140
+ skipped,
141
+ children,
142
+ ref,
143
+ ...props
144
+ }: TestSuiteStatsProps & {
145
+ ref?: React.Ref<HTMLDivElement>;
146
+ }): React.JSX.Element;
147
+ type TestSuiteContentProps = Omit<CollapsiblePanelProps, "className" | "unstyled"> & {
148
+ className?: string;
149
+ };
150
+ declare function TestSuiteContent({
151
+ className,
152
+ children,
153
+ ref,
154
+ ...props
155
+ }: TestSuiteContentProps & {
156
+ ref?: React.Ref<HTMLDivElement>;
157
+ }): React.JSX.Element;
158
+ interface TestProps extends React.HTMLAttributes<HTMLDivElement> {
159
+ name: string;
160
+ status: TestStatusValue;
161
+ duration?: number;
162
+ }
163
+ declare function Test({
164
+ className,
165
+ name,
166
+ status,
167
+ duration,
168
+ children,
169
+ ref,
170
+ ...props
171
+ }: TestProps & {
172
+ ref?: React.Ref<HTMLDivElement>;
173
+ }): React.JSX.Element;
174
+ interface TestStatusProps extends React.HTMLAttributes<HTMLSpanElement> {
175
+ status?: TestStatusValue;
176
+ }
177
+ declare function TestStatus({
178
+ className,
179
+ children,
180
+ status,
181
+ ref,
182
+ ...props
183
+ }: TestStatusProps & {
184
+ ref?: React.Ref<HTMLSpanElement>;
185
+ }): React.JSX.Element;
186
+ interface TestNameProps extends React.HTMLAttributes<HTMLSpanElement> {}
187
+ declare function TestName({
188
+ className,
189
+ children,
190
+ ref,
191
+ ...props
192
+ }: TestNameProps & {
193
+ ref?: React.Ref<HTMLSpanElement>;
194
+ }): React.JSX.Element;
195
+ interface TestDurationProps extends React.HTMLAttributes<HTMLSpanElement> {}
196
+ declare function TestDuration({
197
+ className,
198
+ children,
199
+ ref,
200
+ ...props
201
+ }: TestDurationProps & {
202
+ ref?: React.Ref<HTMLSpanElement>;
203
+ }): React.JSX.Element | null;
204
+ interface TestErrorProps extends React.HTMLAttributes<HTMLDivElement> {
205
+ /** Error message or stack trace. */
206
+ message?: string;
207
+ }
208
+ declare function TestError({
209
+ className,
210
+ message,
211
+ children,
212
+ ref,
213
+ ...props
214
+ }: TestErrorProps & {
215
+ ref?: React.Ref<HTMLDivElement>;
216
+ }): React.JSX.Element;
217
+ interface TestErrorMessageProps extends React.HTMLAttributes<HTMLParagraphElement> {}
218
+ declare function TestErrorMessage({
219
+ className,
220
+ children,
221
+ ref,
222
+ ...props
223
+ }: TestErrorMessageProps & {
224
+ ref?: React.Ref<HTMLParagraphElement>;
225
+ }): React.JSX.Element;
226
+ interface TestErrorStackProps extends React.HTMLAttributes<HTMLPreElement> {}
227
+ declare function TestErrorStack({
228
+ className,
229
+ children,
230
+ ref,
231
+ ...props
232
+ }: TestErrorStackProps & {
233
+ ref?: React.Ref<HTMLPreElement>;
234
+ }): React.JSX.Element;
235
+ //#endregion
236
+ export { Test, TestDuration, TestDurationProps, TestError, TestErrorMessage, TestErrorMessageProps, TestErrorProps, TestErrorStack, TestErrorStackProps, TestName, TestNameProps, TestProps, TestResults, TestResultsContent, TestResultsContentProps, TestResultsDuration, TestResultsDurationProps, TestResultsHeader, TestResultsHeaderProps, TestResultsProgress, TestResultsProgressProps, TestResultsProps, TestResultsSummary, TestResultsSummaryProps, TestStatus, TestStatusProps, TestStatusValue, TestSuite, TestSuiteContent, TestSuiteContentProps, TestSuiteName, TestSuiteNameProps, TestSuiteProps, TestSuiteStats, TestSuiteStatsProps, TestSummary };