impact-chatbot 2.3.24 → 2.3.25

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, setPersistedFormValues, setHierarchyKeyValue } from 'core/actions/smartBotActions';
20
+ import { setChatbotContext, setCurrentAgentChatId, setThinkingContext, 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';
@@ -6669,13 +6669,11 @@ const StreamedContent = ({ botData }) => {
6669
6669
  return renderContent();
6670
6670
  };
6671
6671
 
6672
- const SliderContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
6673
- const formKey = `${messageIndex}_${bodyText?.paramName}`;
6672
+ const SliderContent = ({ bodyText, isFormDisabled = false }) => {
6674
6673
  const { header, headerOrentiation, inputPosition, label, max, min, required, disabled, } = bodyText;
6674
+ const [sliderValue, setSliderValue] = useState(0);
6675
6675
  const chatbotContext = useSelector((state) => state.smartBotReducer.chatbotContext);
6676
- const persistedFormValues = useSelector((state) => state.smartBotReducer.persistedFormValues);
6677
6676
  const dispatch = useDispatch();
6678
- const [sliderValue, setSliderValue] = useState(persistedFormValues[formKey] !== undefined ? persistedFormValues[formKey] : 0);
6679
6677
  if (!bodyText)
6680
6678
  return null;
6681
6679
  const handleChange = (value) => {
@@ -6687,7 +6685,6 @@ const SliderContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
6687
6685
  updated: true
6688
6686
  };
6689
6687
  dispatch(setChatbotContext(chatbotContext));
6690
- dispatch(setPersistedFormValues({ [formKey]: value?.target?.value }));
6691
6688
  }
6692
6689
  catch (error) {
6693
6690
  console.error("Error in slider handleChange", error);
@@ -6696,13 +6693,11 @@ const SliderContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
6696
6693
  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 }) }));
6697
6694
  };
6698
6695
 
6699
- const SelectContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
6700
- const formKey = `${messageIndex}_${bodyText?.paramName}`;
6696
+ const SelectContent = ({ bodyText, isFormDisabled = false }) => {
6701
6697
  const { header, inputPosition, labelOrientation, label, options, isRequired, isDisabled, isMulti, paramName } = bodyText;
6702
6698
  const [isOpen, setIsOpen] = useState(false);
6703
6699
  const [currentOptions, setCurrentOptions] = useState([]);
6704
- const persistedFormValues = useSelector((state) => state.smartBotReducer.persistedFormValues);
6705
- const [currentSelectedOptions, setCurrentSelectedOptions] = useState(persistedFormValues?.[formKey] || []);
6700
+ const [currentSelectedOptions, setCurrentSelectedOptions] = useState([]);
6706
6701
  const [isAllSelected, setIsAllSelected] = useState(false);
6707
6702
  const [initialOptions, setInitialOptions] = useState([]);
6708
6703
  const chatbotContext = useSelector((state) => state.smartBotReducer.chatbotContext);
@@ -6730,7 +6725,6 @@ const SelectContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
6730
6725
  // updated: true
6731
6726
  // };
6732
6727
  dispatch(setChatbotContext(chatbotContext));
6733
- dispatch(setPersistedFormValues({ [formKey]: Array.isArray(selectedOptions) ? selectedOptions : [selectedOptions] }));
6734
6728
  }
6735
6729
  catch (error) {
6736
6730
  console.error("Error in select handleChange", error);
@@ -6752,13 +6746,11 @@ const SelectContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
6752
6746
  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 }) }));
6753
6747
  };
6754
6748
 
6755
- const DatePickerContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
6756
- const formKey = `${messageIndex}_${bodyText?.paramName}`;
6749
+ const DatePickerContent = ({ bodyText, isFormDisabled = false }) => {
6757
6750
  const { displayFormat, label, isRequired, labelOrientation, placeholder, minDate, maxDate, isDisabled, } = bodyText;
6751
+ const [selectedDate, setSelectedDate] = useState(null);
6758
6752
  const chatbotContext = useSelector((state) => state.smartBotReducer.chatbotContext);
6759
- const persistedFormValues = useSelector((state) => state.smartBotReducer.persistedFormValues);
6760
6753
  const dispatch = useDispatch();
6761
- const [selectedDate, setSelectedDate] = useState(persistedFormValues[formKey] || null);
6762
6754
  if (isEmpty$1(bodyText))
6763
6755
  return null;
6764
6756
  const handleDateChange = (date) => {
@@ -6770,7 +6762,6 @@ const DatePickerContent = ({ bodyText, isFormDisabled = false, messageIndex }) =
6770
6762
  updated: true
6771
6763
  };
6772
6764
  dispatch(setChatbotContext(chatbotContext));
6773
- dispatch(setPersistedFormValues({ [formKey]: date }));
6774
6765
  }
6775
6766
  catch (error) {
6776
6767
  console.error("Error in datepicker handleChange", error);
@@ -6785,14 +6776,12 @@ const DatePickerContent = ({ bodyText, isFormDisabled = false, messageIndex }) =
6785
6776
  selectedDate: selectedDate }) }));
6786
6777
  };
6787
6778
 
6788
- const DateRangePickerContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
6789
- const formKey = `${messageIndex}_${bodyText?.paramName}`;
6779
+ const DateRangePickerContent = ({ bodyText, isFormDisabled = false }) => {
6790
6780
  const { displayFormat, label, isRequired, labelOrientation, minDate, maxDate, isDisabled, showMonthYearSelect, } = bodyText;
6781
+ const [startDate, setStartDate] = useState(null);
6782
+ const [endDate, setEndDate] = useState(null);
6791
6783
  const chatbotContext = useSelector((state) => state.smartBotReducer.chatbotContext);
6792
- const persistedFormValues = useSelector((state) => state.smartBotReducer.persistedFormValues);
6793
6784
  const dispatch = useDispatch();
6794
- const [startDate, setStartDate] = useState(persistedFormValues[formKey]?.startDate || null);
6795
- const [endDate, setEndDate] = useState(persistedFormValues[formKey]?.endDate || null);
6796
6785
  if (isEmpty$1(bodyText))
6797
6786
  return null;
6798
6787
  const handleDatesChange = (start, end) => {
@@ -6808,7 +6797,6 @@ const DateRangePickerContent = ({ bodyText, isFormDisabled = false, messageIndex
6808
6797
  updated: true,
6809
6798
  };
6810
6799
  dispatch(setChatbotContext(chatbotContext));
6811
- dispatch(setPersistedFormValues({ [formKey]: { startDate: start, endDate: end } }));
6812
6800
  }
6813
6801
  catch (error) {
6814
6802
  console.error("Error in dateRangePicker handleDatesChange", error);
@@ -6824,13 +6812,11 @@ const DateRangePickerContent = ({ bodyText, isFormDisabled = false, messageIndex
6824
6812
  } }) }));
6825
6813
  };
6826
6814
 
6827
- const CheckboxContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
6828
- const formKey = `${messageIndex}_${bodyText?.paramName}`;
6815
+ const CheckboxContent = ({ bodyText, isFormDisabled = false }) => {
6829
6816
  const { label, checked: checkedValue, required, disabled, } = bodyText;
6830
6817
  const chatbotContext = useSelector((state) => state.smartBotReducer.chatbotContext);
6831
- const persistedFormValues = useSelector((state) => state.smartBotReducer.persistedFormValues);
6832
6818
  const dispatch = useDispatch();
6833
- const [checked, setChecked] = useState(persistedFormValues[formKey] !== undefined ? persistedFormValues[formKey] : checkedValue);
6819
+ const [checked, setChecked] = useState(checkedValue);
6834
6820
  if (isEmpty$1(bodyText))
6835
6821
  return null;
6836
6822
  const handleChange = (isChecked) => {
@@ -6847,7 +6833,6 @@ const CheckboxContent = ({ bodyText, isFormDisabled = false, messageIndex }) =>
6847
6833
  updated: true
6848
6834
  };
6849
6835
  dispatch(setChatbotContext(chatbotContext));
6850
- dispatch(setPersistedFormValues({ [formKey]: isChecked?.currentTarget?.checked }));
6851
6836
  }
6852
6837
  catch (error) {
6853
6838
  console.error("Error in checkbox handleChange", error);
@@ -6856,14 +6841,12 @@ const CheckboxContent = ({ bodyText, isFormDisabled = false, messageIndex }) =>
6856
6841
  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" }) }));
6857
6842
  };
6858
6843
 
6859
- const RadioContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
6860
- const formKey = `${messageIndex}_${bodyText?.paramName}`;
6844
+ const RadioContent = ({ bodyText, isFormDisabled = false }) => {
6861
6845
  const classes = useStyles$6();
6862
6846
  const { label, isDisabled, orientation, options } = bodyText;
6863
6847
  const chatbotContext = useSelector((state) => state.smartBotReducer.chatbotContext);
6864
- const persistedFormValues = useSelector((state) => state.smartBotReducer.persistedFormValues);
6865
6848
  const dispatch = useDispatch();
6866
- const [selectedOption, setSelectedOption] = useState(persistedFormValues[formKey] ?? null);
6849
+ const [selectedOption, setSelectedOption] = useState(null);
6867
6850
  if (isEmpty$1(bodyText))
6868
6851
  return null;
6869
6852
  const handleChange = (selectedOption) => {
@@ -6881,7 +6864,6 @@ const RadioContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
6881
6864
  updated: true
6882
6865
  };
6883
6866
  dispatch(setChatbotContext(chatbotContext));
6884
- dispatch(setPersistedFormValues({ [formKey]: value }));
6885
6867
  }
6886
6868
  catch (error) {
6887
6869
  console.error("Error in radio handleChange", error);
@@ -6890,13 +6872,11 @@ const RadioContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
6890
6872
  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 })] }));
6891
6873
  };
6892
6874
 
6893
- const InputContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
6894
- const formKey = `${messageIndex}_${bodyText?.paramName}`;
6875
+ const InputContent = ({ bodyText, isFormDisabled = false }) => {
6895
6876
  const { label, placeholder, isRequired, isDisabled, inputType, labelOrientation, defaultValue, maxLength, minLength, } = bodyText;
6896
6877
  const chatbotContext = useSelector((state) => state.smartBotReducer.chatbotContext);
6897
- const persistedFormValues = useSelector((state) => state.smartBotReducer.persistedFormValues);
6898
6878
  const dispatch = useDispatch();
6899
- const [value, setValue] = useState(persistedFormValues[formKey] !== undefined ? persistedFormValues[formKey] : (defaultValue || ""));
6879
+ const [value, setValue] = useState(defaultValue || "");
6900
6880
  if (isEmpty$1(bodyText))
6901
6881
  return null;
6902
6882
  const handleChange = (event) => {
@@ -6910,7 +6890,6 @@ const InputContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
6910
6890
  type: inputType,
6911
6891
  };
6912
6892
  dispatch(setChatbotContext(chatbotContext));
6913
- dispatch(setPersistedFormValues({ [formKey]: newValue }));
6914
6893
  }
6915
6894
  catch (error) {
6916
6895
  console.error("Error in input handleChange", error);
@@ -7165,21 +7144,21 @@ const CombinedContent = ({ botData, props }) => {
7165
7144
  case "graph":
7166
7145
  return jsx(GraphContent, { bodyText: parsedData.bodyText }, key);
7167
7146
  case "slider":
7168
- return jsx(SliderContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled, messageIndex: botData.messageIndex }, key);
7147
+ return jsx(SliderContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
7169
7148
  case "select":
7170
- return jsx(SelectContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled, messageIndex: botData.messageIndex }, key);
7149
+ return jsx(SelectContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
7171
7150
  case "datePicker":
7172
- return jsx(DatePickerContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled, messageIndex: botData.messageIndex }, key);
7151
+ return jsx(DatePickerContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
7173
7152
  case "dateRangePicker":
7174
- return jsx(DateRangePickerContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled, messageIndex: botData.messageIndex }, key);
7153
+ return jsx(DateRangePickerContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
7175
7154
  case "checkbox":
7176
- return jsx(CheckboxContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled, messageIndex: botData.messageIndex }, key);
7155
+ return jsx(CheckboxContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
7177
7156
  case "radio":
7178
- return jsx(RadioContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled, messageIndex: botData.messageIndex }, key);
7157
+ return jsx(RadioContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
7179
7158
  case "button":
7180
7159
  return jsx(ButtonContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
7181
7160
  case "input":
7182
- return jsx(InputContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled, messageIndex: botData.messageIndex }, key);
7161
+ return jsx(InputContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
7183
7162
  case "image":
7184
7163
  return jsx(ImageContent, { bodyText: parsedData.bodyText }, key);
7185
7164
  default:
@@ -7261,21 +7240,21 @@ const BotMessage = ({ botData, state, handleLikeDislike, props }) => {
7261
7240
  case "graph":
7262
7241
  return jsx(GraphContent, { bodyText: botData.bodyText });
7263
7242
  case "slider":
7264
- return jsx(SliderContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled, messageIndex: botData.messageIndex });
7243
+ return jsx(SliderContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled });
7265
7244
  case "select":
7266
- return jsx(SelectContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled, messageIndex: botData.messageIndex });
7245
+ return jsx(SelectContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled });
7267
7246
  case "datePicker":
7268
- return jsx(DatePickerContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled, messageIndex: botData.messageIndex });
7247
+ return jsx(DatePickerContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled });
7269
7248
  case "dateRangePicker":
7270
- return jsx(DateRangePickerContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled, messageIndex: botData.messageIndex });
7249
+ return jsx(DateRangePickerContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled });
7271
7250
  case "checkbox":
7272
- return jsx(CheckboxContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled, messageIndex: botData.messageIndex });
7251
+ return jsx(CheckboxContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled });
7273
7252
  case "radio":
7274
- return jsx(RadioContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled, messageIndex: botData.messageIndex });
7253
+ return jsx(RadioContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled });
7275
7254
  case "button":
7276
7255
  return jsx(ButtonContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled });
7277
7256
  case "input":
7278
- return jsx(InputContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled, messageIndex: botData.messageIndex });
7257
+ return jsx(InputContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled });
7279
7258
  case "image":
7280
7259
  return jsx(ImageContent, { bodyText: botData.bodyText });
7281
7260
  case "combined":
@@ -10783,7 +10762,6 @@ const SmartBot = (props) => {
10783
10762
  // />
10784
10763
  // ;
10785
10764
  message.isFormDisabled = index !== lastBotMessageIndex;
10786
- message.messageIndex = index;
10787
10765
  let originalUtilityObject = message.utilityObject;
10788
10766
  let newMessage = cloneDeep(message);
10789
10767
  if (originalUtilityObject) {