impact-chatbot 2.3.23 → 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';
@@ -985,6 +985,10 @@ const getFormattedApplicationName = (applicationURL) => {
985
985
  return "PriceSmart Promo";
986
986
  case "agentic-assort":
987
987
  return "AssortSmart";
988
+ case "source-smart":
989
+ return "SourceSmart"
990
+ case "size-smart":
991
+ return "SizeSmart"
988
992
  default:
989
993
  return "workflow input center";
990
994
  }
@@ -1010,9 +1014,9 @@ const preprocessMarkdown = (content) => {
1010
1014
  .replace(/<br\s*\/?>/g, '\n') // <br> to newline
1011
1015
  // Ensure proper line breaks before numbered lists (at line start)
1012
1016
  .replace(/(^|\n)(\d+\.\s+)/g, '$1\n$2')
1013
- // Ensure proper line breaks before bullet points (-, •) but NOT * (to preserve **bold**)
1014
- // Only match - or at start of line or after newline, followed by space
1015
- .replace(/(^|\n)([-•]\s+)/g, '$1\n$2')
1017
+ // Ensure proper line breaks before the first bullet point in a list (-, •) but NOT * (to preserve **bold**)
1018
+ // Only add a blank line before a bullet that follows a non-list line (paragraph → list transition)
1019
+ .replace(/(^|\n)([^\n-•]*[a-zA-Z0-9][^\n]*)\n([-•]\s+)/g, '$1$2\n\n$3')
1016
1020
  // Handle list items with - or • appearing directly after text without newline
1017
1021
  .replace(/([^\n])([-•])\s+/g, '$1\n\n$2 ')
1018
1022
  // Handle nested list items with proper indentation
@@ -6097,7 +6101,7 @@ const StreamedContent = ({ botData }) => {
6097
6101
  // }
6098
6102
  let endPoint = botData?.utilityObject?.endpoint
6099
6103
  ? `${BASE_API}${botData?.utilityObject?.endpoint}`
6100
- : `${BASE_API}/core/chatbot/navigation-v3`;
6104
+ : `${BASE_API}/core/chatbot/navigation-v2`;
6101
6105
  let method = botData?.utilityObject?.method
6102
6106
  ? botData?.utilityObject?.method
6103
6107
  : "PUT";
@@ -6665,13 +6669,11 @@ const StreamedContent = ({ botData }) => {
6665
6669
  return renderContent();
6666
6670
  };
6667
6671
 
6668
- const SliderContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
6669
- const formKey = `${messageIndex}_${bodyText?.paramName}`;
6672
+ const SliderContent = ({ bodyText, isFormDisabled = false }) => {
6670
6673
  const { header, headerOrentiation, inputPosition, label, max, min, required, disabled, } = bodyText;
6674
+ const [sliderValue, setSliderValue] = useState(0);
6671
6675
  const chatbotContext = useSelector((state) => state.smartBotReducer.chatbotContext);
6672
- const persistedFormValues = useSelector((state) => state.smartBotReducer.persistedFormValues);
6673
6676
  const dispatch = useDispatch();
6674
- const [sliderValue, setSliderValue] = useState(persistedFormValues[formKey] !== undefined ? persistedFormValues[formKey] : 0);
6675
6677
  if (!bodyText)
6676
6678
  return null;
6677
6679
  const handleChange = (value) => {
@@ -6683,7 +6685,6 @@ const SliderContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
6683
6685
  updated: true
6684
6686
  };
6685
6687
  dispatch(setChatbotContext(chatbotContext));
6686
- dispatch(setPersistedFormValues({ [formKey]: value?.target?.value }));
6687
6688
  }
6688
6689
  catch (error) {
6689
6690
  console.error("Error in slider handleChange", error);
@@ -6692,13 +6693,11 @@ const SliderContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
6692
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 }) }));
6693
6694
  };
6694
6695
 
6695
- const SelectContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
6696
- const formKey = `${messageIndex}_${bodyText?.paramName}`;
6696
+ const SelectContent = ({ bodyText, isFormDisabled = false }) => {
6697
6697
  const { header, inputPosition, labelOrientation, label, options, isRequired, isDisabled, isMulti, paramName } = bodyText;
6698
6698
  const [isOpen, setIsOpen] = useState(false);
6699
6699
  const [currentOptions, setCurrentOptions] = useState([]);
6700
- const persistedFormValues = useSelector((state) => state.smartBotReducer.persistedFormValues);
6701
- const [currentSelectedOptions, setCurrentSelectedOptions] = useState(persistedFormValues?.[formKey] || []);
6700
+ const [currentSelectedOptions, setCurrentSelectedOptions] = useState([]);
6702
6701
  const [isAllSelected, setIsAllSelected] = useState(false);
6703
6702
  const [initialOptions, setInitialOptions] = useState([]);
6704
6703
  const chatbotContext = useSelector((state) => state.smartBotReducer.chatbotContext);
@@ -6726,7 +6725,6 @@ const SelectContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
6726
6725
  // updated: true
6727
6726
  // };
6728
6727
  dispatch(setChatbotContext(chatbotContext));
6729
- dispatch(setPersistedFormValues({ [formKey]: Array.isArray(selectedOptions) ? selectedOptions : [selectedOptions] }));
6730
6728
  }
6731
6729
  catch (error) {
6732
6730
  console.error("Error in select handleChange", error);
@@ -6748,13 +6746,11 @@ const SelectContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
6748
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 }) }));
6749
6747
  };
6750
6748
 
6751
- const DatePickerContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
6752
- const formKey = `${messageIndex}_${bodyText?.paramName}`;
6749
+ const DatePickerContent = ({ bodyText, isFormDisabled = false }) => {
6753
6750
  const { displayFormat, label, isRequired, labelOrientation, placeholder, minDate, maxDate, isDisabled, } = bodyText;
6751
+ const [selectedDate, setSelectedDate] = useState(null);
6754
6752
  const chatbotContext = useSelector((state) => state.smartBotReducer.chatbotContext);
6755
- const persistedFormValues = useSelector((state) => state.smartBotReducer.persistedFormValues);
6756
6753
  const dispatch = useDispatch();
6757
- const [selectedDate, setSelectedDate] = useState(persistedFormValues[formKey] || null);
6758
6754
  if (isEmpty$1(bodyText))
6759
6755
  return null;
6760
6756
  const handleDateChange = (date) => {
@@ -6766,7 +6762,6 @@ const DatePickerContent = ({ bodyText, isFormDisabled = false, messageIndex }) =
6766
6762
  updated: true
6767
6763
  };
6768
6764
  dispatch(setChatbotContext(chatbotContext));
6769
- dispatch(setPersistedFormValues({ [formKey]: date }));
6770
6765
  }
6771
6766
  catch (error) {
6772
6767
  console.error("Error in datepicker handleChange", error);
@@ -6781,14 +6776,12 @@ const DatePickerContent = ({ bodyText, isFormDisabled = false, messageIndex }) =
6781
6776
  selectedDate: selectedDate }) }));
6782
6777
  };
6783
6778
 
6784
- const DateRangePickerContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
6785
- const formKey = `${messageIndex}_${bodyText?.paramName}`;
6779
+ const DateRangePickerContent = ({ bodyText, isFormDisabled = false }) => {
6786
6780
  const { displayFormat, label, isRequired, labelOrientation, minDate, maxDate, isDisabled, showMonthYearSelect, } = bodyText;
6781
+ const [startDate, setStartDate] = useState(null);
6782
+ const [endDate, setEndDate] = useState(null);
6787
6783
  const chatbotContext = useSelector((state) => state.smartBotReducer.chatbotContext);
6788
- const persistedFormValues = useSelector((state) => state.smartBotReducer.persistedFormValues);
6789
6784
  const dispatch = useDispatch();
6790
- const [startDate, setStartDate] = useState(persistedFormValues[formKey]?.startDate || null);
6791
- const [endDate, setEndDate] = useState(persistedFormValues[formKey]?.endDate || null);
6792
6785
  if (isEmpty$1(bodyText))
6793
6786
  return null;
6794
6787
  const handleDatesChange = (start, end) => {
@@ -6804,7 +6797,6 @@ const DateRangePickerContent = ({ bodyText, isFormDisabled = false, messageIndex
6804
6797
  updated: true,
6805
6798
  };
6806
6799
  dispatch(setChatbotContext(chatbotContext));
6807
- dispatch(setPersistedFormValues({ [formKey]: { startDate: start, endDate: end } }));
6808
6800
  }
6809
6801
  catch (error) {
6810
6802
  console.error("Error in dateRangePicker handleDatesChange", error);
@@ -6820,13 +6812,11 @@ const DateRangePickerContent = ({ bodyText, isFormDisabled = false, messageIndex
6820
6812
  } }) }));
6821
6813
  };
6822
6814
 
6823
- const CheckboxContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
6824
- const formKey = `${messageIndex}_${bodyText?.paramName}`;
6815
+ const CheckboxContent = ({ bodyText, isFormDisabled = false }) => {
6825
6816
  const { label, checked: checkedValue, required, disabled, } = bodyText;
6826
6817
  const chatbotContext = useSelector((state) => state.smartBotReducer.chatbotContext);
6827
- const persistedFormValues = useSelector((state) => state.smartBotReducer.persistedFormValues);
6828
6818
  const dispatch = useDispatch();
6829
- const [checked, setChecked] = useState(persistedFormValues[formKey] !== undefined ? persistedFormValues[formKey] : checkedValue);
6819
+ const [checked, setChecked] = useState(checkedValue);
6830
6820
  if (isEmpty$1(bodyText))
6831
6821
  return null;
6832
6822
  const handleChange = (isChecked) => {
@@ -6843,7 +6833,6 @@ const CheckboxContent = ({ bodyText, isFormDisabled = false, messageIndex }) =>
6843
6833
  updated: true
6844
6834
  };
6845
6835
  dispatch(setChatbotContext(chatbotContext));
6846
- dispatch(setPersistedFormValues({ [formKey]: isChecked?.currentTarget?.checked }));
6847
6836
  }
6848
6837
  catch (error) {
6849
6838
  console.error("Error in checkbox handleChange", error);
@@ -6852,14 +6841,12 @@ const CheckboxContent = ({ bodyText, isFormDisabled = false, messageIndex }) =>
6852
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" }) }));
6853
6842
  };
6854
6843
 
6855
- const RadioContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
6856
- const formKey = `${messageIndex}_${bodyText?.paramName}`;
6844
+ const RadioContent = ({ bodyText, isFormDisabled = false }) => {
6857
6845
  const classes = useStyles$6();
6858
6846
  const { label, isDisabled, orientation, options } = bodyText;
6859
6847
  const chatbotContext = useSelector((state) => state.smartBotReducer.chatbotContext);
6860
- const persistedFormValues = useSelector((state) => state.smartBotReducer.persistedFormValues);
6861
6848
  const dispatch = useDispatch();
6862
- const [selectedOption, setSelectedOption] = useState(persistedFormValues[formKey] ?? null);
6849
+ const [selectedOption, setSelectedOption] = useState(null);
6863
6850
  if (isEmpty$1(bodyText))
6864
6851
  return null;
6865
6852
  const handleChange = (selectedOption) => {
@@ -6877,7 +6864,6 @@ const RadioContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
6877
6864
  updated: true
6878
6865
  };
6879
6866
  dispatch(setChatbotContext(chatbotContext));
6880
- dispatch(setPersistedFormValues({ [formKey]: value }));
6881
6867
  }
6882
6868
  catch (error) {
6883
6869
  console.error("Error in radio handleChange", error);
@@ -6886,13 +6872,11 @@ const RadioContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
6886
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 })] }));
6887
6873
  };
6888
6874
 
6889
- const InputContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
6890
- const formKey = `${messageIndex}_${bodyText?.paramName}`;
6875
+ const InputContent = ({ bodyText, isFormDisabled = false }) => {
6891
6876
  const { label, placeholder, isRequired, isDisabled, inputType, labelOrientation, defaultValue, maxLength, minLength, } = bodyText;
6892
6877
  const chatbotContext = useSelector((state) => state.smartBotReducer.chatbotContext);
6893
- const persistedFormValues = useSelector((state) => state.smartBotReducer.persistedFormValues);
6894
6878
  const dispatch = useDispatch();
6895
- const [value, setValue] = useState(persistedFormValues[formKey] !== undefined ? persistedFormValues[formKey] : (defaultValue || ""));
6879
+ const [value, setValue] = useState(defaultValue || "");
6896
6880
  if (isEmpty$1(bodyText))
6897
6881
  return null;
6898
6882
  const handleChange = (event) => {
@@ -6906,7 +6890,6 @@ const InputContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
6906
6890
  type: inputType,
6907
6891
  };
6908
6892
  dispatch(setChatbotContext(chatbotContext));
6909
- dispatch(setPersistedFormValues({ [formKey]: newValue }));
6910
6893
  }
6911
6894
  catch (error) {
6912
6895
  console.error("Error in input handleChange", error);
@@ -7161,21 +7144,21 @@ const CombinedContent = ({ botData, props }) => {
7161
7144
  case "graph":
7162
7145
  return jsx(GraphContent, { bodyText: parsedData.bodyText }, key);
7163
7146
  case "slider":
7164
- return jsx(SliderContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled, messageIndex: botData.messageIndex }, key);
7147
+ return jsx(SliderContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
7165
7148
  case "select":
7166
- return jsx(SelectContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled, messageIndex: botData.messageIndex }, key);
7149
+ return jsx(SelectContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
7167
7150
  case "datePicker":
7168
- return jsx(DatePickerContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled, messageIndex: botData.messageIndex }, key);
7151
+ return jsx(DatePickerContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
7169
7152
  case "dateRangePicker":
7170
- return jsx(DateRangePickerContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled, messageIndex: botData.messageIndex }, key);
7153
+ return jsx(DateRangePickerContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
7171
7154
  case "checkbox":
7172
- return jsx(CheckboxContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled, messageIndex: botData.messageIndex }, key);
7155
+ return jsx(CheckboxContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
7173
7156
  case "radio":
7174
- return jsx(RadioContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled, messageIndex: botData.messageIndex }, key);
7157
+ return jsx(RadioContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
7175
7158
  case "button":
7176
7159
  return jsx(ButtonContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
7177
7160
  case "input":
7178
- return jsx(InputContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled, messageIndex: botData.messageIndex }, key);
7161
+ return jsx(InputContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
7179
7162
  case "image":
7180
7163
  return jsx(ImageContent, { bodyText: parsedData.bodyText }, key);
7181
7164
  default:
@@ -7257,21 +7240,21 @@ const BotMessage = ({ botData, state, handleLikeDislike, props }) => {
7257
7240
  case "graph":
7258
7241
  return jsx(GraphContent, { bodyText: botData.bodyText });
7259
7242
  case "slider":
7260
- return jsx(SliderContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled, messageIndex: botData.messageIndex });
7243
+ return jsx(SliderContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled });
7261
7244
  case "select":
7262
- return jsx(SelectContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled, messageIndex: botData.messageIndex });
7245
+ return jsx(SelectContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled });
7263
7246
  case "datePicker":
7264
- return jsx(DatePickerContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled, messageIndex: botData.messageIndex });
7247
+ return jsx(DatePickerContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled });
7265
7248
  case "dateRangePicker":
7266
- return jsx(DateRangePickerContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled, messageIndex: botData.messageIndex });
7249
+ return jsx(DateRangePickerContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled });
7267
7250
  case "checkbox":
7268
- return jsx(CheckboxContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled, messageIndex: botData.messageIndex });
7251
+ return jsx(CheckboxContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled });
7269
7252
  case "radio":
7270
- return jsx(RadioContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled, messageIndex: botData.messageIndex });
7253
+ return jsx(RadioContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled });
7271
7254
  case "button":
7272
7255
  return jsx(ButtonContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled });
7273
7256
  case "input":
7274
- return jsx(InputContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled, messageIndex: botData.messageIndex });
7257
+ return jsx(InputContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled });
7275
7258
  case "image":
7276
7259
  return jsx(ImageContent, { bodyText: botData.bodyText });
7277
7260
  case "combined":
@@ -10779,7 +10762,6 @@ const SmartBot = (props) => {
10779
10762
  // />
10780
10763
  // ;
10781
10764
  message.isFormDisabled = index !== lastBotMessageIndex;
10782
- message.messageIndex = index;
10783
10765
  let originalUtilityObject = message.utilityObject;
10784
10766
  let newMessage = cloneDeep(message);
10785
10767
  if (originalUtilityObject) {