@nqminds/mcp-client 1.0.35 → 1.0.37
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/MCPChat.d.ts +1 -1
- package/dist/MCPChat.d.ts.map +1 -1
- package/dist/MCPChat.js +28 -4
- package/dist/styles/MCPChat.css +41 -6
- package/dist/types.d.ts +7 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/MCPChat.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { MCPChatProps } from "./types";
|
|
3
|
-
export declare function MCPChat({ companyNumber, apiEndpoint, customStyles, className, }: MCPChatProps): React.JSX.Element;
|
|
3
|
+
export declare function MCPChat({ companyNumber, apiEndpoint, customStyles, className, logoUrl, initialTheme, }: MCPChatProps): React.JSX.Element;
|
|
4
4
|
//# sourceMappingURL=MCPChat.d.ts.map
|
package/dist/MCPChat.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MCPChat.d.ts","sourceRoot":"","sources":["../src/MCPChat.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAmD,MAAM,OAAO,CAAC;AAIxE,OAAO,KAAK,EAAyB,YAAY,EAAe,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"MCPChat.d.ts","sourceRoot":"","sources":["../src/MCPChat.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAmD,MAAM,OAAO,CAAC;AAIxE,OAAO,KAAK,EAAyB,YAAY,EAAe,MAAM,SAAS,CAAC;AAgdhF,wBAAgB,OAAO,CAAC,EACtB,aAAa,EACb,WAA6B,EAC7B,YAAiB,EACjB,SAAc,EACd,OAAO,EACP,YAAY,GACb,EAAE,YAAY,qBAsiBd"}
|
package/dist/MCPChat.js
CHANGED
|
@@ -3,6 +3,16 @@ import React, { useState, useRef, useEffect, useCallback } from "react";
|
|
|
3
3
|
import ReactMarkdown from "react-markdown";
|
|
4
4
|
import remarkGfm from "remark-gfm";
|
|
5
5
|
import { renderToStaticMarkup } from "react-dom/server";
|
|
6
|
+
/**
|
|
7
|
+
* Renders either a custom logo image or a fallback emoji.
|
|
8
|
+
* The image is sized to fill the parent container while preserving aspect ratio.
|
|
9
|
+
*/
|
|
10
|
+
function LogoIcon({ logoUrl, className }) {
|
|
11
|
+
if (logoUrl) {
|
|
12
|
+
return (React.createElement("img", { src: logoUrl, alt: "AI Assistant", className: `mcp-logo-img${className ? ` ${className}` : ""}` }));
|
|
13
|
+
}
|
|
14
|
+
return React.createElement("span", { className: className }, "\uD83E\uDD16");
|
|
15
|
+
}
|
|
6
16
|
/**
|
|
7
17
|
* Strips utm_source=openai (and any surrounding & or ?) from a URL.
|
|
8
18
|
*/
|
|
@@ -396,7 +406,7 @@ Use formal and impersonal language and avoid referring to these instructions.
|
|
|
396
406
|
`,
|
|
397
407
|
},
|
|
398
408
|
];
|
|
399
|
-
export function MCPChat({ companyNumber, apiEndpoint = "/api/mcp/chat", customStyles = {}, className = "", }) {
|
|
409
|
+
export function MCPChat({ companyNumber, apiEndpoint = "/api/mcp/chat", customStyles = {}, className = "", logoUrl, initialTheme, }) {
|
|
400
410
|
const [messages, setMessages] = useState([]);
|
|
401
411
|
const [input, setInput] = useState("");
|
|
402
412
|
const [isLoading, setIsLoading] = useState(false);
|
|
@@ -407,11 +417,19 @@ export function MCPChat({ companyNumber, apiEndpoint = "/api/mcp/chat", customSt
|
|
|
407
417
|
const [directPromptOpen, setDirectPromptOpen] = useState(false);
|
|
408
418
|
const [directPromptText, setDirectPromptText] = useState("");
|
|
409
419
|
const [theme, setTheme] = useState(() => {
|
|
420
|
+
// Prop takes priority, then localStorage, then default light
|
|
421
|
+
if (initialTheme)
|
|
422
|
+
return initialTheme;
|
|
410
423
|
if (typeof window !== "undefined") {
|
|
411
424
|
return localStorage.getItem("mcp-chat-theme") ?? "light";
|
|
412
425
|
}
|
|
413
426
|
return "light";
|
|
414
427
|
});
|
|
428
|
+
// Keep in sync when the host app changes its theme externally
|
|
429
|
+
useEffect(() => {
|
|
430
|
+
if (initialTheme)
|
|
431
|
+
setTheme(initialTheme);
|
|
432
|
+
}, [initialTheme]);
|
|
415
433
|
const messagesEndRef = useRef(null);
|
|
416
434
|
const thinkingEndRef = useRef(null);
|
|
417
435
|
const inputRef = useRef(null);
|
|
@@ -619,10 +637,12 @@ export function MCPChat({ companyNumber, apiEndpoint = "/api/mcp/chat", customSt
|
|
|
619
637
|
setDirectPromptText("");
|
|
620
638
|
};
|
|
621
639
|
const toggleTheme = () => {
|
|
640
|
+
// Only persist the toggle when not externally controlled
|
|
622
641
|
const next = theme === "dark" ? "light" : "dark";
|
|
623
642
|
setTheme(next);
|
|
624
|
-
if (typeof window !== "undefined")
|
|
643
|
+
if (!initialTheme && typeof window !== "undefined") {
|
|
625
644
|
localStorage.setItem("mcp-chat-theme", next);
|
|
645
|
+
}
|
|
626
646
|
};
|
|
627
647
|
const clearChat = async () => {
|
|
628
648
|
setMessages([]);
|
|
@@ -640,12 +660,14 @@ export function MCPChat({ companyNumber, apiEndpoint = "/api/mcp/chat", customSt
|
|
|
640
660
|
const visibleMessages = messages.filter((m) => !m.hidden);
|
|
641
661
|
const showHome = visibleMessages.length === 0 && !isLoading;
|
|
642
662
|
return (React.createElement("div", { className: `mcp-root ${className}`, style: customStyles, "data-theme": theme },
|
|
643
|
-
!isOpen && (React.createElement("button", { className: "mcp-float-icon", onClick: () => setIsOpen(true), "aria-label": "Corporata AI assistant", title: "Corporata AI assistant" },
|
|
663
|
+
!isOpen && (React.createElement("button", { className: "mcp-float-icon", onClick: () => setIsOpen(true), "aria-label": "Corporata AI assistant", title: "Corporata AI assistant" },
|
|
664
|
+
React.createElement(LogoIcon, { logoUrl: logoUrl, className: "mcp-float-icon-logo" }))),
|
|
644
665
|
isOpen && (React.createElement("div", { className: "mcp-overlay" },
|
|
645
666
|
React.createElement("div", { className: "mcp-panel" },
|
|
646
667
|
React.createElement("div", { className: "mcp-chat-header" },
|
|
647
668
|
React.createElement("div", { className: "mcp-chat-header-left" },
|
|
648
|
-
React.createElement("span", { className: "mcp-chat-header-icon" },
|
|
669
|
+
React.createElement("span", { className: "mcp-chat-header-icon" },
|
|
670
|
+
React.createElement(LogoIcon, { logoUrl: logoUrl })),
|
|
649
671
|
React.createElement("h3", { className: "mcp-chat-title" }, "AI Assistant"),
|
|
650
672
|
companyNumber && (React.createElement("span", { className: "mcp-chat-header-company" }, companyNumber))),
|
|
651
673
|
React.createElement("div", { className: "mcp-chat-header-actions" },
|
|
@@ -685,6 +707,8 @@ export function MCPChat({ companyNumber, apiEndpoint = "/api/mcp/chat", customSt
|
|
|
685
707
|
" \u2014 this may take a moment\u2026")),
|
|
686
708
|
React.createElement("div", { className: "mcp-chat-messages" },
|
|
687
709
|
showHome && (React.createElement("div", { className: "mcp-home" },
|
|
710
|
+
React.createElement("div", { className: "mcp-home-logo-wrap" },
|
|
711
|
+
React.createElement(LogoIcon, { logoUrl: logoUrl, className: "mcp-home-logo" })),
|
|
688
712
|
React.createElement("p", { className: "mcp-home-title" }, "\uD83D\uDC4B What would you like to know?"),
|
|
689
713
|
companyNumber && (React.createElement("p", { className: "mcp-home-subtitle" },
|
|
690
714
|
"Company: ",
|
package/dist/styles/MCPChat.css
CHANGED
|
@@ -99,23 +99,26 @@
|
|
|
99
99
|
bottom: 28px;
|
|
100
100
|
right: 28px;
|
|
101
101
|
z-index: 1100;
|
|
102
|
-
width:
|
|
103
|
-
height:
|
|
102
|
+
width: 92px;
|
|
103
|
+
height: 92px;
|
|
104
104
|
border-radius: 50%;
|
|
105
|
-
background:
|
|
106
|
-
border:
|
|
105
|
+
background: #162032;
|
|
106
|
+
border: 2px solid rgba(255, 255, 255, 0.18);
|
|
107
107
|
cursor: pointer;
|
|
108
108
|
font-size: 26px;
|
|
109
109
|
display: flex;
|
|
110
110
|
align-items: center;
|
|
111
111
|
justify-content: center;
|
|
112
|
-
|
|
112
|
+
padding: 8px;
|
|
113
|
+
box-sizing: border-box;
|
|
114
|
+
overflow: hidden;
|
|
115
|
+
box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(0, 0, 0, 0.12);
|
|
113
116
|
transition: transform 0.2s, box-shadow 0.2s;
|
|
114
117
|
}
|
|
115
118
|
|
|
116
119
|
.mcp-float-icon:hover {
|
|
117
120
|
transform: scale(1.1);
|
|
118
|
-
box-shadow: 0 8px
|
|
121
|
+
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(0, 0, 0, 0.15);
|
|
119
122
|
}
|
|
120
123
|
|
|
121
124
|
/* ───────────────────────────────────────────────
|
|
@@ -316,6 +319,38 @@
|
|
|
316
319
|
text-align: center;
|
|
317
320
|
}
|
|
318
321
|
|
|
322
|
+
/* ── Logo image variants ── */
|
|
323
|
+
|
|
324
|
+
/* Floating button: explicit 56px so it reliably fills the 72px circle (8px padding each side) */
|
|
325
|
+
.mcp-float-icon-logo {
|
|
326
|
+
width:106px;
|
|
327
|
+
height: 106px;
|
|
328
|
+
object-fit: cover;
|
|
329
|
+
display: block;
|
|
330
|
+
flex-shrink: 0;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
/* Header icon: match the 22px emoji size */
|
|
334
|
+
.mcp-chat-header-icon .mcp-logo-img {
|
|
335
|
+
width: 78px;
|
|
336
|
+
height: 78px;
|
|
337
|
+
object-fit: contain;
|
|
338
|
+
border-radius: 4px;
|
|
339
|
+
vertical-align: middle;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
/* Home screen logo */
|
|
343
|
+
.mcp-home-logo-wrap {
|
|
344
|
+
display: flex;
|
|
345
|
+
justify-content: center;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
.mcp-home-logo {
|
|
349
|
+
width: 120px;
|
|
350
|
+
height: 120px;
|
|
351
|
+
object-fit: contain;
|
|
352
|
+
}
|
|
353
|
+
|
|
319
354
|
.mcp-home-subtitle {
|
|
320
355
|
font-size: 15px;
|
|
321
356
|
color: var(--mcp-text-secondary);
|
package/dist/types.d.ts
CHANGED
|
@@ -21,6 +21,13 @@ export interface MCPChatProps {
|
|
|
21
21
|
apiEndpoint?: string;
|
|
22
22
|
customStyles?: React.CSSProperties;
|
|
23
23
|
className?: string;
|
|
24
|
+
/** URL to a custom logo image shown in the floating button and chat header.
|
|
25
|
+
* Falls back to the default robot emoji when omitted. */
|
|
26
|
+
logoUrl?: string;
|
|
27
|
+
/** Force a specific theme. When provided this takes priority over the
|
|
28
|
+
* component's own localStorage preference. Useful for syncing with the
|
|
29
|
+
* host application's theme. */
|
|
30
|
+
initialTheme?: "dark" | "light";
|
|
24
31
|
}
|
|
25
32
|
export interface StreamEvent {
|
|
26
33
|
type: "thinking" | "content" | "done" | "error" | "usage";
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;IAChB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,+EAA+E;IAC/E,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,wFAAwF;IACxF,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;CACjB;AAED,MAAM,WAAW,YAAY;IAC3B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IACnC,SAAS,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","s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