@blumessage/react-chat 1.1.0 → 1.1.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.
@@ -57,6 +57,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
57
57
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
58
58
  import React, { useState, useEffect, useRef } from "react";
59
59
  import ReactMarkdown from 'react-markdown';
60
+ import remarkGfm from 'remark-gfm';
60
61
  import { MessageCircle, AlertTriangle, Loader2, Send, X, Maximize, Minimize2, Bot, MessageSquare, Phone, Mail, Headphones, Users, User, Heart, Star, Zap } from "lucide-react";
61
62
  // Custom CSS animations that don't depend on Tailwind
62
63
  var customStyles = "\n @keyframes bounce {\n 0%, 100% {\n transform: translateY(0);\n }\n 50% {\n transform: translateY(-25%);\n }\n }\n \n @keyframes spin {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n }\n \n .blumessage-animate-bounce {\n animation: bounce 1s infinite;\n }\n \n .blumessage-animate-spin {\n animation: spin 1s linear infinite;\n }\n";
@@ -102,24 +103,24 @@ var clearStoredConversationId = function (persistent) {
102
103
  }
103
104
  };
104
105
  export var BlumessageChat = function (_a) {
105
- var apiKey = _a.apiKey, _b = _a.placeholder, placeholder = _b === void 0 ? "Type your message..." : _b, _c = _a.theme, theme = _c === void 0 ? 'light' : _c, width = _a.width, height = _a.height, _d = _a.size, size = _d === void 0 ? 'medium' : _d, _e = _a.name, name = _e === void 0 ? "Blumessage AI" : _e, _f = _a.subtitle, subtitle = _f === void 0 ? "Online • Instant responses" : _f, _g = _a.initialMessages, initialMessages = _g === void 0 ? [] : _g, onUserMessage = _a.onUserMessage, onAssistantMessage = _a.onAssistantMessage, initialConversationId = _a.conversationId, onConversationIdChange = _a.onConversationIdChange, onChatWidgetOpen = _a.onChatWidgetOpen, onChatWidgetClosed = _a.onChatWidgetClosed, onError = _a.onError, _h = _a.persistent, persistent = _h === void 0 ? false : _h, _j = _a.showTimestamps, showTimestamps = _j === void 0 ? false : _j, _k = _a.typingText, typingText = _k === void 0 ? "Agent is typing..." : _k, _l = _a.emptyStateText, emptyStateText = _l === void 0 ? "Start a conversation!" : _l,
106
+ var apiKey = _a.apiKey, _b = _a.placeholder, placeholder = _b === void 0 ? "Type your message..." : _b, _c = _a.theme, theme = _c === void 0 ? 'light' : _c, width = _a.width, height = _a.height, _d = _a.size, size = _d === void 0 ? 'medium' : _d, _e = _a.name, name = _e === void 0 ? "Blumessage AI" : _e, _f = _a.subtitle, subtitle = _f === void 0 ? "Online • Instant responses" : _f, _g = _a.initialMessages, initialMessages = _g === void 0 ? [] : _g, onUserMessage = _a.onUserMessage, onAssistantMessage = _a.onAssistantMessage, initialConversationId = _a.conversationId, onConversationIdChange = _a.onConversationIdChange, onChatWidgetOpen = _a.onChatWidgetOpen, onChatWidgetClosed = _a.onChatWidgetClosed, onError = _a.onError, _h = _a.persistent, persistent = _h === void 0 ? false : _h, _j = _a.showTimestamps, showTimestamps = _j === void 0 ? false : _j, _k = _a.typingText, typingText = _k === void 0 ? "Agent is typing..." : _k, _l = _a.emptyStateText, emptyStateText = _l === void 0 ? "Start a conversation!" : _l, _m = _a.markdown, markdown = _m === void 0 ? true : _m,
106
107
  // Floating button props
107
- _m = _a.floating,
108
+ _o = _a.floating,
108
109
  // Floating button props
109
- floating = _m === void 0 ? true : _m, _o = _a.buttonText, buttonText = _o === void 0 ? "Chat with us" : _o, _p = _a.buttonPosition, buttonPosition = _p === void 0 ? 'bottom-right' : _p, buttonStyle = _a.buttonStyle, _q = _a.defaultOpen, defaultOpen = _q === void 0 ? false : _q, _r = _a.maximizeToggleButton, maximizeToggleButton = _r === void 0 ? true : _r, _s = _a.fullScreen, fullScreen = _s === void 0 ? false : _s, _t = _a.icon, icon = _t === void 0 ? 'message-circle' : _t,
110
+ floating = _o === void 0 ? true : _o, _p = _a.buttonText, buttonText = _p === void 0 ? "Chat with us" : _p, _q = _a.buttonPosition, buttonPosition = _q === void 0 ? 'bottom-right' : _q, buttonStyle = _a.buttonStyle, _r = _a.defaultOpen, defaultOpen = _r === void 0 ? false : _r, _s = _a.maximizeToggleButton, maximizeToggleButton = _s === void 0 ? true : _s, _t = _a.fullScreen, fullScreen = _t === void 0 ? false : _t, _u = _a.icon, icon = _u === void 0 ? 'message-circle' : _u,
110
111
  // Styling props
111
- _u = _a.primaryColor,
112
+ _v = _a.primaryColor,
112
113
  // Styling props
113
- primaryColor = _u === void 0 ? "linear-gradient(to right, #3b82f6,rgb(8, 98, 242))" : _u;
114
- var _v = useState(false), isInitialized = _v[0], setIsInitialized = _v[1];
115
- var _w = useState(null), error = _w[0], setError = _w[1];
116
- var _x = useState(initialMessages), messages = _x[0], setMessages = _x[1];
117
- var _y = useState(''), inputValue = _y[0], setInputValue = _y[1];
118
- var _z = useState(initialConversationId || getStoredConversationId(persistent)), conversationId = _z[0], setConversationId = _z[1];
119
- var _0 = useState(defaultOpen), isOpen = _0[0], setIsOpen = _0[1];
120
- var _1 = useState(false), isAnimating = _1[0], setIsAnimating = _1[1];
121
- var _2 = useState(false), isLoading = _2[0], setIsLoading = _2[1];
122
- var _3 = useState(false), isMaximized = _3[0], setIsMaximized = _3[1];
114
+ primaryColor = _v === void 0 ? "linear-gradient(to right, #3b82f6,rgb(8, 98, 242))" : _v;
115
+ var _w = useState(false), isInitialized = _w[0], setIsInitialized = _w[1];
116
+ var _x = useState(null), error = _x[0], setError = _x[1];
117
+ var _y = useState(initialMessages), messages = _y[0], setMessages = _y[1];
118
+ var _z = useState(''), inputValue = _z[0], setInputValue = _z[1];
119
+ var _0 = useState(initialConversationId || getStoredConversationId(persistent)), conversationId = _0[0], setConversationId = _0[1];
120
+ var _1 = useState(defaultOpen), isOpen = _1[0], setIsOpen = _1[1];
121
+ var _2 = useState(false), isAnimating = _2[0], setIsAnimating = _2[1];
122
+ var _3 = useState(false), isLoading = _3[0], setIsLoading = _3[1];
123
+ var _4 = useState(false), isMaximized = _4[0], setIsMaximized = _4[1];
123
124
  var messagesEndRef = useRef(null);
124
125
  var isInitialLoad = useRef(true);
125
126
  // Helper function to format timestamp
@@ -171,7 +172,7 @@ export var BlumessageChat = function (_a) {
171
172
  }
172
173
  return dimensions;
173
174
  };
174
- var _4 = getDimensions(), actualWidth = _4.width, actualHeight = _4.height;
175
+ var _5 = getDimensions(), actualWidth = _5.width, actualHeight = _5.height;
175
176
  // Function to update conversation ID and notify parent
176
177
  var updateConversationId = function (newConversationId) {
177
178
  setConversationId(newConversationId);
@@ -605,7 +606,7 @@ export var BlumessageChat = function (_a) {
605
606
  ? 'blumessage-bg-gradient-to-r blumessage-from-blue-500 blumessage-to-purple-600 blumessage-text-white'
606
607
  : theme === 'light'
607
608
  ? 'blumessage-bg-gray-100'
608
- : 'blumessage-bg-gray-700'), children: message.role === 'assistant' ? (_jsx("div", { className: "blumessage-prose ".concat(theme === 'dark' ? 'blumessage-text-white' : 'blumessage-text-gray-900'), children: _jsx(ReactMarkdown, { children: message.content }) })) : (_jsx("p", { className: "blumessage-text-sm blumessage-whitespace-pre-wrap", children: message.content })) }), showTimestamps && (_jsx("span", { className: "blumessage-text-xs blumessage-text-gray-500", children: formatTimestamp(message.timestamp) }))] }) }, message.id));
609
+ : 'blumessage-bg-gray-700'), children: message.role === 'assistant' ? (_jsx("div", { className: "blumessage-prose ".concat(theme === 'dark' ? 'blumessage-text-white' : 'blumessage-text-gray-900'), children: markdown ? (_jsx(ReactMarkdown, { remarkPlugins: [remarkGfm], children: message.content })) : (_jsx("p", { className: "blumessage-text-sm blumessage-whitespace-pre-wrap", children: message.content })) })) : (_jsx("div", { className: "blumessage-text-sm blumessage-whitespace-pre-wrap blumessage-text-white", children: markdown ? (_jsx(ReactMarkdown, { remarkPlugins: [remarkGfm], children: message.content })) : (_jsx("p", { className: "blumessage-text-sm blumessage-whitespace-pre-wrap", children: message.content })) })) }), showTimestamps && (_jsx("span", { className: "blumessage-text-xs blumessage-text-gray-500", children: formatTimestamp(message.timestamp) }))] }) }, message.id));
609
610
  };
610
611
  // Render chat window component
611
612
  var renderChatWindow = function () {
@@ -635,7 +636,7 @@ export var BlumessageChat = function (_a) {
635
636
  ? 'text-white'
636
637
  : theme === 'dark'
637
638
  ? 'bg-gray-700 text-gray-100 border border-gray-600 shadow-sm'
638
- : 'bg-white text-gray-800 border border-gray-200 shadow-sm'), style: message.role === 'user' ? { backgroundImage: primaryColor } : {}, children: [_jsx("div", { className: "inline-block", children: message.content }), showTimestamps && (_jsx("div", { className: "text-[10px] mt-1 opacity-75 ".concat(message.role === 'user'
639
+ : 'bg-white text-gray-800 border border-gray-200 shadow-sm'), style: message.role === 'user' ? { backgroundImage: primaryColor } : {}, children: [message.role === 'assistant' ? (markdown ? (_jsx(ReactMarkdown, { remarkPlugins: [remarkGfm], children: message.content })) : (_jsx("div", { className: "whitespace-pre-wrap", children: message.content }))) : (_jsx("div", { className: "inline-block", children: markdown ? (_jsx(ReactMarkdown, { remarkPlugins: [remarkGfm], children: message.content })) : (_jsx("div", { className: "whitespace-pre-wrap", children: message.content })) })), showTimestamps && (_jsx("div", { className: "text-[10px] mt-1 opacity-75 ".concat(message.role === 'user'
639
640
  ? 'text-white/75'
640
641
  : theme === 'dark'
641
642
  ? 'text-gray-400'
@@ -38,6 +38,7 @@ export interface BlumessageChatProps {
38
38
  showTimestamps?: boolean;
39
39
  typingText?: string;
40
40
  emptyStateText?: string;
41
+ markdown?: boolean;
41
42
  floating?: boolean;
42
43
  buttonText?: string;
43
44
  buttonPosition?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blumessage/react-chat",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "description": "A React TypeScript chat widget component with floating button, theming, and Blumessage API integration",
5
5
  "license": "UNLICENSED",
6
6
  "author": "Blumessage <contact@blumessage.com>",
@@ -42,7 +42,8 @@
42
42
  },
43
43
  "dependencies": {
44
44
  "lucide-react": "^0.294.0",
45
- "react-markdown": "^9.0.1"
45
+ "react-markdown": "^9.0.1",
46
+ "remark-gfm": "^4.0.1"
46
47
  },
47
48
  "devDependencies": {
48
49
  "@types/react": "^18.2.45",