impact-chatbot 2.3.18 → 2.3.19

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
@@ -4867,7 +4867,7 @@ const useStyles$4 = makeStyles((theme) => ({
4867
4867
  marginTop: pxToRem(16),
4868
4868
  }
4869
4869
  }));
4870
- const ButtonContent = ({ bodyText }) => {
4870
+ const ButtonContent = ({ bodyText, isFormDisabled = false }) => {
4871
4871
  const classes = useStyles$4();
4872
4872
  const handleButtonClick = (button) => {
4873
4873
  // if (button.onClick) {
@@ -4884,7 +4884,7 @@ const ButtonContent = ({ bodyText }) => {
4884
4884
  if (!Array.isArray(bodyText.buttons)) {
4885
4885
  return null;
4886
4886
  }
4887
- return bodyText.buttons.map((button, index) => (jsx(Button, { variant: button.variant || "primary", size: button.size || "medium", onClick: () => handleButtonClick(), disabled: button.disabled, className: button.className, icon: button.icon, iconPlacement: button.iconPlacement || "left", children: button.label }, index)));
4887
+ return bodyText.buttons.map((button, index) => (jsx(Button, { variant: button.variant || "primary", size: button.size || "medium", onClick: () => handleButtonClick(), disabled: button.disabled || isFormDisabled, className: button.className, icon: button.icon, iconPlacement: button.iconPlacement || "left", children: button.label }, index)));
4888
4888
  };
4889
4889
  return (jsxs("div", { className: classes.buttonContainer, children: [bodyText.message && (jsx("div", { className: classes.message, children: bodyText.message })), jsx("div", { className: classes.buttonRow, children: renderButtons() })] }));
4890
4890
  };
@@ -6635,7 +6635,7 @@ const StreamedContent = ({ botData }) => {
6635
6635
  return renderContent();
6636
6636
  };
6637
6637
 
6638
- const SliderContent = ({ bodyText }) => {
6638
+ const SliderContent = ({ bodyText, isFormDisabled = false }) => {
6639
6639
  const { header, headerOrentiation, inputPosition, label, max, min, required, disabled, } = bodyText;
6640
6640
  const [sliderValue, setSliderValue] = useState(0);
6641
6641
  const chatbotContext = useSelector((state) => state.smartBotReducer.chatbotContext);
@@ -6656,10 +6656,10 @@ const SliderContent = ({ bodyText }) => {
6656
6656
  console.error("Error in slider handleChange", error);
6657
6657
  }
6658
6658
  };
6659
- 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, onChange: (e) => handleChange(e), value: sliderValue }) }));
6659
+ 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 }) }));
6660
6660
  };
6661
6661
 
6662
- const SelectContent = ({ bodyText }) => {
6662
+ const SelectContent = ({ bodyText, isFormDisabled = false }) => {
6663
6663
  const { header, inputPosition, labelOrientation, label, options, isRequired, isDisabled, isMulti, paramName } = bodyText;
6664
6664
  const [isOpen, setIsOpen] = useState(false);
6665
6665
  const [currentOptions, setCurrentOptions] = useState([]);
@@ -6709,10 +6709,10 @@ const SelectContent = ({ bodyText }) => {
6709
6709
  return (jsx("div", { style: { width: "100%", marginTop: "10px" }, children: jsx(Select, { currentOptions: currentOptions, setCurrentOptions: setCurrentOptions, label: heirarchyKeyValuePairs[paramName] || label, labelOrientation: labelOrientation,
6710
6710
  // inputPosition={inputPosition}
6711
6711
  // header={header}
6712
- isRequired: isRequired, isDisabled: isDisabled, 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 }) }));
6712
+ 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 }) }));
6713
6713
  };
6714
6714
 
6715
- const DatePickerContent = ({ bodyText }) => {
6715
+ const DatePickerContent = ({ bodyText, isFormDisabled = false }) => {
6716
6716
  const { displayFormat, label, isRequired, labelOrientation, placeholder, minDate, maxDate, isDisabled, } = bodyText;
6717
6717
  const [selectedDate, setSelectedDate] = useState(null);
6718
6718
  const chatbotContext = useSelector((state) => state.smartBotReducer.chatbotContext);
@@ -6736,13 +6736,13 @@ const DatePickerContent = ({ bodyText }) => {
6736
6736
  return (jsx("div", { style: { width: "100%", marginTop: "10px" }, children: jsx(DatePicker, { displayFormat: displayFormat, label: label, required: isRequired, labelOrientation: labelOrientation, placeholder: placeholder,
6737
6737
  // minDate={minDate}
6738
6738
  // maxDate={maxDate}
6739
- disabled: isDisabled, setSelectedDate: (date) => handleDateChange(date),
6739
+ isDisabled: isDisabled || isFormDisabled, setSelectedDate: (date) => handleDateChange(date),
6740
6740
  // showMonthYearSelect
6741
6741
  // showWeekNumbers
6742
6742
  selectedDate: selectedDate }) }));
6743
6743
  };
6744
6744
 
6745
- const DateRangePickerContent = ({ bodyText }) => {
6745
+ const DateRangePickerContent = ({ bodyText, isFormDisabled = false }) => {
6746
6746
  const { displayFormat, label, isRequired, labelOrientation, minDate, maxDate, isDisabled, showMonthYearSelect, } = bodyText;
6747
6747
  const [startDate, setStartDate] = useState(null);
6748
6748
  const [endDate, setEndDate] = useState(null);
@@ -6768,7 +6768,7 @@ const DateRangePickerContent = ({ bodyText }) => {
6768
6768
  console.error("Error in dateRangePicker handleDatesChange", error);
6769
6769
  }
6770
6770
  };
6771
- return (jsx("div", { style: { width: "100%", marginTop: "10px" }, children: jsx(DateRangePicker, { displayFormat: displayFormat, label: label, isRequired: isRequired, labelOrientation: labelOrientation || "top", minDate: minDate, maxDate: maxDate, isDisabled: isDisabled, startDate: startDate, setStartDate: setStartDate, endDate: endDate, setEndDate: setEndDate, showMonthYearSelect: showMonthYearSelect, handleDatesChange: handleDatesChange, onPrimaryButtonClick: () => handleDatesChange(startDate, endDate), onSecondaryButtonClick: () => {
6771
+ return (jsx("div", { style: { width: "100%", marginTop: "10px" }, children: jsx(DateRangePicker, { displayFormat: displayFormat, label: label, isRequired: isRequired, labelOrientation: labelOrientation || "top", minDate: minDate, maxDate: maxDate, isDisabled: isDisabled || isFormDisabled, startDate: startDate, setStartDate: setStartDate, endDate: endDate, setEndDate: setEndDate, showMonthYearSelect: showMonthYearSelect, handleDatesChange: handleDatesChange, onPrimaryButtonClick: () => handleDatesChange(startDate, endDate), onSecondaryButtonClick: () => {
6772
6772
  setStartDate(null);
6773
6773
  setEndDate(null);
6774
6774
  }, onResetClick: () => {
@@ -6778,7 +6778,7 @@ const DateRangePickerContent = ({ bodyText }) => {
6778
6778
  } }) }));
6779
6779
  };
6780
6780
 
6781
- const CheckboxContent = ({ bodyText }) => {
6781
+ const CheckboxContent = ({ bodyText, isFormDisabled = false }) => {
6782
6782
  const { label, checked: checkedValue, required, disabled, } = bodyText;
6783
6783
  const chatbotContext = useSelector((state) => state.smartBotReducer.chatbotContext);
6784
6784
  const dispatch = useDispatch();
@@ -6804,10 +6804,10 @@ const CheckboxContent = ({ bodyText }) => {
6804
6804
  console.error("Error in checkbox handleChange", error);
6805
6805
  }
6806
6806
  };
6807
- return (jsx("div", { style: { width: '100%', marginTop: '10px' }, children: jsx(Checkbox, { label: label, checked: checked, required: required, disabled: disabled, onChange: (e) => handleChange(e), variant: "default" }) }));
6807
+ 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" }) }));
6808
6808
  };
6809
6809
 
6810
- const RadioContent = ({ bodyText }) => {
6810
+ const RadioContent = ({ bodyText, isFormDisabled = false }) => {
6811
6811
  const classes = useStyles$6();
6812
6812
  const { label, isDisabled, orientation, options } = bodyText;
6813
6813
  const chatbotContext = useSelector((state) => state.smartBotReducer.chatbotContext);
@@ -6835,10 +6835,10 @@ const RadioContent = ({ bodyText }) => {
6835
6835
  console.error("Error in radio handleChange", error);
6836
6836
  }
6837
6837
  };
6838
- 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, disabled: isDisabled, selectedOption: selectedOption })] }));
6838
+ 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 })] }));
6839
6839
  };
6840
6840
 
6841
- const InputContent = ({ bodyText }) => {
6841
+ const InputContent = ({ bodyText, isFormDisabled = false }) => {
6842
6842
  const { label, placeholder, isRequired, isDisabled, inputType, labelOrientation, defaultValue, maxLength, minLength, } = bodyText;
6843
6843
  const chatbotContext = useSelector((state) => state.smartBotReducer.chatbotContext);
6844
6844
  const dispatch = useDispatch();
@@ -6861,7 +6861,7 @@ const InputContent = ({ bodyText }) => {
6861
6861
  console.error("Error in input handleChange", error);
6862
6862
  }
6863
6863
  };
6864
- return (jsx("div", { style: { width: '100%', marginTop: '10px' }, children: jsx(Input, { label: label, placeholder: placeholder, value: value, onChange: handleChange, required: isRequired, disabled: isDisabled, type: inputType || "text", labelOrientation: labelOrientation, maxLength: maxLength, minLength: minLength }) }));
6864
+ return (jsx("div", { style: { width: '100%', marginTop: '10px' }, children: jsx(Input, { label: label, placeholder: placeholder, value: value, onChange: handleChange, required: isRequired, isDisabled: isDisabled || isFormDisabled, type: inputType || "text", labelOrientation: labelOrientation, maxLength: maxLength, minLength: minLength }) }));
6865
6865
  };
6866
6866
 
6867
6867
  const ImageContent = ({ bodyText }) => {
@@ -7086,6 +7086,7 @@ const TabularContent = ({ steps, currentTabValue, children, questions = [], ques
7086
7086
  };
7087
7087
 
7088
7088
  const CombinedContent = ({ botData, props }) => {
7089
+ const isFormDisabled = botData?.isFormDisabled || false;
7089
7090
  const isTabEnabled = botData?.utilityData?.isTabEnabled;
7090
7091
  // Get the array of content items from bodyText
7091
7092
  const contentItems = Array.isArray(botData.bodyText) ? botData.bodyText : [];
@@ -7109,21 +7110,21 @@ const CombinedContent = ({ botData, props }) => {
7109
7110
  case "graph":
7110
7111
  return jsx(GraphContent, { bodyText: parsedData.bodyText }, key);
7111
7112
  case "slider":
7112
- return jsx(SliderContent, { bodyText: parsedData.bodyText }, key);
7113
+ return jsx(SliderContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
7113
7114
  case "select":
7114
- return jsx(SelectContent, { bodyText: parsedData.bodyText }, key);
7115
+ return jsx(SelectContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
7115
7116
  case "datePicker":
7116
- return jsx(DatePickerContent, { bodyText: parsedData.bodyText }, key);
7117
+ return jsx(DatePickerContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
7117
7118
  case "dateRangePicker":
7118
- return jsx(DateRangePickerContent, { bodyText: parsedData.bodyText }, key);
7119
+ return jsx(DateRangePickerContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
7119
7120
  case "checkbox":
7120
- return jsx(CheckboxContent, { bodyText: parsedData.bodyText }, key);
7121
+ return jsx(CheckboxContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
7121
7122
  case "radio":
7122
- return jsx(RadioContent, { bodyText: parsedData.bodyText }, key);
7123
+ return jsx(RadioContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
7123
7124
  case "button":
7124
- return jsx(ButtonContent, { bodyText: parsedData.bodyText }, key);
7125
+ return jsx(ButtonContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
7125
7126
  case "input":
7126
- return jsx(InputContent, { bodyText: parsedData.bodyText }, key);
7127
+ return jsx(InputContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
7127
7128
  case "image":
7128
7129
  return jsx(ImageContent, { bodyText: parsedData.bodyText }, key);
7129
7130
  default:
@@ -7205,21 +7206,21 @@ const BotMessage = ({ botData, state, handleLikeDislike, props }) => {
7205
7206
  case "graph":
7206
7207
  return jsx(GraphContent, { bodyText: botData.bodyText });
7207
7208
  case "slider":
7208
- return jsx(SliderContent, { bodyText: botData.bodyText });
7209
+ return jsx(SliderContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled });
7209
7210
  case "select":
7210
- return jsx(SelectContent, { bodyText: botData.bodyText });
7211
+ return jsx(SelectContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled });
7211
7212
  case "datePicker":
7212
- return jsx(DatePickerContent, { bodyText: botData.bodyText });
7213
+ return jsx(DatePickerContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled });
7213
7214
  case "dateRangePicker":
7214
- return jsx(DateRangePickerContent, { bodyText: botData.bodyText });
7215
+ return jsx(DateRangePickerContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled });
7215
7216
  case "checkbox":
7216
- return jsx(CheckboxContent, { bodyText: botData.bodyText });
7217
+ return jsx(CheckboxContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled });
7217
7218
  case "radio":
7218
- return jsx(RadioContent, { bodyText: botData.bodyText });
7219
+ return jsx(RadioContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled });
7219
7220
  case "button":
7220
- return jsx(ButtonContent, { bodyText: botData.bodyText });
7221
+ return jsx(ButtonContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled });
7221
7222
  case "input":
7222
- return jsx(InputContent, { bodyText: botData.bodyText });
7223
+ return jsx(InputContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled });
7223
7224
  case "image":
7224
7225
  return jsx(ImageContent, { bodyText: botData.bodyText });
7225
7226
  case "combined":
@@ -10194,7 +10195,9 @@ const SmartBot = (props) => {
10194
10195
  customChatConfig: customChatConfig,
10195
10196
  loader: loader,
10196
10197
  };
10197
- chatDataInfoRef?.current[currentMode]?.conversations?.[1]?.messages.forEach((message, index) => {
10198
+ const allMessages = chatDataInfoRef?.current[currentMode]?.conversations?.[1]?.messages || [];
10199
+ const lastBotMessageIndex = allMessages.reduce((lastIdx, msg, idx) => msg.userType === "bot" ? idx : lastIdx, -1);
10200
+ allMessages.forEach((message, index) => {
10198
10201
  if (message.userType === "bot") {
10199
10202
  // let BotMessageJsx =
10200
10203
  // <BotMessage
@@ -10204,6 +10207,7 @@ const SmartBot = (props) => {
10204
10207
  // props={properties}
10205
10208
  // />
10206
10209
  // ;
10210
+ message.isFormDisabled = index !== lastBotMessageIndex;
10207
10211
  message.jsx = (jsx(BotMessage, { botData: message, state: loadingState, handleLikeDislike: handleLikeDislike, props: properties }));
10208
10212
  message.firstMessage = true;
10209
10213
  // message.enableLikes = true;