mcp-chat-ui 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -19,13 +19,51 @@ npm install mcp-chat-ui
19
19
 
20
20
  ## Quick Start
21
21
 
22
+ ### For React Projects
23
+
22
24
  Import CSS in App.tsx
23
25
 
24
26
  ```App.tsx
25
27
  import "mcp-chat-ui/styles.css";
28
+ ```
29
+
30
+ ### For Angular Projects
31
+
32
+ **Option 1: Import in global styles.css (Recommended)**
33
+
34
+ Open your `src/styles.css` file and add this import at the top:
26
35
 
36
+ ```css
37
+ @import "mcp-chat-ui/dist/styles.css";
27
38
  ```
28
39
 
40
+ **Option 2: Add to angular.json**
41
+
42
+ If Option 1 doesn't work, add the CSS file to your `angular.json` configuration:
43
+
44
+ ```json
45
+ {
46
+ "projects": {
47
+ "your-app-name": {
48
+ "architect": {
49
+ "build": {
50
+ "options": {
51
+ "styles": [
52
+ "src/styles.css",
53
+ "node_modules/mcp-chat-ui/dist/styles.css"
54
+ ]
55
+ }
56
+ }
57
+ }
58
+ }
59
+ }
60
+ }
61
+ ```
62
+
63
+ **Important:** Do **not** import the CSS in TypeScript/component files for Angular projects. After making changes, restart your Angular dev server (`ng serve`).
64
+
65
+ ### Initialize the SDK
66
+
29
67
  Initialize the SDK (required):
30
68
 
31
69
  ```ts
package/dist/ChatUI.js CHANGED
@@ -576,6 +576,8 @@ function ChatUI(props) {
576
576
  (0, react_1.useEffect)(() => {
577
577
  if (!apiBase || !apiKey || !sessionId)
578
578
  return;
579
+ if (!authToken || !initCompleted)
580
+ return;
579
581
  const controller = new AbortController();
580
582
  let cancelled = false;
581
583
  (() => __awaiter(this, void 0, void 0, function* () {
@@ -655,7 +657,7 @@ function ChatUI(props) {
655
657
  cancelled = true;
656
658
  controller.abort();
657
659
  };
658
- }, [apiBase, apiKey, authToken, sessionId, domain]);
660
+ }, [apiBase, apiKey, authToken, sessionId, domain, initCompleted]);
659
661
  const canSend = (0, react_1.useMemo)(() => (!!input.trim() || selectedFiles.length > 0 || !!selectedTaskCard) &&
660
662
  !!sessionId &&
661
663
  !!apiBase &&
@@ -979,6 +981,10 @@ function ChatUI(props) {
979
981
  function sendMessage() {
980
982
  return __awaiter(this, void 0, void 0, function* () {
981
983
  var _a, _b;
984
+ const selectedTask = selectedTaskCard;
985
+ if (selectedTask) {
986
+ setSelectedTaskCard(null);
987
+ }
982
988
  if (!sessionId)
983
989
  return;
984
990
  if (!initCompleted) {
@@ -991,7 +997,7 @@ function ChatUI(props) {
991
997
  const promptText = input.trim();
992
998
  const hasText = !!promptText;
993
999
  const hasFiles = selectedFiles.length > 0;
994
- const hasSelectedCard = !!selectedTaskCard;
1000
+ const hasSelectedCard = !!selectedTask;
995
1001
  if (!hasText && !hasFiles && !hasSelectedCard)
996
1002
  return;
997
1003
  const filesToUpload = selectedFiles;
@@ -1000,7 +1006,7 @@ function ChatUI(props) {
1000
1006
  }));
1001
1007
  const selectionLine = hasSelectedCard
1002
1008
  ? formatText(text.composer.selectionLineTemplate, {
1003
- id: String((_a = selectedTaskCard === null || selectedTaskCard === void 0 ? void 0 : selectedTaskCard.RequestId) !== null && _a !== void 0 ? _a : ""),
1009
+ id: String((_a = selectedTask === null || selectedTask === void 0 ? void 0 : selectedTask.RequestId) !== null && _a !== void 0 ? _a : ""),
1004
1010
  })
1005
1011
  : "";
1006
1012
  const userContent = selectionLine
@@ -1075,8 +1081,8 @@ function ChatUI(props) {
1075
1081
  SessionId: sessionId,
1076
1082
  UserMessage: userContent,
1077
1083
  };
1078
- if ((selectedTaskCard === null || selectedTaskCard === void 0 ? void 0 : selectedTaskCard.RequestId) !== undefined && (selectedTaskCard === null || selectedTaskCard === void 0 ? void 0 : selectedTaskCard.RequestId) !== null) {
1079
- payload.RequestId = selectedTaskCard.RequestId;
1084
+ if ((selectedTask === null || selectedTask === void 0 ? void 0 : selectedTask.RequestId) !== undefined && (selectedTask === null || selectedTask === void 0 ? void 0 : selectedTask.RequestId) !== null) {
1085
+ payload.RequestId = selectedTask.RequestId;
1080
1086
  }
1081
1087
  if (initServiceId && initServiceId.trim() !== "") {
1082
1088
  const n = Number(initServiceId);
@@ -12,7 +12,7 @@ const classNames_1 = require("../utils/classNames");
12
12
  const format_1 = require("../utils/format");
13
13
  function MessageItem({ m, openOverlay, isRtl, onOpenTaskCard, onSelectTaskCard, selectedTaskCardId, canSpeak, isSpeaking, onSpeak, onStopSpeak, textButtonTheme, text, taskCardSize, }) {
14
14
  const isUser = m.role === "User";
15
- const alignRight = isUser;
15
+ const alignRight = isUser || isRtl;
16
16
  return ((0, jsx_runtime_1.jsx)(framer_motion_1.motion.div, { initial: { opacity: 0, y: 6 }, animate: { opacity: 1, y: 0 }, exit: { opacity: 0, y: -6 }, transition: { duration: 0.18 }, className: (0, classNames_1.classNames)("flex w-full", alignRight ? "justify-end" : "justify-start"), children: (0, jsx_runtime_1.jsxs)("div", { className: (0, classNames_1.classNames)("max-w-[85%]", isUser ? "" : "w-full"), children: [(0, jsx_runtime_1.jsxs)("div", { className: (0, classNames_1.classNames)(isUser
17
17
  ? "rounded-2xl px-4 py-3 shadow-sm"
18
18
  : "px-1 py-0"), style: Object.assign({ direction: isRtl ? "rtl" : "ltr", textAlign: isRtl ? "right" : "left" }, (isUser
@@ -15,5 +15,5 @@ function MessageList({ messages, pending, openOverlay, onOpenTaskCard, onSelectT
15
15
  !!m.content &&
16
16
  m.content.trim() !== "";
17
17
  return ((0, jsx_runtime_1.jsx)(MessageItem_1.default, { m: m, openOverlay: openOverlay, onOpenTaskCard: onOpenTaskCard, onSelectTaskCard: onSelectTaskCard, selectedTaskCardId: selectedTaskCardId, isRtl: isRtl, canSpeak: canSpeak, isSpeaking: canSpeak && speakingMessageIndex === i, onSpeak: canSpeak ? () => onSpeak(m.content, i) : undefined, onStopSpeak: canSpeak ? onStopSpeak : undefined, textButtonTheme: textButtonTheme, text: messageItemText, taskCardSize: taskCardSize }, `${(_a = m.ts) !== null && _a !== void 0 ? _a : i}-${i}`));
18
- }), pending && (0, jsx_runtime_1.jsx)(TypingDots_1.default, {}, "typing")] }) }), (0, jsx_runtime_1.jsx)("div", { ref: listEndRef })] }) }));
18
+ }), pending && (0, jsx_runtime_1.jsx)(TypingDots_1.default, { alignRight: isRtl }, "typing")] }) }), (0, jsx_runtime_1.jsx)("div", { ref: listEndRef })] }) }));
19
19
  }
@@ -1 +1,5 @@
1
- export default function TypingDots(): import("react/jsx-runtime").JSX.Element;
1
+ type TypingDotsProps = {
2
+ alignRight?: boolean;
3
+ };
4
+ export default function TypingDots({ alignRight }: TypingDotsProps): import("react/jsx-runtime").JSX.Element;
5
+ export {};
@@ -3,6 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = TypingDots;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const framer_motion_1 = require("framer-motion");
6
- function TypingDots() {
7
- return ((0, jsx_runtime_1.jsx)(framer_motion_1.motion.div, { initial: { opacity: 0, y: 6 }, animate: { opacity: 1, y: 0 }, exit: { opacity: 0, y: -6 }, transition: { duration: 0.18 }, className: "flex w-full justify-start", children: (0, jsx_runtime_1.jsxs)("div", { className: "text-[1rem] leading-7 text-gray-900", children: [(0, jsx_runtime_1.jsx)("span", { className: "inline-block h-1.5 w-1.5 animate-bounce rounded-full bg-gray-400 [animation-delay:0ms]" }), (0, jsx_runtime_1.jsx)("span", { className: "ml-1 inline-block h-1.5 w-1.5 animate-bounce rounded-full bg-gray-400 [animation-delay:150ms]" }), (0, jsx_runtime_1.jsx)("span", { className: "ml-1 inline-block h-1.5 w-1.5 animate-bounce rounded-full bg-gray-400 [animation-delay:300ms]" })] }) }));
6
+ function TypingDots({ alignRight }) {
7
+ return ((0, jsx_runtime_1.jsx)(framer_motion_1.motion.div, { initial: { opacity: 0, y: 6 }, animate: { opacity: 1, y: 0 }, exit: { opacity: 0, y: -6 }, transition: { duration: 0.18 }, className: `flex w-full ${alignRight ? "justify-end" : "justify-start"}`, children: (0, jsx_runtime_1.jsxs)("div", { className: "text-[1rem] leading-7 text-gray-900", children: [(0, jsx_runtime_1.jsx)("span", { className: "inline-block h-1.5 w-1.5 animate-bounce rounded-full bg-gray-400 [animation-delay:0ms]" }), (0, jsx_runtime_1.jsx)("span", { className: "ml-1 inline-block h-1.5 w-1.5 animate-bounce rounded-full bg-gray-400 [animation-delay:150ms]" }), (0, jsx_runtime_1.jsx)("span", { className: "ml-1 inline-block h-1.5 w-1.5 animate-bounce rounded-full bg-gray-400 [animation-delay:300ms]" })] }) }));
8
8
  }
package/dist/config.d.ts CHANGED
@@ -168,6 +168,7 @@ export type ChatUISDKConfig = {
168
168
  showInitPanel?: boolean;
169
169
  initializeChat: boolean;
170
170
  contextWindow: string;
171
+ initializeLanguage?: string;
171
172
  };
172
173
  declare class SDKConfigStore {
173
174
  private settings;
@@ -55,7 +55,7 @@ function GetConfigValue(key) {
55
55
  }
56
56
  function InitializeChatSession() {
57
57
  return __awaiter(this, arguments, void 0, function* (options = {}) {
58
- var _a, _b, _c, _d, _e;
58
+ var _a, _b, _c, _d, _e, _f;
59
59
  const config = GetConfig();
60
60
  const apiBase = chatDefaults_1.DEFAULT_API_BASE;
61
61
  const apiKey = chatDefaults_1.DEFAULT_API_KEY;
@@ -79,10 +79,11 @@ function InitializeChatSession() {
79
79
  const defaultDomain = config.isDab ? chatDefaults_1.DEFAULT_DOMAIN : "";
80
80
  const domain = ((_c = options.domain) !== null && _c !== void 0 ? _c : localStorage_1.ls.get(storageKeys_1.STORAGE_KEYS.domain, defaultDomain)).trim();
81
81
  const contextWindow = (_d = options.contextWindow) !== null && _d !== void 0 ? _d : config.contextWindow;
82
+ const initializeLanguage = ((_e = config.initializeLanguage) !== null && _e !== void 0 ? _e : "").trim() || "ar-JO";
82
83
  const bodyPayload = {
83
84
  Domain: domain,
84
85
  ContextWindow: contextWindow || "ComposeRequest",
85
- InitializeLangauge: "ar-JO",
86
+ InitializeLangauge: initializeLanguage,
86
87
  };
87
88
  if (options.initServiceId !== undefined && options.initServiceId !== null) {
88
89
  const n = Number(options.initServiceId);
@@ -110,11 +111,11 @@ function InitializeChatSession() {
110
111
  try {
111
112
  msg = yield initRes.text();
112
113
  }
113
- catch (_f) { }
114
+ catch (_g) { }
114
115
  throw new Error(`initializeChat failed: ${initRes.status} ${initRes.statusText}${msg ? ` - ${msg}` : ""}`);
115
116
  }
116
117
  const initPayload = yield initRes.json().catch(() => ({}));
117
- const resolvedSessionId = (_e = initPayload === null || initPayload === void 0 ? void 0 : initPayload.SessionId) !== null && _e !== void 0 ? _e : sessionId;
118
+ const resolvedSessionId = (_f = initPayload === null || initPayload === void 0 ? void 0 : initPayload.SessionId) !== null && _f !== void 0 ? _f : sessionId;
118
119
  if (initPayload === null || initPayload === void 0 ? void 0 : initPayload.SessionId) {
119
120
  localStorage_1.ls.set(storageKeys_1.STORAGE_KEYS.sessionId, initPayload.SessionId);
120
121
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mcp-chat-ui",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "React Chat UI SDK with speech, file upload, and task actions.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",