@mcp-elements/react 0.1.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.
- package/LICENSE +21 -0
- package/dist/index.d.ts +592 -0
- package/dist/index.js +1793 -0
- package/dist/index.js.map +1 -0
- package/package.json +38 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,1793 @@
|
|
|
1
|
+
// src/button.tsx
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { cn } from "@mcp-elements/core";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
var Button = forwardRef(
|
|
6
|
+
({ variant = "primary", size = "md", className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
7
|
+
"button",
|
|
8
|
+
{
|
|
9
|
+
ref,
|
|
10
|
+
className: cn("mcpe-btn", `mcpe-btn-${variant}`, `mcpe-btn-${size}`, className),
|
|
11
|
+
...props
|
|
12
|
+
}
|
|
13
|
+
)
|
|
14
|
+
);
|
|
15
|
+
Button.displayName = "Button";
|
|
16
|
+
|
|
17
|
+
// src/badge.tsx
|
|
18
|
+
import { cn as cn2 } from "@mcp-elements/core";
|
|
19
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
20
|
+
function Badge({ variant = "default", className, ...props }) {
|
|
21
|
+
return /* @__PURE__ */ jsx2("div", { className: cn2("mcpe-badge", `mcpe-badge-${variant}`, className), ...props });
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// src/card.tsx
|
|
25
|
+
import { forwardRef as forwardRef2 } from "react";
|
|
26
|
+
import { cn as cn3 } from "@mcp-elements/core";
|
|
27
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
28
|
+
var Card = forwardRef2(
|
|
29
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsx3("div", { ref, className: cn3("mcpe-card", className), ...props })
|
|
30
|
+
);
|
|
31
|
+
Card.displayName = "Card";
|
|
32
|
+
var CardHeader = forwardRef2(
|
|
33
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsx3("div", { ref, className: cn3("mcpe-card-header", className), ...props })
|
|
34
|
+
);
|
|
35
|
+
CardHeader.displayName = "CardHeader";
|
|
36
|
+
var CardTitle = forwardRef2(
|
|
37
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsx3("h3", { ref, className: cn3("mcpe-card-title", className), ...props })
|
|
38
|
+
);
|
|
39
|
+
CardTitle.displayName = "CardTitle";
|
|
40
|
+
var CardDescription = forwardRef2(
|
|
41
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsx3("p", { ref, className: cn3("mcpe-card-description", className), ...props })
|
|
42
|
+
);
|
|
43
|
+
CardDescription.displayName = "CardDescription";
|
|
44
|
+
var CardContent = forwardRef2(
|
|
45
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsx3("div", { ref, className: cn3("mcpe-card-content", className), ...props })
|
|
46
|
+
);
|
|
47
|
+
CardContent.displayName = "CardContent";
|
|
48
|
+
var CardFooter = forwardRef2(
|
|
49
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsx3("div", { ref, className: cn3("mcpe-card-footer", className), ...props })
|
|
50
|
+
);
|
|
51
|
+
CardFooter.displayName = "CardFooter";
|
|
52
|
+
|
|
53
|
+
// src/input.tsx
|
|
54
|
+
import { forwardRef as forwardRef3 } from "react";
|
|
55
|
+
import { cn as cn4 } from "@mcp-elements/core";
|
|
56
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
57
|
+
var Input = forwardRef3(
|
|
58
|
+
({ className, type = "text", ...props }, ref) => /* @__PURE__ */ jsx4("input", { ref, type, className: cn4("mcpe-input", className), ...props })
|
|
59
|
+
);
|
|
60
|
+
Input.displayName = "Input";
|
|
61
|
+
|
|
62
|
+
// src/textarea.tsx
|
|
63
|
+
import { forwardRef as forwardRef4 } from "react";
|
|
64
|
+
import { cn as cn5 } from "@mcp-elements/core";
|
|
65
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
66
|
+
var Textarea = forwardRef4(
|
|
67
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsx5("textarea", { ref, className: cn5("mcpe-textarea", className), ...props })
|
|
68
|
+
);
|
|
69
|
+
Textarea.displayName = "Textarea";
|
|
70
|
+
|
|
71
|
+
// src/avatar.tsx
|
|
72
|
+
import { forwardRef as forwardRef5, useState } from "react";
|
|
73
|
+
import { cn as cn6 } from "@mcp-elements/core";
|
|
74
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
75
|
+
var Avatar = forwardRef5(
|
|
76
|
+
({ src, alt, fallback, className, ...props }, ref) => {
|
|
77
|
+
const [hasError, setHasError] = useState(false);
|
|
78
|
+
return /* @__PURE__ */ jsx6("div", { ref, className: cn6("mcpe-avatar", className), ...props, children: src && !hasError ? /* @__PURE__ */ jsx6("img", { src, alt, className: "mcpe-avatar-image", onError: () => setHasError(true) }) : /* @__PURE__ */ jsx6("span", { className: "mcpe-avatar-fallback", children: fallback }) });
|
|
79
|
+
}
|
|
80
|
+
);
|
|
81
|
+
Avatar.displayName = "Avatar";
|
|
82
|
+
|
|
83
|
+
// src/separator.tsx
|
|
84
|
+
import { forwardRef as forwardRef6 } from "react";
|
|
85
|
+
import { cn as cn7 } from "@mcp-elements/core";
|
|
86
|
+
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
87
|
+
var Separator = forwardRef6(
|
|
88
|
+
({ orientation = "horizontal", className, ...props }, ref) => /* @__PURE__ */ jsx7(
|
|
89
|
+
"div",
|
|
90
|
+
{
|
|
91
|
+
ref,
|
|
92
|
+
role: "separator",
|
|
93
|
+
"aria-orientation": orientation,
|
|
94
|
+
className: cn7("mcpe-separator", `mcpe-separator-${orientation}`, className),
|
|
95
|
+
...props
|
|
96
|
+
}
|
|
97
|
+
)
|
|
98
|
+
);
|
|
99
|
+
Separator.displayName = "Separator";
|
|
100
|
+
|
|
101
|
+
// src/skeleton.tsx
|
|
102
|
+
import { cn as cn8 } from "@mcp-elements/core";
|
|
103
|
+
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
104
|
+
function Skeleton({ className, ...props }) {
|
|
105
|
+
return /* @__PURE__ */ jsx8("div", { className: cn8("mcpe-skeleton", className), ...props });
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// src/dialog.tsx
|
|
109
|
+
import { useEffect, useRef, useId, createContext, useContext } from "react";
|
|
110
|
+
import { cn as cn9, trapFocus, lockScroll } from "@mcp-elements/core";
|
|
111
|
+
|
|
112
|
+
// src/hooks/use-dialog.ts
|
|
113
|
+
import { useState as useState2, useMemo } from "react";
|
|
114
|
+
import { createDialog } from "@mcp-elements/core";
|
|
115
|
+
function useDialog(config = {}) {
|
|
116
|
+
const [open, setOpen] = useState2(false);
|
|
117
|
+
const api = useMemo(
|
|
118
|
+
() => createDialog({ ...config, onOpenChange: setOpen }),
|
|
119
|
+
[config.modal]
|
|
120
|
+
);
|
|
121
|
+
return { open, setOpen, ...api };
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// src/dialog.tsx
|
|
125
|
+
import { jsx as jsx9, jsxs } from "react/jsx-runtime";
|
|
126
|
+
var DialogIdContext = createContext("");
|
|
127
|
+
function Dialog({ open: controlledOpen, onOpenChange, modal = true, children }) {
|
|
128
|
+
const dialog = useDialog({ modal });
|
|
129
|
+
const isOpen = controlledOpen ?? dialog.open;
|
|
130
|
+
const setOpen = onOpenChange ?? dialog.setOpen;
|
|
131
|
+
const contentRef = useRef(null);
|
|
132
|
+
const dialogId = useId();
|
|
133
|
+
useEffect(() => {
|
|
134
|
+
if (!isOpen || !modal) return;
|
|
135
|
+
const unlock = lockScroll();
|
|
136
|
+
return unlock;
|
|
137
|
+
}, [isOpen, modal]);
|
|
138
|
+
useEffect(() => {
|
|
139
|
+
if (!isOpen || !contentRef.current) return;
|
|
140
|
+
const el = contentRef.current;
|
|
141
|
+
const handler = (e) => {
|
|
142
|
+
if (e.key === "Escape") {
|
|
143
|
+
setOpen(false);
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
trapFocus(el, e);
|
|
147
|
+
};
|
|
148
|
+
el.addEventListener("keydown", handler);
|
|
149
|
+
return () => el.removeEventListener("keydown", handler);
|
|
150
|
+
}, [isOpen]);
|
|
151
|
+
if (!isOpen) return null;
|
|
152
|
+
return /* @__PURE__ */ jsxs(DialogIdContext.Provider, { value: dialogId, children: [
|
|
153
|
+
/* @__PURE__ */ jsx9("div", { className: "mcpe-dialog-overlay", onClick: () => setOpen(false) }),
|
|
154
|
+
/* @__PURE__ */ jsxs("div", { ref: contentRef, className: "mcpe-dialog-content", role: "dialog", "aria-modal": modal, "aria-labelledby": `${dialogId}-title`, "aria-describedby": `${dialogId}-description`, children: [
|
|
155
|
+
children,
|
|
156
|
+
/* @__PURE__ */ jsxs(
|
|
157
|
+
"button",
|
|
158
|
+
{
|
|
159
|
+
className: "mcpe-dialog-close",
|
|
160
|
+
"aria-label": "Close",
|
|
161
|
+
onClick: () => setOpen(false),
|
|
162
|
+
type: "button",
|
|
163
|
+
children: [
|
|
164
|
+
/* @__PURE__ */ jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: "15", height: "15", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
165
|
+
/* @__PURE__ */ jsx9("path", { d: "M18 6 6 18" }),
|
|
166
|
+
/* @__PURE__ */ jsx9("path", { d: "m6 6 12 12" })
|
|
167
|
+
] }),
|
|
168
|
+
/* @__PURE__ */ jsx9("span", { className: "sr-only", children: "Close" })
|
|
169
|
+
]
|
|
170
|
+
}
|
|
171
|
+
)
|
|
172
|
+
] })
|
|
173
|
+
] });
|
|
174
|
+
}
|
|
175
|
+
function DialogHeader({ className, ...props }) {
|
|
176
|
+
return /* @__PURE__ */ jsx9("div", { className: cn9("mcpe-dialog-header", className), ...props });
|
|
177
|
+
}
|
|
178
|
+
function DialogFooter({ className, ...props }) {
|
|
179
|
+
return /* @__PURE__ */ jsx9("div", { className: cn9("mcpe-dialog-footer", className), ...props });
|
|
180
|
+
}
|
|
181
|
+
function DialogTitle({ className, ...props }) {
|
|
182
|
+
const dialogId = useContext(DialogIdContext);
|
|
183
|
+
return /* @__PURE__ */ jsx9("h2", { id: `${dialogId}-title`, className: cn9("mcpe-dialog-title", className), ...props });
|
|
184
|
+
}
|
|
185
|
+
function DialogDescription({ className, ...props }) {
|
|
186
|
+
const dialogId = useContext(DialogIdContext);
|
|
187
|
+
return /* @__PURE__ */ jsx9("p", { id: `${dialogId}-description`, className: cn9("mcpe-dialog-description", className), ...props });
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// src/tabs.tsx
|
|
191
|
+
import { useRef as useRef2, useEffect as useEffect2 } from "react";
|
|
192
|
+
import { cn as cn10 } from "@mcp-elements/core";
|
|
193
|
+
|
|
194
|
+
// src/hooks/use-tabs.ts
|
|
195
|
+
import { useState as useState3, useMemo as useMemo2 } from "react";
|
|
196
|
+
import { createTabs } from "@mcp-elements/core";
|
|
197
|
+
function useTabs(items, config = {}) {
|
|
198
|
+
const [value, setValue] = useState3(config.defaultValue ?? items[0]?.value ?? "");
|
|
199
|
+
const api = useMemo2(
|
|
200
|
+
() => createTabs(items, { ...config, onValueChange: setValue }),
|
|
201
|
+
[items, config.defaultValue]
|
|
202
|
+
);
|
|
203
|
+
return { value, setValue, ...api };
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// src/tabs.tsx
|
|
207
|
+
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
208
|
+
function Tabs({ items, defaultValue, children, className }) {
|
|
209
|
+
const api = useTabs(items, { defaultValue });
|
|
210
|
+
return /* @__PURE__ */ jsx10("div", { className, children: children(api) });
|
|
211
|
+
}
|
|
212
|
+
function TabsList({ className, ...props }) {
|
|
213
|
+
return /* @__PURE__ */ jsx10("div", { role: "tablist", className: cn10("mcpe-tabs-list", className), ...props });
|
|
214
|
+
}
|
|
215
|
+
function TabsTrigger({ isActive, className, ...props }) {
|
|
216
|
+
const ref = useRef2(null);
|
|
217
|
+
useEffect2(() => {
|
|
218
|
+
if (isActive && ref.current) {
|
|
219
|
+
ref.current.focus();
|
|
220
|
+
}
|
|
221
|
+
}, [isActive]);
|
|
222
|
+
return /* @__PURE__ */ jsx10(
|
|
223
|
+
"button",
|
|
224
|
+
{
|
|
225
|
+
ref,
|
|
226
|
+
role: "tab",
|
|
227
|
+
"aria-selected": isActive,
|
|
228
|
+
tabIndex: isActive ? 0 : -1,
|
|
229
|
+
className: cn10("mcpe-tabs-trigger", isActive && "mcpe-tabs-trigger-active", className),
|
|
230
|
+
...props
|
|
231
|
+
}
|
|
232
|
+
);
|
|
233
|
+
}
|
|
234
|
+
function TabsContent({ className, ...props }) {
|
|
235
|
+
return /* @__PURE__ */ jsx10("div", { role: "tabpanel", className: cn10("mcpe-tabs-content", className), ...props });
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
// src/accordion.tsx
|
|
239
|
+
import { cn as cn11 } from "@mcp-elements/core";
|
|
240
|
+
|
|
241
|
+
// src/hooks/use-accordion.ts
|
|
242
|
+
import { useState as useState4, useMemo as useMemo3 } from "react";
|
|
243
|
+
import { createAccordion } from "@mcp-elements/core";
|
|
244
|
+
function useAccordion(items, config = {}) {
|
|
245
|
+
const [expandedValues, setExpandedValues] = useState4([]);
|
|
246
|
+
const api = useMemo3(
|
|
247
|
+
() => createAccordion(items, { ...config, onValueChange: setExpandedValues }),
|
|
248
|
+
[items, config.type, config.collapsible]
|
|
249
|
+
);
|
|
250
|
+
return { expandedValues, setExpandedValues, ...api };
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
// src/accordion.tsx
|
|
254
|
+
import { jsx as jsx11, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
255
|
+
function Accordion({ items, type, collapsible, children, className }) {
|
|
256
|
+
const api = useAccordion(items, { type, collapsible });
|
|
257
|
+
return /* @__PURE__ */ jsx11("div", { className, children: children(api) });
|
|
258
|
+
}
|
|
259
|
+
function AccordionItem({ className, ...props }) {
|
|
260
|
+
return /* @__PURE__ */ jsx11("div", { className: cn11("mcpe-accordion-item", className), ...props });
|
|
261
|
+
}
|
|
262
|
+
function AccordionTrigger({ isExpanded, className, children, ...props }) {
|
|
263
|
+
return /* @__PURE__ */ jsx11("h3", { children: /* @__PURE__ */ jsxs2(
|
|
264
|
+
"button",
|
|
265
|
+
{
|
|
266
|
+
"aria-expanded": isExpanded,
|
|
267
|
+
className: cn11("mcpe-accordion-trigger", className),
|
|
268
|
+
...props,
|
|
269
|
+
children: [
|
|
270
|
+
children,
|
|
271
|
+
/* @__PURE__ */ jsx11("svg", { className: "mcpe-accordion-chevron", xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsx11("path", { d: "m6 9 6 6 6-6" }) })
|
|
272
|
+
]
|
|
273
|
+
}
|
|
274
|
+
) });
|
|
275
|
+
}
|
|
276
|
+
function AccordionContent({ className, ...props }) {
|
|
277
|
+
return /* @__PURE__ */ jsx11("div", { role: "region", className: cn11("mcpe-accordion-content", className), ...props });
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
// src/select.tsx
|
|
281
|
+
import { useRef as useRef3, useEffect as useEffect3 } from "react";
|
|
282
|
+
import { cn as cn12, createClickOutsideHandler } from "@mcp-elements/core";
|
|
283
|
+
|
|
284
|
+
// src/hooks/use-select.ts
|
|
285
|
+
import { useState as useState5, useMemo as useMemo4, useCallback } from "react";
|
|
286
|
+
import { createSelect } from "@mcp-elements/core";
|
|
287
|
+
function useSelect(options, config = {}) {
|
|
288
|
+
const [isOpen, setIsOpen] = useState5(false);
|
|
289
|
+
const [selectedValue, setSelectedValue] = useState5(null);
|
|
290
|
+
const [highlightedIndex, setHighlightedIndex] = useState5(0);
|
|
291
|
+
const api = useMemo4(
|
|
292
|
+
() => createSelect(options, {
|
|
293
|
+
...config,
|
|
294
|
+
onValueChange: setSelectedValue,
|
|
295
|
+
onOpenChange: setIsOpen
|
|
296
|
+
}),
|
|
297
|
+
[options]
|
|
298
|
+
);
|
|
299
|
+
const handleKeyDown = useCallback(
|
|
300
|
+
(e) => {
|
|
301
|
+
api.handleKeyDown(e.nativeEvent, isOpen, highlightedIndex, setHighlightedIndex);
|
|
302
|
+
},
|
|
303
|
+
[api, isOpen, highlightedIndex]
|
|
304
|
+
);
|
|
305
|
+
const { handleKeyDown: _coreHandleKeyDown, ...restApi } = api;
|
|
306
|
+
return {
|
|
307
|
+
isOpen,
|
|
308
|
+
setIsOpen,
|
|
309
|
+
selectedValue,
|
|
310
|
+
setSelectedValue,
|
|
311
|
+
highlightedIndex,
|
|
312
|
+
setHighlightedIndex,
|
|
313
|
+
handleKeyDown,
|
|
314
|
+
...restApi
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
// src/select.tsx
|
|
319
|
+
import { jsx as jsx12, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
320
|
+
function Select({ options, placeholder = "Select...", className, onChange }) {
|
|
321
|
+
const select = useSelect(options);
|
|
322
|
+
const containerRef = useRef3(null);
|
|
323
|
+
const selectedLabel = options.find((o) => o.value === select.selectedValue)?.label;
|
|
324
|
+
useEffect3(() => {
|
|
325
|
+
if (!select.isOpen || !containerRef.current) return;
|
|
326
|
+
return createClickOutsideHandler(containerRef.current, () => select.setIsOpen(false));
|
|
327
|
+
}, [select.isOpen]);
|
|
328
|
+
useEffect3(() => {
|
|
329
|
+
if (select.selectedValue && onChange) {
|
|
330
|
+
onChange(select.selectedValue);
|
|
331
|
+
}
|
|
332
|
+
}, [select.selectedValue]);
|
|
333
|
+
return /* @__PURE__ */ jsxs3("div", { ref: containerRef, className: cn12("relative", className), children: [
|
|
334
|
+
/* @__PURE__ */ jsxs3(
|
|
335
|
+
"button",
|
|
336
|
+
{
|
|
337
|
+
className: "mcpe-select-trigger",
|
|
338
|
+
"aria-expanded": select.isOpen,
|
|
339
|
+
"aria-haspopup": "listbox",
|
|
340
|
+
"aria-activedescendant": select.isOpen && select.highlightedIndex >= 0 ? `select-option-${options[select.highlightedIndex]?.value}` : void 0,
|
|
341
|
+
onClick: () => select.setIsOpen(!select.isOpen),
|
|
342
|
+
onKeyDown: select.handleKeyDown,
|
|
343
|
+
type: "button",
|
|
344
|
+
children: [
|
|
345
|
+
/* @__PURE__ */ jsx12("span", { className: cn12(!selectedLabel && "text-muted-foreground"), children: selectedLabel || placeholder }),
|
|
346
|
+
/* @__PURE__ */ jsx12(
|
|
347
|
+
"svg",
|
|
348
|
+
{
|
|
349
|
+
className: cn12("h-4 w-4 opacity-50 transition-transform", select.isOpen && "rotate-180"),
|
|
350
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
351
|
+
viewBox: "0 0 24 24",
|
|
352
|
+
fill: "none",
|
|
353
|
+
stroke: "currentColor",
|
|
354
|
+
strokeWidth: "2",
|
|
355
|
+
strokeLinecap: "round",
|
|
356
|
+
strokeLinejoin: "round",
|
|
357
|
+
children: /* @__PURE__ */ jsx12("path", { d: "m6 9 6 6 6-6" })
|
|
358
|
+
}
|
|
359
|
+
)
|
|
360
|
+
]
|
|
361
|
+
}
|
|
362
|
+
),
|
|
363
|
+
select.isOpen && /* @__PURE__ */ jsx12("div", { className: "mcpe-select-content absolute top-full mt-1 w-full", children: /* @__PURE__ */ jsx12("div", { className: "mcpe-select-viewport", role: "listbox", children: options.map((option, index) => /* @__PURE__ */ jsxs3(
|
|
364
|
+
"div",
|
|
365
|
+
{
|
|
366
|
+
role: "option",
|
|
367
|
+
"aria-selected": option.value === select.selectedValue,
|
|
368
|
+
"aria-disabled": option.disabled || void 0,
|
|
369
|
+
className: cn12(
|
|
370
|
+
"mcpe-select-item",
|
|
371
|
+
index === select.highlightedIndex && !option.disabled && "mcpe-select-item-active",
|
|
372
|
+
option.value === select.selectedValue && "mcpe-select-item-selected",
|
|
373
|
+
option.disabled && "opacity-50 pointer-events-none"
|
|
374
|
+
),
|
|
375
|
+
onClick: () => {
|
|
376
|
+
if (!option.disabled) {
|
|
377
|
+
select.setSelectedValue(option.value);
|
|
378
|
+
select.setIsOpen(false);
|
|
379
|
+
}
|
|
380
|
+
},
|
|
381
|
+
onMouseEnter: () => {
|
|
382
|
+
if (!option.disabled) select.setHighlightedIndex(index);
|
|
383
|
+
},
|
|
384
|
+
children: [
|
|
385
|
+
option.value === select.selectedValue && /* @__PURE__ */ jsx12("svg", { className: "absolute right-2 h-4 w-4", xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsx12("path", { d: "M20 6 9 17l-5-5" }) }),
|
|
386
|
+
option.label
|
|
387
|
+
]
|
|
388
|
+
},
|
|
389
|
+
option.value
|
|
390
|
+
)) }) })
|
|
391
|
+
] });
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
// src/tooltip.tsx
|
|
395
|
+
import { cn as cn13 } from "@mcp-elements/core";
|
|
396
|
+
|
|
397
|
+
// src/hooks/use-tooltip.ts
|
|
398
|
+
import { useState as useState6, useMemo as useMemo5, useEffect as useEffect4 } from "react";
|
|
399
|
+
import { createTooltip } from "@mcp-elements/core";
|
|
400
|
+
function useTooltip(config = {}) {
|
|
401
|
+
const [open, setOpen] = useState6(false);
|
|
402
|
+
const api = useMemo5(
|
|
403
|
+
() => createTooltip({ ...config, onOpenChange: setOpen }),
|
|
404
|
+
[config.delay]
|
|
405
|
+
);
|
|
406
|
+
useEffect4(() => {
|
|
407
|
+
return () => api.destroy();
|
|
408
|
+
}, [api]);
|
|
409
|
+
return { open, setOpen, ...api };
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
// src/tooltip.tsx
|
|
413
|
+
import { jsx as jsx13, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
414
|
+
function Tooltip({ content, delay, children, className, side = "top" }) {
|
|
415
|
+
const tooltip = useTooltip({ delay });
|
|
416
|
+
const positionClasses = side === "top" ? "bottom-full left-1/2 -translate-x-1/2 mb-2" : "top-full left-1/2 -translate-x-1/2 mt-2";
|
|
417
|
+
const triggerProps = tooltip.getTriggerProps();
|
|
418
|
+
const contentProps = tooltip.getContentProps(tooltip.open);
|
|
419
|
+
return /* @__PURE__ */ jsxs4("div", { className: "relative inline-flex", ...triggerProps, children: [
|
|
420
|
+
children,
|
|
421
|
+
tooltip.open && /* @__PURE__ */ jsx13(
|
|
422
|
+
"div",
|
|
423
|
+
{
|
|
424
|
+
...contentProps,
|
|
425
|
+
className: cn13("mcpe-tooltip-content absolute", positionClasses, className),
|
|
426
|
+
children: content
|
|
427
|
+
}
|
|
428
|
+
)
|
|
429
|
+
] });
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
// src/popover.tsx
|
|
433
|
+
import { useRef as useRef4, useEffect as useEffect5 } from "react";
|
|
434
|
+
import { cn as cn14, createClickOutsideHandler as createClickOutsideHandler2 } from "@mcp-elements/core";
|
|
435
|
+
|
|
436
|
+
// src/hooks/use-popover.ts
|
|
437
|
+
import { useState as useState7, useMemo as useMemo6 } from "react";
|
|
438
|
+
import { createPopover } from "@mcp-elements/core";
|
|
439
|
+
function usePopover(config = {}) {
|
|
440
|
+
const [open, setOpen] = useState7(false);
|
|
441
|
+
const api = useMemo6(
|
|
442
|
+
() => createPopover({ ...config, onOpenChange: setOpen }),
|
|
443
|
+
[]
|
|
444
|
+
);
|
|
445
|
+
return { open, setOpen, ...api };
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
// src/popover.tsx
|
|
449
|
+
import { jsx as jsx14, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
450
|
+
function Popover({ trigger, children, className }) {
|
|
451
|
+
const popover = usePopover();
|
|
452
|
+
const containerRef = useRef4(null);
|
|
453
|
+
useEffect5(() => {
|
|
454
|
+
if (!popover.open || !containerRef.current) return;
|
|
455
|
+
return createClickOutsideHandler2(containerRef.current, () => popover.setOpen(false));
|
|
456
|
+
}, [popover.open]);
|
|
457
|
+
return /* @__PURE__ */ jsxs5("div", { ref: containerRef, className: "relative inline-block", children: [
|
|
458
|
+
/* @__PURE__ */ jsx14("div", { onClick: () => popover.setOpen(!popover.open), children: trigger }),
|
|
459
|
+
popover.open && /* @__PURE__ */ jsx14(
|
|
460
|
+
"div",
|
|
461
|
+
{
|
|
462
|
+
className: cn14("mcpe-popover-content absolute top-full mt-2", className),
|
|
463
|
+
role: "dialog",
|
|
464
|
+
onKeyDown: (e) => {
|
|
465
|
+
if (e.key === "Escape") popover.setOpen(false);
|
|
466
|
+
},
|
|
467
|
+
children
|
|
468
|
+
}
|
|
469
|
+
)
|
|
470
|
+
] });
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
// src/toast.tsx
|
|
474
|
+
import { cn as cn15 } from "@mcp-elements/core";
|
|
475
|
+
|
|
476
|
+
// src/hooks/use-toast.ts
|
|
477
|
+
import { useState as useState8, useEffect as useEffect6, useCallback as useCallback2 } from "react";
|
|
478
|
+
import { toast as toastManager } from "@mcp-elements/core";
|
|
479
|
+
function useToast() {
|
|
480
|
+
const [toasts, setToasts] = useState8([]);
|
|
481
|
+
useEffect6(() => {
|
|
482
|
+
return toastManager.subscribe((state) => {
|
|
483
|
+
setToasts([...state.toasts]);
|
|
484
|
+
});
|
|
485
|
+
}, []);
|
|
486
|
+
const dismiss = useCallback2((id) => {
|
|
487
|
+
toastManager.dismiss(id);
|
|
488
|
+
}, []);
|
|
489
|
+
return { toasts, dismiss, toast: toastManager };
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
// src/toast.tsx
|
|
493
|
+
import { jsx as jsx15, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
494
|
+
function Toaster({ position = "bottom-right", className }) {
|
|
495
|
+
const { toasts, dismiss } = useToast();
|
|
496
|
+
return /* @__PURE__ */ jsx15("div", { className: cn15("mcpe-toaster", `mcpe-toaster-${position}`, className), children: toasts.map((t) => /* @__PURE__ */ jsxs6(
|
|
497
|
+
"div",
|
|
498
|
+
{
|
|
499
|
+
className: cn15(
|
|
500
|
+
"mcpe-toast group",
|
|
501
|
+
t.variant === "destructive" && "mcpe-toast-destructive",
|
|
502
|
+
t.variant === "success" && "mcpe-toast-success"
|
|
503
|
+
),
|
|
504
|
+
children: [
|
|
505
|
+
/* @__PURE__ */ jsxs6("div", { className: "flex-1", children: [
|
|
506
|
+
t.title && /* @__PURE__ */ jsx15("div", { className: "mcpe-toast-title", children: t.title }),
|
|
507
|
+
t.description && /* @__PURE__ */ jsx15("div", { className: "mcpe-toast-description", children: t.description })
|
|
508
|
+
] }),
|
|
509
|
+
t.action && /* @__PURE__ */ jsx15("button", { className: "mcpe-toast-action", onClick: t.action.onClick, type: "button", children: t.action.label }),
|
|
510
|
+
/* @__PURE__ */ jsx15(
|
|
511
|
+
"button",
|
|
512
|
+
{
|
|
513
|
+
className: "mcpe-toast-close",
|
|
514
|
+
onClick: () => dismiss(t.id),
|
|
515
|
+
type: "button",
|
|
516
|
+
"aria-label": "Close",
|
|
517
|
+
children: /* @__PURE__ */ jsxs6("svg", { xmlns: "http://www.w3.org/2000/svg", width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
518
|
+
/* @__PURE__ */ jsx15("path", { d: "M18 6 6 18" }),
|
|
519
|
+
/* @__PURE__ */ jsx15("path", { d: "m6 6 12 12" })
|
|
520
|
+
] })
|
|
521
|
+
}
|
|
522
|
+
)
|
|
523
|
+
]
|
|
524
|
+
},
|
|
525
|
+
t.id
|
|
526
|
+
)) });
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
// src/drawer.tsx
|
|
530
|
+
import { useEffect as useEffect7, useRef as useRef5 } from "react";
|
|
531
|
+
import { cn as cn16, trapFocus as trapFocus2, lockScroll as lockScroll2 } from "@mcp-elements/core";
|
|
532
|
+
|
|
533
|
+
// src/hooks/use-drawer.ts
|
|
534
|
+
import { useState as useState9, useMemo as useMemo7 } from "react";
|
|
535
|
+
import { createDrawer } from "@mcp-elements/core";
|
|
536
|
+
function useDrawer(config = {}) {
|
|
537
|
+
const [open, setOpen] = useState9(false);
|
|
538
|
+
const api = useMemo7(
|
|
539
|
+
() => createDrawer({ ...config, onOpenChange: setOpen }),
|
|
540
|
+
[config.side]
|
|
541
|
+
);
|
|
542
|
+
return { open, setOpen, ...api };
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
// src/drawer.tsx
|
|
546
|
+
import { Fragment, jsx as jsx16, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
547
|
+
function Drawer({ open: controlledOpen, onOpenChange, side = "right", children }) {
|
|
548
|
+
const drawer = useDrawer({ side });
|
|
549
|
+
const isOpen = controlledOpen ?? drawer.open;
|
|
550
|
+
const setOpen = onOpenChange ?? drawer.setOpen;
|
|
551
|
+
const contentRef = useRef5(null);
|
|
552
|
+
useEffect7(() => {
|
|
553
|
+
if (!isOpen) return;
|
|
554
|
+
const unlock = lockScroll2();
|
|
555
|
+
return unlock;
|
|
556
|
+
}, [isOpen]);
|
|
557
|
+
useEffect7(() => {
|
|
558
|
+
if (!isOpen || !contentRef.current) return;
|
|
559
|
+
const el = contentRef.current;
|
|
560
|
+
const handler = (e) => {
|
|
561
|
+
if (e.key === "Escape") {
|
|
562
|
+
setOpen(false);
|
|
563
|
+
return;
|
|
564
|
+
}
|
|
565
|
+
trapFocus2(el, e);
|
|
566
|
+
};
|
|
567
|
+
el.addEventListener("keydown", handler);
|
|
568
|
+
return () => el.removeEventListener("keydown", handler);
|
|
569
|
+
}, [isOpen]);
|
|
570
|
+
if (!isOpen) return null;
|
|
571
|
+
return /* @__PURE__ */ jsxs7(Fragment, { children: [
|
|
572
|
+
/* @__PURE__ */ jsx16("div", { className: "mcpe-drawer-overlay", onClick: () => setOpen(false) }),
|
|
573
|
+
/* @__PURE__ */ jsxs7(
|
|
574
|
+
"div",
|
|
575
|
+
{
|
|
576
|
+
ref: contentRef,
|
|
577
|
+
className: cn16("mcpe-drawer-content", `mcpe-drawer-content-${side}`),
|
|
578
|
+
role: "dialog",
|
|
579
|
+
"aria-modal": true,
|
|
580
|
+
children: [
|
|
581
|
+
children,
|
|
582
|
+
/* @__PURE__ */ jsx16("button", { className: "mcpe-drawer-close", "aria-label": "Close", onClick: () => setOpen(false), type: "button", children: /* @__PURE__ */ jsxs7("svg", { xmlns: "http://www.w3.org/2000/svg", width: "15", height: "15", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
583
|
+
/* @__PURE__ */ jsx16("path", { d: "M18 6 6 18" }),
|
|
584
|
+
/* @__PURE__ */ jsx16("path", { d: "m6 6 12 12" })
|
|
585
|
+
] }) })
|
|
586
|
+
]
|
|
587
|
+
}
|
|
588
|
+
)
|
|
589
|
+
] });
|
|
590
|
+
}
|
|
591
|
+
function DrawerHeader({ className, ...props }) {
|
|
592
|
+
return /* @__PURE__ */ jsx16("div", { className: cn16("mcpe-drawer-header", className), ...props });
|
|
593
|
+
}
|
|
594
|
+
function DrawerFooter({ className, ...props }) {
|
|
595
|
+
return /* @__PURE__ */ jsx16("div", { className: cn16("mcpe-drawer-footer", className), ...props });
|
|
596
|
+
}
|
|
597
|
+
function DrawerTitle({ className, ...props }) {
|
|
598
|
+
return /* @__PURE__ */ jsx16("h2", { className: cn16("mcpe-drawer-title", className), ...props });
|
|
599
|
+
}
|
|
600
|
+
function DrawerDescription({ className, ...props }) {
|
|
601
|
+
return /* @__PURE__ */ jsx16("p", { className: cn16("mcpe-drawer-description", className), ...props });
|
|
602
|
+
}
|
|
603
|
+
function DrawerBody({ className, ...props }) {
|
|
604
|
+
return /* @__PURE__ */ jsx16("div", { className: cn16("mcpe-drawer-body", className), ...props });
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
// src/dropdown-menu.tsx
|
|
608
|
+
import { useRef as useRef6, useEffect as useEffect8 } from "react";
|
|
609
|
+
import { cn as cn17, createClickOutsideHandler as createClickOutsideHandler3 } from "@mcp-elements/core";
|
|
610
|
+
|
|
611
|
+
// src/hooks/use-dropdown-menu.ts
|
|
612
|
+
import { useState as useState10, useMemo as useMemo8, useCallback as useCallback3 } from "react";
|
|
613
|
+
import { createDropdownMenu } from "@mcp-elements/core";
|
|
614
|
+
function useDropdownMenu(items, config = {}) {
|
|
615
|
+
const [isOpen, setIsOpen] = useState10(false);
|
|
616
|
+
const [highlightedIndex, setHighlightedIndex] = useState10(0);
|
|
617
|
+
const api = useMemo8(
|
|
618
|
+
() => createDropdownMenu(items, { ...config, onOpenChange: setIsOpen }),
|
|
619
|
+
[items]
|
|
620
|
+
);
|
|
621
|
+
const { handleKeyDown: _coreHandleKeyDown, ...restApi } = api;
|
|
622
|
+
const handleKeyDown = useCallback3(
|
|
623
|
+
(e) => {
|
|
624
|
+
api.handleKeyDown(e.nativeEvent, isOpen, highlightedIndex, setHighlightedIndex);
|
|
625
|
+
},
|
|
626
|
+
[api, isOpen, highlightedIndex]
|
|
627
|
+
);
|
|
628
|
+
return {
|
|
629
|
+
isOpen,
|
|
630
|
+
setIsOpen,
|
|
631
|
+
highlightedIndex,
|
|
632
|
+
setHighlightedIndex,
|
|
633
|
+
handleKeyDown,
|
|
634
|
+
...restApi
|
|
635
|
+
};
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
// src/dropdown-menu.tsx
|
|
639
|
+
import { jsx as jsx17, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
640
|
+
function DropdownMenu({ trigger, items, className, align = "end" }) {
|
|
641
|
+
const menu = useDropdownMenu(items);
|
|
642
|
+
const containerRef = useRef6(null);
|
|
643
|
+
useEffect8(() => {
|
|
644
|
+
if (!menu.isOpen || !containerRef.current) return;
|
|
645
|
+
return createClickOutsideHandler3(containerRef.current, () => menu.setIsOpen(false));
|
|
646
|
+
}, [menu.isOpen]);
|
|
647
|
+
const actionItems = items.filter((i) => i.type !== "separator" && i.type !== "label" && !i.disabled);
|
|
648
|
+
return /* @__PURE__ */ jsxs8("div", { ref: containerRef, className: "relative inline-block", onKeyDown: menu.handleKeyDown, children: [
|
|
649
|
+
/* @__PURE__ */ jsx17(
|
|
650
|
+
"div",
|
|
651
|
+
{
|
|
652
|
+
onClick: () => menu.setIsOpen(!menu.isOpen),
|
|
653
|
+
"aria-haspopup": "menu",
|
|
654
|
+
"aria-expanded": menu.isOpen,
|
|
655
|
+
children: trigger
|
|
656
|
+
}
|
|
657
|
+
),
|
|
658
|
+
menu.isOpen && /* @__PURE__ */ jsx17(
|
|
659
|
+
"div",
|
|
660
|
+
{
|
|
661
|
+
className: cn17(
|
|
662
|
+
"mcpe-dropdown-menu-content absolute top-full mt-1",
|
|
663
|
+
align === "end" ? "right-0" : "left-0",
|
|
664
|
+
className
|
|
665
|
+
),
|
|
666
|
+
role: "menu",
|
|
667
|
+
children: items.map((item) => {
|
|
668
|
+
if (item.type === "separator") {
|
|
669
|
+
return /* @__PURE__ */ jsx17("div", { className: "mcpe-dropdown-menu-separator", role: "separator" }, item.id);
|
|
670
|
+
}
|
|
671
|
+
if (item.type === "label") {
|
|
672
|
+
return /* @__PURE__ */ jsx17("div", { className: "mcpe-dropdown-menu-label", children: item.label }, item.id);
|
|
673
|
+
}
|
|
674
|
+
const actionIndex = actionItems.findIndex((ai) => ai.id === item.id);
|
|
675
|
+
return /* @__PURE__ */ jsxs8(
|
|
676
|
+
"div",
|
|
677
|
+
{
|
|
678
|
+
role: "menuitem",
|
|
679
|
+
"aria-disabled": item.disabled || void 0,
|
|
680
|
+
className: cn17(
|
|
681
|
+
"mcpe-dropdown-menu-item",
|
|
682
|
+
actionIndex === menu.highlightedIndex && !item.disabled && "mcpe-dropdown-menu-item-active",
|
|
683
|
+
item.disabled && "opacity-50 pointer-events-none"
|
|
684
|
+
),
|
|
685
|
+
onClick: () => {
|
|
686
|
+
if (!item.disabled) {
|
|
687
|
+
item.onSelect?.();
|
|
688
|
+
menu.setIsOpen(false);
|
|
689
|
+
}
|
|
690
|
+
},
|
|
691
|
+
onMouseEnter: () => {
|
|
692
|
+
if (!item.disabled) menu.setHighlightedIndex(actionIndex);
|
|
693
|
+
},
|
|
694
|
+
children: [
|
|
695
|
+
/* @__PURE__ */ jsx17("span", { className: "flex-1", children: item.label }),
|
|
696
|
+
item.shortcut && /* @__PURE__ */ jsx17("span", { className: "mcpe-dropdown-menu-shortcut", children: item.shortcut })
|
|
697
|
+
]
|
|
698
|
+
},
|
|
699
|
+
item.id
|
|
700
|
+
);
|
|
701
|
+
})
|
|
702
|
+
}
|
|
703
|
+
)
|
|
704
|
+
] });
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
// src/switch.tsx
|
|
708
|
+
import { forwardRef as forwardRef7 } from "react";
|
|
709
|
+
import { cn as cn18 } from "@mcp-elements/core";
|
|
710
|
+
import { jsx as jsx18, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
711
|
+
var Switch = forwardRef7(
|
|
712
|
+
({ checked = false, onCheckedChange, disabled, className, id, name }, ref) => /* @__PURE__ */ jsxs9(
|
|
713
|
+
"button",
|
|
714
|
+
{
|
|
715
|
+
ref,
|
|
716
|
+
type: "button",
|
|
717
|
+
role: "switch",
|
|
718
|
+
id,
|
|
719
|
+
"aria-checked": checked,
|
|
720
|
+
"aria-disabled": disabled || void 0,
|
|
721
|
+
disabled,
|
|
722
|
+
className: cn18("mcpe-switch", className),
|
|
723
|
+
onClick: () => onCheckedChange?.(!checked),
|
|
724
|
+
onKeyDown: (e) => {
|
|
725
|
+
if (e.key === " " || e.key === "Enter") {
|
|
726
|
+
e.preventDefault();
|
|
727
|
+
onCheckedChange?.(!checked);
|
|
728
|
+
}
|
|
729
|
+
},
|
|
730
|
+
children: [
|
|
731
|
+
/* @__PURE__ */ jsx18("span", { className: "mcpe-switch-thumb" }),
|
|
732
|
+
name && /* @__PURE__ */ jsx18("input", { type: "hidden", name, value: checked ? "on" : "off" })
|
|
733
|
+
]
|
|
734
|
+
}
|
|
735
|
+
)
|
|
736
|
+
);
|
|
737
|
+
Switch.displayName = "Switch";
|
|
738
|
+
|
|
739
|
+
// src/progress.tsx
|
|
740
|
+
import { forwardRef as forwardRef8 } from "react";
|
|
741
|
+
import { cn as cn19 } from "@mcp-elements/core";
|
|
742
|
+
import { jsx as jsx19 } from "react/jsx-runtime";
|
|
743
|
+
var Progress = forwardRef8(
|
|
744
|
+
({ value = 0, max = 100, className, ...props }, ref) => {
|
|
745
|
+
const percentage = Math.min(Math.max(value / max * 100, 0), 100);
|
|
746
|
+
return /* @__PURE__ */ jsx19(
|
|
747
|
+
"div",
|
|
748
|
+
{
|
|
749
|
+
ref,
|
|
750
|
+
role: "progressbar",
|
|
751
|
+
"aria-valuenow": value,
|
|
752
|
+
"aria-valuemin": 0,
|
|
753
|
+
"aria-valuemax": max,
|
|
754
|
+
className: cn19("mcpe-progress", className),
|
|
755
|
+
...props,
|
|
756
|
+
children: /* @__PURE__ */ jsx19(
|
|
757
|
+
"div",
|
|
758
|
+
{
|
|
759
|
+
className: "mcpe-progress-indicator",
|
|
760
|
+
style: { transform: `translateX(-${100 - percentage}%)` }
|
|
761
|
+
}
|
|
762
|
+
)
|
|
763
|
+
}
|
|
764
|
+
);
|
|
765
|
+
}
|
|
766
|
+
);
|
|
767
|
+
Progress.displayName = "Progress";
|
|
768
|
+
|
|
769
|
+
// src/loader.tsx
|
|
770
|
+
import { cn as cn20 } from "@mcp-elements/core";
|
|
771
|
+
import { jsx as jsx20 } from "react/jsx-runtime";
|
|
772
|
+
function Loader({ size = "md", variant = "primary", className, ...props }) {
|
|
773
|
+
return /* @__PURE__ */ jsx20(
|
|
774
|
+
"div",
|
|
775
|
+
{
|
|
776
|
+
role: "status",
|
|
777
|
+
"aria-label": "Loading",
|
|
778
|
+
className: cn20("mcpe-loader", `mcpe-loader-${size}`, `mcpe-loader-${variant}`, className),
|
|
779
|
+
...props,
|
|
780
|
+
children: /* @__PURE__ */ jsx20("span", { className: "sr-only", children: "Loading..." })
|
|
781
|
+
}
|
|
782
|
+
);
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
// src/chips.tsx
|
|
786
|
+
import { cn as cn21 } from "@mcp-elements/core";
|
|
787
|
+
import { jsx as jsx21, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
788
|
+
function Chip({ variant = "default", onRemove, className, children, ...props }) {
|
|
789
|
+
return /* @__PURE__ */ jsxs10(
|
|
790
|
+
"span",
|
|
791
|
+
{
|
|
792
|
+
className: cn21("mcpe-chip", `mcpe-chip-${variant}`, onRemove && "mcpe-chip-removable", className),
|
|
793
|
+
...props,
|
|
794
|
+
children: [
|
|
795
|
+
children,
|
|
796
|
+
onRemove && /* @__PURE__ */ jsx21(
|
|
797
|
+
"button",
|
|
798
|
+
{
|
|
799
|
+
type: "button",
|
|
800
|
+
className: "mcpe-chip-remove",
|
|
801
|
+
onClick: (e) => {
|
|
802
|
+
e.stopPropagation();
|
|
803
|
+
onRemove();
|
|
804
|
+
},
|
|
805
|
+
"aria-label": "Remove",
|
|
806
|
+
children: /* @__PURE__ */ jsxs10("svg", { xmlns: "http://www.w3.org/2000/svg", width: "12", height: "12", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
807
|
+
/* @__PURE__ */ jsx21("path", { d: "M18 6 6 18" }),
|
|
808
|
+
/* @__PURE__ */ jsx21("path", { d: "m6 6 12 12" })
|
|
809
|
+
] })
|
|
810
|
+
}
|
|
811
|
+
)
|
|
812
|
+
]
|
|
813
|
+
}
|
|
814
|
+
);
|
|
815
|
+
}
|
|
816
|
+
function Chips({ className, ...props }) {
|
|
817
|
+
return /* @__PURE__ */ jsx21("div", { className: cn21("mcpe-chips", className), ...props });
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
// src/password-input.tsx
|
|
821
|
+
import { forwardRef as forwardRef9, useState as useState11 } from "react";
|
|
822
|
+
import { cn as cn22 } from "@mcp-elements/core";
|
|
823
|
+
import { jsx as jsx22, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
824
|
+
var PasswordInput = forwardRef9(
|
|
825
|
+
({ className, ...props }, ref) => {
|
|
826
|
+
const [showPassword, setShowPassword] = useState11(false);
|
|
827
|
+
return /* @__PURE__ */ jsxs11("div", { className: "mcpe-password-input-wrapper", children: [
|
|
828
|
+
/* @__PURE__ */ jsx22(
|
|
829
|
+
"input",
|
|
830
|
+
{
|
|
831
|
+
ref,
|
|
832
|
+
type: showPassword ? "text" : "password",
|
|
833
|
+
className: cn22("mcpe-password-input", className),
|
|
834
|
+
...props
|
|
835
|
+
}
|
|
836
|
+
),
|
|
837
|
+
/* @__PURE__ */ jsx22(
|
|
838
|
+
"button",
|
|
839
|
+
{
|
|
840
|
+
type: "button",
|
|
841
|
+
className: "mcpe-password-toggle",
|
|
842
|
+
onClick: () => setShowPassword(!showPassword),
|
|
843
|
+
"aria-label": showPassword ? "Hide password" : "Show password",
|
|
844
|
+
children: showPassword ? /* @__PURE__ */ jsxs11("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
845
|
+
/* @__PURE__ */ jsx22("path", { d: "M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24" }),
|
|
846
|
+
/* @__PURE__ */ jsx22("line", { x1: "1", y1: "1", x2: "23", y2: "23" })
|
|
847
|
+
] }) : /* @__PURE__ */ jsxs11("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
848
|
+
/* @__PURE__ */ jsx22("path", { d: "M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z" }),
|
|
849
|
+
/* @__PURE__ */ jsx22("circle", { cx: "12", cy: "12", r: "3" })
|
|
850
|
+
] })
|
|
851
|
+
}
|
|
852
|
+
)
|
|
853
|
+
] });
|
|
854
|
+
}
|
|
855
|
+
);
|
|
856
|
+
PasswordInput.displayName = "PasswordInput";
|
|
857
|
+
|
|
858
|
+
// src/counter.tsx
|
|
859
|
+
import { cn as cn23 } from "@mcp-elements/core";
|
|
860
|
+
import { jsx as jsx23, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
861
|
+
function Counter({ value, onChange, min = 0, max = 99, step = 1, disabled, className }) {
|
|
862
|
+
const decrement = () => onChange(Math.max(min, value - step));
|
|
863
|
+
const increment = () => onChange(Math.min(max, value + step));
|
|
864
|
+
return /* @__PURE__ */ jsxs12("div", { className: cn23("mcpe-counter", className), children: [
|
|
865
|
+
/* @__PURE__ */ jsx23(
|
|
866
|
+
"button",
|
|
867
|
+
{
|
|
868
|
+
type: "button",
|
|
869
|
+
className: "mcpe-counter-button",
|
|
870
|
+
onClick: decrement,
|
|
871
|
+
disabled: disabled || value <= min,
|
|
872
|
+
"aria-label": "Decrease",
|
|
873
|
+
children: /* @__PURE__ */ jsx23("svg", { xmlns: "http://www.w3.org/2000/svg", width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsx23("path", { d: "M5 12h14" }) })
|
|
874
|
+
}
|
|
875
|
+
),
|
|
876
|
+
/* @__PURE__ */ jsx23(
|
|
877
|
+
"input",
|
|
878
|
+
{
|
|
879
|
+
type: "text",
|
|
880
|
+
inputMode: "numeric",
|
|
881
|
+
className: "mcpe-counter-input",
|
|
882
|
+
value,
|
|
883
|
+
onChange: (e) => {
|
|
884
|
+
const num = parseInt(e.target.value, 10);
|
|
885
|
+
if (!isNaN(num)) onChange(Math.max(min, Math.min(max, num)));
|
|
886
|
+
},
|
|
887
|
+
disabled,
|
|
888
|
+
"aria-label": "Count"
|
|
889
|
+
}
|
|
890
|
+
),
|
|
891
|
+
/* @__PURE__ */ jsx23(
|
|
892
|
+
"button",
|
|
893
|
+
{
|
|
894
|
+
type: "button",
|
|
895
|
+
className: "mcpe-counter-button",
|
|
896
|
+
onClick: increment,
|
|
897
|
+
disabled: disabled || value >= max,
|
|
898
|
+
"aria-label": "Increase",
|
|
899
|
+
children: /* @__PURE__ */ jsxs12("svg", { xmlns: "http://www.w3.org/2000/svg", width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
900
|
+
/* @__PURE__ */ jsx23("path", { d: "M5 12h14" }),
|
|
901
|
+
/* @__PURE__ */ jsx23("path", { d: "M12 5v14" })
|
|
902
|
+
] })
|
|
903
|
+
}
|
|
904
|
+
)
|
|
905
|
+
] });
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
// src/alert.tsx
|
|
909
|
+
import { forwardRef as forwardRef10 } from "react";
|
|
910
|
+
import { cn as cn24 } from "@mcp-elements/core";
|
|
911
|
+
import { jsx as jsx24 } from "react/jsx-runtime";
|
|
912
|
+
var Alert = forwardRef10(
|
|
913
|
+
({ variant = "default", className, ...props }, ref) => /* @__PURE__ */ jsx24(
|
|
914
|
+
"div",
|
|
915
|
+
{
|
|
916
|
+
ref,
|
|
917
|
+
role: "alert",
|
|
918
|
+
className: cn24("mcpe-alert", `mcpe-alert-${variant}`, className),
|
|
919
|
+
...props
|
|
920
|
+
}
|
|
921
|
+
)
|
|
922
|
+
);
|
|
923
|
+
Alert.displayName = "Alert";
|
|
924
|
+
function AlertTitle({ className, ...props }) {
|
|
925
|
+
return /* @__PURE__ */ jsx24("h5", { className: cn24("mcpe-alert-title", className), ...props });
|
|
926
|
+
}
|
|
927
|
+
function AlertDescription({ className, ...props }) {
|
|
928
|
+
return /* @__PURE__ */ jsx24("div", { className: cn24("mcpe-alert-description", className), ...props });
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
// src/prompt-input.tsx
|
|
932
|
+
import { forwardRef as forwardRef11 } from "react";
|
|
933
|
+
import { cn as cn25 } from "@mcp-elements/core";
|
|
934
|
+
import { jsx as jsx25, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
935
|
+
var PromptInput = forwardRef11(
|
|
936
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsx25("div", { ref, className: cn25("mcpe-prompt-input", className), ...props })
|
|
937
|
+
);
|
|
938
|
+
PromptInput.displayName = "PromptInput";
|
|
939
|
+
var PromptInputTextarea = forwardRef11(
|
|
940
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsx25("textarea", { ref, className: cn25("mcpe-prompt-input-textarea", className), rows: 3, ...props })
|
|
941
|
+
);
|
|
942
|
+
PromptInputTextarea.displayName = "PromptInputTextarea";
|
|
943
|
+
var PromptInputFooter = forwardRef11(
|
|
944
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsx25("div", { ref, className: cn25("mcpe-prompt-input-footer", className), ...props })
|
|
945
|
+
);
|
|
946
|
+
PromptInputFooter.displayName = "PromptInputFooter";
|
|
947
|
+
var PromptInputActions = forwardRef11(
|
|
948
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsx25("div", { ref, className: cn25("mcpe-prompt-input-actions", className), ...props })
|
|
949
|
+
);
|
|
950
|
+
PromptInputActions.displayName = "PromptInputActions";
|
|
951
|
+
function PromptInputCharCount({ count, max, className }) {
|
|
952
|
+
return /* @__PURE__ */ jsxs13("span", { className: cn25("mcpe-prompt-input-char-count", className), children: [
|
|
953
|
+
count,
|
|
954
|
+
max != null && `/${max}`
|
|
955
|
+
] });
|
|
956
|
+
}
|
|
957
|
+
var PromptInputAttachments = forwardRef11(
|
|
958
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsx25("div", { ref, className: cn25("mcpe-prompt-input-attachments", className), ...props })
|
|
959
|
+
);
|
|
960
|
+
PromptInputAttachments.displayName = "PromptInputAttachments";
|
|
961
|
+
function PromptInputAttachment({ onRemove, className, children, ...props }) {
|
|
962
|
+
return /* @__PURE__ */ jsxs13("span", { className: cn25("mcpe-prompt-input-attachment", className), ...props, children: [
|
|
963
|
+
children,
|
|
964
|
+
onRemove && /* @__PURE__ */ jsx25(
|
|
965
|
+
"button",
|
|
966
|
+
{
|
|
967
|
+
type: "button",
|
|
968
|
+
className: "mcpe-prompt-input-attachment-remove",
|
|
969
|
+
onClick: (e) => {
|
|
970
|
+
e.stopPropagation();
|
|
971
|
+
onRemove();
|
|
972
|
+
},
|
|
973
|
+
"aria-label": "Remove",
|
|
974
|
+
children: /* @__PURE__ */ jsxs13("svg", { xmlns: "http://www.w3.org/2000/svg", width: "10", height: "10", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
975
|
+
/* @__PURE__ */ jsx25("path", { d: "M18 6 6 18" }),
|
|
976
|
+
/* @__PURE__ */ jsx25("path", { d: "m6 6 12 12" })
|
|
977
|
+
] })
|
|
978
|
+
}
|
|
979
|
+
)
|
|
980
|
+
] });
|
|
981
|
+
}
|
|
982
|
+
|
|
983
|
+
// src/chat-bubble.tsx
|
|
984
|
+
import { forwardRef as forwardRef12 } from "react";
|
|
985
|
+
import { cn as cn26 } from "@mcp-elements/core";
|
|
986
|
+
import { jsx as jsx26, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
987
|
+
var ChatBubble = forwardRef12(
|
|
988
|
+
({ variant = "ai", className, ...props }, ref) => /* @__PURE__ */ jsx26("div", { ref, className: cn26("mcpe-chat-bubble", `mcpe-chat-bubble-${variant}`, className), ...props })
|
|
989
|
+
);
|
|
990
|
+
ChatBubble.displayName = "ChatBubble";
|
|
991
|
+
function ChatBubbleAvatar({ src, alt, className }) {
|
|
992
|
+
return /* @__PURE__ */ jsx26("img", { src, alt, className: cn26("mcpe-chat-bubble-avatar", className) });
|
|
993
|
+
}
|
|
994
|
+
var ChatBubbleContent = forwardRef12(
|
|
995
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsx26("div", { ref, className: cn26("mcpe-chat-bubble-content", className), ...props })
|
|
996
|
+
);
|
|
997
|
+
ChatBubbleContent.displayName = "ChatBubbleContent";
|
|
998
|
+
var ChatBubbleTimestamp = forwardRef12(
|
|
999
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsx26("span", { ref, className: cn26("mcpe-chat-bubble-timestamp", className), ...props })
|
|
1000
|
+
);
|
|
1001
|
+
ChatBubbleTimestamp.displayName = "ChatBubbleTimestamp";
|
|
1002
|
+
function ChatBubbleTyping({ className }) {
|
|
1003
|
+
return /* @__PURE__ */ jsxs14("div", { className: cn26("mcpe-chat-bubble-typing", className), children: [
|
|
1004
|
+
/* @__PURE__ */ jsx26("span", { className: "mcpe-chat-bubble-typing-dot" }),
|
|
1005
|
+
/* @__PURE__ */ jsx26("span", { className: "mcpe-chat-bubble-typing-dot" }),
|
|
1006
|
+
/* @__PURE__ */ jsx26("span", { className: "mcpe-chat-bubble-typing-dot" })
|
|
1007
|
+
] });
|
|
1008
|
+
}
|
|
1009
|
+
|
|
1010
|
+
// src/ai-badge.tsx
|
|
1011
|
+
import { cn as cn27 } from "@mcp-elements/core";
|
|
1012
|
+
import { jsx as jsx27, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
1013
|
+
function AiBadge({ variant = "default", showIcon = true, className, children, ...props }) {
|
|
1014
|
+
return /* @__PURE__ */ jsxs15("span", { className: cn27("mcpe-ai-badge", `mcpe-ai-badge-${variant}`, className), ...props, children: [
|
|
1015
|
+
showIcon && /* @__PURE__ */ jsx27("svg", { xmlns: "http://www.w3.org/2000/svg", width: "12", height: "12", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsx27("path", { d: "M12 3l1.912 5.813a2 2 0 0 0 1.275 1.275L21 12l-5.813 1.912a2 2 0 0 0-1.275 1.275L12 21l-1.912-5.813a2 2 0 0 1-1.275-1.275L3 12l5.813-1.912a2 2 0 0 1 1.275-1.275L12 3z" }) }),
|
|
1016
|
+
children
|
|
1017
|
+
] });
|
|
1018
|
+
}
|
|
1019
|
+
|
|
1020
|
+
// src/suggestion-chips.tsx
|
|
1021
|
+
import { forwardRef as forwardRef13 } from "react";
|
|
1022
|
+
import { cn as cn28 } from "@mcp-elements/core";
|
|
1023
|
+
import { jsx as jsx28 } from "react/jsx-runtime";
|
|
1024
|
+
var SuggestionChips = forwardRef13(
|
|
1025
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsx28("div", { ref, className: cn28("mcpe-suggestion-chips", className), ...props })
|
|
1026
|
+
);
|
|
1027
|
+
SuggestionChips.displayName = "SuggestionChips";
|
|
1028
|
+
var SuggestionChip = forwardRef13(
|
|
1029
|
+
({ variant = "default", className, ...props }, ref) => /* @__PURE__ */ jsx28(
|
|
1030
|
+
"button",
|
|
1031
|
+
{
|
|
1032
|
+
ref,
|
|
1033
|
+
type: "button",
|
|
1034
|
+
className: cn28("mcpe-suggestion-chip", `mcpe-suggestion-chip-${variant}`, className),
|
|
1035
|
+
...props
|
|
1036
|
+
}
|
|
1037
|
+
)
|
|
1038
|
+
);
|
|
1039
|
+
SuggestionChip.displayName = "SuggestionChip";
|
|
1040
|
+
|
|
1041
|
+
// src/source-card.tsx
|
|
1042
|
+
import { forwardRef as forwardRef14 } from "react";
|
|
1043
|
+
import { cn as cn29 } from "@mcp-elements/core";
|
|
1044
|
+
import { jsx as jsx29, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
1045
|
+
var SourceCards = forwardRef14(
|
|
1046
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsx29("div", { ref, className: cn29("mcpe-source-cards", className), ...props })
|
|
1047
|
+
);
|
|
1048
|
+
SourceCards.displayName = "SourceCards";
|
|
1049
|
+
var SourceCard = forwardRef14(
|
|
1050
|
+
({ favicon, title, domain, index, className, ...props }, ref) => /* @__PURE__ */ jsxs16(
|
|
1051
|
+
"a",
|
|
1052
|
+
{
|
|
1053
|
+
ref,
|
|
1054
|
+
className: cn29("mcpe-source-card", className),
|
|
1055
|
+
target: "_blank",
|
|
1056
|
+
rel: "noopener noreferrer",
|
|
1057
|
+
...props,
|
|
1058
|
+
children: [
|
|
1059
|
+
favicon && /* @__PURE__ */ jsx29("img", { className: "mcpe-source-card-favicon", src: favicon, alt: domain }),
|
|
1060
|
+
/* @__PURE__ */ jsxs16("div", { className: "mcpe-source-card-body", children: [
|
|
1061
|
+
/* @__PURE__ */ jsx29("p", { className: "mcpe-source-card-title", children: title }),
|
|
1062
|
+
/* @__PURE__ */ jsx29("p", { className: "mcpe-source-card-domain", children: domain })
|
|
1063
|
+
] }),
|
|
1064
|
+
index != null && /* @__PURE__ */ jsx29("span", { className: "mcpe-source-card-index", children: index })
|
|
1065
|
+
]
|
|
1066
|
+
}
|
|
1067
|
+
)
|
|
1068
|
+
);
|
|
1069
|
+
SourceCard.displayName = "SourceCard";
|
|
1070
|
+
|
|
1071
|
+
// src/streaming-text.tsx
|
|
1072
|
+
import { forwardRef as forwardRef15 } from "react";
|
|
1073
|
+
import { cn as cn30 } from "@mcp-elements/core";
|
|
1074
|
+
import { jsx as jsx30 } from "react/jsx-runtime";
|
|
1075
|
+
var StreamingText = forwardRef15(
|
|
1076
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsx30("div", { ref, className: cn30("mcpe-streaming-text-cursor", className), ...props })
|
|
1077
|
+
);
|
|
1078
|
+
StreamingText.displayName = "StreamingText";
|
|
1079
|
+
var StreamingTextFadeIn = forwardRef15(
|
|
1080
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsx30("span", { ref, className: cn30("mcpe-streaming-text-fade-in", className), ...props })
|
|
1081
|
+
);
|
|
1082
|
+
StreamingTextFadeIn.displayName = "StreamingTextFadeIn";
|
|
1083
|
+
var StreamingTextWord = forwardRef15(
|
|
1084
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsx30("span", { ref, className: cn30("mcpe-streaming-text-word", className), ...props })
|
|
1085
|
+
);
|
|
1086
|
+
StreamingTextWord.displayName = "StreamingTextWord";
|
|
1087
|
+
var StreamingTextLine = forwardRef15(
|
|
1088
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsx30("div", { ref, className: cn30("mcpe-streaming-text-line", className), ...props })
|
|
1089
|
+
);
|
|
1090
|
+
StreamingTextLine.displayName = "StreamingTextLine";
|
|
1091
|
+
var StreamingTextSkeleton = forwardRef15(
|
|
1092
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsx30("div", { ref, className: cn30("mcpe-streaming-text-skeleton", className), ...props })
|
|
1093
|
+
);
|
|
1094
|
+
StreamingTextSkeleton.displayName = "StreamingTextSkeleton";
|
|
1095
|
+
var StreamingTextSkeletonLine = forwardRef15(
|
|
1096
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsx30("div", { ref, className: cn30("mcpe-streaming-text-skeleton-line", className), ...props })
|
|
1097
|
+
);
|
|
1098
|
+
StreamingTextSkeletonLine.displayName = "StreamingTextSkeletonLine";
|
|
1099
|
+
|
|
1100
|
+
// src/feedback.tsx
|
|
1101
|
+
import { forwardRef as forwardRef16 } from "react";
|
|
1102
|
+
import { cn as cn31 } from "@mcp-elements/core";
|
|
1103
|
+
import { jsx as jsx31, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
1104
|
+
var Feedback = forwardRef16(
|
|
1105
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsx31("div", { ref, className: cn31("mcpe-feedback", className), ...props })
|
|
1106
|
+
);
|
|
1107
|
+
Feedback.displayName = "Feedback";
|
|
1108
|
+
function FeedbackButton({ type, selected = false, className, ...props }) {
|
|
1109
|
+
return /* @__PURE__ */ jsx31(
|
|
1110
|
+
"button",
|
|
1111
|
+
{
|
|
1112
|
+
type: "button",
|
|
1113
|
+
className: cn31(
|
|
1114
|
+
"mcpe-feedback-btn",
|
|
1115
|
+
`mcpe-feedback-btn-${type}`,
|
|
1116
|
+
selected && "mcpe-feedback-btn-selected",
|
|
1117
|
+
className
|
|
1118
|
+
),
|
|
1119
|
+
...props,
|
|
1120
|
+
children: type === "up" ? /* @__PURE__ */ jsxs17("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
1121
|
+
/* @__PURE__ */ jsx31("path", { d: "M7 10v12" }),
|
|
1122
|
+
/* @__PURE__ */ jsx31("path", { d: "M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z" })
|
|
1123
|
+
] }) : /* @__PURE__ */ jsxs17("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
1124
|
+
/* @__PURE__ */ jsx31("path", { d: "M17 14V2" }),
|
|
1125
|
+
/* @__PURE__ */ jsx31("path", { d: "M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z" })
|
|
1126
|
+
] })
|
|
1127
|
+
}
|
|
1128
|
+
);
|
|
1129
|
+
}
|
|
1130
|
+
function FeedbackSeparator({ className }) {
|
|
1131
|
+
return /* @__PURE__ */ jsx31("span", { className: cn31("mcpe-feedback-separator", className) });
|
|
1132
|
+
}
|
|
1133
|
+
var FeedbackForm = forwardRef16(
|
|
1134
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsx31("div", { ref, className: cn31("mcpe-feedback-form", className), ...props })
|
|
1135
|
+
);
|
|
1136
|
+
FeedbackForm.displayName = "FeedbackForm";
|
|
1137
|
+
var FeedbackInput = forwardRef16(
|
|
1138
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsx31("input", { ref, className: cn31("mcpe-feedback-input", className), placeholder: "Add a comment...", ...props })
|
|
1139
|
+
);
|
|
1140
|
+
FeedbackInput.displayName = "FeedbackInput";
|
|
1141
|
+
var FeedbackSubmit = forwardRef16(
|
|
1142
|
+
({ className, children = "Submit", ...props }, ref) => /* @__PURE__ */ jsx31("button", { ref, className: cn31("mcpe-feedback-submit", className), ...props, children })
|
|
1143
|
+
);
|
|
1144
|
+
FeedbackSubmit.displayName = "FeedbackSubmit";
|
|
1145
|
+
|
|
1146
|
+
// src/mcp/mcp-server-status.tsx
|
|
1147
|
+
import { cn as cn32 } from "@mcp-elements/core";
|
|
1148
|
+
import { jsx as jsx32, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
1149
|
+
var STATUS_LABELS = {
|
|
1150
|
+
connected: "Connected",
|
|
1151
|
+
connecting: "Connecting",
|
|
1152
|
+
disconnected: "Disconnected",
|
|
1153
|
+
error: "Error"
|
|
1154
|
+
};
|
|
1155
|
+
function McpServerStatus({ status, serverName, className, ...props }) {
|
|
1156
|
+
return /* @__PURE__ */ jsxs18(
|
|
1157
|
+
"span",
|
|
1158
|
+
{
|
|
1159
|
+
role: "status",
|
|
1160
|
+
"aria-live": "polite",
|
|
1161
|
+
"aria-label": serverName ? `${serverName}: ${STATUS_LABELS[status]}` : STATUS_LABELS[status],
|
|
1162
|
+
...props,
|
|
1163
|
+
className: cn32(
|
|
1164
|
+
"mcpe-mcp-server-status",
|
|
1165
|
+
`mcpe-mcp-server-status-${status}`,
|
|
1166
|
+
className
|
|
1167
|
+
),
|
|
1168
|
+
children: [
|
|
1169
|
+
/* @__PURE__ */ jsx32("span", { className: "mcpe-mcp-server-status-dot", "aria-hidden": "true" }),
|
|
1170
|
+
serverName ? `${serverName} \xB7 ${STATUS_LABELS[status]}` : STATUS_LABELS[status]
|
|
1171
|
+
]
|
|
1172
|
+
}
|
|
1173
|
+
);
|
|
1174
|
+
}
|
|
1175
|
+
|
|
1176
|
+
// src/mcp/mcp-tool-call.tsx
|
|
1177
|
+
import { useEffect as useEffect9, useState as useState12 } from "react";
|
|
1178
|
+
import { cn as cn33 } from "@mcp-elements/core";
|
|
1179
|
+
import { jsx as jsx33, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
1180
|
+
var STATUS_LABELS2 = {
|
|
1181
|
+
idle: "idle",
|
|
1182
|
+
pending: "pending",
|
|
1183
|
+
running: "running",
|
|
1184
|
+
done: "done",
|
|
1185
|
+
error: "error",
|
|
1186
|
+
cancelled: "cancelled"
|
|
1187
|
+
};
|
|
1188
|
+
function snapFromState(state) {
|
|
1189
|
+
return {
|
|
1190
|
+
status: state.status,
|
|
1191
|
+
tool: state.tool,
|
|
1192
|
+
args: state.args,
|
|
1193
|
+
result: state.result,
|
|
1194
|
+
error: state.error,
|
|
1195
|
+
startedAt: state.startedAt,
|
|
1196
|
+
endedAt: state.endedAt
|
|
1197
|
+
};
|
|
1198
|
+
}
|
|
1199
|
+
function McpToolCall({ state, toolName, args, onRetry, className }) {
|
|
1200
|
+
const [snap, setSnap] = useState12(() => snapFromState(state));
|
|
1201
|
+
useEffect9(() => {
|
|
1202
|
+
setSnap(snapFromState(state));
|
|
1203
|
+
return state.subscribe((s) => setSnap({ ...s }));
|
|
1204
|
+
}, [state]);
|
|
1205
|
+
const displayName = snap.tool ?? toolName ?? "unknown";
|
|
1206
|
+
const displayArgs = snap.args ?? args;
|
|
1207
|
+
return /* @__PURE__ */ jsxs19("div", { className: cn33("mcpe-mcp-tool-call", className), children: [
|
|
1208
|
+
/* @__PURE__ */ jsxs19("div", { className: "mcpe-mcp-tool-call-header", children: [
|
|
1209
|
+
/* @__PURE__ */ jsxs19("div", { className: "mcpe-mcp-tool-call-name", children: [
|
|
1210
|
+
/* @__PURE__ */ jsx33("span", { className: "mcpe-mcp-tool-call-icon", "aria-hidden": "true", children: "fn" }),
|
|
1211
|
+
/* @__PURE__ */ jsx33("span", { className: "mcpe-mcp-tool-call-title", children: displayName })
|
|
1212
|
+
] }),
|
|
1213
|
+
/* @__PURE__ */ jsxs19("span", { className: cn33("mcpe-mcp-tool-call-badge", `mcpe-mcp-tool-call-badge-${snap.status}`), children: [
|
|
1214
|
+
snap.status === "running" && /* @__PURE__ */ jsxs19("svg", { className: "animate-spin h-3 w-3", fill: "none", viewBox: "0 0 24 24", "aria-hidden": "true", children: [
|
|
1215
|
+
/* @__PURE__ */ jsx33("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }),
|
|
1216
|
+
/* @__PURE__ */ jsx33("path", { className: "opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z" })
|
|
1217
|
+
] }),
|
|
1218
|
+
STATUS_LABELS2[snap.status]
|
|
1219
|
+
] })
|
|
1220
|
+
] }),
|
|
1221
|
+
displayArgs && /* @__PURE__ */ jsx33("pre", { className: "mcpe-mcp-tool-call-args", children: JSON.stringify(displayArgs, null, 2) }),
|
|
1222
|
+
snap.status === "running" && /* @__PURE__ */ jsx33("div", { className: "mcpe-mcp-tool-call-progress", role: "progressbar", "aria-label": "Tool running", children: /* @__PURE__ */ jsx33("div", { className: "mcpe-mcp-tool-call-progress-bar", style: { width: "60%" } }) }),
|
|
1223
|
+
snap.status === "done" && snap.result && /* @__PURE__ */ jsx33("div", { className: "mcpe-mcp-tool-call-result mcpe-mcp-tool-call-result-done", children: snap.result.content.filter((c) => c.type === "text").map((c, i) => /* @__PURE__ */ jsx33("p", { className: "whitespace-pre-wrap text-sm", children: "text" in c ? c.text : null }, i)) }),
|
|
1224
|
+
snap.status === "error" && snap.error && /* @__PURE__ */ jsxs19("div", { className: "mcpe-mcp-tool-call-result mcpe-mcp-tool-call-result-error", children: [
|
|
1225
|
+
/* @__PURE__ */ jsx33("p", { className: "text-sm", children: snap.error.message }),
|
|
1226
|
+
onRetry && /* @__PURE__ */ jsx33("div", { className: "mcpe-mcp-tool-call-footer mt-2", children: /* @__PURE__ */ jsx33(
|
|
1227
|
+
"button",
|
|
1228
|
+
{
|
|
1229
|
+
onClick: onRetry,
|
|
1230
|
+
className: "text-xs underline underline-offset-2 hover:no-underline",
|
|
1231
|
+
children: "Retry"
|
|
1232
|
+
}
|
|
1233
|
+
) })
|
|
1234
|
+
] })
|
|
1235
|
+
] });
|
|
1236
|
+
}
|
|
1237
|
+
|
|
1238
|
+
// src/mcp/mcp-tool-form.tsx
|
|
1239
|
+
import { useState as useState13 } from "react";
|
|
1240
|
+
import { cn as cn34, schemaToFields } from "@mcp-elements/core";
|
|
1241
|
+
import { jsx as jsx34, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
1242
|
+
function FieldInput({
|
|
1243
|
+
field,
|
|
1244
|
+
value,
|
|
1245
|
+
onChange
|
|
1246
|
+
}) {
|
|
1247
|
+
const str = typeof value === "string" ? value : value == null ? "" : String(value);
|
|
1248
|
+
switch (field.kind) {
|
|
1249
|
+
case "switch":
|
|
1250
|
+
return /* @__PURE__ */ jsx34(
|
|
1251
|
+
"input",
|
|
1252
|
+
{
|
|
1253
|
+
type: "checkbox",
|
|
1254
|
+
id: field.key,
|
|
1255
|
+
checked: Boolean(value),
|
|
1256
|
+
onChange: (e) => onChange(e.target.checked),
|
|
1257
|
+
className: "mcpe-switch",
|
|
1258
|
+
"aria-label": field.label
|
|
1259
|
+
}
|
|
1260
|
+
);
|
|
1261
|
+
case "select":
|
|
1262
|
+
return /* @__PURE__ */ jsxs20(
|
|
1263
|
+
"select",
|
|
1264
|
+
{
|
|
1265
|
+
id: field.key,
|
|
1266
|
+
value: str,
|
|
1267
|
+
onChange: (e) => onChange(e.target.value),
|
|
1268
|
+
className: "mcpe-select",
|
|
1269
|
+
required: field.required,
|
|
1270
|
+
children: [
|
|
1271
|
+
/* @__PURE__ */ jsx34("option", { value: "", children: "Select\u2026" }),
|
|
1272
|
+
field.options?.map((opt) => /* @__PURE__ */ jsx34("option", { value: opt.value, children: opt.label }, opt.value))
|
|
1273
|
+
]
|
|
1274
|
+
}
|
|
1275
|
+
);
|
|
1276
|
+
case "multiselect":
|
|
1277
|
+
return /* @__PURE__ */ jsx34(
|
|
1278
|
+
"select",
|
|
1279
|
+
{
|
|
1280
|
+
id: field.key,
|
|
1281
|
+
multiple: true,
|
|
1282
|
+
value: Array.isArray(value) ? value.map(String) : [],
|
|
1283
|
+
onChange: (e) => {
|
|
1284
|
+
const selected = Array.from(e.target.selectedOptions).map((o) => o.value);
|
|
1285
|
+
onChange(selected);
|
|
1286
|
+
},
|
|
1287
|
+
className: "mcpe-select",
|
|
1288
|
+
required: field.required,
|
|
1289
|
+
children: field.options?.map((opt) => /* @__PURE__ */ jsx34("option", { value: opt.value, children: opt.label }, opt.value))
|
|
1290
|
+
}
|
|
1291
|
+
);
|
|
1292
|
+
case "textarea":
|
|
1293
|
+
return /* @__PURE__ */ jsx34(
|
|
1294
|
+
"textarea",
|
|
1295
|
+
{
|
|
1296
|
+
id: field.key,
|
|
1297
|
+
value: str,
|
|
1298
|
+
onChange: (e) => onChange(e.target.value),
|
|
1299
|
+
className: "mcpe-textarea",
|
|
1300
|
+
required: field.required,
|
|
1301
|
+
minLength: field.minLength,
|
|
1302
|
+
maxLength: field.maxLength,
|
|
1303
|
+
rows: 4
|
|
1304
|
+
}
|
|
1305
|
+
);
|
|
1306
|
+
case "number":
|
|
1307
|
+
return /* @__PURE__ */ jsx34(
|
|
1308
|
+
"input",
|
|
1309
|
+
{
|
|
1310
|
+
type: "number",
|
|
1311
|
+
id: field.key,
|
|
1312
|
+
value: str,
|
|
1313
|
+
onChange: (e) => onChange(e.target.valueAsNumber),
|
|
1314
|
+
className: "mcpe-input",
|
|
1315
|
+
required: field.required,
|
|
1316
|
+
min: field.min,
|
|
1317
|
+
max: field.max
|
|
1318
|
+
}
|
|
1319
|
+
);
|
|
1320
|
+
case "unknown":
|
|
1321
|
+
return /* @__PURE__ */ jsx34(
|
|
1322
|
+
"input",
|
|
1323
|
+
{
|
|
1324
|
+
type: "text",
|
|
1325
|
+
id: field.key,
|
|
1326
|
+
value: str,
|
|
1327
|
+
onChange: (e) => onChange(e.target.value),
|
|
1328
|
+
className: "mcpe-input",
|
|
1329
|
+
disabled: true,
|
|
1330
|
+
placeholder: "(unsupported field type)"
|
|
1331
|
+
}
|
|
1332
|
+
);
|
|
1333
|
+
default:
|
|
1334
|
+
return /* @__PURE__ */ jsx34(
|
|
1335
|
+
"input",
|
|
1336
|
+
{
|
|
1337
|
+
type: field.kind === "email" ? "email" : field.kind === "url" ? "url" : field.kind === "date" ? "date" : "text",
|
|
1338
|
+
id: field.key,
|
|
1339
|
+
value: str,
|
|
1340
|
+
onChange: (e) => onChange(e.target.value),
|
|
1341
|
+
className: "mcpe-input",
|
|
1342
|
+
required: field.required,
|
|
1343
|
+
pattern: field.pattern,
|
|
1344
|
+
minLength: field.minLength,
|
|
1345
|
+
maxLength: field.maxLength
|
|
1346
|
+
}
|
|
1347
|
+
);
|
|
1348
|
+
}
|
|
1349
|
+
}
|
|
1350
|
+
function McpToolForm({
|
|
1351
|
+
schema,
|
|
1352
|
+
onSubmit,
|
|
1353
|
+
loading = false,
|
|
1354
|
+
submitLabel = "Run",
|
|
1355
|
+
className
|
|
1356
|
+
}) {
|
|
1357
|
+
const fields = schemaToFields(schema);
|
|
1358
|
+
const [values, setValues] = useState13(() => {
|
|
1359
|
+
const defaults = {};
|
|
1360
|
+
for (const f of fields) {
|
|
1361
|
+
if (f.defaultValue !== void 0) defaults[f.key] = f.defaultValue;
|
|
1362
|
+
}
|
|
1363
|
+
return defaults;
|
|
1364
|
+
});
|
|
1365
|
+
function setValue(key, value) {
|
|
1366
|
+
setValues((prev) => ({ ...prev, [key]: value }));
|
|
1367
|
+
}
|
|
1368
|
+
function handleSubmit(e) {
|
|
1369
|
+
e.preventDefault();
|
|
1370
|
+
onSubmit(values);
|
|
1371
|
+
}
|
|
1372
|
+
if (fields.length === 0) {
|
|
1373
|
+
return /* @__PURE__ */ jsxs20("form", { onSubmit: handleSubmit, className: cn34("mcpe-mcp-tool-form", className), children: [
|
|
1374
|
+
/* @__PURE__ */ jsx34("p", { className: "text-sm text-muted-foreground", children: "This tool takes no inputs." }),
|
|
1375
|
+
/* @__PURE__ */ jsx34("div", { className: "mcpe-mcp-tool-form-submit", children: /* @__PURE__ */ jsx34("button", { type: "submit", className: "mcpe-btn mcpe-btn-primary mcpe-btn-sm", disabled: loading, children: loading ? "Running\u2026" : submitLabel }) })
|
|
1376
|
+
] });
|
|
1377
|
+
}
|
|
1378
|
+
return /* @__PURE__ */ jsxs20("form", { onSubmit: handleSubmit, className: cn34("mcpe-mcp-tool-form", className), children: [
|
|
1379
|
+
fields.map((field) => /* @__PURE__ */ jsxs20("div", { className: "mcpe-mcp-tool-form-field", children: [
|
|
1380
|
+
/* @__PURE__ */ jsx34(
|
|
1381
|
+
"label",
|
|
1382
|
+
{
|
|
1383
|
+
htmlFor: field.key,
|
|
1384
|
+
className: cn34("mcpe-mcp-tool-form-label", field.required && "mcpe-mcp-tool-form-label-required"),
|
|
1385
|
+
children: field.label
|
|
1386
|
+
}
|
|
1387
|
+
),
|
|
1388
|
+
/* @__PURE__ */ jsx34(FieldInput, { field, value: values[field.key], onChange: (v) => setValue(field.key, v) }),
|
|
1389
|
+
field.help && /* @__PURE__ */ jsx34("p", { className: "mcpe-mcp-tool-form-help", children: field.help })
|
|
1390
|
+
] }, field.key)),
|
|
1391
|
+
/* @__PURE__ */ jsx34("div", { className: "mcpe-mcp-tool-form-submit", children: /* @__PURE__ */ jsx34("button", { type: "submit", className: "mcpe-btn mcpe-btn-primary mcpe-btn-sm", disabled: loading, children: loading ? "Running\u2026" : submitLabel }) })
|
|
1392
|
+
] });
|
|
1393
|
+
}
|
|
1394
|
+
|
|
1395
|
+
// src/mcp/mcp-consent-dialog.tsx
|
|
1396
|
+
import { cn as cn35, parseScopes } from "@mcp-elements/core";
|
|
1397
|
+
import { jsx as jsx35, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
1398
|
+
function McpConsentDialog({
|
|
1399
|
+
open,
|
|
1400
|
+
serverName,
|
|
1401
|
+
serverIcon,
|
|
1402
|
+
scopes,
|
|
1403
|
+
onApprove,
|
|
1404
|
+
onDeny,
|
|
1405
|
+
className
|
|
1406
|
+
}) {
|
|
1407
|
+
const parsed = parseScopes(scopes.join(" "));
|
|
1408
|
+
return /* @__PURE__ */ jsx35(Dialog, { open, onOpenChange: (o) => {
|
|
1409
|
+
if (!o) onDeny();
|
|
1410
|
+
}, children: /* @__PURE__ */ jsxs21("div", { className: cn35(className), children: [
|
|
1411
|
+
/* @__PURE__ */ jsxs21(DialogHeader, { children: [
|
|
1412
|
+
/* @__PURE__ */ jsx35(DialogTitle, { children: "Permission Request" }),
|
|
1413
|
+
/* @__PURE__ */ jsx35(DialogDescription, { children: "Review and approve the permissions this server is requesting." })
|
|
1414
|
+
] }),
|
|
1415
|
+
/* @__PURE__ */ jsxs21("div", { className: "mcpe-mcp-consent-dialog-server", children: [
|
|
1416
|
+
/* @__PURE__ */ jsx35("div", { className: "mcpe-mcp-consent-dialog-icon", "aria-hidden": "true", children: serverIcon ? /* @__PURE__ */ jsx35("img", { src: serverIcon, alt: "", className: "h-full w-full object-cover" }) : serverName[0]?.toUpperCase() ?? "?" }),
|
|
1417
|
+
/* @__PURE__ */ jsxs21("div", { children: [
|
|
1418
|
+
/* @__PURE__ */ jsx35("p", { className: "mcpe-mcp-consent-dialog-server-name", children: serverName }),
|
|
1419
|
+
/* @__PURE__ */ jsx35("p", { className: "mcpe-mcp-consent-dialog-server-meta", children: "is requesting access to" })
|
|
1420
|
+
] })
|
|
1421
|
+
] }),
|
|
1422
|
+
/* @__PURE__ */ jsx35(
|
|
1423
|
+
"div",
|
|
1424
|
+
{
|
|
1425
|
+
className: "mcpe-mcp-consent-dialog-scopes",
|
|
1426
|
+
role: "list",
|
|
1427
|
+
"aria-label": "Requested permissions",
|
|
1428
|
+
children: parsed.map((s) => /* @__PURE__ */ jsx35("div", { className: "mcpe-mcp-consent-dialog-scope-item", role: "listitem", children: /* @__PURE__ */ jsxs21("div", { className: "flex-1 min-w-0", children: [
|
|
1429
|
+
/* @__PURE__ */ jsx35("p", { className: "mcpe-mcp-consent-dialog-scope-resource", children: s.resource }),
|
|
1430
|
+
/* @__PURE__ */ jsx35("div", { className: "mcpe-mcp-consent-dialog-scope-perms", children: s.permissions.map((p) => /* @__PURE__ */ jsx35("span", { className: "mcpe-mcp-consent-dialog-scope-perm", children: p }, p)) })
|
|
1431
|
+
] }) }, s.raw))
|
|
1432
|
+
}
|
|
1433
|
+
),
|
|
1434
|
+
/* @__PURE__ */ jsx35(DialogFooter, { children: /* @__PURE__ */ jsxs21("div", { className: "mcpe-mcp-consent-dialog-actions", children: [
|
|
1435
|
+
/* @__PURE__ */ jsx35(Button, { variant: "outline", onClick: onDeny, className: "flex-1", children: "Deny" }),
|
|
1436
|
+
/* @__PURE__ */ jsx35(Button, { variant: "primary", onClick: onApprove, className: "flex-1", children: "Allow" })
|
|
1437
|
+
] }) })
|
|
1438
|
+
] }) });
|
|
1439
|
+
}
|
|
1440
|
+
|
|
1441
|
+
// src/mcp/mcp-scope-inspector.tsx
|
|
1442
|
+
import { useState as useState14 } from "react";
|
|
1443
|
+
import { cn as cn36, parseScopes as parseScopes2 } from "@mcp-elements/core";
|
|
1444
|
+
import { jsx as jsx36, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
1445
|
+
function ChevronIcon({ className }) {
|
|
1446
|
+
return /* @__PURE__ */ jsx36(
|
|
1447
|
+
"svg",
|
|
1448
|
+
{
|
|
1449
|
+
className: cn36("mcpe-mcp-scope-inspector-chevron", className),
|
|
1450
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1451
|
+
viewBox: "0 0 24 24",
|
|
1452
|
+
fill: "none",
|
|
1453
|
+
stroke: "currentColor",
|
|
1454
|
+
strokeWidth: "2",
|
|
1455
|
+
strokeLinecap: "round",
|
|
1456
|
+
strokeLinejoin: "round",
|
|
1457
|
+
"aria-hidden": "true",
|
|
1458
|
+
children: /* @__PURE__ */ jsx36("path", { d: "m6 9 6 6 6-6" })
|
|
1459
|
+
}
|
|
1460
|
+
);
|
|
1461
|
+
}
|
|
1462
|
+
function McpScopeInspector({ scopes, descriptions = {}, className }) {
|
|
1463
|
+
const parsed = typeof scopes === "string" ? parseScopes2(scopes) : scopes;
|
|
1464
|
+
const [openKeys, setOpenKeys] = useState14(/* @__PURE__ */ new Set());
|
|
1465
|
+
function toggle(key) {
|
|
1466
|
+
setOpenKeys((prev) => {
|
|
1467
|
+
const next = new Set(prev);
|
|
1468
|
+
if (next.has(key)) next.delete(key);
|
|
1469
|
+
else next.add(key);
|
|
1470
|
+
return next;
|
|
1471
|
+
});
|
|
1472
|
+
}
|
|
1473
|
+
return /* @__PURE__ */ jsx36("div", { className: cn36("mcpe-mcp-scope-inspector", className), role: "list", children: parsed.map((s) => {
|
|
1474
|
+
const rawKey = s.raw;
|
|
1475
|
+
const isOpen = openKeys.has(rawKey);
|
|
1476
|
+
const description = descriptions[rawKey] ?? descriptions[s.resource] ?? s.description;
|
|
1477
|
+
const safeKey = rawKey.replace(/[^a-zA-Z0-9]/g, "-");
|
|
1478
|
+
const triggerId = `scope-trigger-${safeKey}`;
|
|
1479
|
+
const bodyId = `scope-body-${safeKey}`;
|
|
1480
|
+
return /* @__PURE__ */ jsxs22("div", { className: "mcpe-mcp-scope-inspector-item", role: "listitem", children: [
|
|
1481
|
+
/* @__PURE__ */ jsxs22(
|
|
1482
|
+
"button",
|
|
1483
|
+
{
|
|
1484
|
+
id: triggerId,
|
|
1485
|
+
className: "mcpe-mcp-scope-inspector-trigger",
|
|
1486
|
+
"aria-expanded": isOpen,
|
|
1487
|
+
"aria-controls": bodyId,
|
|
1488
|
+
onClick: () => toggle(rawKey),
|
|
1489
|
+
type: "button",
|
|
1490
|
+
children: [
|
|
1491
|
+
/* @__PURE__ */ jsxs22("div", { className: "flex items-center gap-3", children: [
|
|
1492
|
+
/* @__PURE__ */ jsx36("span", { className: "mcpe-mcp-scope-inspector-resource", children: s.resource }),
|
|
1493
|
+
/* @__PURE__ */ jsx36("div", { className: "mcpe-mcp-scope-inspector-perms", children: s.permissions.map((p) => /* @__PURE__ */ jsx36("span", { className: "mcpe-mcp-scope-inspector-perm", children: p }, p)) })
|
|
1494
|
+
] }),
|
|
1495
|
+
/* @__PURE__ */ jsx36(ChevronIcon, { className: isOpen ? "mcpe-mcp-scope-inspector-chevron-open" : void 0 })
|
|
1496
|
+
]
|
|
1497
|
+
}
|
|
1498
|
+
),
|
|
1499
|
+
isOpen && description && /* @__PURE__ */ jsx36(
|
|
1500
|
+
"div",
|
|
1501
|
+
{
|
|
1502
|
+
id: bodyId,
|
|
1503
|
+
role: "region",
|
|
1504
|
+
"aria-labelledby": triggerId,
|
|
1505
|
+
className: "mcpe-mcp-scope-inspector-body",
|
|
1506
|
+
children: description
|
|
1507
|
+
}
|
|
1508
|
+
)
|
|
1509
|
+
] }, rawKey);
|
|
1510
|
+
}) });
|
|
1511
|
+
}
|
|
1512
|
+
|
|
1513
|
+
// src/mcp/mcp-resource-browser.tsx
|
|
1514
|
+
import { cn as cn37 } from "@mcp-elements/core";
|
|
1515
|
+
import { jsx as jsx37, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
1516
|
+
function mimeTypeLabel(mimeType) {
|
|
1517
|
+
if (!mimeType) return "res";
|
|
1518
|
+
if (mimeType.includes("json")) return "json";
|
|
1519
|
+
if (mimeType.includes("text")) return "txt";
|
|
1520
|
+
if (mimeType.includes("image")) return "img";
|
|
1521
|
+
if (mimeType.includes("pdf")) return "pdf";
|
|
1522
|
+
return mimeType.split("/")[1]?.slice(0, 4) ?? "res";
|
|
1523
|
+
}
|
|
1524
|
+
function McpResourceBrowser({
|
|
1525
|
+
resources,
|
|
1526
|
+
selectedUri,
|
|
1527
|
+
onSelect,
|
|
1528
|
+
loading = false,
|
|
1529
|
+
className
|
|
1530
|
+
}) {
|
|
1531
|
+
if (loading) {
|
|
1532
|
+
return /* @__PURE__ */ jsx37("div", { className: cn37("mcpe-mcp-resource-browser", className), children: Array.from({ length: 4 }).map((_, i) => /* @__PURE__ */ jsxs23("div", { className: "flex items-center gap-3 px-3 py-2.5", children: [
|
|
1533
|
+
/* @__PURE__ */ jsx37(Skeleton, { className: "h-8 w-8 rounded-md" }),
|
|
1534
|
+
/* @__PURE__ */ jsx37(Skeleton, { className: "h-4 flex-1" }),
|
|
1535
|
+
/* @__PURE__ */ jsx37(Skeleton, { className: "h-3 w-10" })
|
|
1536
|
+
] }, i)) });
|
|
1537
|
+
}
|
|
1538
|
+
if (resources.length === 0) {
|
|
1539
|
+
return /* @__PURE__ */ jsx37("div", { className: cn37("mcpe-mcp-resource-browser", className), children: /* @__PURE__ */ jsx37("p", { className: "mcpe-mcp-resource-browser-empty", children: "No resources available" }) });
|
|
1540
|
+
}
|
|
1541
|
+
return /* @__PURE__ */ jsx37("div", { className: cn37("mcpe-mcp-resource-browser", className), role: "list", children: resources.map((r) => /* @__PURE__ */ jsxs23(
|
|
1542
|
+
"button",
|
|
1543
|
+
{
|
|
1544
|
+
type: "button",
|
|
1545
|
+
role: "listitem",
|
|
1546
|
+
className: cn37(
|
|
1547
|
+
"mcpe-mcp-resource-browser-item w-full text-left",
|
|
1548
|
+
selectedUri === r.uri && "mcpe-mcp-resource-browser-item-selected"
|
|
1549
|
+
),
|
|
1550
|
+
onClick: () => onSelect?.(r),
|
|
1551
|
+
"aria-selected": selectedUri === r.uri,
|
|
1552
|
+
"aria-label": r.name,
|
|
1553
|
+
children: [
|
|
1554
|
+
/* @__PURE__ */ jsx37("span", { className: "mcpe-mcp-resource-browser-icon", "aria-hidden": "true", children: mimeTypeLabel(r.mimeType) }),
|
|
1555
|
+
/* @__PURE__ */ jsx37("span", { className: "mcpe-mcp-resource-browser-name", children: r.name }),
|
|
1556
|
+
r.mimeType && /* @__PURE__ */ jsx37("span", { className: "mcpe-mcp-resource-browser-type", children: r.mimeType.split("/")[0] })
|
|
1557
|
+
]
|
|
1558
|
+
},
|
|
1559
|
+
r.uri
|
|
1560
|
+
)) });
|
|
1561
|
+
}
|
|
1562
|
+
|
|
1563
|
+
// src/mcp/mcp-app-frame.tsx
|
|
1564
|
+
import { useEffect as useEffect10, useRef as useRef7, useCallback as useCallback4 } from "react";
|
|
1565
|
+
import { cn as cn38, createAppBridge } from "@mcp-elements/core";
|
|
1566
|
+
import { jsx as jsx38 } from "react/jsx-runtime";
|
|
1567
|
+
function McpAppFrame({
|
|
1568
|
+
src,
|
|
1569
|
+
onMessage,
|
|
1570
|
+
height = 480,
|
|
1571
|
+
sandbox = "allow-scripts allow-same-origin",
|
|
1572
|
+
className
|
|
1573
|
+
}) {
|
|
1574
|
+
const frameRef = useRef7(null);
|
|
1575
|
+
const postToFrame = useCallback4((msg) => {
|
|
1576
|
+
frameRef.current?.contentWindow?.postMessage(msg, "*");
|
|
1577
|
+
}, []);
|
|
1578
|
+
useEffect10(() => {
|
|
1579
|
+
if (!onMessage) return;
|
|
1580
|
+
const bridge = createAppBridge({ postMessage: postToFrame });
|
|
1581
|
+
const unsub = bridge.onMessage(onMessage);
|
|
1582
|
+
const handler = (e) => {
|
|
1583
|
+
bridge.receive(e.data);
|
|
1584
|
+
};
|
|
1585
|
+
window.addEventListener("message", handler);
|
|
1586
|
+
return () => {
|
|
1587
|
+
window.removeEventListener("message", handler);
|
|
1588
|
+
unsub();
|
|
1589
|
+
};
|
|
1590
|
+
}, [onMessage, postToFrame]);
|
|
1591
|
+
return /* @__PURE__ */ jsx38("div", { className: cn38("mcpe-mcp-app-frame", className), children: /* @__PURE__ */ jsx38(
|
|
1592
|
+
"iframe",
|
|
1593
|
+
{
|
|
1594
|
+
ref: frameRef,
|
|
1595
|
+
src,
|
|
1596
|
+
sandbox,
|
|
1597
|
+
style: { height },
|
|
1598
|
+
title: "MCP App",
|
|
1599
|
+
"aria-label": "MCP App frame"
|
|
1600
|
+
}
|
|
1601
|
+
) });
|
|
1602
|
+
}
|
|
1603
|
+
|
|
1604
|
+
// src/hooks/use-mcp-tool-state.ts
|
|
1605
|
+
import { useEffect as useEffect11, useState as useState15 } from "react";
|
|
1606
|
+
import { createToolState } from "@mcp-elements/core";
|
|
1607
|
+
function useMcpToolState() {
|
|
1608
|
+
const [api] = useState15(() => createToolState());
|
|
1609
|
+
const [snap, setSnap] = useState15({
|
|
1610
|
+
status: api.status,
|
|
1611
|
+
tool: api.tool,
|
|
1612
|
+
args: api.args,
|
|
1613
|
+
result: api.result,
|
|
1614
|
+
error: api.error,
|
|
1615
|
+
startedAt: api.startedAt,
|
|
1616
|
+
endedAt: api.endedAt
|
|
1617
|
+
});
|
|
1618
|
+
useEffect11(() => {
|
|
1619
|
+
return api.subscribe((s) => setSnap({ ...s }));
|
|
1620
|
+
}, [api]);
|
|
1621
|
+
return { ...snap, ...api };
|
|
1622
|
+
}
|
|
1623
|
+
|
|
1624
|
+
// src/hooks/use-mcp-oauth.ts
|
|
1625
|
+
import { useEffect as useEffect12, useState as useState16 } from "react";
|
|
1626
|
+
import { createOAuthFlow } from "@mcp-elements/core";
|
|
1627
|
+
function useMcpOAuth() {
|
|
1628
|
+
const [api] = useState16(() => createOAuthFlow());
|
|
1629
|
+
const [snap, setSnap] = useState16({
|
|
1630
|
+
status: api.status,
|
|
1631
|
+
verifier: api.verifier,
|
|
1632
|
+
state: api.state,
|
|
1633
|
+
tokens: api.tokens,
|
|
1634
|
+
error: api.error
|
|
1635
|
+
});
|
|
1636
|
+
useEffect12(() => {
|
|
1637
|
+
return api.subscribe((s) => setSnap({ ...s }));
|
|
1638
|
+
}, [api]);
|
|
1639
|
+
return { ...snap, ...api };
|
|
1640
|
+
}
|
|
1641
|
+
|
|
1642
|
+
// src/hooks/use-mcp-app-bridge.ts
|
|
1643
|
+
import { useCallback as useCallback5, useEffect as useEffect13, useRef as useRef8 } from "react";
|
|
1644
|
+
import { createAppBridge as createAppBridge2 } from "@mcp-elements/core";
|
|
1645
|
+
function useMcpAppBridge(options = {}) {
|
|
1646
|
+
const { onMessage } = options;
|
|
1647
|
+
const frameRef = useRef8(null);
|
|
1648
|
+
const onMessageRef = useRef8(onMessage);
|
|
1649
|
+
useEffect13(() => {
|
|
1650
|
+
onMessageRef.current = onMessage;
|
|
1651
|
+
});
|
|
1652
|
+
const postToFrame = useCallback5((env) => {
|
|
1653
|
+
frameRef.current?.contentWindow?.postMessage(env, "*");
|
|
1654
|
+
}, []);
|
|
1655
|
+
const sendRef = useRef8(() => {
|
|
1656
|
+
});
|
|
1657
|
+
useEffect13(() => {
|
|
1658
|
+
const bridge = createAppBridge2({ postMessage: postToFrame });
|
|
1659
|
+
sendRef.current = (env) => bridge.send(env);
|
|
1660
|
+
const handler = (e) => bridge.receive(e.data);
|
|
1661
|
+
window.addEventListener("message", handler);
|
|
1662
|
+
const unsub = bridge.onMessage((env) => onMessageRef.current?.(env));
|
|
1663
|
+
return () => {
|
|
1664
|
+
window.removeEventListener("message", handler);
|
|
1665
|
+
unsub();
|
|
1666
|
+
};
|
|
1667
|
+
}, [postToFrame]);
|
|
1668
|
+
const send = useCallback5((env) => {
|
|
1669
|
+
sendRef.current(env);
|
|
1670
|
+
}, []);
|
|
1671
|
+
return { send, frameRef };
|
|
1672
|
+
}
|
|
1673
|
+
|
|
1674
|
+
// src/hooks/use-mcp-schema-form.ts
|
|
1675
|
+
import { useCallback as useCallback6, useMemo as useMemo9, useState as useState17 } from "react";
|
|
1676
|
+
import { schemaToFields as schemaToFields2 } from "@mcp-elements/core";
|
|
1677
|
+
function buildDefaults(fs) {
|
|
1678
|
+
const defaults = {};
|
|
1679
|
+
for (const f of fs) {
|
|
1680
|
+
if (f.defaultValue !== void 0) defaults[f.key] = f.defaultValue;
|
|
1681
|
+
}
|
|
1682
|
+
return defaults;
|
|
1683
|
+
}
|
|
1684
|
+
function useMcpSchemaForm(schema) {
|
|
1685
|
+
const fields = useMemo9(() => schemaToFields2(schema), [schema]);
|
|
1686
|
+
const [values, setValues] = useState17(() => buildDefaults(fields));
|
|
1687
|
+
const setValue = useCallback6((key, value) => {
|
|
1688
|
+
setValues((prev) => ({ ...prev, [key]: value }));
|
|
1689
|
+
}, []);
|
|
1690
|
+
const reset = useCallback6(() => {
|
|
1691
|
+
setValues(buildDefaults(fields));
|
|
1692
|
+
}, [fields]);
|
|
1693
|
+
return { fields, values, setValue, reset };
|
|
1694
|
+
}
|
|
1695
|
+
export {
|
|
1696
|
+
Accordion,
|
|
1697
|
+
AccordionContent,
|
|
1698
|
+
AccordionItem,
|
|
1699
|
+
AccordionTrigger,
|
|
1700
|
+
AiBadge,
|
|
1701
|
+
Alert,
|
|
1702
|
+
AlertDescription,
|
|
1703
|
+
AlertTitle,
|
|
1704
|
+
Avatar,
|
|
1705
|
+
Badge,
|
|
1706
|
+
Button,
|
|
1707
|
+
Card,
|
|
1708
|
+
CardContent,
|
|
1709
|
+
CardDescription,
|
|
1710
|
+
CardFooter,
|
|
1711
|
+
CardHeader,
|
|
1712
|
+
CardTitle,
|
|
1713
|
+
ChatBubble,
|
|
1714
|
+
ChatBubbleAvatar,
|
|
1715
|
+
ChatBubbleContent,
|
|
1716
|
+
ChatBubbleTimestamp,
|
|
1717
|
+
ChatBubbleTyping,
|
|
1718
|
+
Chip,
|
|
1719
|
+
Chips,
|
|
1720
|
+
Counter,
|
|
1721
|
+
Dialog,
|
|
1722
|
+
DialogDescription,
|
|
1723
|
+
DialogFooter,
|
|
1724
|
+
DialogHeader,
|
|
1725
|
+
DialogTitle,
|
|
1726
|
+
Drawer,
|
|
1727
|
+
DrawerBody,
|
|
1728
|
+
DrawerDescription,
|
|
1729
|
+
DrawerFooter,
|
|
1730
|
+
DrawerHeader,
|
|
1731
|
+
DrawerTitle,
|
|
1732
|
+
DropdownMenu,
|
|
1733
|
+
Feedback,
|
|
1734
|
+
FeedbackButton,
|
|
1735
|
+
FeedbackForm,
|
|
1736
|
+
FeedbackInput,
|
|
1737
|
+
FeedbackSeparator,
|
|
1738
|
+
FeedbackSubmit,
|
|
1739
|
+
Input,
|
|
1740
|
+
Loader,
|
|
1741
|
+
McpAppFrame,
|
|
1742
|
+
McpConsentDialog,
|
|
1743
|
+
McpResourceBrowser,
|
|
1744
|
+
McpScopeInspector,
|
|
1745
|
+
McpServerStatus,
|
|
1746
|
+
McpToolCall,
|
|
1747
|
+
McpToolForm,
|
|
1748
|
+
PasswordInput,
|
|
1749
|
+
Popover,
|
|
1750
|
+
Progress,
|
|
1751
|
+
PromptInput,
|
|
1752
|
+
PromptInputActions,
|
|
1753
|
+
PromptInputAttachment,
|
|
1754
|
+
PromptInputAttachments,
|
|
1755
|
+
PromptInputCharCount,
|
|
1756
|
+
PromptInputFooter,
|
|
1757
|
+
PromptInputTextarea,
|
|
1758
|
+
Select,
|
|
1759
|
+
Separator,
|
|
1760
|
+
Skeleton,
|
|
1761
|
+
SourceCard,
|
|
1762
|
+
SourceCards,
|
|
1763
|
+
StreamingText,
|
|
1764
|
+
StreamingTextFadeIn,
|
|
1765
|
+
StreamingTextLine,
|
|
1766
|
+
StreamingTextSkeleton,
|
|
1767
|
+
StreamingTextSkeletonLine,
|
|
1768
|
+
StreamingTextWord,
|
|
1769
|
+
SuggestionChip,
|
|
1770
|
+
SuggestionChips,
|
|
1771
|
+
Switch,
|
|
1772
|
+
Tabs,
|
|
1773
|
+
TabsContent,
|
|
1774
|
+
TabsList,
|
|
1775
|
+
TabsTrigger,
|
|
1776
|
+
Textarea,
|
|
1777
|
+
Toaster,
|
|
1778
|
+
Tooltip,
|
|
1779
|
+
useAccordion,
|
|
1780
|
+
useDialog,
|
|
1781
|
+
useDrawer,
|
|
1782
|
+
useDropdownMenu,
|
|
1783
|
+
useMcpAppBridge,
|
|
1784
|
+
useMcpOAuth,
|
|
1785
|
+
useMcpSchemaForm,
|
|
1786
|
+
useMcpToolState,
|
|
1787
|
+
usePopover,
|
|
1788
|
+
useSelect,
|
|
1789
|
+
useTabs,
|
|
1790
|
+
useToast,
|
|
1791
|
+
useTooltip
|
|
1792
|
+
};
|
|
1793
|
+
//# sourceMappingURL=index.js.map
|