@blumessage/react-chat 1.5.1 → 1.7.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.
@@ -237,7 +237,7 @@ primaryColor = "linear-gradient(to right, #3b82f6,rgb(8, 98, 242))",
237
237
  // Help bubble props
238
238
  showHelpBubble = true, helpBubbleMessage = "Have a question? We're here to help!", helpBubbleIcon = 'message-circle-question-mark', helpBubbleIconName, helpBubbleShowAfter = 1, // 1 second
239
239
  helpBubbleHideAfter = 5, // 5 seconds
240
- helpBubbleBackgroundColor = "#000000", }, ref) => {
240
+ helpBubbleBackgroundColor = "#000000", context, }, ref) => {
241
241
  const [isInitialized, setIsInitialized] = (0, react_1.useState)(false);
242
242
  const [error, setError] = (0, react_1.useState)(null);
243
243
  const [messages, setMessages] = (0, react_1.useState)(initialMessages);
@@ -496,6 +496,10 @@ helpBubbleBackgroundColor = "#000000", }, ref) => {
496
496
  if (token) {
497
497
  requestBody.token = token;
498
498
  }
499
+ // Include user context if provided
500
+ if (context && Object.keys(context).length > 0) {
501
+ requestBody.context = context;
502
+ }
499
503
  const response = await fetch('https://api.blumessage.com/api/v1/conversations', {
500
504
  method: 'POST',
501
505
  headers: {
@@ -711,6 +715,10 @@ helpBubbleBackgroundColor = "#000000", }, ref) => {
711
715
  if (token) {
712
716
  requestBody.token = token;
713
717
  }
718
+ // Include user context if provided
719
+ if (context && Object.keys(context).length > 0) {
720
+ requestBody.context = context;
721
+ }
714
722
  const response = await fetch('https://api.blumessage.com/api/v1/conversations', {
715
723
  method: 'POST',
716
724
  headers: {
@@ -1007,7 +1015,25 @@ helpBubbleBackgroundColor = "#000000", }, ref) => {
1007
1015
  ? 'bg-gray-900 border-gray-700'
1008
1016
  : 'bg-white border-gray-100'}`, style: { padding: isMobile ? '12px 16px' : '16px 24px' }, children: (0, jsx_runtime_1.jsxs)("div", { className: `flex items-center rounded-2xl px-4 py-3 border ${theme === 'dark'
1009
1017
  ? 'bg-gray-800 border-gray-600'
1010
- : 'bg-gray-50 border-gray-200'}`, children: [(0, jsx_runtime_1.jsx)("textarea", { className: `flex-1 border-none bg-transparent outline-none text-sm font-inherit resize-none ${theme === 'dark' ? 'text-gray-100' : 'text-gray-700'}`, placeholder: placeholder, value: inputValue, onChange: (e) => setInputValue(e.target.value), onKeyDown: handleKeyPress, rows: 1, style: {
1018
+ : 'bg-gray-50 border-gray-200'}`, children: [(0, jsx_runtime_1.jsx)("textarea", { className: `flex-1 border-none bg-transparent outline-none text-sm font-inherit resize-none ${theme === 'dark' ? 'text-gray-100' : 'text-gray-700'}`, placeholder: placeholder, value: inputValue, onChange: (e) => {
1019
+ const newValue = e.target.value;
1020
+ if (newValue.length <= 1000) {
1021
+ setInputValue(newValue);
1022
+ }
1023
+ }, onPaste: (e) => {
1024
+ e.preventDefault();
1025
+ const pastedText = e.clipboardData.getData('text');
1026
+ const currentValue = inputValue;
1027
+ const newValue = currentValue + pastedText;
1028
+ if (newValue.length <= 1000) {
1029
+ setInputValue(newValue);
1030
+ }
1031
+ else {
1032
+ // Truncate to exactly 1000 characters
1033
+ const truncatedValue = newValue.substring(0, 1000);
1034
+ setInputValue(truncatedValue);
1035
+ }
1036
+ }, onKeyDown: handleKeyPress, rows: 1, maxLength: 1000, style: {
1011
1037
  minHeight: '20px',
1012
1038
  maxHeight: isMobile ? '100px' : '120px',
1013
1039
  overflowY: inputValue.split('\n').length > 4 ? 'auto' : 'hidden',