reactbridge-sdk 0.2.15 → 0.2.17

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/index.js CHANGED
@@ -881,6 +881,42 @@ toggleButtonClass = defaultToggleButtonClass, toggleButtonTitle = "Open chat ass
881
881
  document.addEventListener("mousedown", handleClickOutside);
882
882
  return () => document.removeEventListener("mousedown", handleClickOutside);
883
883
  }, [isUploadMenuOpen, isOpen, renderMode]);
884
+ // Add scrollbar styling for textareas
885
+ React.useEffect(() => {
886
+ const styleId = "react-bridge-textarea-styles";
887
+ // Check if styles are already injected
888
+ if (!document.getElementById(styleId)) {
889
+ const style = document.createElement("style");
890
+ style.id = styleId;
891
+ style.textContent = `
892
+ .react-bridge-textarea {
893
+ scrollbar-width: thin;
894
+ scrollbar-color: rgba(0, 0, 0, 0.3) transparent;
895
+ }
896
+
897
+ .react-bridge-textarea::-webkit-scrollbar {
898
+ width: 6px;
899
+ }
900
+
901
+ .react-bridge-textarea::-webkit-scrollbar-track {
902
+ background: transparent;
903
+ }
904
+
905
+ .react-bridge-textarea::-webkit-scrollbar-thumb {
906
+ background: rgba(0, 0, 0, 0.3);
907
+ border-radius: 3px;
908
+ }
909
+
910
+ .react-bridge-textarea::-webkit-scrollbar-thumb:hover {
911
+ background: rgba(0, 0, 0, 0.5);
912
+ }
913
+ `;
914
+ document.head.appendChild(style);
915
+ }
916
+ return () => {
917
+ // Optional: cleanup if needed
918
+ };
919
+ }, []);
884
920
  const handleSubmit = (e) => __awaiter(this, void 0, void 0, function* () {
885
921
  e.preventDefault();
886
922
  if ((!inputValue.trim() && !selectedFile) || isLoading)
@@ -1006,7 +1042,7 @@ toggleButtonClass = defaultToggleButtonClass, toggleButtonTitle = "Open chat ass
1006
1042
  gap: theme.spacing.sm,
1007
1043
  alignItems: "flex-end",
1008
1044
  } },
1009
- React.createElement("textarea", { ref: textareaRef, value: inputValue, onChange: handleTextareaChange, onKeyDown: handleKeyDown, placeholder: placeholder, disabled: isLoading, style: {
1045
+ React.createElement("textarea", { ref: textareaRef, value: inputValue, onChange: handleTextareaChange, onKeyDown: handleKeyDown, placeholder: placeholder, disabled: isLoading, className: "react-bridge-textarea", style: {
1010
1046
  flex: 1,
1011
1047
  padding: theme.spacing.sm,
1012
1048
  fontSize: theme.fontSizes.md,
@@ -1020,6 +1056,7 @@ toggleButtonClass = defaultToggleButtonClass, toggleButtonTitle = "Open chat ass
1020
1056
  minHeight: "40px",
1021
1057
  maxHeight: "120px",
1022
1058
  height: `${textareaHeight}px`,
1059
+ scrollbarWidth: "thin",
1023
1060
  } }),
1024
1061
  React.createElement("button", { type: "button", onClick: () => setIsUploadMenuOpen(!isUploadMenuOpen), disabled: isLoading, title: "Attach file", style: {
1025
1062
  padding: theme.spacing.sm,
@@ -1212,7 +1249,7 @@ toggleButtonClass = defaultToggleButtonClass, toggleButtonTitle = "Open chat ass
1212
1249
  gap: theme.spacing.sm,
1213
1250
  alignItems: "flex-end",
1214
1251
  } },
1215
- React.createElement("textarea", { ref: textareaRef, value: inputValue, onChange: handleTextareaChange, onKeyDown: handleKeyDown, placeholder: placeholder, disabled: isLoading, style: {
1252
+ React.createElement("textarea", { ref: textareaRef, value: inputValue, onChange: handleTextareaChange, onKeyDown: handleKeyDown, placeholder: placeholder, disabled: isLoading, className: "react-bridge-textarea", style: {
1216
1253
  flex: 1,
1217
1254
  padding: theme.spacing.sm,
1218
1255
  fontSize: theme.fontSizes.md,
@@ -1226,6 +1263,7 @@ toggleButtonClass = defaultToggleButtonClass, toggleButtonTitle = "Open chat ass
1226
1263
  minHeight: "40px",
1227
1264
  maxHeight: "120px",
1228
1265
  height: `${textareaHeight}px`,
1266
+ scrollbarWidth: "thin",
1229
1267
  } }),
1230
1268
  React.createElement("button", { type: "button", onClick: () => setIsUploadMenuOpen(!isUploadMenuOpen), disabled: isLoading, title: "Attach file", style: {
1231
1269
  padding: theme.spacing.sm,
@@ -1359,6 +1397,34 @@ const MIC_ICON_SVG = (React.createElement("svg", { xmlns: "http://www.w3.org/200
1359
1397
  // Plus Icon SVG
1360
1398
  const PLUS_ICON_SVG = (React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "1em", height: "1em", fill: "currentColor" },
1361
1399
  React.createElement("path", { d: "M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z" })));
1400
+ // Expandable Message Component for Search Results
1401
+ const SearchResultItem = ({ content, theme, isExpanded, onToggleExpand, }) => {
1402
+ const characterLimit = 300;
1403
+ const isLongMessage = content.length > characterLimit;
1404
+ const displayText = isExpanded ? content : content.substring(0, characterLimit);
1405
+ return (React.createElement("div", { style: {
1406
+ display: "flex",
1407
+ flexDirection: "column",
1408
+ gap: "8px",
1409
+ } },
1410
+ React.createElement("div", { style: {
1411
+ whiteSpace: "pre-wrap",
1412
+ wordWrap: "break-word",
1413
+ overflowWrap: "break-word",
1414
+ color: theme.colors.text,
1415
+ } }, displayText),
1416
+ isLongMessage && (React.createElement("button", { onClick: onToggleExpand, style: {
1417
+ background: "none",
1418
+ border: "none",
1419
+ color: theme.colors.primary,
1420
+ cursor: "pointer",
1421
+ textDecoration: "underline",
1422
+ padding: "0",
1423
+ textAlign: "left",
1424
+ fontSize: theme.fontSizes.sm,
1425
+ fontWeight: "bold",
1426
+ } }, isExpanded ? "Show less" : "Show more..."))));
1427
+ };
1362
1428
  function ReactBridgeSearch({ onIntentDetected, currentContext, placeholder = "Search...", width = "100%", maxResults = 5, theme: themeOverride, onError, onSpeechStart, onSpeechEnd, onTranscript, onAgentResponse, }) {
1363
1429
  const { theme: contextTheme } = useReactBridgeContext();
1364
1430
  const theme = Object.assign(Object.assign({}, contextTheme), themeOverride);
@@ -1376,6 +1442,7 @@ function ReactBridgeSearch({ onIntentDetected, currentContext, placeholder = "Se
1376
1442
  const [isUploadMenuOpen, setIsUploadMenuOpen] = React.useState(false);
1377
1443
  const [selectedFile, setSelectedFile] = React.useState(null);
1378
1444
  const [filePreview, setFilePreview] = React.useState(null);
1445
+ const [expandedMessages, setExpandedMessages] = React.useState(new Set());
1379
1446
  const containerRef = React.useRef(null);
1380
1447
  const fileInputRef = React.useRef(null);
1381
1448
  // Close dropdown and upload menu when clicking outside
@@ -1458,6 +1525,19 @@ function ReactBridgeSearch({ onIntentDetected, currentContext, placeholder = "Se
1458
1525
  fileInputRef.current.value = "";
1459
1526
  }
1460
1527
  };
1528
+ // Toggle message expansion
1529
+ const toggleMessageExpansion = React.useCallback((messageId) => {
1530
+ setExpandedMessages((prev) => {
1531
+ const newSet = new Set(prev);
1532
+ if (newSet.has(messageId)) {
1533
+ newSet.delete(messageId);
1534
+ }
1535
+ else {
1536
+ newSet.add(messageId);
1537
+ }
1538
+ return newSet;
1539
+ });
1540
+ }, []);
1461
1541
  const handleSubmit = (e) => __awaiter(this, void 0, void 0, function* () {
1462
1542
  e.preventDefault();
1463
1543
  if ((!inputValue.trim() && !selectedFile) || isLoading)
@@ -1484,7 +1564,8 @@ function ReactBridgeSearch({ onIntentDetected, currentContext, placeholder = "Se
1484
1564
  // Get only assistant messages (not system messages)
1485
1565
  const displayMessages = messages
1486
1566
  .filter((msg) => msg.role === "assistant")
1487
- .slice(-maxResults);
1567
+ .slice(-maxResults)
1568
+ .reverse();
1488
1569
  return (React.createElement("div", { ref: containerRef, style: {
1489
1570
  position: "relative",
1490
1571
  width,
@@ -1656,12 +1737,12 @@ function ReactBridgeSearch({ onIntentDetected, currentContext, placeholder = "Se
1656
1737
  borderBottom: `1px solid ${theme.colors.border}`,
1657
1738
  fontSize: theme.fontSizes.sm,
1658
1739
  color: theme.colors.text,
1659
- cursor: "pointer",
1660
1740
  }, onMouseEnter: (e) => {
1661
1741
  e.currentTarget.style.backgroundColor = theme.colors.surface;
1662
1742
  }, onMouseLeave: (e) => {
1663
1743
  e.currentTarget.style.backgroundColor = theme.colors.background;
1664
- } }, message.content)))))));
1744
+ } },
1745
+ React.createElement(SearchResultItem, { content: message.content, theme: theme, isExpanded: expandedMessages.has(message.id), onToggleExpand: () => toggleMessageExpansion(message.id) }))))))));
1665
1746
  }
1666
1747
 
1667
1748
  const darkTheme = {
@@ -2407,8 +2488,9 @@ const AnalyticsDrawer = ({ isOpen, onClose, configs, isLoading, theme, onDirecti
2407
2488
  };
2408
2489
 
2409
2490
  // Analytics Icon SVG
2410
- const ANALYTICS_ICON_SVG = (React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "1em", height: "1em", fill: "currentColor" },
2411
- React.createElement("path", { d: "M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM9 17H7v-7h2v7zm4 0h-2V7h2v10zm4 0h-2v-4h2v4z" })));
2491
+ const ANALYTICS_ICON_SVG = (React.createElement(React.Fragment, null,
2492
+ React.createElement("svg", { width: "36", height: "36", viewBox: "0 0 40 40", fill: "currentColor", xmlns: "http://www.w3.org/2000/svg" },
2493
+ React.createElement("path", { d: "M10 10 L 35 20 L 10 30 L 15 20 Z", fill: "currentColor" }))));
2412
2494
  const AnalyticsWidget = ({ position = "bottom-right", theme: customTheme, onDirectiveAction, }) => {
2413
2495
  const { theme: contextTheme } = useReactBridgeContext();
2414
2496
  const theme = customTheme || contextTheme;