@eshal-bot/chat-widget 0.1.2 → 0.1.3

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.
@@ -1258,6 +1258,7 @@
1258
1258
  };
1259
1259
  const ChatHeader = _ref => {
1260
1260
  let {
1261
+ conciergeName,
1261
1262
  companyName,
1262
1263
  companyLogo,
1263
1264
  primaryColor,
@@ -1311,7 +1312,7 @@
1311
1312
  fontSize: fontSize ? "calc(".concat(fontSize, " + ").concat(isMinimized ? "6px" : "10px", ")") : isMinimized ? "13px" : "15px",
1312
1313
  color: textColor || "#FFFFFF"
1313
1314
  },
1314
- children: companyName
1315
+ children: conciergeName
1315
1316
  })
1316
1317
  })]
1317
1318
  }), /*#__PURE__*/jsxRuntimeExports.jsxs("div", {
@@ -55245,7 +55246,14 @@
55245
55246
  } = _ref8,
55246
55247
  props = _objectWithoutProperties$1(_ref8, _excluded7);
55247
55248
  return /*#__PURE__*/jsxRuntimeExports.jsx("ul", _objectSpread2(_objectSpread2({
55248
- className: "list-disc pl-5 space-y-1"
55249
+ className: "list-disc space-y-1",
55250
+ style: {
55251
+ listStyleType: "disc",
55252
+ paddingInlineStart: isRtl ? undefined : "1.25rem",
55253
+ paddingInlineEnd: isRtl ? "1.25rem" : undefined,
55254
+ marginTop: "0.5rem",
55255
+ marginBottom: "0.5rem"
55256
+ }
55249
55257
  }, props), {}, {
55250
55258
  children: children
55251
55259
  }));
@@ -55257,7 +55265,14 @@
55257
55265
  } = _ref9,
55258
55266
  props = _objectWithoutProperties$1(_ref9, _excluded8);
55259
55267
  return /*#__PURE__*/jsxRuntimeExports.jsx("ol", _objectSpread2(_objectSpread2({
55260
- className: "list-decimal pl-5 space-y-1"
55268
+ className: "list-decimal space-y-1",
55269
+ style: {
55270
+ listStyleType: "decimal",
55271
+ paddingInlineStart: isRtl ? undefined : "1.25rem",
55272
+ paddingInlineEnd: isRtl ? "1.25rem" : undefined,
55273
+ marginTop: "0.5rem",
55274
+ marginBottom: "0.5rem"
55275
+ }
55261
55276
  }, props), {}, {
55262
55277
  children: children
55263
55278
  }));
@@ -55504,181 +55519,6 @@
55504
55519
  });
55505
55520
  };
55506
55521
 
55507
- const MessageList = _ref => {
55508
- let {
55509
- messages = [],
55510
- isDark,
55511
- primaryColor,
55512
- isLoading,
55513
- agentMessageBubbleColor,
55514
- userMessageBoxColor,
55515
- textColor,
55516
- fontFamily,
55517
- fontSize,
55518
- formatTime,
55519
- isRtl = false
55520
- } = _ref;
55521
- const containerRef = reactExports.useRef(null);
55522
- const messagesEndRef = reactExports.useRef(null);
55523
- const shouldAutoScrollRef = reactExports.useRef(true);
55524
- const autoScrollKey = reactExports.useMemo(() => messages.map(message => {
55525
- var _message$content$leng, _message$content;
55526
- return "".concat(message.id, ":").concat((_message$content$leng = (_message$content = message.content) === null || _message$content === void 0 ? void 0 : _message$content.length) !== null && _message$content$leng !== void 0 ? _message$content$leng : 0, ":").concat(message.isProcessing ? 1 : 0);
55527
- }).join("|"), [messages]);
55528
- const updateAutoScrollIntent = reactExports.useCallback(() => {
55529
- const container = containerRef.current;
55530
- if (!container) {
55531
- return;
55532
- }
55533
- const distanceFromBottom = container.scrollHeight - container.scrollTop - container.clientHeight;
55534
- shouldAutoScrollRef.current = distanceFromBottom < 160;
55535
- }, []);
55536
- reactExports.useEffect(() => {
55537
- const container = containerRef.current;
55538
- if (!container) {
55539
- return undefined;
55540
- }
55541
- container.addEventListener("scroll", updateAutoScrollIntent, {
55542
- passive: true
55543
- });
55544
- updateAutoScrollIntent();
55545
- return () => {
55546
- container.removeEventListener("scroll", updateAutoScrollIntent);
55547
- };
55548
- }, [updateAutoScrollIntent]);
55549
- reactExports.useEffect(() => {
55550
- if (!shouldAutoScrollRef.current) {
55551
- return undefined;
55552
- }
55553
- if (typeof window === "undefined") {
55554
- return undefined;
55555
- }
55556
- const frame = window.requestAnimationFrame(() => {
55557
- var _messagesEndRef$curre;
55558
- (_messagesEndRef$curre = messagesEndRef.current) === null || _messagesEndRef$curre === void 0 || _messagesEndRef$curre.scrollIntoView({
55559
- behavior: "smooth",
55560
- block: "end"
55561
- });
55562
- });
55563
- return () => {
55564
- window.cancelAnimationFrame(frame);
55565
- };
55566
- }, [autoScrollKey, isLoading]);
55567
- return /*#__PURE__*/jsxRuntimeExports.jsxs("div", {
55568
- ref: containerRef,
55569
- className: "chat-messages flex-1 overflow-y-auto px-5 py-4 space-y-4 min-h-0 ".concat(isDark ? "bg-gray-900" : "bg-gradient-to-b from-gray-50/50 to-white", " break-words"),
55570
- children: [messages.map(message => /*#__PURE__*/jsxRuntimeExports.jsx(MessageBubble, {
55571
- message: message,
55572
- isDark: isDark,
55573
- primaryColor: primaryColor,
55574
- agentMessageBubbleColor: agentMessageBubbleColor,
55575
- userMessageBoxColor: userMessageBoxColor,
55576
- textColor: textColor,
55577
- fontFamily: fontFamily,
55578
- fontSize: fontSize,
55579
- formatTime: formatTime,
55580
- isRtl: isRtl
55581
- }, message.id)), /*#__PURE__*/jsxRuntimeExports.jsx("div", {
55582
- ref: messagesEndRef,
55583
- className: "h-px"
55584
- })]
55585
- });
55586
- };
55587
-
55588
- const ChatInput = _ref => {
55589
- let {
55590
- inputValue,
55591
- setInputValue,
55592
- onSend,
55593
- isDark,
55594
- primaryColor,
55595
- isOpen,
55596
- isMinimized,
55597
- isLoading,
55598
- placeholder,
55599
- textColor,
55600
- fontFamily,
55601
- fontSize,
55602
- isRtl = false
55603
- } = _ref;
55604
- const textareaRef = reactExports.useRef(null);
55605
- useGoogleFont(fontFamily);
55606
- reactExports.useEffect(() => {
55607
- if (isOpen && !isMinimized) {
55608
- var _textareaRef$current;
55609
- (_textareaRef$current = textareaRef.current) === null || _textareaRef$current === void 0 || _textareaRef$current.focus();
55610
- }
55611
- }, [isOpen, isMinimized]);
55612
- reactExports.useEffect(() => {
55613
- const textarea = textareaRef.current;
55614
- if (textarea) {
55615
- textarea.style.height = "auto";
55616
- textarea.style.height = "".concat(Math.min(textarea.scrollHeight, 120), "px");
55617
- }
55618
- }, [inputValue]);
55619
- const handleKeyPress = event => {
55620
- if (event.key === "Enter" && !event.shiftKey) {
55621
- event.preventDefault();
55622
- onSend();
55623
- }
55624
- };
55625
- const handleChange = event => {
55626
- setInputValue(event.target.value);
55627
- };
55628
- const isDisabled = !inputValue.trim() || isLoading;
55629
- const separatorColor = isDark ? "#374151" : "#e5e7eb";
55630
- return /*#__PURE__*/jsxRuntimeExports.jsx("div", {
55631
- className: "px-5 py-4 border-t flex-shrink-0 ".concat(isDark ? "border-gray-700 bg-gray-900" : "border-gray-200 bg-white"),
55632
- style: {
55633
- borderTopColor: separatorColor,
55634
- borderTopWidth: "1px",
55635
- borderTopStyle: "solid"
55636
- },
55637
- children: /*#__PURE__*/jsxRuntimeExports.jsxs("div", {
55638
- className: "flex gap-2.5 items-end",
55639
- children: [/*#__PURE__*/jsxRuntimeExports.jsx("div", {
55640
- className: "flex-1 flex items-center min-h-[48px] ".concat(isDark ? "bg-gray-800" : "bg-gray-50", " rounded-2xl border transition-all duration-200"),
55641
- style: {
55642
- borderColor: inputValue ? primaryColor : isDark ? "#374151" : "#e5e7eb",
55643
- borderWidth: inputValue ? "2px" : "1px"
55644
- },
55645
- children: /*#__PURE__*/jsxRuntimeExports.jsx("textarea", {
55646
- id: "chat-widget-input",
55647
- ref: textareaRef,
55648
- value: inputValue,
55649
- onChange: handleChange,
55650
- onKeyDown: handleKeyPress,
55651
- placeholder: placeholder || "Type your message...",
55652
- rows: 1,
55653
- disabled: isLoading,
55654
- dir: isRtl ? "rtl" : "ltr",
55655
- className: "w-full px-4 py-0 bg-transparent rounded-xl leading-normal ".concat(isDark ? "text-gray-100" : "text-gray-900", " placeholder-gray-400 resize-none outline-none scrollbar-hide"),
55656
- style: {
55657
- maxHeight: "120px",
55658
- lineHeight: "48px",
55659
- fontFamily: fontFamily || "Inter",
55660
- fontSize: fontSize || "14px",
55661
- color: textColor || (isDark ? "#f3f4f6" : "#111827"),
55662
- textAlign: isRtl ? "right" : "left"
55663
- }
55664
- })
55665
- }), /*#__PURE__*/jsxRuntimeExports.jsx("button", {
55666
- onClick: onSend,
55667
- disabled: isDisabled,
55668
- className: "h-12 w-12 p-0 rounded-xl transition-all duration-200 flex items-center justify-center shadow-lg disabled:opacity-40 disabled:cursor-not-allowed disabled:shadow-none ".concat(!isDisabled ? "scale-100" : "scale-95"),
55669
- style: {
55670
- backgroundColor: !isDisabled ? primaryColor : isDark ? "#374151" : "#e5e7eb",
55671
- color: !isDisabled ? "white" : "#9ca3af"
55672
- },
55673
- "aria-label": "Send message",
55674
- children: /*#__PURE__*/jsxRuntimeExports.jsx(Send, {
55675
- className: "w-5 h-5"
55676
- })
55677
- })]
55678
- })
55679
- });
55680
- };
55681
-
55682
55522
  const clamp = (value, min, max) => {
55683
55523
  if (Number.isNaN(value)) {
55684
55524
  return min;
@@ -55961,6 +55801,199 @@
55961
55801
  });
55962
55802
  };
55963
55803
 
55804
+ const MessageList = _ref => {
55805
+ let {
55806
+ messages = [],
55807
+ isDark,
55808
+ primaryColor,
55809
+ isLoading,
55810
+ agentMessageBubbleColor,
55811
+ userMessageBoxColor,
55812
+ textColor,
55813
+ fontFamily,
55814
+ fontSize,
55815
+ formatTime,
55816
+ isRtl = false,
55817
+ quickQuestions = [],
55818
+ shouldShowQuickQuestions = false,
55819
+ onQuickQuestion,
55820
+ quickQuestionsLayout = "vertical"
55821
+ } = _ref;
55822
+ const containerRef = reactExports.useRef(null);
55823
+ const messagesEndRef = reactExports.useRef(null);
55824
+ const shouldAutoScrollRef = reactExports.useRef(true);
55825
+ const autoScrollKey = reactExports.useMemo(() => messages.map(message => {
55826
+ var _message$content$leng, _message$content;
55827
+ return "".concat(message.id, ":").concat((_message$content$leng = (_message$content = message.content) === null || _message$content === void 0 ? void 0 : _message$content.length) !== null && _message$content$leng !== void 0 ? _message$content$leng : 0, ":").concat(message.isProcessing ? 1 : 0);
55828
+ }).join("|"), [messages]);
55829
+ const updateAutoScrollIntent = reactExports.useCallback(() => {
55830
+ const container = containerRef.current;
55831
+ if (!container) {
55832
+ return;
55833
+ }
55834
+ const distanceFromBottom = container.scrollHeight - container.scrollTop - container.clientHeight;
55835
+ shouldAutoScrollRef.current = distanceFromBottom < 160;
55836
+ }, []);
55837
+ reactExports.useEffect(() => {
55838
+ const container = containerRef.current;
55839
+ if (!container) {
55840
+ return undefined;
55841
+ }
55842
+ container.addEventListener("scroll", updateAutoScrollIntent, {
55843
+ passive: true
55844
+ });
55845
+ updateAutoScrollIntent();
55846
+ return () => {
55847
+ container.removeEventListener("scroll", updateAutoScrollIntent);
55848
+ };
55849
+ }, [updateAutoScrollIntent]);
55850
+ reactExports.useEffect(() => {
55851
+ if (!shouldAutoScrollRef.current) {
55852
+ return undefined;
55853
+ }
55854
+ if (typeof window === "undefined") {
55855
+ return undefined;
55856
+ }
55857
+ const frame = window.requestAnimationFrame(() => {
55858
+ var _messagesEndRef$curre;
55859
+ (_messagesEndRef$curre = messagesEndRef.current) === null || _messagesEndRef$curre === void 0 || _messagesEndRef$curre.scrollIntoView({
55860
+ behavior: "smooth",
55861
+ block: "end"
55862
+ });
55863
+ });
55864
+ return () => {
55865
+ window.cancelAnimationFrame(frame);
55866
+ };
55867
+ }, [autoScrollKey, isLoading]);
55868
+ return /*#__PURE__*/jsxRuntimeExports.jsxs("div", {
55869
+ ref: containerRef,
55870
+ className: "chat-messages flex-1 overflow-y-auto px-5 py-4 space-y-4 min-h-0 ".concat(isDark ? "bg-gray-900" : "bg-gradient-to-b from-gray-50/50 to-white", " break-words"),
55871
+ children: [messages.map(message => /*#__PURE__*/jsxRuntimeExports.jsx(MessageBubble, {
55872
+ message: message,
55873
+ isDark: isDark,
55874
+ primaryColor: primaryColor,
55875
+ agentMessageBubbleColor: agentMessageBubbleColor,
55876
+ userMessageBoxColor: userMessageBoxColor,
55877
+ textColor: textColor,
55878
+ fontFamily: fontFamily,
55879
+ fontSize: fontSize,
55880
+ formatTime: formatTime,
55881
+ isRtl: isRtl
55882
+ }, message.id)), shouldShowQuickQuestions && quickQuestions.length > 0 && /*#__PURE__*/jsxRuntimeExports.jsx("div", {
55883
+ className: "pt-1",
55884
+ children: /*#__PURE__*/jsxRuntimeExports.jsx(QuickQuestions, {
55885
+ questions: quickQuestions,
55886
+ isDark: isDark,
55887
+ primaryColor: primaryColor,
55888
+ onQuestionClick: onQuickQuestion,
55889
+ isTyping: isLoading,
55890
+ layout: quickQuestionsLayout,
55891
+ fontFamily: fontFamily,
55892
+ fontSize: fontSize,
55893
+ textColor: textColor,
55894
+ isRtl: isRtl
55895
+ })
55896
+ }), /*#__PURE__*/jsxRuntimeExports.jsx("div", {
55897
+ ref: messagesEndRef,
55898
+ className: "h-px"
55899
+ })]
55900
+ });
55901
+ };
55902
+
55903
+ const ChatInput = _ref => {
55904
+ let {
55905
+ inputValue,
55906
+ setInputValue,
55907
+ onSend,
55908
+ isDark,
55909
+ primaryColor,
55910
+ isOpen,
55911
+ isMinimized,
55912
+ isLoading,
55913
+ placeholder,
55914
+ textColor,
55915
+ fontFamily,
55916
+ fontSize,
55917
+ isRtl = false
55918
+ } = _ref;
55919
+ const textareaRef = reactExports.useRef(null);
55920
+ useGoogleFont(fontFamily);
55921
+ reactExports.useEffect(() => {
55922
+ if (isOpen && !isMinimized) {
55923
+ var _textareaRef$current;
55924
+ (_textareaRef$current = textareaRef.current) === null || _textareaRef$current === void 0 || _textareaRef$current.focus();
55925
+ }
55926
+ }, [isOpen, isMinimized]);
55927
+ reactExports.useEffect(() => {
55928
+ const textarea = textareaRef.current;
55929
+ if (textarea) {
55930
+ textarea.style.height = "auto";
55931
+ textarea.style.height = "".concat(Math.min(textarea.scrollHeight, 120), "px");
55932
+ }
55933
+ }, [inputValue]);
55934
+ const handleKeyPress = event => {
55935
+ if (event.key === "Enter" && !event.shiftKey) {
55936
+ event.preventDefault();
55937
+ onSend();
55938
+ }
55939
+ };
55940
+ const handleChange = event => {
55941
+ setInputValue(event.target.value);
55942
+ };
55943
+ const isDisabled = !inputValue.trim() || isLoading;
55944
+ const separatorColor = isDark ? "#374151" : "#e5e7eb";
55945
+ return /*#__PURE__*/jsxRuntimeExports.jsx("div", {
55946
+ className: "px-5 py-4 border-t flex-shrink-0 ".concat(isDark ? "border-gray-700 bg-gray-900" : "border-gray-200 bg-white"),
55947
+ style: {
55948
+ borderTopColor: separatorColor,
55949
+ borderTopWidth: "1px",
55950
+ borderTopStyle: "solid"
55951
+ },
55952
+ children: /*#__PURE__*/jsxRuntimeExports.jsxs("div", {
55953
+ className: "flex gap-2.5 items-end",
55954
+ children: [/*#__PURE__*/jsxRuntimeExports.jsx("div", {
55955
+ className: "flex-1 flex items-center min-h-[48px] ".concat(isDark ? "bg-gray-800" : "bg-gray-50", " rounded-2xl border transition-all duration-200"),
55956
+ style: {
55957
+ borderColor: inputValue ? primaryColor : isDark ? "#374151" : "#e5e7eb",
55958
+ borderWidth: inputValue ? "2px" : "1px"
55959
+ },
55960
+ children: /*#__PURE__*/jsxRuntimeExports.jsx("textarea", {
55961
+ id: "chat-widget-input",
55962
+ ref: textareaRef,
55963
+ value: inputValue,
55964
+ onChange: handleChange,
55965
+ onKeyDown: handleKeyPress,
55966
+ placeholder: placeholder || "Type your message...",
55967
+ rows: 1,
55968
+ disabled: isLoading,
55969
+ dir: isRtl ? "rtl" : "ltr",
55970
+ className: "w-full px-4 py-0 bg-transparent rounded-xl leading-normal ".concat(isDark ? "text-gray-100" : "text-gray-900", " placeholder-gray-400 resize-none outline-none scrollbar-hide"),
55971
+ style: {
55972
+ maxHeight: "120px",
55973
+ lineHeight: "48px",
55974
+ fontFamily: fontFamily || "Inter",
55975
+ fontSize: fontSize || "14px",
55976
+ color: textColor || (isDark ? "#f3f4f6" : "#111827"),
55977
+ textAlign: isRtl ? "right" : "left"
55978
+ }
55979
+ })
55980
+ }), /*#__PURE__*/jsxRuntimeExports.jsx("button", {
55981
+ onClick: onSend,
55982
+ disabled: isDisabled,
55983
+ className: "h-12 w-12 p-0 rounded-xl transition-all duration-200 flex items-center justify-center shadow-lg disabled:opacity-40 disabled:cursor-not-allowed disabled:shadow-none ".concat(!isDisabled ? "scale-100" : "scale-95"),
55984
+ style: {
55985
+ backgroundColor: !isDisabled ? primaryColor : isDark ? "#374151" : "#e5e7eb",
55986
+ color: !isDisabled ? "white" : "#9ca3af"
55987
+ },
55988
+ "aria-label": "Send message",
55989
+ children: /*#__PURE__*/jsxRuntimeExports.jsx(Send, {
55990
+ className: "w-5 h-5"
55991
+ })
55992
+ })]
55993
+ })
55994
+ });
55995
+ };
55996
+
55964
55997
  const DEFAULT_AGENT_BUBBLE_COLOR = "#ffffff";
55965
55998
  const DEFAULT_USER_MESSAGE_COLOR = "#f5f5f5";
55966
55999
  const DEFAULT_TEXT_COLOR = "#000000";
@@ -55989,6 +56022,7 @@
55989
56022
  isDark,
55990
56023
  primaryColor,
55991
56024
  textColor,
56025
+ conciergeName,
55992
56026
  companyName,
55993
56027
  companyLogo,
55994
56028
  messages,
@@ -56018,8 +56052,8 @@
56018
56052
  return undefined;
56019
56053
  }
56020
56054
  return {
56021
- backgroundColor: basePrimaryColor,
56022
- borderColor: basePrimaryColor
56055
+ backgroundColor: basePrimaryColor
56056
+ // borderColor: basePrimaryColor,
56023
56057
  };
56024
56058
  }, [basePrimaryColor, isDark]);
56025
56059
  const resolvedAgentBubbleColor = reactExports.useMemo(() => {
@@ -56061,6 +56095,7 @@
56061
56095
  children: [/*#__PURE__*/jsxRuntimeExports.jsx("div", {
56062
56096
  className: "flex-shrink-0",
56063
56097
  children: /*#__PURE__*/jsxRuntimeExports.jsx(ChatHeader, {
56098
+ conciergeName: conciergeName,
56064
56099
  companyName: companyName,
56065
56100
  companyLogo: companyLogo,
56066
56101
  primaryColor: primaryColor,
@@ -56086,21 +56121,11 @@
56086
56121
  fontFamily: fontFamily,
56087
56122
  fontSize: fontSize,
56088
56123
  formatTime: formatTime,
56089
- isRtl: isRtlLanguage
56090
- }), shouldShowQuickQuestions && /*#__PURE__*/jsxRuntimeExports.jsx("div", {
56091
- className: "px-5 pb-4 flex-shrink-0",
56092
- children: /*#__PURE__*/jsxRuntimeExports.jsx(QuickQuestions, {
56093
- questions: quickQuestions,
56094
- isDark: isDark,
56095
- primaryColor: primaryColor,
56096
- onQuestionClick: onQuickQuestion !== null && onQuickQuestion !== void 0 ? onQuickQuestion : onDirectSend,
56097
- isTyping: isLoading,
56098
- layout: quickQuestionsLayout,
56099
- fontFamily: fontFamily,
56100
- fontSize: fontSize,
56101
- textColor: resolvedTextColor,
56102
- isRtl: isRtlLanguage
56103
- })
56124
+ isRtl: isRtlLanguage,
56125
+ quickQuestions: quickQuestions,
56126
+ shouldShowQuickQuestions: shouldShowQuickQuestions,
56127
+ onQuickQuestion: onQuickQuestion !== null && onQuickQuestion !== void 0 ? onQuickQuestion : onDirectSend,
56128
+ quickQuestionsLayout: quickQuestionsLayout
56104
56129
  }), /*#__PURE__*/jsxRuntimeExports.jsx(ChatInput, {
56105
56130
  inputValue: inputValue,
56106
56131
  setInputValue: setInputValue,
@@ -56159,6 +56184,7 @@
56159
56184
  primaryColor = "#2563eb",
56160
56185
  position = "bottom-right",
56161
56186
  companyName = "Support Team",
56187
+ conciergeName,
56162
56188
  companyLogo = null,
56163
56189
  welcomeMessage = "Hi! How can we help?",
56164
56190
  quickQuestions = [],
@@ -56232,6 +56258,7 @@
56232
56258
  primaryColor: primaryColor,
56233
56259
  textColor: textColor,
56234
56260
  companyName: companyName,
56261
+ conciergeName: conciergeName,
56235
56262
  companyLogo: companyLogo,
56236
56263
  messages: messages,
56237
56264
  isLoading: isLoading,
@@ -56269,6 +56296,7 @@
56269
56296
  primaryColor: '#2563eb',
56270
56297
  position: 'bottom-right',
56271
56298
  companyName: 'Support Team',
56299
+ conciergeName: null,
56272
56300
  companyLogo: null,
56273
56301
  welcomeMessage: 'Hi! How can we help?',
56274
56302
  quickQuestions: [],