@mcp-b/react-components 0.1.1 → 0.1.3
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.
- package/dist/Button-QCM8ZKgR.d.ts +98 -0
- package/dist/CodeBlock-CttHhWcb.js +356 -0
- package/dist/CodeBlock-V6pgafSS.d.ts +174 -0
- package/dist/Select-CRsKCJ9x.d.ts +200 -0
- package/dist/class-names-9UtZwb0J.js +12 -0
- package/dist/components/Accordion.d.ts +81 -0
- package/dist/components/Accordion.js +97 -0
- package/dist/components/AgentConnection.d.ts +69 -0
- package/dist/components/AgentConnection.js +176 -0
- package/dist/components/AlertDialog.d.ts +148 -0
- package/dist/components/AlertDialog.js +141 -0
- package/dist/components/Artifact.d.ts +128 -0
- package/dist/components/Artifact.js +115 -0
- package/dist/components/Autocomplete.d.ts +186 -0
- package/dist/components/Autocomplete.js +186 -0
- package/dist/components/Avatar.d.ts +134 -0
- package/dist/components/Avatar.js +118 -0
- package/dist/components/Badge.d.ts +68 -0
- package/dist/components/Badge.js +108 -0
- package/dist/components/Button.d.ts +2 -0
- package/dist/components/Button.js +73 -0
- package/dist/components/Card.d.ts +87 -0
- package/dist/components/Card.js +81 -0
- package/dist/components/ChainOfThought.d.ts +153 -0
- package/dist/components/ChainOfThought.js +157 -0
- package/dist/components/Checkbox.d.ts +35 -0
- package/dist/components/Checkbox.js +47 -0
- package/dist/components/CheckboxGroup.d.ts +76 -0
- package/dist/components/CheckboxGroup.js +69 -0
- package/dist/components/CodeBlock.d.ts +2 -0
- package/dist/components/CodeBlock.js +2 -0
- package/dist/components/Collapsible.d.ts +127 -0
- package/dist/components/Collapsible.js +103 -0
- package/dist/components/Combobox.d.ts +177 -0
- package/dist/components/Combobox.js +179 -0
- package/dist/components/Commit.d.ts +265 -0
- package/dist/components/Commit.js +282 -0
- package/dist/components/Context.d.ts +129 -0
- package/dist/components/Context.js +309 -0
- package/dist/components/ContextMenu.d.ts +282 -0
- package/dist/components/ContextMenu.js +270 -0
- package/dist/components/Conversation.d.ts +166 -0
- package/dist/components/Conversation.js +202 -0
- package/dist/components/Dialog.d.ts +120 -0
- package/dist/components/Dialog.js +114 -0
- package/dist/components/EnvironmentVariables.d.ts +176 -0
- package/dist/components/EnvironmentVariables.js +221 -0
- package/dist/components/Field.d.ts +281 -0
- package/dist/components/Field.js +274 -0
- package/dist/components/Fieldset.d.ts +93 -0
- package/dist/components/Fieldset.js +81 -0
- package/dist/components/FileTree.d.ts +116 -0
- package/dist/components/FileTree.js +310 -0
- package/dist/components/Form.d.ts +94 -0
- package/dist/components/Form.js +88 -0
- package/dist/components/GithubMotionMark.d.ts +13 -0
- package/dist/components/GithubMotionMark.js +23 -0
- package/dist/components/Input.d.ts +33 -0
- package/dist/components/Input.js +27 -0
- package/dist/components/Label.d.ts +44 -0
- package/dist/components/Label.js +41 -0
- package/dist/components/Menu.d.ts +395 -0
- package/dist/components/Menu.js +338 -0
- package/dist/components/Menubar.d.ts +331 -0
- package/dist/components/Menubar.js +299 -0
- package/dist/components/Message.d.ts +216 -0
- package/dist/components/Message.js +245 -0
- package/dist/components/Meter.d.ts +151 -0
- package/dist/components/Meter.js +121 -0
- package/dist/components/ModelSelector.d.ts +198 -0
- package/dist/components/ModelSelector.js +306 -0
- package/dist/components/NaniteScene.d.ts +33 -0
- package/dist/components/NaniteScene.js +405 -0
- package/dist/components/NavigationMenu.d.ts +256 -0
- package/dist/components/NavigationMenu.js +228 -0
- package/dist/components/NumberField.d.ts +159 -0
- package/dist/components/NumberField.js +123 -0
- package/dist/components/Popover.d.ts +278 -0
- package/dist/components/Popover.js +245 -0
- package/dist/components/PreviewCard.d.ts +156 -0
- package/dist/components/PreviewCard.js +156 -0
- package/dist/components/PricingPage.d.ts +209 -0
- package/dist/components/PricingPage.js +506 -0
- package/dist/components/Progress.d.ts +58 -0
- package/dist/components/Progress.js +51 -0
- package/dist/components/PromptInput.d.ts +399 -0
- package/dist/components/PromptInput.js +737 -0
- package/dist/components/Queue.d.ts +241 -0
- package/dist/components/Queue.js +225 -0
- package/dist/components/RadioGroup.d.ts +78 -0
- package/dist/components/RadioGroup.js +72 -0
- package/dist/components/Reasoning.d.ts +88 -0
- package/dist/components/Reasoning.js +187 -0
- package/dist/components/ScrollArea.d.ts +160 -0
- package/dist/components/ScrollArea.js +145 -0
- package/dist/components/Select.d.ts +2 -0
- package/dist/components/Select.js +260 -0
- package/dist/components/Separator.d.ts +45 -0
- package/dist/components/Separator.js +40 -0
- package/dist/components/Shell.d.ts +163 -0
- package/dist/components/Shell.js +137 -0
- package/dist/components/Slider.d.ts +120 -0
- package/dist/components/Slider.js +115 -0
- package/dist/components/Sources.d.ts +91 -0
- package/dist/components/Sources.js +121 -0
- package/dist/components/Stepper.d.ts +190 -0
- package/dist/components/Stepper.js +315 -0
- package/dist/components/Switch.d.ts +57 -0
- package/dist/components/Switch.js +55 -0
- package/dist/components/Tabs.d.ts +84 -0
- package/dist/components/Tabs.js +78 -0
- package/dist/components/Task.d.ts +100 -0
- package/dist/components/Task.js +120 -0
- package/dist/components/Terminal.d.ts +118 -0
- package/dist/components/Terminal.js +234 -0
- package/dist/components/TestResults.d.ts +236 -0
- package/dist/components/TestResults.js +346 -0
- package/dist/components/Toast.d.ts +192 -0
- package/dist/components/Toast.js +163 -0
- package/dist/components/Toggle.d.ts +69 -0
- package/dist/components/Toggle.js +66 -0
- package/dist/components/ToggleGroup.d.ts +69 -0
- package/dist/components/ToggleGroup.js +99 -0
- package/dist/components/Tool.d.ts +119 -0
- package/dist/components/Tool.js +192 -0
- package/dist/components/Toolbar.d.ts +162 -0
- package/dist/components/Toolbar.js +126 -0
- package/dist/components/Tooltip.d.ts +81 -0
- package/dist/components/Tooltip.js +74 -0
- package/dist/components/WebPreview.d.ts +143 -0
- package/dist/components/WebPreview.js +280 -0
- package/dist/components/useStickToBottom.d.ts +30 -0
- package/dist/components/useStickToBottom.js +95 -0
- package/dist/copy-button-BIATcZWZ.d.ts +16 -0
- package/dist/copy-button-BNgclDrO.js +43 -0
- package/dist/icons-BsWc8g4E.js +221 -0
- package/dist/styles/accordion.css +10 -10
- package/dist/styles/agent-connection.css +18 -17
- package/dist/styles/alert-dialog.css +48 -29
- package/dist/styles/artifact.css +10 -10
- package/dist/styles/autocomplete.css +25 -24
- package/dist/styles/avatar.css +96 -6
- package/dist/styles/badge.css +78 -14
- package/dist/styles/base.css +9 -9
- package/dist/styles/button.css +57 -38
- package/dist/styles/card.css +57 -10
- package/dist/styles/chain-of-thought.css +47 -33
- package/dist/styles/checkbox.css +24 -10
- package/dist/styles/code-block.css +22 -15
- package/dist/styles/collapsible.css +14 -12
- package/dist/styles/combobox.css +26 -25
- package/dist/styles/commit.css +49 -24
- package/dist/styles/context-menu.css +70 -16
- package/dist/styles/context.css +15 -15
- package/dist/styles/conversation.css +12 -12
- package/dist/styles/dialog.css +52 -16
- package/dist/styles/environment-variables.css +19 -19
- package/dist/styles/field.css +184 -22
- package/dist/styles/fieldset.css +5 -4
- package/dist/styles/file-tree.css +17 -17
- package/dist/styles/index.css.d.ts +1 -0
- package/dist/styles/input.css +45 -11
- package/dist/styles/label.css +21 -4
- package/dist/styles/menu.css +55 -32
- package/dist/styles/menubar.css +80 -28
- package/dist/styles/message.css +22 -13
- package/dist/styles/meter.css +8 -8
- package/dist/styles/model-selector.css +33 -21
- package/dist/styles/navigation-menu.css +26 -24
- package/dist/styles/number-field.css +20 -18
- package/dist/styles/popover.css +38 -28
- package/dist/styles/preview-card.css +15 -13
- package/dist/styles/pricing-page.css +53 -53
- package/dist/styles/progress.css +7 -7
- package/dist/styles/prompt-input.css +73 -24
- package/dist/styles/queue.css +58 -32
- package/dist/styles/radio.css +26 -11
- package/dist/styles/reasoning.css +15 -11
- package/dist/styles/scroll-area.css +6 -6
- package/dist/styles/scrollbars.css +4 -4
- package/dist/styles/select.css +84 -25
- package/dist/styles/separator.css +1 -1
- package/dist/styles/shell.css +21 -20
- package/dist/styles/slider.css +35 -11
- package/dist/styles/sources.css +20 -20
- package/dist/styles/stepper.css +22 -22
- package/dist/styles/switch.css +29 -13
- package/dist/styles/tabs.css +23 -16
- package/dist/styles/task.css +27 -23
- package/dist/styles/terminal.css +16 -13
- package/dist/styles/test-results.css +79 -32
- package/dist/styles/toast.css +26 -25
- package/dist/styles/toggle-group.css +12 -12
- package/dist/styles/toggle.css +29 -11
- package/dist/styles/tool.css +54 -32
- package/dist/styles/toolbar.css +30 -28
- package/dist/styles/tooltip.css +10 -8
- package/dist/styles/web-preview.css +37 -21
- package/dist/utils/structured-code.d.ts +10 -0
- package/dist/utils/structured-code.js +81 -0
- package/package.json +17 -8
- package/dist/index.d.ts +0 -7236
- package/dist/index.js +0 -8945
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
import { t as cx } from "../class-names-9UtZwb0J.js";
|
|
2
|
+
import { Button } from "./Button.js";
|
|
3
|
+
import { Popover } from "./Popover.js";
|
|
4
|
+
import { Separator } from "./Separator.js";
|
|
5
|
+
import * as React from "react";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
//#region src/components/Context.tsx
|
|
8
|
+
const ContextContext = React.createContext(null);
|
|
9
|
+
function useContextContext() {
|
|
10
|
+
const ctx = React.useContext(ContextContext);
|
|
11
|
+
if (!ctx) throw new Error("Context subcomponents must be used inside <Context>.");
|
|
12
|
+
return ctx;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Displays token / context usage with a hover card breakdown. The trigger is
|
|
16
|
+
* a button showing a compact percentage indicator; hovering or clicking opens
|
|
17
|
+
* a popover with category rows and total cost.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```tsx
|
|
21
|
+
* <Context
|
|
22
|
+
* usedTokens={42_300}
|
|
23
|
+
* maxTokens={200_000}
|
|
24
|
+
* modelId="claude-opus-4-6"
|
|
25
|
+
* usage={{ input: 30000, output: 12300 }}
|
|
26
|
+
* totalCostUsd={0.42}
|
|
27
|
+
* >
|
|
28
|
+
* <ContextTrigger />
|
|
29
|
+
* <ContextContent>
|
|
30
|
+
* <ContextContentHeader />
|
|
31
|
+
* <ContextContentBody />
|
|
32
|
+
* <ContextContentFooter />
|
|
33
|
+
* </ContextContent>
|
|
34
|
+
* </Context>
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
function Context({ className, usedTokens, maxTokens, usage, modelId, totalCostUsd, open, defaultOpen, onOpenChange, children, ref, ...props }) {
|
|
38
|
+
const ctxValue = React.useMemo(() => ({
|
|
39
|
+
usedTokens,
|
|
40
|
+
maxTokens,
|
|
41
|
+
usage,
|
|
42
|
+
modelId,
|
|
43
|
+
totalCostUsd
|
|
44
|
+
}), [
|
|
45
|
+
usedTokens,
|
|
46
|
+
maxTokens,
|
|
47
|
+
usage,
|
|
48
|
+
modelId,
|
|
49
|
+
totalCostUsd
|
|
50
|
+
]);
|
|
51
|
+
return /* @__PURE__ */ jsx(ContextContext.Provider, {
|
|
52
|
+
value: ctxValue,
|
|
53
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
54
|
+
ref,
|
|
55
|
+
className: cx("context", className),
|
|
56
|
+
...props,
|
|
57
|
+
children: /* @__PURE__ */ jsx(Popover.Root, {
|
|
58
|
+
open,
|
|
59
|
+
defaultOpen,
|
|
60
|
+
onOpenChange,
|
|
61
|
+
children
|
|
62
|
+
})
|
|
63
|
+
})
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
function ContextTrigger({ className, children, ...props }) {
|
|
67
|
+
const { usedTokens, maxTokens } = useContextContext();
|
|
68
|
+
const percent = maxTokens > 0 ? usedTokens / maxTokens * 100 : 0;
|
|
69
|
+
if (React.isValidElement(children)) return /* @__PURE__ */ jsx(Popover.Trigger, { render: children });
|
|
70
|
+
if (children) return /* @__PURE__ */ jsx(Popover.Trigger, { children });
|
|
71
|
+
return /* @__PURE__ */ jsx(Popover.Trigger, { render: /* @__PURE__ */ jsxs(Button, {
|
|
72
|
+
variant: "ghost",
|
|
73
|
+
color: "neutral",
|
|
74
|
+
size: "sm",
|
|
75
|
+
className: cx("context__trigger", className),
|
|
76
|
+
"aria-label": `Context usage: ${percent.toFixed(0)}%`,
|
|
77
|
+
...props,
|
|
78
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
79
|
+
className: "context__trigger-ring",
|
|
80
|
+
"aria-hidden": "true",
|
|
81
|
+
children: /* @__PURE__ */ jsx(ProgressRing, {
|
|
82
|
+
percent,
|
|
83
|
+
size: 16,
|
|
84
|
+
stroke: 2.5
|
|
85
|
+
})
|
|
86
|
+
}), /* @__PURE__ */ jsxs("span", {
|
|
87
|
+
className: "context__trigger-label",
|
|
88
|
+
children: [percent.toFixed(0), "%"]
|
|
89
|
+
})]
|
|
90
|
+
}) });
|
|
91
|
+
}
|
|
92
|
+
function ContextContent({ className, children, ...props }) {
|
|
93
|
+
return /* @__PURE__ */ jsx(Popover.Portal, { children: /* @__PURE__ */ jsx(Popover.Positioner, { children: /* @__PURE__ */ jsx(Popover.Popup, {
|
|
94
|
+
className: cx("context__content", className),
|
|
95
|
+
...props,
|
|
96
|
+
children
|
|
97
|
+
}) }) });
|
|
98
|
+
}
|
|
99
|
+
function ContextContentHeader({ className, children, ref, ...props }) {
|
|
100
|
+
const { usedTokens, maxTokens, modelId } = useContextContext();
|
|
101
|
+
const percent = maxTokens > 0 ? usedTokens / maxTokens * 100 : 0;
|
|
102
|
+
if (children) return /* @__PURE__ */ jsx("div", {
|
|
103
|
+
ref,
|
|
104
|
+
className: cx("context__header", className),
|
|
105
|
+
...props,
|
|
106
|
+
children
|
|
107
|
+
});
|
|
108
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
109
|
+
ref,
|
|
110
|
+
className: cx("context__header", className),
|
|
111
|
+
...props,
|
|
112
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
113
|
+
className: "context__ring",
|
|
114
|
+
"aria-hidden": "true",
|
|
115
|
+
children: [/* @__PURE__ */ jsx(ProgressRing, {
|
|
116
|
+
percent,
|
|
117
|
+
size: 48,
|
|
118
|
+
stroke: 6
|
|
119
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
120
|
+
className: "context__ring-label",
|
|
121
|
+
children: [percent.toFixed(0), "%"]
|
|
122
|
+
})]
|
|
123
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
124
|
+
className: "context__header-text",
|
|
125
|
+
children: [
|
|
126
|
+
/* @__PURE__ */ jsx("div", {
|
|
127
|
+
className: "context__header-title",
|
|
128
|
+
children: "Context usage"
|
|
129
|
+
}),
|
|
130
|
+
/* @__PURE__ */ jsxs("div", {
|
|
131
|
+
className: "context__header-meta",
|
|
132
|
+
children: [
|
|
133
|
+
usedTokens.toLocaleString(),
|
|
134
|
+
" / ",
|
|
135
|
+
maxTokens.toLocaleString(),
|
|
136
|
+
" tokens"
|
|
137
|
+
]
|
|
138
|
+
}),
|
|
139
|
+
modelId ? /* @__PURE__ */ jsx("div", {
|
|
140
|
+
className: "context__header-model",
|
|
141
|
+
children: modelId
|
|
142
|
+
}) : null
|
|
143
|
+
]
|
|
144
|
+
})]
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
function ContextContentBody({ className, children, ref, ...props }) {
|
|
148
|
+
const { usage } = useContextContext();
|
|
149
|
+
if (children) return /* @__PURE__ */ jsx("div", {
|
|
150
|
+
ref,
|
|
151
|
+
className: cx("context__body", className),
|
|
152
|
+
...props,
|
|
153
|
+
children
|
|
154
|
+
});
|
|
155
|
+
const rows = [];
|
|
156
|
+
const inputTokens = getUsageTokens(usage, "input");
|
|
157
|
+
const outputTokens = getUsageTokens(usage, "output");
|
|
158
|
+
const reasoningTokens = getUsageTokens(usage, "reasoning");
|
|
159
|
+
const cacheTokens = getUsageTokens(usage, "cache");
|
|
160
|
+
if (inputTokens !== void 0) rows.push({
|
|
161
|
+
label: "Input",
|
|
162
|
+
tokens: inputTokens
|
|
163
|
+
});
|
|
164
|
+
if (outputTokens !== void 0) rows.push({
|
|
165
|
+
label: "Output",
|
|
166
|
+
tokens: outputTokens
|
|
167
|
+
});
|
|
168
|
+
if (reasoningTokens !== void 0) rows.push({
|
|
169
|
+
label: "Reasoning",
|
|
170
|
+
tokens: reasoningTokens
|
|
171
|
+
});
|
|
172
|
+
if (cacheTokens !== void 0) rows.push({
|
|
173
|
+
label: "Cache",
|
|
174
|
+
tokens: cacheTokens
|
|
175
|
+
});
|
|
176
|
+
if (usage?.categories) rows.push(...usage.categories);
|
|
177
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
178
|
+
ref,
|
|
179
|
+
className: cx("context__body", className),
|
|
180
|
+
...props,
|
|
181
|
+
children: [/* @__PURE__ */ jsx(Separator, {}), /* @__PURE__ */ jsx("ul", {
|
|
182
|
+
className: "context__rows",
|
|
183
|
+
children: rows.map((row) => /* @__PURE__ */ jsxs("li", {
|
|
184
|
+
className: "context__row",
|
|
185
|
+
children: [
|
|
186
|
+
/* @__PURE__ */ jsx("span", {
|
|
187
|
+
className: "context__row-label",
|
|
188
|
+
children: row.label
|
|
189
|
+
}),
|
|
190
|
+
/* @__PURE__ */ jsx("span", {
|
|
191
|
+
className: "context__row-value",
|
|
192
|
+
children: row.tokens.toLocaleString()
|
|
193
|
+
}),
|
|
194
|
+
row.costUsd !== void 0 ? /* @__PURE__ */ jsxs("span", {
|
|
195
|
+
className: "context__row-cost",
|
|
196
|
+
children: ["$", row.costUsd.toFixed(4)]
|
|
197
|
+
}) : null
|
|
198
|
+
]
|
|
199
|
+
}, row.label))
|
|
200
|
+
})]
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
function ContextContentFooter({ className, children, ref, ...props }) {
|
|
204
|
+
const { totalCostUsd } = useContextContext();
|
|
205
|
+
if (children) return /* @__PURE__ */ jsx("div", {
|
|
206
|
+
ref,
|
|
207
|
+
className: cx("context__footer", className),
|
|
208
|
+
...props,
|
|
209
|
+
children
|
|
210
|
+
});
|
|
211
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
212
|
+
ref,
|
|
213
|
+
className: cx("context__footer", className),
|
|
214
|
+
...props,
|
|
215
|
+
children: [/* @__PURE__ */ jsx(Separator, {}), totalCostUsd !== void 0 ? /* @__PURE__ */ jsxs("div", {
|
|
216
|
+
className: "context__footer-row",
|
|
217
|
+
children: [/* @__PURE__ */ jsx("span", { children: "Total" }), /* @__PURE__ */ jsxs("span", {
|
|
218
|
+
className: "context__footer-cost",
|
|
219
|
+
children: ["$", totalCostUsd.toFixed(4)]
|
|
220
|
+
})]
|
|
221
|
+
}) : null]
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
function ContextInputUsage(props) {
|
|
225
|
+
return /* @__PURE__ */ jsx(ContextUsageRow, {
|
|
226
|
+
usageKey: "input",
|
|
227
|
+
defaultLabel: "Input",
|
|
228
|
+
...props
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
function ContextOutputUsage(props) {
|
|
232
|
+
return /* @__PURE__ */ jsx(ContextUsageRow, {
|
|
233
|
+
usageKey: "output",
|
|
234
|
+
defaultLabel: "Output",
|
|
235
|
+
...props
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
function ContextReasoningUsage(props) {
|
|
239
|
+
return /* @__PURE__ */ jsx(ContextUsageRow, {
|
|
240
|
+
usageKey: "reasoning",
|
|
241
|
+
defaultLabel: "Reasoning",
|
|
242
|
+
...props
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
function ContextCacheUsage(props) {
|
|
246
|
+
return /* @__PURE__ */ jsx(ContextUsageRow, {
|
|
247
|
+
usageKey: "cache",
|
|
248
|
+
defaultLabel: "Cache",
|
|
249
|
+
...props
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
function ContextUsageRow({ className, children, label, usageKey, defaultLabel, ref, ...props }) {
|
|
253
|
+
const { usage } = useContextContext();
|
|
254
|
+
const tokens = getUsageTokens(usage, usageKey) ?? 0;
|
|
255
|
+
if (children) return children;
|
|
256
|
+
if (!tokens) return null;
|
|
257
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
258
|
+
ref,
|
|
259
|
+
className: cx("context__row", className),
|
|
260
|
+
...props,
|
|
261
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
262
|
+
className: "context__row-label",
|
|
263
|
+
children: label ?? defaultLabel
|
|
264
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
265
|
+
className: "context__row-value",
|
|
266
|
+
children: tokens.toLocaleString()
|
|
267
|
+
})]
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
function getUsageTokens(usage, key) {
|
|
271
|
+
if (!usage) return void 0;
|
|
272
|
+
if (key === "input") return usage.input ?? usage.inputTokens;
|
|
273
|
+
if (key === "output") return usage.output ?? usage.outputTokens;
|
|
274
|
+
if (key === "reasoning") return usage.reasoning ?? usage.reasoningTokens;
|
|
275
|
+
return usage.cache ?? usage.cachedInputTokens;
|
|
276
|
+
}
|
|
277
|
+
function ProgressRing({ percent, size, stroke }) {
|
|
278
|
+
const radius = (size - stroke) / 2;
|
|
279
|
+
const circumference = 2 * Math.PI * radius;
|
|
280
|
+
const offset = circumference - Math.max(0, Math.min(100, percent)) / 100 * circumference;
|
|
281
|
+
return /* @__PURE__ */ jsxs("svg", {
|
|
282
|
+
width: size,
|
|
283
|
+
height: size,
|
|
284
|
+
viewBox: `0 0 ${size} ${size}`,
|
|
285
|
+
focusable: "false",
|
|
286
|
+
"aria-hidden": "true",
|
|
287
|
+
children: [/* @__PURE__ */ jsx("circle", {
|
|
288
|
+
cx: size / 2,
|
|
289
|
+
cy: size / 2,
|
|
290
|
+
r: radius,
|
|
291
|
+
fill: "none",
|
|
292
|
+
stroke: "var(--sigvelo-color-neutral-border-subtle)",
|
|
293
|
+
strokeWidth: stroke
|
|
294
|
+
}), /* @__PURE__ */ jsx("circle", {
|
|
295
|
+
cx: size / 2,
|
|
296
|
+
cy: size / 2,
|
|
297
|
+
r: radius,
|
|
298
|
+
fill: "none",
|
|
299
|
+
stroke: "var(--sigvelo-color-primary-bg)",
|
|
300
|
+
strokeWidth: stroke,
|
|
301
|
+
strokeDasharray: circumference,
|
|
302
|
+
strokeDashoffset: offset,
|
|
303
|
+
strokeLinecap: "round",
|
|
304
|
+
transform: `rotate(-90 ${size / 2} ${size / 2})`
|
|
305
|
+
})]
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
//#endregion
|
|
309
|
+
export { Context, ContextCacheUsage, ContextContent, ContextContentBody, ContextContentFooter, ContextContentHeader, ContextInputUsage, ContextOutputUsage, ContextReasoningUsage, ContextTrigger };
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { ContextMenu as ContextMenu$1 } from "@base-ui/react/context-menu";
|
|
3
|
+
|
|
4
|
+
//#region src/components/ContextMenu.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Props for the ContextMenu.Root component.
|
|
7
|
+
*/
|
|
8
|
+
interface ContextMenuProps extends React.ComponentPropsWithoutRef<typeof ContextMenu$1.Root> {}
|
|
9
|
+
/**
|
|
10
|
+
* Props for the ContextMenu.Trigger component.
|
|
11
|
+
*/
|
|
12
|
+
interface ContextMenuTriggerProps extends Omit<React.ComponentPropsWithoutRef<typeof ContextMenu$1.Trigger>, "className"> {
|
|
13
|
+
/** Additional CSS class names */
|
|
14
|
+
className?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Props for the ContextMenu.Portal component.
|
|
18
|
+
*/
|
|
19
|
+
interface ContextMenuPortalProps extends React.ComponentPropsWithoutRef<typeof ContextMenu$1.Portal> {}
|
|
20
|
+
/**
|
|
21
|
+
* Props for the ContextMenu.Positioner component.
|
|
22
|
+
*/
|
|
23
|
+
interface ContextMenuPositionerProps extends Omit<React.ComponentPropsWithoutRef<typeof ContextMenu$1.Positioner>, "className"> {
|
|
24
|
+
/** Additional CSS class names */
|
|
25
|
+
className?: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Props for the ContextMenu.Popup component.
|
|
29
|
+
*/
|
|
30
|
+
interface ContextMenuPopupProps extends Omit<React.ComponentPropsWithoutRef<typeof ContextMenu$1.Popup>, "className"> {
|
|
31
|
+
/** Additional CSS class names */
|
|
32
|
+
className?: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Props for the ContextMenu.Item component.
|
|
36
|
+
*/
|
|
37
|
+
interface ContextMenuItemProps extends Omit<React.ComponentPropsWithoutRef<typeof ContextMenu$1.Item>, "className"> {
|
|
38
|
+
/** Additional CSS class names */
|
|
39
|
+
className?: string;
|
|
40
|
+
inset?: boolean;
|
|
41
|
+
variant?: "default" | "destructive";
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Props for the ContextMenu.Separator component.
|
|
45
|
+
*/
|
|
46
|
+
interface ContextMenuSeparatorProps extends Omit<React.ComponentPropsWithoutRef<typeof ContextMenu$1.Separator>, "className"> {
|
|
47
|
+
/** Additional CSS class names */
|
|
48
|
+
className?: string;
|
|
49
|
+
}
|
|
50
|
+
interface ContextMenuGroupProps extends Omit<React.ComponentPropsWithoutRef<typeof ContextMenu$1.Group>, "className"> {
|
|
51
|
+
className?: string;
|
|
52
|
+
}
|
|
53
|
+
interface ContextMenuLabelProps extends Omit<React.ComponentPropsWithoutRef<typeof ContextMenu$1.GroupLabel>, "className"> {
|
|
54
|
+
className?: string;
|
|
55
|
+
inset?: boolean;
|
|
56
|
+
}
|
|
57
|
+
interface ContextMenuCheckboxItemProps extends Omit<React.ComponentPropsWithoutRef<typeof ContextMenu$1.CheckboxItem>, "className"> {
|
|
58
|
+
className?: string;
|
|
59
|
+
}
|
|
60
|
+
interface ContextMenuRadioGroupProps extends Omit<React.ComponentPropsWithoutRef<typeof ContextMenu$1.RadioGroup>, "className"> {
|
|
61
|
+
className?: string;
|
|
62
|
+
}
|
|
63
|
+
interface ContextMenuRadioItemProps extends Omit<React.ComponentPropsWithoutRef<typeof ContextMenu$1.RadioItem>, "className"> {
|
|
64
|
+
className?: string;
|
|
65
|
+
}
|
|
66
|
+
interface ContextMenuShortcutProps extends React.HTMLAttributes<HTMLSpanElement> {}
|
|
67
|
+
interface ContextMenuSubProps extends React.ComponentPropsWithoutRef<typeof ContextMenu$1.SubmenuRoot> {}
|
|
68
|
+
interface ContextMenuSubTriggerProps extends Omit<React.ComponentPropsWithoutRef<typeof ContextMenu$1.SubmenuTrigger>, "className"> {
|
|
69
|
+
className?: string;
|
|
70
|
+
inset?: boolean;
|
|
71
|
+
}
|
|
72
|
+
type ContextMenuPlacementProps = Pick<ContextMenuPositionerProps, "anchor" | "positionMethod" | "side" | "sideOffset" | "align" | "alignOffset" | "collisionBoundary" | "collisionPadding" | "sticky" | "arrowPadding" | "disableAnchorTracking" | "collisionAvoidance">;
|
|
73
|
+
type ContextMenuContentProps = ContextMenuPopupProps & ContextMenuPlacementProps;
|
|
74
|
+
type ContextMenuSubContentProps = ContextMenuContentProps;
|
|
75
|
+
/**
|
|
76
|
+
* Root component that manages context menu state.
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```tsx
|
|
80
|
+
* <ContextMenu.Root>
|
|
81
|
+
* <ContextMenu.Trigger>Right click here</ContextMenu.Trigger>
|
|
82
|
+
* <ContextMenu.Portal>
|
|
83
|
+
* <ContextMenu.Positioner>
|
|
84
|
+
* <ContextMenu.Popup>
|
|
85
|
+
* <ContextMenu.Item>Cut</ContextMenu.Item>
|
|
86
|
+
* <ContextMenu.Item>Copy</ContextMenu.Item>
|
|
87
|
+
* <ContextMenu.Item>Paste</ContextMenu.Item>
|
|
88
|
+
* </ContextMenu.Popup>
|
|
89
|
+
* </ContextMenu.Positioner>
|
|
90
|
+
* </ContextMenu.Portal>
|
|
91
|
+
* </ContextMenu.Root>
|
|
92
|
+
* ```
|
|
93
|
+
*
|
|
94
|
+
* @see {@link https://base-ui.com/react/components/context-menu | Base UI ContextMenu}
|
|
95
|
+
*/
|
|
96
|
+
declare const ContextMenuRoot: (props: ContextMenuProps) => React.JSX.Element;
|
|
97
|
+
/**
|
|
98
|
+
* Interactive area that activates the menu on right-click or long-press.
|
|
99
|
+
*/
|
|
100
|
+
declare function ContextMenuTrigger({
|
|
101
|
+
className,
|
|
102
|
+
ref,
|
|
103
|
+
...props
|
|
104
|
+
}: ContextMenuTriggerProps & {
|
|
105
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
106
|
+
}): React.JSX.Element;
|
|
107
|
+
/**
|
|
108
|
+
* Renders menu content in a portal.
|
|
109
|
+
*/
|
|
110
|
+
declare const ContextMenuPortal: (props: ContextMenuPortalProps) => React.JSX.Element;
|
|
111
|
+
/**
|
|
112
|
+
* Positions the menu at the pointer location.
|
|
113
|
+
*/
|
|
114
|
+
declare function ContextMenuPositioner({
|
|
115
|
+
className,
|
|
116
|
+
ref,
|
|
117
|
+
...props
|
|
118
|
+
}: ContextMenuPositionerProps & {
|
|
119
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
120
|
+
}): React.JSX.Element;
|
|
121
|
+
/**
|
|
122
|
+
* Container for menu items.
|
|
123
|
+
*/
|
|
124
|
+
declare function ContextMenuPopup({
|
|
125
|
+
className,
|
|
126
|
+
ref,
|
|
127
|
+
...props
|
|
128
|
+
}: ContextMenuPopupProps & {
|
|
129
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
130
|
+
}): React.JSX.Element;
|
|
131
|
+
declare function ContextMenuContent({
|
|
132
|
+
anchor,
|
|
133
|
+
positionMethod,
|
|
134
|
+
side,
|
|
135
|
+
sideOffset,
|
|
136
|
+
align,
|
|
137
|
+
alignOffset,
|
|
138
|
+
collisionBoundary,
|
|
139
|
+
collisionPadding,
|
|
140
|
+
sticky,
|
|
141
|
+
arrowPadding,
|
|
142
|
+
disableAnchorTracking,
|
|
143
|
+
collisionAvoidance,
|
|
144
|
+
...props
|
|
145
|
+
}: ContextMenuContentProps & {
|
|
146
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
147
|
+
}): React.JSX.Element;
|
|
148
|
+
/**
|
|
149
|
+
* Interactive menu item.
|
|
150
|
+
*/
|
|
151
|
+
declare function ContextMenuItem({
|
|
152
|
+
className,
|
|
153
|
+
inset,
|
|
154
|
+
variant,
|
|
155
|
+
ref,
|
|
156
|
+
...props
|
|
157
|
+
}: ContextMenuItemProps & {
|
|
158
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
159
|
+
}): React.JSX.Element;
|
|
160
|
+
/**
|
|
161
|
+
* Visual separator between menu sections.
|
|
162
|
+
*/
|
|
163
|
+
declare function ContextMenuSeparator({
|
|
164
|
+
className,
|
|
165
|
+
ref,
|
|
166
|
+
...props
|
|
167
|
+
}: ContextMenuSeparatorProps & {
|
|
168
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
169
|
+
}): React.JSX.Element;
|
|
170
|
+
declare function ContextMenuGroup({
|
|
171
|
+
className,
|
|
172
|
+
ref,
|
|
173
|
+
...props
|
|
174
|
+
}: ContextMenuGroupProps & {
|
|
175
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
176
|
+
}): React.JSX.Element;
|
|
177
|
+
declare function ContextMenuLabel({
|
|
178
|
+
className,
|
|
179
|
+
inset,
|
|
180
|
+
ref,
|
|
181
|
+
...props
|
|
182
|
+
}: ContextMenuLabelProps & {
|
|
183
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
184
|
+
}): React.JSX.Element;
|
|
185
|
+
declare function ContextMenuCheckboxItem({
|
|
186
|
+
className,
|
|
187
|
+
children,
|
|
188
|
+
ref,
|
|
189
|
+
...props
|
|
190
|
+
}: ContextMenuCheckboxItemProps & {
|
|
191
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
192
|
+
}): React.JSX.Element;
|
|
193
|
+
declare function ContextMenuRadioGroup({
|
|
194
|
+
className,
|
|
195
|
+
ref,
|
|
196
|
+
...props
|
|
197
|
+
}: ContextMenuRadioGroupProps & {
|
|
198
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
199
|
+
}): React.JSX.Element;
|
|
200
|
+
declare function ContextMenuRadioItem({
|
|
201
|
+
className,
|
|
202
|
+
children,
|
|
203
|
+
ref,
|
|
204
|
+
...props
|
|
205
|
+
}: ContextMenuRadioItemProps & {
|
|
206
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
207
|
+
}): React.JSX.Element;
|
|
208
|
+
declare function ContextMenuShortcut({
|
|
209
|
+
className,
|
|
210
|
+
ref,
|
|
211
|
+
...props
|
|
212
|
+
}: ContextMenuShortcutProps & {
|
|
213
|
+
ref?: React.Ref<HTMLSpanElement>;
|
|
214
|
+
}): React.JSX.Element;
|
|
215
|
+
declare function ContextMenuSub(props: ContextMenuSubProps): React.JSX.Element;
|
|
216
|
+
declare function ContextMenuSubContent({
|
|
217
|
+
side,
|
|
218
|
+
align,
|
|
219
|
+
sideOffset,
|
|
220
|
+
...props
|
|
221
|
+
}: ContextMenuSubContentProps & {
|
|
222
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
223
|
+
}): React.JSX.Element;
|
|
224
|
+
declare function ContextMenuSubTrigger({
|
|
225
|
+
className,
|
|
226
|
+
inset,
|
|
227
|
+
children,
|
|
228
|
+
ref,
|
|
229
|
+
...props
|
|
230
|
+
}: ContextMenuSubTriggerProps & {
|
|
231
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
232
|
+
}): React.JSX.Element;
|
|
233
|
+
/**
|
|
234
|
+
* A context menu that appears at the pointer on right-click or long-press.
|
|
235
|
+
* Provides keyboard navigation and supports nested submenus.
|
|
236
|
+
*
|
|
237
|
+
* @example
|
|
238
|
+
* ```tsx
|
|
239
|
+
* // Basic context menu
|
|
240
|
+
* <ContextMenu.Root>
|
|
241
|
+
* <ContextMenu.Trigger>
|
|
242
|
+
* <div style={{ padding: '2rem', border: '1px dashed gray' }}>
|
|
243
|
+
* Right-click here
|
|
244
|
+
* </div>
|
|
245
|
+
* </ContextMenu.Trigger>
|
|
246
|
+
* <ContextMenu.Portal>
|
|
247
|
+
* <ContextMenu.Positioner>
|
|
248
|
+
* <ContextMenu.Popup>
|
|
249
|
+
* <ContextMenu.Item onClick={() => console.log('Cut')}>Cut</ContextMenu.Item>
|
|
250
|
+
* <ContextMenu.Item onClick={() => console.log('Copy')}>Copy</ContextMenu.Item>
|
|
251
|
+
* <ContextMenu.Item onClick={() => console.log('Paste')}>Paste</ContextMenu.Item>
|
|
252
|
+
* <ContextMenu.Separator />
|
|
253
|
+
* <ContextMenu.Item onClick={() => console.log('Delete')}>Delete</ContextMenu.Item>
|
|
254
|
+
* </ContextMenu.Popup>
|
|
255
|
+
* </ContextMenu.Positioner>
|
|
256
|
+
* </ContextMenu.Portal>
|
|
257
|
+
* </ContextMenu.Root>
|
|
258
|
+
* ```
|
|
259
|
+
*
|
|
260
|
+
* @see {@link https://base-ui.com/react/components/context-menu | Base UI ContextMenu}
|
|
261
|
+
*/
|
|
262
|
+
declare const ContextMenu: ((props: ContextMenuProps) => React.JSX.Element) & {
|
|
263
|
+
Root: (props: ContextMenuProps) => React.JSX.Element;
|
|
264
|
+
Trigger: typeof ContextMenuTrigger;
|
|
265
|
+
Portal: (props: ContextMenuPortalProps) => React.JSX.Element;
|
|
266
|
+
Positioner: typeof ContextMenuPositioner;
|
|
267
|
+
Popup: typeof ContextMenuPopup;
|
|
268
|
+
Content: typeof ContextMenuContent;
|
|
269
|
+
Item: typeof ContextMenuItem;
|
|
270
|
+
Separator: typeof ContextMenuSeparator;
|
|
271
|
+
Group: typeof ContextMenuGroup;
|
|
272
|
+
Label: typeof ContextMenuLabel;
|
|
273
|
+
CheckboxItem: typeof ContextMenuCheckboxItem;
|
|
274
|
+
RadioGroup: typeof ContextMenuRadioGroup;
|
|
275
|
+
RadioItem: typeof ContextMenuRadioItem;
|
|
276
|
+
Shortcut: typeof ContextMenuShortcut;
|
|
277
|
+
Sub: typeof ContextMenuSub;
|
|
278
|
+
SubContent: typeof ContextMenuSubContent;
|
|
279
|
+
SubTrigger: typeof ContextMenuSubTrigger;
|
|
280
|
+
};
|
|
281
|
+
//#endregion
|
|
282
|
+
export { ContextMenu, ContextMenuCheckboxItem, ContextMenuCheckboxItemProps, ContextMenuContent, ContextMenuContentProps, ContextMenuGroup, ContextMenuGroupProps, ContextMenuItem, ContextMenuItemProps, ContextMenuLabel, ContextMenuLabelProps, ContextMenuPopup, ContextMenuPopupProps, ContextMenuPortal, ContextMenuPortalProps, ContextMenuPositioner, ContextMenuPositionerProps, ContextMenuProps, ContextMenuRadioGroup, ContextMenuRadioGroupProps, ContextMenuRadioItem, ContextMenuRadioItemProps, ContextMenuRoot, ContextMenuSeparator, ContextMenuSeparatorProps, ContextMenuShortcut, ContextMenuShortcutProps, ContextMenuSub, ContextMenuSubContent, ContextMenuSubContentProps, ContextMenuSubProps, ContextMenuSubTrigger, ContextMenuSubTriggerProps, ContextMenuTrigger, ContextMenuTriggerProps };
|