impact-chatbot 2.3.21 → 2.3.23

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.esm.js CHANGED
@@ -17,7 +17,7 @@ import rehypeSanitize from 'rehype-sanitize';
17
17
  import remarkBreaks from 'remark-breaks';
18
18
  import remarkGfm from 'remark-gfm';
19
19
  import { setSelectedFilters, setFilterConfiguration } from 'core/actions/filterAction';
20
- import { setChatbotContext, setCurrentAgentChatId, setThinkingContext, setHierarchyKeyValue } from 'core/actions/smartBotActions';
20
+ import { setChatbotContext, setCurrentAgentChatId, setThinkingContext, setPersistedFormValues, setHierarchyKeyValue } from 'core/actions/smartBotActions';
21
21
  import { useNavigate, useLocation } from 'react-router-dom-v5-compat';
22
22
  import RefreshIcon from '@mui/icons-material/Refresh';
23
23
  import styled from 'styled-components';
@@ -6097,7 +6097,7 @@ const StreamedContent = ({ botData }) => {
6097
6097
  // }
6098
6098
  let endPoint = botData?.utilityObject?.endpoint
6099
6099
  ? `${BASE_API}${botData?.utilityObject?.endpoint}`
6100
- : `${BASE_API}/core/chatbot/navigation-v2`;
6100
+ : `${BASE_API}/core/chatbot/navigation-v3`;
6101
6101
  let method = botData?.utilityObject?.method
6102
6102
  ? botData?.utilityObject?.method
6103
6103
  : "PUT";
@@ -6665,11 +6665,13 @@ const StreamedContent = ({ botData }) => {
6665
6665
  return renderContent();
6666
6666
  };
6667
6667
 
6668
- const SliderContent = ({ bodyText, isFormDisabled = false }) => {
6668
+ const SliderContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
6669
+ const formKey = `${messageIndex}_${bodyText?.paramName}`;
6669
6670
  const { header, headerOrentiation, inputPosition, label, max, min, required, disabled, } = bodyText;
6670
- const [sliderValue, setSliderValue] = useState(0);
6671
6671
  const chatbotContext = useSelector((state) => state.smartBotReducer.chatbotContext);
6672
+ const persistedFormValues = useSelector((state) => state.smartBotReducer.persistedFormValues);
6672
6673
  const dispatch = useDispatch();
6674
+ const [sliderValue, setSliderValue] = useState(persistedFormValues[formKey] !== undefined ? persistedFormValues[formKey] : 0);
6673
6675
  if (!bodyText)
6674
6676
  return null;
6675
6677
  const handleChange = (value) => {
@@ -6681,6 +6683,7 @@ const SliderContent = ({ bodyText, isFormDisabled = false }) => {
6681
6683
  updated: true
6682
6684
  };
6683
6685
  dispatch(setChatbotContext(chatbotContext));
6686
+ dispatch(setPersistedFormValues({ [formKey]: value?.target?.value }));
6684
6687
  }
6685
6688
  catch (error) {
6686
6689
  console.error("Error in slider handleChange", error);
@@ -6689,11 +6692,13 @@ const SliderContent = ({ bodyText, isFormDisabled = false }) => {
6689
6692
  return (jsx("div", { style: { width: "100%", marginTop: "10px" }, children: jsx(Slider, { header: header, headerOrientation: headerOrentiation, inputPosition: inputPosition, label: label, max: max, min: min, required: required, disabled: disabled || isFormDisabled, onChange: (e) => handleChange(e), value: sliderValue }) }));
6690
6693
  };
6691
6694
 
6692
- const SelectContent = ({ bodyText, isFormDisabled = false }) => {
6695
+ const SelectContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
6696
+ const formKey = `${messageIndex}_${bodyText?.paramName}`;
6693
6697
  const { header, inputPosition, labelOrientation, label, options, isRequired, isDisabled, isMulti, paramName } = bodyText;
6694
6698
  const [isOpen, setIsOpen] = useState(false);
6695
6699
  const [currentOptions, setCurrentOptions] = useState([]);
6696
- const [currentSelectedOptions, setCurrentSelectedOptions] = useState([]);
6700
+ const persistedFormValues = useSelector((state) => state.smartBotReducer.persistedFormValues);
6701
+ const [currentSelectedOptions, setCurrentSelectedOptions] = useState(persistedFormValues?.[formKey] || []);
6697
6702
  const [isAllSelected, setIsAllSelected] = useState(false);
6698
6703
  const [initialOptions, setInitialOptions] = useState([]);
6699
6704
  const chatbotContext = useSelector((state) => state.smartBotReducer.chatbotContext);
@@ -6721,6 +6726,7 @@ const SelectContent = ({ bodyText, isFormDisabled = false }) => {
6721
6726
  // updated: true
6722
6727
  // };
6723
6728
  dispatch(setChatbotContext(chatbotContext));
6729
+ dispatch(setPersistedFormValues({ [formKey]: Array.isArray(selectedOptions) ? selectedOptions : [selectedOptions] }));
6724
6730
  }
6725
6731
  catch (error) {
6726
6732
  console.error("Error in select handleChange", error);
@@ -6742,11 +6748,13 @@ const SelectContent = ({ bodyText, isFormDisabled = false }) => {
6742
6748
  isRequired: isRequired, isDisabled: isDisabled || isFormDisabled, handleChange: (selected) => onChange(selected), isCloseWhenClickOutside: true, setIsOpen: setIsOpen, isOpen: isOpen, selectedOptions: currentSelectedOptions, setSelectedOptions: setCurrentSelectedOptions, initialOptions: initialOptions, isMulti: isMulti, isSelectAll: isAllSelected, setIsSelectAll: setIsAllSelected, toggleSelectAll: true, isWithSearch: isMulti ? true : false }) }));
6743
6749
  };
6744
6750
 
6745
- const DatePickerContent = ({ bodyText, isFormDisabled = false }) => {
6751
+ const DatePickerContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
6752
+ const formKey = `${messageIndex}_${bodyText?.paramName}`;
6746
6753
  const { displayFormat, label, isRequired, labelOrientation, placeholder, minDate, maxDate, isDisabled, } = bodyText;
6747
- const [selectedDate, setSelectedDate] = useState(null);
6748
6754
  const chatbotContext = useSelector((state) => state.smartBotReducer.chatbotContext);
6755
+ const persistedFormValues = useSelector((state) => state.smartBotReducer.persistedFormValues);
6749
6756
  const dispatch = useDispatch();
6757
+ const [selectedDate, setSelectedDate] = useState(persistedFormValues[formKey] || null);
6750
6758
  if (isEmpty$1(bodyText))
6751
6759
  return null;
6752
6760
  const handleDateChange = (date) => {
@@ -6758,6 +6766,7 @@ const DatePickerContent = ({ bodyText, isFormDisabled = false }) => {
6758
6766
  updated: true
6759
6767
  };
6760
6768
  dispatch(setChatbotContext(chatbotContext));
6769
+ dispatch(setPersistedFormValues({ [formKey]: date }));
6761
6770
  }
6762
6771
  catch (error) {
6763
6772
  console.error("Error in datepicker handleChange", error);
@@ -6772,12 +6781,14 @@ const DatePickerContent = ({ bodyText, isFormDisabled = false }) => {
6772
6781
  selectedDate: selectedDate }) }));
6773
6782
  };
6774
6783
 
6775
- const DateRangePickerContent = ({ bodyText, isFormDisabled = false }) => {
6784
+ const DateRangePickerContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
6785
+ const formKey = `${messageIndex}_${bodyText?.paramName}`;
6776
6786
  const { displayFormat, label, isRequired, labelOrientation, minDate, maxDate, isDisabled, showMonthYearSelect, } = bodyText;
6777
- const [startDate, setStartDate] = useState(null);
6778
- const [endDate, setEndDate] = useState(null);
6779
6787
  const chatbotContext = useSelector((state) => state.smartBotReducer.chatbotContext);
6788
+ const persistedFormValues = useSelector((state) => state.smartBotReducer.persistedFormValues);
6780
6789
  const dispatch = useDispatch();
6790
+ const [startDate, setStartDate] = useState(persistedFormValues[formKey]?.startDate || null);
6791
+ const [endDate, setEndDate] = useState(persistedFormValues[formKey]?.endDate || null);
6781
6792
  if (isEmpty$1(bodyText))
6782
6793
  return null;
6783
6794
  const handleDatesChange = (start, end) => {
@@ -6793,6 +6804,7 @@ const DateRangePickerContent = ({ bodyText, isFormDisabled = false }) => {
6793
6804
  updated: true,
6794
6805
  };
6795
6806
  dispatch(setChatbotContext(chatbotContext));
6807
+ dispatch(setPersistedFormValues({ [formKey]: { startDate: start, endDate: end } }));
6796
6808
  }
6797
6809
  catch (error) {
6798
6810
  console.error("Error in dateRangePicker handleDatesChange", error);
@@ -6808,11 +6820,13 @@ const DateRangePickerContent = ({ bodyText, isFormDisabled = false }) => {
6808
6820
  } }) }));
6809
6821
  };
6810
6822
 
6811
- const CheckboxContent = ({ bodyText, isFormDisabled = false }) => {
6823
+ const CheckboxContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
6824
+ const formKey = `${messageIndex}_${bodyText?.paramName}`;
6812
6825
  const { label, checked: checkedValue, required, disabled, } = bodyText;
6813
6826
  const chatbotContext = useSelector((state) => state.smartBotReducer.chatbotContext);
6827
+ const persistedFormValues = useSelector((state) => state.smartBotReducer.persistedFormValues);
6814
6828
  const dispatch = useDispatch();
6815
- const [checked, setChecked] = useState(checkedValue);
6829
+ const [checked, setChecked] = useState(persistedFormValues[formKey] !== undefined ? persistedFormValues[formKey] : checkedValue);
6816
6830
  if (isEmpty$1(bodyText))
6817
6831
  return null;
6818
6832
  const handleChange = (isChecked) => {
@@ -6829,6 +6843,7 @@ const CheckboxContent = ({ bodyText, isFormDisabled = false }) => {
6829
6843
  updated: true
6830
6844
  };
6831
6845
  dispatch(setChatbotContext(chatbotContext));
6846
+ dispatch(setPersistedFormValues({ [formKey]: isChecked?.currentTarget?.checked }));
6832
6847
  }
6833
6848
  catch (error) {
6834
6849
  console.error("Error in checkbox handleChange", error);
@@ -6837,12 +6852,14 @@ const CheckboxContent = ({ bodyText, isFormDisabled = false }) => {
6837
6852
  return (jsx("div", { style: { width: '100%', marginTop: '10px' }, children: jsx(Checkbox, { label: label, checked: checked, required: required, disabled: disabled || isFormDisabled, onChange: (e) => handleChange(e), variant: "default" }) }));
6838
6853
  };
6839
6854
 
6840
- const RadioContent = ({ bodyText, isFormDisabled = false }) => {
6855
+ const RadioContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
6856
+ const formKey = `${messageIndex}_${bodyText?.paramName}`;
6841
6857
  const classes = useStyles$6();
6842
6858
  const { label, isDisabled, orientation, options } = bodyText;
6843
6859
  const chatbotContext = useSelector((state) => state.smartBotReducer.chatbotContext);
6860
+ const persistedFormValues = useSelector((state) => state.smartBotReducer.persistedFormValues);
6844
6861
  const dispatch = useDispatch();
6845
- const [selectedOption, setSelectedOption] = useState(null);
6862
+ const [selectedOption, setSelectedOption] = useState(persistedFormValues[formKey] ?? null);
6846
6863
  if (isEmpty$1(bodyText))
6847
6864
  return null;
6848
6865
  const handleChange = (selectedOption) => {
@@ -6860,6 +6877,7 @@ const RadioContent = ({ bodyText, isFormDisabled = false }) => {
6860
6877
  updated: true
6861
6878
  };
6862
6879
  dispatch(setChatbotContext(chatbotContext));
6880
+ dispatch(setPersistedFormValues({ [formKey]: value }));
6863
6881
  }
6864
6882
  catch (error) {
6865
6883
  console.error("Error in radio handleChange", error);
@@ -6868,11 +6886,13 @@ const RadioContent = ({ bodyText, isFormDisabled = false }) => {
6868
6886
  return (jsxs("div", { style: { width: "100%", marginTop: "10px" }, children: [bodyText?.label && jsx("p", { className: classes.radioGrpLabel, children: bodyText.label }), jsx(RadioButtonGroup, { name: "radio-group", options: options, onChange: (e) => handleChange(e), orientation: orientation, isDisabled: isDisabled || isFormDisabled, selectedOption: selectedOption })] }));
6869
6887
  };
6870
6888
 
6871
- const InputContent = ({ bodyText, isFormDisabled = false }) => {
6889
+ const InputContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
6890
+ const formKey = `${messageIndex}_${bodyText?.paramName}`;
6872
6891
  const { label, placeholder, isRequired, isDisabled, inputType, labelOrientation, defaultValue, maxLength, minLength, } = bodyText;
6873
6892
  const chatbotContext = useSelector((state) => state.smartBotReducer.chatbotContext);
6893
+ const persistedFormValues = useSelector((state) => state.smartBotReducer.persistedFormValues);
6874
6894
  const dispatch = useDispatch();
6875
- const [value, setValue] = useState(defaultValue || "");
6895
+ const [value, setValue] = useState(persistedFormValues[formKey] !== undefined ? persistedFormValues[formKey] : (defaultValue || ""));
6876
6896
  if (isEmpty$1(bodyText))
6877
6897
  return null;
6878
6898
  const handleChange = (event) => {
@@ -6886,6 +6906,7 @@ const InputContent = ({ bodyText, isFormDisabled = false }) => {
6886
6906
  type: inputType,
6887
6907
  };
6888
6908
  dispatch(setChatbotContext(chatbotContext));
6909
+ dispatch(setPersistedFormValues({ [formKey]: newValue }));
6889
6910
  }
6890
6911
  catch (error) {
6891
6912
  console.error("Error in input handleChange", error);
@@ -7140,21 +7161,21 @@ const CombinedContent = ({ botData, props }) => {
7140
7161
  case "graph":
7141
7162
  return jsx(GraphContent, { bodyText: parsedData.bodyText }, key);
7142
7163
  case "slider":
7143
- return jsx(SliderContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
7164
+ return jsx(SliderContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled, messageIndex: botData.messageIndex }, key);
7144
7165
  case "select":
7145
- return jsx(SelectContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
7166
+ return jsx(SelectContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled, messageIndex: botData.messageIndex }, key);
7146
7167
  case "datePicker":
7147
- return jsx(DatePickerContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
7168
+ return jsx(DatePickerContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled, messageIndex: botData.messageIndex }, key);
7148
7169
  case "dateRangePicker":
7149
- return jsx(DateRangePickerContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
7170
+ return jsx(DateRangePickerContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled, messageIndex: botData.messageIndex }, key);
7150
7171
  case "checkbox":
7151
- return jsx(CheckboxContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
7172
+ return jsx(CheckboxContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled, messageIndex: botData.messageIndex }, key);
7152
7173
  case "radio":
7153
- return jsx(RadioContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
7174
+ return jsx(RadioContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled, messageIndex: botData.messageIndex }, key);
7154
7175
  case "button":
7155
7176
  return jsx(ButtonContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
7156
7177
  case "input":
7157
- return jsx(InputContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
7178
+ return jsx(InputContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled, messageIndex: botData.messageIndex }, key);
7158
7179
  case "image":
7159
7180
  return jsx(ImageContent, { bodyText: parsedData.bodyText }, key);
7160
7181
  default:
@@ -7236,21 +7257,21 @@ const BotMessage = ({ botData, state, handleLikeDislike, props }) => {
7236
7257
  case "graph":
7237
7258
  return jsx(GraphContent, { bodyText: botData.bodyText });
7238
7259
  case "slider":
7239
- return jsx(SliderContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled });
7260
+ return jsx(SliderContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled, messageIndex: botData.messageIndex });
7240
7261
  case "select":
7241
- return jsx(SelectContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled });
7262
+ return jsx(SelectContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled, messageIndex: botData.messageIndex });
7242
7263
  case "datePicker":
7243
- return jsx(DatePickerContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled });
7264
+ return jsx(DatePickerContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled, messageIndex: botData.messageIndex });
7244
7265
  case "dateRangePicker":
7245
- return jsx(DateRangePickerContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled });
7266
+ return jsx(DateRangePickerContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled, messageIndex: botData.messageIndex });
7246
7267
  case "checkbox":
7247
- return jsx(CheckboxContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled });
7268
+ return jsx(CheckboxContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled, messageIndex: botData.messageIndex });
7248
7269
  case "radio":
7249
- return jsx(RadioContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled });
7270
+ return jsx(RadioContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled, messageIndex: botData.messageIndex });
7250
7271
  case "button":
7251
7272
  return jsx(ButtonContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled });
7252
7273
  case "input":
7253
- return jsx(InputContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled });
7274
+ return jsx(InputContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled, messageIndex: botData.messageIndex });
7254
7275
  case "image":
7255
7276
  return jsx(ImageContent, { bodyText: botData.bodyText });
7256
7277
  case "combined":
@@ -10758,6 +10779,7 @@ const SmartBot = (props) => {
10758
10779
  // />
10759
10780
  // ;
10760
10781
  message.isFormDisabled = index !== lastBotMessageIndex;
10782
+ message.messageIndex = index;
10761
10783
  let originalUtilityObject = message.utilityObject;
10762
10784
  let newMessage = cloneDeep(message);
10763
10785
  if (originalUtilityObject) {
@@ -11197,7 +11219,7 @@ const SmartBot = (props) => {
11197
11219
  },
11198
11220
  icon: jsx(SvgNavigationIcon, {}),
11199
11221
  },
11200
- ], utilityList: utilityList, isAssistantThinking: loader, isCustomScreen: showChatPlaceholder, customScreenJsx: jsx(ChatPlaceholder, { dateFormat: dateFormat, chatDataRef: chatDataRef, currentMode: currentMode, setShowChatPlaceholder: setShowChatPlaceholder, setLoader: setLoader, setCurrentAgentId: setCurrentAgentId, baseUrl: baseUrl, setBaseUrl: setBaseUrl, setCurrentSessionId: setCurrentSessionId, customChatConfig: customChatConfig, chatDataInfoRef: chatDataInfoRef, setChatDataState: setChatDataState, userInput: userInput, legacyAgentScreen: legacyAgentScreen, activeConversationId: activeConversationId, chatBodyRef: chatBodyRef, chatbotContext: chatbotContext, setInitValue: setInitValue, setSessionId: setSessionId, thinkingContent: thinkingContext?.thinkingContent, setThinkingContent: setThinkingContent, isThinking: isThinking, setIsThinking: setIsThinking, chatId: chatId, setChatId: setChatId, isStop: isStop, setIsStop: setIsStop, functionsRef: functionsRef, functionsState: functionsState, setFunctionsState: setFunctionsState, thinkingHeaderMessage: thinkingContext?.thinkingHeaderMessage, setThinkingHeaderMessage: setThinkingHeaderMessage, uniqueChatId: uniqueChatId, setUniqueChatId: setUniqueChatId, fieldNumber: fieldNumber, setFieldNumber: setFieldNumber, setAdditionalArgs: setAdditionalArgs, displayQuestions: displayQuestions, questions: questions, setActiveConversationId: setActiveConversationId }), inputText: userInput, threadList: ["Home"], hideMenuArrow: hideMenu, newChatScreen: newChatScreen, isModuleListLoading: modulesLoading, suggestionBanner: {
11222
+ ], utilityList: utilityList, isAssistantThinking: false, isCustomScreen: showChatPlaceholder, customScreenJsx: jsx(ChatPlaceholder, { dateFormat: dateFormat, chatDataRef: chatDataRef, currentMode: currentMode, setShowChatPlaceholder: setShowChatPlaceholder, setLoader: setLoader, setCurrentAgentId: setCurrentAgentId, baseUrl: baseUrl, setBaseUrl: setBaseUrl, setCurrentSessionId: setCurrentSessionId, customChatConfig: customChatConfig, chatDataInfoRef: chatDataInfoRef, setChatDataState: setChatDataState, userInput: userInput, legacyAgentScreen: legacyAgentScreen, activeConversationId: activeConversationId, chatBodyRef: chatBodyRef, chatbotContext: chatbotContext, setInitValue: setInitValue, setSessionId: setSessionId, thinkingContent: thinkingContext?.thinkingContent, setThinkingContent: setThinkingContent, isThinking: isThinking, setIsThinking: setIsThinking, chatId: chatId, setChatId: setChatId, isStop: isStop, setIsStop: setIsStop, functionsRef: functionsRef, functionsState: functionsState, setFunctionsState: setFunctionsState, thinkingHeaderMessage: thinkingContext?.thinkingHeaderMessage, setThinkingHeaderMessage: setThinkingHeaderMessage, uniqueChatId: uniqueChatId, setUniqueChatId: setUniqueChatId, fieldNumber: fieldNumber, setFieldNumber: setFieldNumber, setAdditionalArgs: setAdditionalArgs, displayQuestions: displayQuestions, questions: questions, setActiveConversationId: setActiveConversationId }), inputText: userInput, threadList: ["Home"], hideMenuArrow: hideMenu, newChatScreen: newChatScreen, isModuleListLoading: modulesLoading, suggestionBanner: {
11201
11223
  freeTextHeading: "Try adding more details :",
11202
11224
  freeTextContent: "Alan works better when you provide more context and pointed questions",
11203
11225
  }, isStopIcon: isStop, onStopIconClick: onStopIconClick, footerText: "AI-generated responses may contain errors\u2014please verify important information", showSuggestionBanner: showSuggestionBanner, onCloseSuggestionBanner: () => {