mcp-chat-ui 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/README.md +327 -0
  2. package/dist/ChatUI.d.ts +2 -0
  3. package/dist/ChatUI.js +1781 -0
  4. package/dist/components/Composer.d.ts +35 -0
  5. package/dist/components/Composer.js +19 -0
  6. package/dist/components/DocumentViewer.d.ts +24 -0
  7. package/dist/components/DocumentViewer.js +16 -0
  8. package/dist/components/FormattedText.d.ts +9 -0
  9. package/dist/components/FormattedText.js +98 -0
  10. package/dist/components/InitPanel.d.ts +41 -0
  11. package/dist/components/InitPanel.js +20 -0
  12. package/dist/components/MessageItem.d.ts +19 -0
  13. package/dist/components/MessageItem.js +50 -0
  14. package/dist/components/MessageList.d.ts +22 -0
  15. package/dist/components/MessageList.js +19 -0
  16. package/dist/components/TakeActionModal.d.ts +26 -0
  17. package/dist/components/TakeActionModal.js +26 -0
  18. package/dist/components/TaskCardsModal.d.ts +13 -0
  19. package/dist/components/TaskCardsModal.js +17 -0
  20. package/dist/components/ToolResultOverlay.d.ts +9 -0
  21. package/dist/components/ToolResultOverlay.js +14 -0
  22. package/dist/components/TopBar.d.ts +13 -0
  23. package/dist/components/TopBar.js +9 -0
  24. package/dist/components/TypingDots.d.ts +1 -0
  25. package/dist/components/TypingDots.js +8 -0
  26. package/dist/components/VoiceOverlay.d.ts +11 -0
  27. package/dist/components/VoiceOverlay.js +9 -0
  28. package/dist/config.d.ts +179 -0
  29. package/dist/config.js +24 -0
  30. package/dist/constants/chatDefaults.d.ts +19 -0
  31. package/dist/constants/chatDefaults.js +234 -0
  32. package/dist/helpers/api.d.ts +12 -0
  33. package/dist/helpers/api.js +104 -0
  34. package/dist/helpers/taskAttributes.d.ts +11 -0
  35. package/dist/helpers/taskAttributes.js +41 -0
  36. package/dist/index.d.ts +5 -0
  37. package/dist/index.js +14 -0
  38. package/dist/models/chat.types.d.ts +72 -0
  39. package/dist/models/chat.types.js +2 -0
  40. package/dist/sdkUtilities.d.ts +27 -0
  41. package/dist/sdkUtilities.js +188 -0
  42. package/dist/styles.css +1412 -0
  43. package/dist/utils/classNames.d.ts +1 -0
  44. package/dist/utils/classNames.js +6 -0
  45. package/dist/utils/format.d.ts +2 -0
  46. package/dist/utils/format.js +18 -0
  47. package/dist/utils/generateGuid.d.ts +1 -0
  48. package/dist/utils/generateGuid.js +10 -0
  49. package/dist/utils/localStorage.d.ts +6 -0
  50. package/dist/utils/localStorage.js +39 -0
  51. package/dist/utils/storageKeys.d.ts +16 -0
  52. package/dist/utils/storageKeys.js +25 -0
  53. package/dist/utils/textDirection.d.ts +2 -0
  54. package/dist/utils/textDirection.js +20 -0
  55. package/package.json +52 -0
@@ -0,0 +1 @@
1
+ export declare function classNames(...xs: Array<string | false | null | undefined>): string;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.classNames = classNames;
4
+ function classNames(...xs) {
5
+ return xs.filter(Boolean).join(" ");
6
+ }
@@ -0,0 +1,2 @@
1
+ export declare function fmtTime(ts?: number): string;
2
+ export declare function safeStringify(x: unknown): string;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fmtTime = fmtTime;
4
+ exports.safeStringify = safeStringify;
5
+ function fmtTime(ts) {
6
+ if (!ts)
7
+ return "";
8
+ const d = new Date(ts);
9
+ return d.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" });
10
+ }
11
+ function safeStringify(x) {
12
+ try {
13
+ return typeof x === "string" ? x : JSON.stringify(x, null, 2);
14
+ }
15
+ catch (_a) {
16
+ return String(x);
17
+ }
18
+ }
@@ -0,0 +1 @@
1
+ export declare function generateGuid(): string;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateGuid = generateGuid;
4
+ function generateGuid() {
5
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) {
6
+ const r = (Math.random() * 16) | 0;
7
+ const v = c === "x" ? r : (r & 0x3) | 0x8;
8
+ return v.toString(16);
9
+ });
10
+ }
@@ -0,0 +1,6 @@
1
+ export declare const ls: {
2
+ get<T>(key: string, fallback: T): T;
3
+ set<T>(key: string, value: T): void;
4
+ remove(key: string): void;
5
+ removeByPrefix(prefix: string): void;
6
+ };
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ls = void 0;
4
+ exports.ls = {
5
+ get(key, fallback) {
6
+ try {
7
+ const raw = localStorage.getItem(key);
8
+ return raw ? JSON.parse(raw) : fallback;
9
+ }
10
+ catch (_a) {
11
+ return fallback;
12
+ }
13
+ },
14
+ set(key, value) {
15
+ try {
16
+ localStorage.setItem(key, JSON.stringify(value));
17
+ }
18
+ catch (_a) { }
19
+ },
20
+ remove(key) {
21
+ try {
22
+ localStorage.removeItem(key);
23
+ }
24
+ catch (_a) { }
25
+ },
26
+ removeByPrefix(prefix) {
27
+ try {
28
+ const keys = [];
29
+ for (let i = 0; i < localStorage.length; i++) {
30
+ const key = localStorage.key(i);
31
+ if (key && key.startsWith(prefix)) {
32
+ keys.push(key);
33
+ }
34
+ }
35
+ keys.forEach((key) => localStorage.removeItem(key));
36
+ }
37
+ catch (_a) { }
38
+ },
39
+ };
@@ -0,0 +1,16 @@
1
+ export declare const STORAGE_KEYS: {
2
+ serviceBaseUrl: string;
3
+ apiSubscriptionKey: string;
4
+ loginSubscriptionKey: string;
5
+ authToken: string;
6
+ sessionId: string;
7
+ contextWindow: string;
8
+ initUsername: string;
9
+ domain: string;
10
+ speechLang: string;
11
+ ttsLang: string;
12
+ messagesPrefix: string;
13
+ initCompletedPrefix: string;
14
+ };
15
+ export declare function getMessagesKey(sessionId: string): string;
16
+ export declare function getInitCompletedKey(sessionId: string): string;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.STORAGE_KEYS = void 0;
4
+ exports.getMessagesKey = getMessagesKey;
5
+ exports.getInitCompletedKey = getInitCompletedKey;
6
+ exports.STORAGE_KEYS = {
7
+ serviceBaseUrl: "chat.serviceBaseUrl",
8
+ apiSubscriptionKey: "chat.apiSubscriptionKey",
9
+ loginSubscriptionKey: "chat.loginSubscriptionKey",
10
+ authToken: "chat.authToken",
11
+ sessionId: "chat.sessionId",
12
+ contextWindow: "chat.contextWindow",
13
+ initUsername: "chat.initUsername",
14
+ domain: "chat.domain",
15
+ speechLang: "speech.lang",
16
+ ttsLang: "speech.ttsLang",
17
+ messagesPrefix: "chat.msgs.",
18
+ initCompletedPrefix: "chat.initCompleted.",
19
+ };
20
+ function getMessagesKey(sessionId) {
21
+ return `${exports.STORAGE_KEYS.messagesPrefix}${sessionId}`;
22
+ }
23
+ function getInitCompletedKey(sessionId) {
24
+ return `${exports.STORAGE_KEYS.initCompletedPrefix}${sessionId}`;
25
+ }
@@ -0,0 +1,2 @@
1
+ export declare function isRtlLocale(locale?: string | null): boolean;
2
+ export declare function getTextDirection(text: string): "rtl" | "ltr" | null;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isRtlLocale = isRtlLocale;
4
+ exports.getTextDirection = getTextDirection;
5
+ const RTL_LANGS = new Set(["ar", "he", "fa", "ur", "ps", "dv", "ku", "ug", "yi"]);
6
+ const RTL_TEXT_RE = /[\u0590-\u08ff\uFB1D-\uFDFD\uFE70-\uFEFC]/;
7
+ const LTR_TEXT_RE = /[A-Za-z]/;
8
+ function isRtlLocale(locale) {
9
+ const lang = (locale || "").split("-")[0].toLowerCase();
10
+ return RTL_LANGS.has(lang);
11
+ }
12
+ function getTextDirection(text) {
13
+ for (const ch of text) {
14
+ if (RTL_TEXT_RE.test(ch))
15
+ return "rtl";
16
+ if (LTR_TEXT_RE.test(ch))
17
+ return "ltr";
18
+ }
19
+ return null;
20
+ }
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "mcp-chat-ui",
3
+ "version": "1.0.0",
4
+ "description": "React Chat UI SDK with speech, file upload, and task actions.",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": [
8
+ "dist",
9
+ "dist/styles.css"
10
+ ],
11
+ "exports": {
12
+ ".": {
13
+ "types": "./dist/index.d.ts",
14
+ "default": "./dist/index.js"
15
+ },
16
+ "./styles.css": "./dist/styles.css"
17
+ },
18
+ "scripts": {
19
+ "build": "npm run build:css && tsc",
20
+ "build:css": "postcss src/styles.css -o dist/styles.css",
21
+ "test": "echo \"Error: no test specified\" && exit 1"
22
+ },
23
+ "author": "nazo",
24
+ "license": "ISC",
25
+ "peerDependencies": {
26
+ "react": "^19.0.0",
27
+ "react-dom": "^19.0.0"
28
+ },
29
+ "peerDependenciesMeta": {
30
+ "react": {
31
+ "optional": true
32
+ },
33
+ "react-dom": {
34
+ "optional": true
35
+ }
36
+ },
37
+ "dependencies": {
38
+ "classnames": "^2.5.1",
39
+ "framer-motion": "^12.23.22",
40
+ "lucide-react": "^0.544.0",
41
+ "microsoft-cognitiveservices-speech-sdk": "^1.47.0"
42
+ },
43
+ "devDependencies": {
44
+ "@types/react": "^19.1.13",
45
+ "@types/react-dom": "^19.1.9",
46
+ "autoprefixer": "^10.4.21",
47
+ "postcss": "^8.5.6",
48
+ "postcss-cli": "^11.0.0",
49
+ "tailwindcss": "^3.4.17",
50
+ "typescript": "^5.8.3"
51
+ }
52
+ }