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.
@@ -1,6 +1,5 @@
1
- declare const CheckboxContent: ({ bodyText, isFormDisabled, messageIndex }: {
1
+ declare const CheckboxContent: ({ bodyText, isFormDisabled }: {
2
2
  bodyText: any;
3
3
  isFormDisabled?: boolean;
4
- messageIndex: any;
5
4
  }) => import("react/jsx-runtime").JSX.Element;
6
5
  export default CheckboxContent;
@@ -1,6 +1,5 @@
1
- declare const DatePickerContent: ({ bodyText, isFormDisabled, messageIndex }: {
1
+ declare const DatePickerContent: ({ bodyText, isFormDisabled }: {
2
2
  bodyText: any;
3
3
  isFormDisabled?: boolean;
4
- messageIndex: any;
5
4
  }) => import("react/jsx-runtime").JSX.Element;
6
5
  export default DatePickerContent;
@@ -1,6 +1,5 @@
1
- declare const DateRangePickerContent: ({ bodyText, isFormDisabled, messageIndex }: {
1
+ declare const DateRangePickerContent: ({ bodyText, isFormDisabled }: {
2
2
  bodyText: any;
3
3
  isFormDisabled?: boolean;
4
- messageIndex: any;
5
4
  }) => import("react/jsx-runtime").JSX.Element;
6
5
  export default DateRangePickerContent;
@@ -1,6 +1,5 @@
1
- declare const InputContent: ({ bodyText, isFormDisabled, messageIndex }: {
1
+ declare const InputContent: ({ bodyText, isFormDisabled }: {
2
2
  bodyText: any;
3
3
  isFormDisabled?: boolean;
4
- messageIndex: any;
5
4
  }) => import("react/jsx-runtime").JSX.Element;
6
5
  export default InputContent;
@@ -1,6 +1,5 @@
1
- declare const RadioContent: ({ bodyText, isFormDisabled, messageIndex }: {
1
+ declare const RadioContent: ({ bodyText, isFormDisabled }: {
2
2
  bodyText: any;
3
3
  isFormDisabled?: boolean;
4
- messageIndex: any;
5
4
  }) => import("react/jsx-runtime").JSX.Element;
6
5
  export default RadioContent;
@@ -1,6 +1,5 @@
1
- declare const SelectContent: ({ bodyText, isFormDisabled, messageIndex }: {
1
+ declare const SelectContent: ({ bodyText, isFormDisabled }: {
2
2
  bodyText: any;
3
3
  isFormDisabled?: boolean;
4
- messageIndex: any;
5
4
  }) => import("react/jsx-runtime").JSX.Element;
6
5
  export default SelectContent;
@@ -1,6 +1,5 @@
1
- declare const SliderContent: ({ bodyText, isFormDisabled, messageIndex }: {
1
+ declare const SliderContent: ({ bodyText, isFormDisabled }: {
2
2
  bodyText: any;
3
3
  isFormDisabled?: boolean;
4
- messageIndex: any;
5
4
  }) => import("react/jsx-runtime").JSX.Element;
6
5
  export default SliderContent;
package/dist/index.cjs.js CHANGED
@@ -6691,13 +6691,11 @@ const StreamedContent = ({ botData }) => {
6691
6691
  return renderContent();
6692
6692
  };
6693
6693
 
6694
- const SliderContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
6695
- const formKey = `${messageIndex}_${bodyText?.paramName}`;
6694
+ const SliderContent = ({ bodyText, isFormDisabled = false }) => {
6696
6695
  const { header, headerOrentiation, inputPosition, label, max, min, required, disabled, } = bodyText;
6696
+ const [sliderValue, setSliderValue] = React.useState(0);
6697
6697
  const chatbotContext = reactRedux.useSelector((state) => state.smartBotReducer.chatbotContext);
6698
- const persistedFormValues = reactRedux.useSelector((state) => state.smartBotReducer.persistedFormValues);
6699
6698
  const dispatch = reactRedux.useDispatch();
6700
- const [sliderValue, setSliderValue] = React.useState(persistedFormValues[formKey] !== undefined ? persistedFormValues[formKey] : 0);
6701
6699
  if (!bodyText)
6702
6700
  return null;
6703
6701
  const handleChange = (value) => {
@@ -6709,7 +6707,6 @@ const SliderContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
6709
6707
  updated: true
6710
6708
  };
6711
6709
  dispatch(smartBotActions.setChatbotContext(chatbotContext));
6712
- dispatch(smartBotActions.setPersistedFormValues({ [formKey]: value?.target?.value }));
6713
6710
  }
6714
6711
  catch (error) {
6715
6712
  console.error("Error in slider handleChange", error);
@@ -6718,13 +6715,11 @@ const SliderContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
6718
6715
  return (jsxRuntime.jsx("div", { style: { width: "100%", marginTop: "10px" }, children: jsxRuntime.jsx(impactUiV3.Slider, { header: header, headerOrientation: headerOrentiation, inputPosition: inputPosition, label: label, max: max, min: min, required: required, disabled: disabled || isFormDisabled, onChange: (e) => handleChange(e), value: sliderValue }) }));
6719
6716
  };
6720
6717
 
6721
- const SelectContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
6722
- const formKey = `${messageIndex}_${bodyText?.paramName}`;
6718
+ const SelectContent = ({ bodyText, isFormDisabled = false }) => {
6723
6719
  const { header, inputPosition, labelOrientation, label, options, isRequired, isDisabled, isMulti, paramName } = bodyText;
6724
6720
  const [isOpen, setIsOpen] = React.useState(false);
6725
6721
  const [currentOptions, setCurrentOptions] = React.useState([]);
6726
- const persistedFormValues = reactRedux.useSelector((state) => state.smartBotReducer.persistedFormValues);
6727
- const [currentSelectedOptions, setCurrentSelectedOptions] = React.useState(persistedFormValues?.[formKey] || []);
6722
+ const [currentSelectedOptions, setCurrentSelectedOptions] = React.useState([]);
6728
6723
  const [isAllSelected, setIsAllSelected] = React.useState(false);
6729
6724
  const [initialOptions, setInitialOptions] = React.useState([]);
6730
6725
  const chatbotContext = reactRedux.useSelector((state) => state.smartBotReducer.chatbotContext);
@@ -6752,7 +6747,6 @@ const SelectContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
6752
6747
  // updated: true
6753
6748
  // };
6754
6749
  dispatch(smartBotActions.setChatbotContext(chatbotContext));
6755
- dispatch(smartBotActions.setPersistedFormValues({ [formKey]: Array.isArray(selectedOptions) ? selectedOptions : [selectedOptions] }));
6756
6750
  }
6757
6751
  catch (error) {
6758
6752
  console.error("Error in select handleChange", error);
@@ -6774,13 +6768,11 @@ const SelectContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
6774
6768
  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 }) }));
6775
6769
  };
6776
6770
 
6777
- const DatePickerContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
6778
- const formKey = `${messageIndex}_${bodyText?.paramName}`;
6771
+ const DatePickerContent = ({ bodyText, isFormDisabled = false }) => {
6779
6772
  const { displayFormat, label, isRequired, labelOrientation, placeholder, minDate, maxDate, isDisabled, } = bodyText;
6773
+ const [selectedDate, setSelectedDate] = React.useState(null);
6780
6774
  const chatbotContext = reactRedux.useSelector((state) => state.smartBotReducer.chatbotContext);
6781
- const persistedFormValues = reactRedux.useSelector((state) => state.smartBotReducer.persistedFormValues);
6782
6775
  const dispatch = reactRedux.useDispatch();
6783
- const [selectedDate, setSelectedDate] = React.useState(persistedFormValues[formKey] || null);
6784
6776
  if (lodash.isEmpty(bodyText))
6785
6777
  return null;
6786
6778
  const handleDateChange = (date) => {
@@ -6792,7 +6784,6 @@ const DatePickerContent = ({ bodyText, isFormDisabled = false, messageIndex }) =
6792
6784
  updated: true
6793
6785
  };
6794
6786
  dispatch(smartBotActions.setChatbotContext(chatbotContext));
6795
- dispatch(smartBotActions.setPersistedFormValues({ [formKey]: date }));
6796
6787
  }
6797
6788
  catch (error) {
6798
6789
  console.error("Error in datepicker handleChange", error);
@@ -6807,14 +6798,12 @@ const DatePickerContent = ({ bodyText, isFormDisabled = false, messageIndex }) =
6807
6798
  selectedDate: selectedDate }) }));
6808
6799
  };
6809
6800
 
6810
- const DateRangePickerContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
6811
- const formKey = `${messageIndex}_${bodyText?.paramName}`;
6801
+ const DateRangePickerContent = ({ bodyText, isFormDisabled = false }) => {
6812
6802
  const { displayFormat, label, isRequired, labelOrientation, minDate, maxDate, isDisabled, showMonthYearSelect, } = bodyText;
6803
+ const [startDate, setStartDate] = React.useState(null);
6804
+ const [endDate, setEndDate] = React.useState(null);
6813
6805
  const chatbotContext = reactRedux.useSelector((state) => state.smartBotReducer.chatbotContext);
6814
- const persistedFormValues = reactRedux.useSelector((state) => state.smartBotReducer.persistedFormValues);
6815
6806
  const dispatch = reactRedux.useDispatch();
6816
- const [startDate, setStartDate] = React.useState(persistedFormValues[formKey]?.startDate || null);
6817
- const [endDate, setEndDate] = React.useState(persistedFormValues[formKey]?.endDate || null);
6818
6807
  if (lodash.isEmpty(bodyText))
6819
6808
  return null;
6820
6809
  const handleDatesChange = (start, end) => {
@@ -6830,7 +6819,6 @@ const DateRangePickerContent = ({ bodyText, isFormDisabled = false, messageIndex
6830
6819
  updated: true,
6831
6820
  };
6832
6821
  dispatch(smartBotActions.setChatbotContext(chatbotContext));
6833
- dispatch(smartBotActions.setPersistedFormValues({ [formKey]: { startDate: start, endDate: end } }));
6834
6822
  }
6835
6823
  catch (error) {
6836
6824
  console.error("Error in dateRangePicker handleDatesChange", error);
@@ -6846,13 +6834,11 @@ const DateRangePickerContent = ({ bodyText, isFormDisabled = false, messageIndex
6846
6834
  } }) }));
6847
6835
  };
6848
6836
 
6849
- const CheckboxContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
6850
- const formKey = `${messageIndex}_${bodyText?.paramName}`;
6837
+ const CheckboxContent = ({ bodyText, isFormDisabled = false }) => {
6851
6838
  const { label, checked: checkedValue, required, disabled, } = bodyText;
6852
6839
  const chatbotContext = reactRedux.useSelector((state) => state.smartBotReducer.chatbotContext);
6853
- const persistedFormValues = reactRedux.useSelector((state) => state.smartBotReducer.persistedFormValues);
6854
6840
  const dispatch = reactRedux.useDispatch();
6855
- const [checked, setChecked] = React.useState(persistedFormValues[formKey] !== undefined ? persistedFormValues[formKey] : checkedValue);
6841
+ const [checked, setChecked] = React.useState(checkedValue);
6856
6842
  if (lodash.isEmpty(bodyText))
6857
6843
  return null;
6858
6844
  const handleChange = (isChecked) => {
@@ -6869,7 +6855,6 @@ const CheckboxContent = ({ bodyText, isFormDisabled = false, messageIndex }) =>
6869
6855
  updated: true
6870
6856
  };
6871
6857
  dispatch(smartBotActions.setChatbotContext(chatbotContext));
6872
- dispatch(smartBotActions.setPersistedFormValues({ [formKey]: isChecked?.currentTarget?.checked }));
6873
6858
  }
6874
6859
  catch (error) {
6875
6860
  console.error("Error in checkbox handleChange", error);
@@ -6878,14 +6863,12 @@ const CheckboxContent = ({ bodyText, isFormDisabled = false, messageIndex }) =>
6878
6863
  return (jsxRuntime.jsx("div", { style: { width: '100%', marginTop: '10px' }, children: jsxRuntime.jsx(impactUiV3.Checkbox, { label: label, checked: checked, required: required, disabled: disabled || isFormDisabled, onChange: (e) => handleChange(e), variant: "default" }) }));
6879
6864
  };
6880
6865
 
6881
- const RadioContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
6882
- const formKey = `${messageIndex}_${bodyText?.paramName}`;
6866
+ const RadioContent = ({ bodyText, isFormDisabled = false }) => {
6883
6867
  const classes = useStyles$6();
6884
6868
  const { label, isDisabled, orientation, options } = bodyText;
6885
6869
  const chatbotContext = reactRedux.useSelector((state) => state.smartBotReducer.chatbotContext);
6886
- const persistedFormValues = reactRedux.useSelector((state) => state.smartBotReducer.persistedFormValues);
6887
6870
  const dispatch = reactRedux.useDispatch();
6888
- const [selectedOption, setSelectedOption] = React.useState(persistedFormValues[formKey] ?? null);
6871
+ const [selectedOption, setSelectedOption] = React.useState(null);
6889
6872
  if (lodash.isEmpty(bodyText))
6890
6873
  return null;
6891
6874
  const handleChange = (selectedOption) => {
@@ -6903,7 +6886,6 @@ const RadioContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
6903
6886
  updated: true
6904
6887
  };
6905
6888
  dispatch(smartBotActions.setChatbotContext(chatbotContext));
6906
- dispatch(smartBotActions.setPersistedFormValues({ [formKey]: value }));
6907
6889
  }
6908
6890
  catch (error) {
6909
6891
  console.error("Error in radio handleChange", error);
@@ -6912,13 +6894,11 @@ const RadioContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
6912
6894
  return (jsxRuntime.jsxs("div", { style: { width: "100%", marginTop: "10px" }, children: [bodyText?.label && jsxRuntime.jsx("p", { className: classes.radioGrpLabel, children: bodyText.label }), jsxRuntime.jsx(impactUiV3.RadioButtonGroup, { name: "radio-group", options: options, onChange: (e) => handleChange(e), orientation: orientation, isDisabled: isDisabled || isFormDisabled, selectedOption: selectedOption })] }));
6913
6895
  };
6914
6896
 
6915
- const InputContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
6916
- const formKey = `${messageIndex}_${bodyText?.paramName}`;
6897
+ const InputContent = ({ bodyText, isFormDisabled = false }) => {
6917
6898
  const { label, placeholder, isRequired, isDisabled, inputType, labelOrientation, defaultValue, maxLength, minLength, } = bodyText;
6918
6899
  const chatbotContext = reactRedux.useSelector((state) => state.smartBotReducer.chatbotContext);
6919
- const persistedFormValues = reactRedux.useSelector((state) => state.smartBotReducer.persistedFormValues);
6920
6900
  const dispatch = reactRedux.useDispatch();
6921
- const [value, setValue] = React.useState(persistedFormValues[formKey] !== undefined ? persistedFormValues[formKey] : (defaultValue || ""));
6901
+ const [value, setValue] = React.useState(defaultValue || "");
6922
6902
  if (lodash.isEmpty(bodyText))
6923
6903
  return null;
6924
6904
  const handleChange = (event) => {
@@ -6932,7 +6912,6 @@ const InputContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
6932
6912
  type: inputType,
6933
6913
  };
6934
6914
  dispatch(smartBotActions.setChatbotContext(chatbotContext));
6935
- dispatch(smartBotActions.setPersistedFormValues({ [formKey]: newValue }));
6936
6915
  }
6937
6916
  catch (error) {
6938
6917
  console.error("Error in input handleChange", error);
@@ -7187,21 +7166,21 @@ const CombinedContent = ({ botData, props }) => {
7187
7166
  case "graph":
7188
7167
  return jsxRuntime.jsx(GraphContent, { bodyText: parsedData.bodyText }, key);
7189
7168
  case "slider":
7190
- return jsxRuntime.jsx(SliderContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled, messageIndex: botData.messageIndex }, key);
7169
+ return jsxRuntime.jsx(SliderContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
7191
7170
  case "select":
7192
- return jsxRuntime.jsx(SelectContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled, messageIndex: botData.messageIndex }, key);
7171
+ return jsxRuntime.jsx(SelectContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
7193
7172
  case "datePicker":
7194
- return jsxRuntime.jsx(DatePickerContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled, messageIndex: botData.messageIndex }, key);
7173
+ return jsxRuntime.jsx(DatePickerContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
7195
7174
  case "dateRangePicker":
7196
- return jsxRuntime.jsx(DateRangePickerContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled, messageIndex: botData.messageIndex }, key);
7175
+ return jsxRuntime.jsx(DateRangePickerContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
7197
7176
  case "checkbox":
7198
- return jsxRuntime.jsx(CheckboxContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled, messageIndex: botData.messageIndex }, key);
7177
+ return jsxRuntime.jsx(CheckboxContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
7199
7178
  case "radio":
7200
- return jsxRuntime.jsx(RadioContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled, messageIndex: botData.messageIndex }, key);
7179
+ return jsxRuntime.jsx(RadioContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
7201
7180
  case "button":
7202
7181
  return jsxRuntime.jsx(ButtonContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
7203
7182
  case "input":
7204
- return jsxRuntime.jsx(InputContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled, messageIndex: botData.messageIndex }, key);
7183
+ return jsxRuntime.jsx(InputContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
7205
7184
  case "image":
7206
7185
  return jsxRuntime.jsx(ImageContent, { bodyText: parsedData.bodyText }, key);
7207
7186
  default:
@@ -7283,21 +7262,21 @@ const BotMessage = ({ botData, state, handleLikeDislike, props }) => {
7283
7262
  case "graph":
7284
7263
  return jsxRuntime.jsx(GraphContent, { bodyText: botData.bodyText });
7285
7264
  case "slider":
7286
- return jsxRuntime.jsx(SliderContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled, messageIndex: botData.messageIndex });
7265
+ return jsxRuntime.jsx(SliderContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled });
7287
7266
  case "select":
7288
- return jsxRuntime.jsx(SelectContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled, messageIndex: botData.messageIndex });
7267
+ return jsxRuntime.jsx(SelectContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled });
7289
7268
  case "datePicker":
7290
- return jsxRuntime.jsx(DatePickerContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled, messageIndex: botData.messageIndex });
7269
+ return jsxRuntime.jsx(DatePickerContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled });
7291
7270
  case "dateRangePicker":
7292
- return jsxRuntime.jsx(DateRangePickerContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled, messageIndex: botData.messageIndex });
7271
+ return jsxRuntime.jsx(DateRangePickerContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled });
7293
7272
  case "checkbox":
7294
- return jsxRuntime.jsx(CheckboxContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled, messageIndex: botData.messageIndex });
7273
+ return jsxRuntime.jsx(CheckboxContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled });
7295
7274
  case "radio":
7296
- return jsxRuntime.jsx(RadioContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled, messageIndex: botData.messageIndex });
7275
+ return jsxRuntime.jsx(RadioContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled });
7297
7276
  case "button":
7298
7277
  return jsxRuntime.jsx(ButtonContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled });
7299
7278
  case "input":
7300
- return jsxRuntime.jsx(InputContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled, messageIndex: botData.messageIndex });
7279
+ return jsxRuntime.jsx(InputContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled });
7301
7280
  case "image":
7302
7281
  return jsxRuntime.jsx(ImageContent, { bodyText: botData.bodyText });
7303
7282
  case "combined":
@@ -10805,7 +10784,6 @@ const SmartBot = (props) => {
10805
10784
  // />
10806
10785
  // ;
10807
10786
  message.isFormDisabled = index !== lastBotMessageIndex;
10808
- message.messageIndex = index;
10809
10787
  let originalUtilityObject = message.utilityObject;
10810
10788
  let newMessage = lodash.cloneDeep(message);
10811
10789
  if (originalUtilityObject) {