@mcp-b/react-components 0.3.0 → 0.5.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 (59) hide show
  1. package/dist/{CodeBlock-C2Xjxu9M.js → CodeBlock-D-a84xBL.js} +1 -1
  2. package/dist/{FileTree-D0c9Yj9U.js → FileTree-D8rtTLgK.js} +1 -1
  3. package/dist/attachment-preview-ChtC3HiU.js +25 -0
  4. package/dist/components/Activity.js +1 -1
  5. package/dist/components/AgentChat.d.ts +31 -1
  6. package/dist/components/AgentChat.js +166 -38
  7. package/dist/components/AgentConnection.js +3 -3
  8. package/dist/components/Artifact.js +1 -1
  9. package/dist/components/BrowserLiveView.js +2 -2
  10. package/dist/components/BrowserReplay.js +1 -1
  11. package/dist/components/ChainOfThought.d.ts +1 -1
  12. package/dist/components/ChainOfThought.js +1 -1
  13. package/dist/components/CodeBlock.js +1 -1
  14. package/dist/components/Commit.js +2 -2
  15. package/dist/components/Context.d.ts +28 -27
  16. package/dist/components/Context.js +48 -47
  17. package/dist/components/ContextMenu.js +1 -1
  18. package/dist/components/Conversation.js +1 -1
  19. package/dist/components/Dialog.js +1 -1
  20. package/dist/components/EnvironmentVariables.js +1 -1
  21. package/dist/components/FileTree.js +1 -1
  22. package/dist/components/Menubar.js +1 -1
  23. package/dist/components/Message.d.ts +16 -2
  24. package/dist/components/Message.js +39 -5
  25. package/dist/components/ModelSelector.js +1 -1
  26. package/dist/components/NavigationMenu.js +1 -1
  27. package/dist/components/PricingPage.js +2 -2
  28. package/dist/components/PromptInput.d.ts +532 -2
  29. package/dist/components/PromptInput.js +158 -20
  30. package/dist/components/Queue.js +1 -1
  31. package/dist/components/Reasoning.js +9 -17
  32. package/dist/components/Select.js +1 -1
  33. package/dist/components/Sources.js +1 -1
  34. package/dist/components/Stepper.js +1 -1
  35. package/dist/components/Task.js +1 -1
  36. package/dist/components/Terminal.js +2 -2
  37. package/dist/components/TestResults.js +1 -1
  38. package/dist/components/ThinkChat.d.ts +24 -5
  39. package/dist/components/ThinkChat.js +87 -19
  40. package/dist/components/WebPreview.js +1 -1
  41. package/dist/components/WorkspaceExplorer.js +3 -3
  42. package/dist/components/icons.d.ts +2 -2
  43. package/dist/components/icons.js +2 -2
  44. package/dist/{copy-button-Dd6DEhOm.js → copy-button-BmJEAKuP.js} +1 -1
  45. package/dist/{icons-DQC4Zw5R.js → icons-CZRH4FVH.js} +1 -15
  46. package/dist/{icons-ctdVxng0.d.ts → icons-CmO7-pNY.d.ts} +1 -2
  47. package/dist/styles/agent-chat.css +39 -6
  48. package/dist/styles/attachment-preview.css +21 -0
  49. package/dist/styles/context.css +9 -17
  50. package/dist/styles/conversation.css +3 -3
  51. package/dist/styles/index.css +1 -1
  52. package/dist/styles/message.css +50 -2
  53. package/dist/styles/prompt-input.css +189 -6
  54. package/dist/styles/reasoning.css +0 -1
  55. package/package.json +2 -2
  56. package/dist/PromptInput-Dzn-fOPc.d.ts +0 -444
  57. package/dist/components/Tool.d.ts +0 -123
  58. package/dist/components/Tool.js +0 -209
  59. package/dist/styles/tool.css +0 -203
@@ -1,209 +0,0 @@
1
- import { CollapsiblePanel, CollapsibleRoot, CollapsibleTrigger } from "./Collapsible.js";
2
- import { t as cx } from "../class-names-9UtZwb0J.js";
3
- import { A as SpinnerIcon, F as XIcon, N as WarningIcon, P as WrenchIcon, d as DotIcon, l as ChevronRightIcon, o as CheckIcon } from "../icons-DQC4Zw5R.js";
4
- import { Badge } from "./Badge.js";
5
- import { i as CodeBlockContent, r as CodeBlockContainer, t as CodeBlock } from "../CodeBlock-C2Xjxu9M.js";
6
- import { formatStructuredCodeDisplay } from "../utils/structured-code.js";
7
- import * as React from "react";
8
- import { jsx, jsxs } from "react/jsx-runtime";
9
- import { getToolName } from "ai";
10
- //#region src/components/Tool.tsx
11
- const STATE_TO_COLOR = {
12
- "input-streaming": "primary",
13
- "input-available": "neutral",
14
- "approval-requested": "warning",
15
- "approval-responded": "neutral",
16
- "output-available": "success",
17
- "output-error": "destructive",
18
- "output-denied": "destructive"
19
- };
20
- const STATE_LABEL = {
21
- "input-streaming": "Pending",
22
- "input-available": "Running",
23
- "approval-requested": "Awaiting Approval",
24
- "approval-responded": "Responded",
25
- "output-available": "Completed",
26
- "output-error": "Error",
27
- "output-denied": "Denied"
28
- };
29
- const STATE_ICON = {
30
- "input-streaming": /* @__PURE__ */ jsx(DotIcon, {}),
31
- "input-available": /* @__PURE__ */ jsx(SpinnerIcon, { className: "tool__status-spinner" }),
32
- "approval-requested": /* @__PURE__ */ jsx(WarningIcon, {}),
33
- "approval-responded": /* @__PURE__ */ jsx(CheckIcon, {}),
34
- "output-available": /* @__PURE__ */ jsx(CheckIcon, {}),
35
- "output-error": /* @__PURE__ */ jsx(XIcon, {}),
36
- "output-denied": /* @__PURE__ */ jsx(XIcon, {})
37
- };
38
- function getStatusBadge(status) {
39
- return /* @__PURE__ */ jsxs(Badge, {
40
- color: STATE_TO_COLOR[status],
41
- size: "sm",
42
- className: "tool__header-badge",
43
- children: [STATE_ICON[status], STATE_LABEL[status]]
44
- });
45
- }
46
- const ToolContext = React.createContext(null);
47
- function useToolContext() {
48
- const ctx = React.useContext(ToolContext);
49
- if (!ctx) throw new Error("Tool subcomponents must be used inside <Tool>.");
50
- return ctx;
51
- }
52
- /**
53
- * Displays a collapsible tool invocation (name, input, output, state).
54
- * The state drives the status badge color and default open behavior —
55
- * `output-available`, `output-error`, and `output-denied` auto-open.
56
- * Adapted from Vercel AI Elements and restyled with Sigvelo CSS tokens.
57
- *
58
- * @example
59
- * ```tsx
60
- * <Tool part={part}>
61
- * <ToolHeader />
62
- * <ToolContent>
63
- * <ToolInput />
64
- * <ToolOutput />
65
- * </ToolContent>
66
- * </Tool>
67
- * ```
68
- *
69
- * @see {@link https://elements.ai-sdk.dev/components/tool | AI Elements Tool}
70
- */
71
- function Tool({ className, part, state: stateProp, defaultOpen, ref, ...props }) {
72
- const state = stateProp ?? part?.state;
73
- const autoOpen = state === "output-available" || state === "output-error" || state === "output-denied";
74
- const ctx = React.useMemo(() => ({
75
- state,
76
- part
77
- }), [state, part]);
78
- return /* @__PURE__ */ jsx(ToolContext.Provider, {
79
- value: ctx,
80
- children: /* @__PURE__ */ jsx(CollapsibleRoot, {
81
- ref,
82
- className: cx("tool", className),
83
- defaultOpen: defaultOpen ?? autoOpen,
84
- "data-state": state ?? void 0,
85
- ...props,
86
- unstyled: true
87
- })
88
- });
89
- }
90
- /**
91
- * Clickable header that shows the tool type, name, and state badge.
92
- */
93
- function ToolHeader({ className, type: typeProp, toolName, title: titleProp, state: stateProp, ref, ...props }) {
94
- const { state: contextState, part } = useToolContext();
95
- const state = stateProp ?? contextState ?? "input-available";
96
- const type = typeProp ?? (part?.type === "dynamic-tool" ? "dynamic-tool" : "function");
97
- const title = titleProp ?? part?.title;
98
- const derivedName = part && typeProp === void 0 && toolName === void 0 ? getToolName(part) : type === "dynamic-tool" && toolName ? toolName : type.startsWith("tool-") ? type.split("-").slice(1).join("-") : toolName ?? type;
99
- return /* @__PURE__ */ jsxs(CollapsibleTrigger, {
100
- ref,
101
- className: cx("tool__header", className),
102
- ...props,
103
- unstyled: true,
104
- children: [
105
- /* @__PURE__ */ jsx("span", {
106
- className: "tool__header-tool-icon",
107
- "aria-hidden": "true",
108
- children: /* @__PURE__ */ jsx(WrenchIcon, {})
109
- }),
110
- /* @__PURE__ */ jsx("span", {
111
- className: "tool__header-type",
112
- children: type
113
- }),
114
- /* @__PURE__ */ jsx("span", {
115
- className: "tool__header-name",
116
- children: derivedName
117
- }),
118
- title ? /* @__PURE__ */ jsx("span", {
119
- className: "tool__header-title",
120
- children: title
121
- }) : null,
122
- /* @__PURE__ */ jsx("span", { className: "tool__header-spacer" }),
123
- getStatusBadge(state),
124
- /* @__PURE__ */ jsx("span", {
125
- className: "tool__header-icon",
126
- "aria-hidden": "true",
127
- children: /* @__PURE__ */ jsx(ChevronRightIcon, {})
128
- })
129
- ]
130
- });
131
- }
132
- /**
133
- * Collapsible panel holding ToolInput and ToolOutput.
134
- */
135
- function ToolContent({ className, children, ref, ...props }) {
136
- return /* @__PURE__ */ jsx(CollapsiblePanel, {
137
- ref,
138
- className: cx("tool__content", className),
139
- ...props,
140
- unstyled: true,
141
- children: /* @__PURE__ */ jsx("div", {
142
- className: "tool__content-inner",
143
- children
144
- })
145
- });
146
- }
147
- /**
148
- * Displays the tool input as a JSON code block. Renders nothing while the
149
- * input is still undefined.
150
- */
151
- function ToolInput({ className, input: inputProp, ref, ...props }) {
152
- const { state, part } = useToolContext();
153
- const input = inputProp !== void 0 ? inputProp : part?.input;
154
- const formattedInput = React.useMemo(() => input === void 0 ? null : formatStructuredCodeDisplay(input), [input]);
155
- if (formattedInput === null) return null;
156
- const isStreaming = state === "input-streaming";
157
- return /* @__PURE__ */ jsxs("div", {
158
- ref,
159
- className: cx("tool__section", className),
160
- ...props,
161
- children: [/* @__PURE__ */ jsx("div", {
162
- className: "tool__section-label",
163
- children: "Input"
164
- }), /* @__PURE__ */ jsx(CodeBlock, {
165
- code: formattedInput.code,
166
- language: formattedInput.language,
167
- className: "tool__code-block",
168
- isStreaming,
169
- children: /* @__PURE__ */ jsx(CodeBlockContainer, { children: /* @__PURE__ */ jsx(CodeBlockContent, {}) })
170
- })]
171
- });
172
- }
173
- /**
174
- * Displays the tool output or error text.
175
- */
176
- function ToolOutput({ className, output: outputProp, errorText: errorTextProp, ref, ...props }) {
177
- const { part } = useToolContext();
178
- const output = outputProp !== void 0 ? outputProp : part && "output" in part ? part.output : void 0;
179
- const errorText = errorTextProp !== void 0 ? errorTextProp : part && "errorText" in part ? part.errorText : void 0;
180
- const formattedOutput = React.useMemo(() => {
181
- if (output && typeof output === "object" && !React.isValidElement(output)) return formatStructuredCodeDisplay(output);
182
- if (typeof output === "string") return {
183
- code: output,
184
- language: "json"
185
- };
186
- return null;
187
- }, [output]);
188
- const isError = errorText !== void 0;
189
- if (!(output || errorText)) return null;
190
- return /* @__PURE__ */ jsxs("div", {
191
- ref,
192
- className: cx("tool__section", isError && "tool__section--error", className),
193
- ...props,
194
- children: [/* @__PURE__ */ jsx("div", {
195
- className: "tool__section-label",
196
- children: isError ? "Error" : "Output"
197
- }), isError ? /* @__PURE__ */ jsx("div", {
198
- className: "tool__error-text",
199
- children: errorText
200
- }) : formattedOutput ? /* @__PURE__ */ jsx(CodeBlock, {
201
- code: formattedOutput.code,
202
- language: formattedOutput.language,
203
- className: "tool__code-block",
204
- children: /* @__PURE__ */ jsx(CodeBlockContainer, { children: /* @__PURE__ */ jsx(CodeBlockContent, {}) })
205
- }) : /* @__PURE__ */ jsx("div", { children: output })]
206
- });
207
- }
208
- //#endregion
209
- export { Tool, ToolContent, ToolHeader, ToolInput, ToolOutput, getStatusBadge };
@@ -1,203 +0,0 @@
1
- .tool {
2
- display: flex;
3
- flex-direction: column;
4
- width: 100%;
5
- font-family: var(--sigvelo-font-sans);
6
- color: var(--sigvelo-color-text);
7
- /* Ploy-style: hairline outline on the canvas, plain content inside */
8
- background-color: transparent;
9
- border: var(--sigvelo-border-style) var(--sigvelo-border-width)
10
- var(--sigvelo-color-neutral-border-subtle);
11
- border-radius: var(--sigvelo-radius-lg);
12
- overflow: hidden;
13
- }
14
-
15
- .tool__header {
16
- display: flex;
17
- align-items: center;
18
- gap: 0.5rem;
19
- width: 100%;
20
- padding-block: 0.625rem;
21
- padding-inline: 0.875rem;
22
- background-color: transparent;
23
- border: none;
24
- /* Muted header row, Ploy/Codex style — content carries the emphasis */
25
- color: var(--sigvelo-color-text-muted);
26
- font-family: inherit;
27
- font-size: 0.8125rem;
28
- font-weight: var(--sigvelo-font-weight-semibold);
29
- text-align: start;
30
- cursor: pointer;
31
- transition: background-color var(--sigvelo-duration-fast) var(--sigvelo-ease-standard);
32
- }
33
-
34
- .tool__header:hover:not([data-disabled]) {
35
- background-color: var(--sigvelo-color-neutral-bg-subtle);
36
- }
37
-
38
- .tool__header:focus-visible {
39
- outline: none;
40
- box-shadow:
41
- 0 0 0 2px var(--sigvelo-color-canvas),
42
- 0 0 0 4px var(--sigvelo-color-focus);
43
- }
44
-
45
- .tool__header-tool-icon,
46
- .tool__header-icon {
47
- display: inline-flex;
48
- color: var(--sigvelo-color-text-muted);
49
- }
50
-
51
- .tool__header-icon {
52
- transition: transform var(--sigvelo-duration-medium) var(--sigvelo-ease-emphasized);
53
- }
54
-
55
- .tool__header[data-panel-open] .tool__header-icon {
56
- transform: rotate(90deg);
57
- }
58
-
59
- .tool__header-type {
60
- display: inline-flex;
61
- align-items: center;
62
- padding-block: 0.125rem;
63
- padding-inline: 0.4375rem;
64
- font-family: var(--sigvelo-font-mono);
65
- font-size: 0.6875rem;
66
- text-transform: uppercase;
67
- letter-spacing: 0.025em;
68
- color: var(--sigvelo-color-text-muted);
69
- background-color: var(--sigvelo-color-neutral-bg-subtle);
70
- border-radius: var(--sigvelo-radius-sm);
71
- }
72
-
73
- .tool__header-name {
74
- font-family: var(--sigvelo-font-mono);
75
- font-size: 0.8125rem;
76
- }
77
-
78
- .tool__header-name,
79
- .tool__header-title {
80
- min-width: 0;
81
- overflow: hidden;
82
- text-overflow: ellipsis;
83
- white-space: nowrap;
84
- }
85
-
86
- .tool__header-title {
87
- color: var(--sigvelo-color-text-muted);
88
- font-weight: var(--sigvelo-font-weight-normal);
89
- }
90
-
91
- .tool__header-spacer {
92
- flex: 1;
93
- }
94
-
95
- .tool__header-badge {
96
- gap: 0.25rem;
97
- }
98
-
99
- .tool__status-spinner {
100
- animation: tool-spin 900ms linear infinite;
101
- }
102
-
103
- .tool__content {
104
- height: var(--collapsible-panel-height);
105
- overflow: hidden;
106
- transition:
107
- height var(--sigvelo-duration-medium) var(--sigvelo-ease-standard),
108
- opacity var(--sigvelo-duration-fast) var(--sigvelo-ease-standard);
109
- }
110
-
111
- .tool__content[data-starting-style],
112
- .tool__content[data-ending-style] {
113
- height: 0;
114
- opacity: 0;
115
- }
116
-
117
- .tool__content-inner {
118
- display: flex;
119
- flex-direction: column;
120
- gap: 0.75rem;
121
- padding-block: 0.75rem;
122
- padding-inline: 0.875rem;
123
- transition:
124
- transform var(--sigvelo-duration-medium) var(--sigvelo-ease-emphasized),
125
- opacity var(--sigvelo-duration-fast) var(--sigvelo-ease-standard);
126
- }
127
-
128
- .tool__content[data-closed] .tool__content-inner,
129
- .tool__content[data-starting-style] .tool__content-inner,
130
- .tool__content[data-ending-style] .tool__content-inner {
131
- transform: translateY(-4px);
132
- opacity: 0;
133
- }
134
-
135
- .tool__section {
136
- display: flex;
137
- flex-direction: column;
138
- gap: 0.375rem;
139
- min-height: 0;
140
- }
141
-
142
- .tool__section > :not(.tool__section-label) {
143
- max-height: 20rem;
144
- overflow: auto;
145
- }
146
-
147
- .tool__section-label {
148
- font-size: 0.6875rem;
149
- font-weight: var(--sigvelo-font-weight-semibold);
150
- text-transform: uppercase;
151
- letter-spacing: 0.05em;
152
- color: var(--sigvelo-color-text-muted);
153
- }
154
-
155
- .tool__code-block {
156
- min-width: 0;
157
- }
158
-
159
- /* Blend nested code into the outlined box — plain content, no panel-in-panel */
160
- .code-block.tool__code-block {
161
- background-color: transparent;
162
- }
163
-
164
- .tool__code-block .code-block__content,
165
- .tool__code-block .code-block__content--highlighted pre.shiki,
166
- .tool__code-block .code-block__content--highlighted pre.shiki code {
167
- white-space: pre-wrap;
168
- word-break: break-word;
169
- overflow-wrap: anywhere;
170
- }
171
-
172
- .tool__error-text {
173
- padding: 0.5rem 0.75rem;
174
- font-family: var(--sigvelo-font-mono);
175
- font-size: 0.75rem;
176
- color: var(--sigvelo-color-danger-text);
177
- background-color: var(--sigvelo-color-danger-bg-subtle);
178
- border-radius: var(--sigvelo-radius-sm);
179
- white-space: pre-wrap;
180
- }
181
-
182
- @media (forced-colors: active) {
183
- .tool {
184
- border: 1px solid CanvasText;
185
- }
186
-
187
- .tool__header:focus-visible {
188
- outline: 2px solid Highlight;
189
- outline-offset: 2px;
190
- }
191
- }
192
-
193
- @keyframes tool-spin {
194
- to {
195
- transform: rotate(360deg);
196
- }
197
- }
198
-
199
- @media (prefers-reduced-motion: reduce) {
200
- .tool__status-spinner {
201
- animation: none;
202
- }
203
- }