impact-chatbot 2.3.17 → 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.
@@ -1,4 +1,5 @@
1
- declare const ButtonContent: ({ bodyText }: {
1
+ declare const ButtonContent: ({ bodyText, isFormDisabled }: {
2
2
  bodyText: any;
3
+ isFormDisabled?: boolean;
3
4
  }) => import("react/jsx-runtime").JSX.Element;
4
5
  export default ButtonContent;
@@ -1,4 +1,5 @@
1
- declare const CheckboxContent: ({ bodyText }: {
1
+ declare const CheckboxContent: ({ bodyText, isFormDisabled }: {
2
2
  bodyText: any;
3
+ isFormDisabled?: boolean;
3
4
  }) => import("react/jsx-runtime").JSX.Element;
4
5
  export default CheckboxContent;
@@ -1,4 +1,5 @@
1
- declare const DatePickerContent: ({ bodyText }: {
1
+ declare const DatePickerContent: ({ bodyText, isFormDisabled }: {
2
2
  bodyText: any;
3
+ isFormDisabled?: boolean;
3
4
  }) => import("react/jsx-runtime").JSX.Element;
4
5
  export default DatePickerContent;
@@ -0,0 +1,5 @@
1
+ declare const DateRangePickerContent: ({ bodyText, isFormDisabled }: {
2
+ bodyText: any;
3
+ isFormDisabled?: boolean;
4
+ }) => import("react/jsx-runtime").JSX.Element;
5
+ export default DateRangePickerContent;
@@ -1,4 +1,5 @@
1
- declare const InputContent: ({ bodyText }: {
1
+ declare const InputContent: ({ bodyText, isFormDisabled }: {
2
2
  bodyText: any;
3
+ isFormDisabled?: boolean;
3
4
  }) => import("react/jsx-runtime").JSX.Element;
4
5
  export default InputContent;
@@ -1,4 +1,5 @@
1
- declare const RadioContent: ({ bodyText }: {
1
+ declare const RadioContent: ({ bodyText, isFormDisabled }: {
2
2
  bodyText: any;
3
+ isFormDisabled?: boolean;
3
4
  }) => import("react/jsx-runtime").JSX.Element;
4
5
  export default RadioContent;
@@ -1,4 +1,5 @@
1
- declare const SelectContent: ({ bodyText }: {
1
+ declare const SelectContent: ({ bodyText, isFormDisabled }: {
2
2
  bodyText: any;
3
+ isFormDisabled?: boolean;
3
4
  }) => import("react/jsx-runtime").JSX.Element;
4
5
  export default SelectContent;
@@ -1,4 +1,5 @@
1
- declare const SliderContent: ({ bodyText }: {
1
+ declare const SliderContent: ({ bodyText, isFormDisabled }: {
2
2
  bodyText: any;
3
+ isFormDisabled?: boolean;
3
4
  }) => import("react/jsx-runtime").JSX.Element;
4
5
  export default SliderContent;
package/dist/index.cjs.js CHANGED
@@ -456,6 +456,26 @@ const parseResponse = (data, type, agentId = "", currentMode = "", disableTimeAn
456
456
  paramName: data?.data?.param_name
457
457
  }
458
458
  };
459
+ case "dateRangePicker":
460
+ return {
461
+ ...data,
462
+ timeStamp: timeString,
463
+ userType: "bot",
464
+ userName: userName,
465
+ headerTitle: data?.data?.label || "",
466
+ bodyType: "dateRangePicker",
467
+ bodyText: {
468
+ displayFormat: data?.data?.displayFormat,
469
+ label: data?.data?.label,
470
+ isRequired: data?.data?.isRequired,
471
+ labelOrientation: data?.data?.labelOrientation,
472
+ minDate: data?.data?.minDate,
473
+ maxDate: data?.data?.maxDate,
474
+ isDisabled: data?.data?.isDisabled,
475
+ showMonthYearSelect: data?.data?.showMonthYearSelect,
476
+ paramName: data?.data?.param_name
477
+ }
478
+ };
459
479
  case "checkbox":
460
480
  return {
461
481
  ...data,
@@ -4869,7 +4889,7 @@ const useStyles$4 = styles.makeStyles((theme) => ({
4869
4889
  marginTop: pxToRem(16),
4870
4890
  }
4871
4891
  }));
4872
- const ButtonContent = ({ bodyText }) => {
4892
+ const ButtonContent = ({ bodyText, isFormDisabled = false }) => {
4873
4893
  const classes = useStyles$4();
4874
4894
  const handleButtonClick = (button) => {
4875
4895
  // if (button.onClick) {
@@ -4886,7 +4906,7 @@ const ButtonContent = ({ bodyText }) => {
4886
4906
  if (!Array.isArray(bodyText.buttons)) {
4887
4907
  return null;
4888
4908
  }
4889
- return bodyText.buttons.map((button, index) => (jsxRuntime.jsx(impactUiV3.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)));
4909
+ return bodyText.buttons.map((button, index) => (jsxRuntime.jsx(impactUiV3.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)));
4890
4910
  };
4891
4911
  return (jsxRuntime.jsxs("div", { className: classes.buttonContainer, children: [bodyText.message && (jsxRuntime.jsx("div", { className: classes.message, children: bodyText.message })), jsxRuntime.jsx("div", { className: classes.buttonRow, children: renderButtons() })] }));
4892
4912
  };
@@ -6637,7 +6657,7 @@ const StreamedContent = ({ botData }) => {
6637
6657
  return renderContent();
6638
6658
  };
6639
6659
 
6640
- const SliderContent = ({ bodyText }) => {
6660
+ const SliderContent = ({ bodyText, isFormDisabled = false }) => {
6641
6661
  const { header, headerOrentiation, inputPosition, label, max, min, required, disabled, } = bodyText;
6642
6662
  const [sliderValue, setSliderValue] = React.useState(0);
6643
6663
  const chatbotContext = reactRedux.useSelector((state) => state.smartBotReducer.chatbotContext);
@@ -6658,10 +6678,10 @@ const SliderContent = ({ bodyText }) => {
6658
6678
  console.error("Error in slider handleChange", error);
6659
6679
  }
6660
6680
  };
6661
- 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, onChange: (e) => handleChange(e), value: sliderValue }) }));
6681
+ 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 }) }));
6662
6682
  };
6663
6683
 
6664
- const SelectContent = ({ bodyText }) => {
6684
+ const SelectContent = ({ bodyText, isFormDisabled = false }) => {
6665
6685
  const { header, inputPosition, labelOrientation, label, options, isRequired, isDisabled, isMulti, paramName } = bodyText;
6666
6686
  const [isOpen, setIsOpen] = React.useState(false);
6667
6687
  const [currentOptions, setCurrentOptions] = React.useState([]);
@@ -6711,10 +6731,10 @@ const SelectContent = ({ bodyText }) => {
6711
6731
  return (jsxRuntime.jsx("div", { style: { width: "100%", marginTop: "10px" }, children: jsxRuntime.jsx(impactUiV3.Select, { currentOptions: currentOptions, setCurrentOptions: setCurrentOptions, label: heirarchyKeyValuePairs[paramName] || label, labelOrientation: labelOrientation,
6712
6732
  // inputPosition={inputPosition}
6713
6733
  // header={header}
6714
- 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 }) }));
6734
+ 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 }) }));
6715
6735
  };
6716
6736
 
6717
- const DatePickerContent = ({ bodyText }) => {
6737
+ const DatePickerContent = ({ bodyText, isFormDisabled = false }) => {
6718
6738
  const { displayFormat, label, isRequired, labelOrientation, placeholder, minDate, maxDate, isDisabled, } = bodyText;
6719
6739
  const [selectedDate, setSelectedDate] = React.useState(null);
6720
6740
  const chatbotContext = reactRedux.useSelector((state) => state.smartBotReducer.chatbotContext);
@@ -6738,13 +6758,49 @@ const DatePickerContent = ({ bodyText }) => {
6738
6758
  return (jsxRuntime.jsx("div", { style: { width: "100%", marginTop: "10px" }, children: jsxRuntime.jsx(impactUiV3.DatePicker, { displayFormat: displayFormat, label: label, required: isRequired, labelOrientation: labelOrientation, placeholder: placeholder,
6739
6759
  // minDate={minDate}
6740
6760
  // maxDate={maxDate}
6741
- disabled: isDisabled, setSelectedDate: (date) => handleDateChange(date),
6761
+ isDisabled: isDisabled || isFormDisabled, setSelectedDate: (date) => handleDateChange(date),
6742
6762
  // showMonthYearSelect
6743
6763
  // showWeekNumbers
6744
6764
  selectedDate: selectedDate }) }));
6745
6765
  };
6746
6766
 
6747
- const CheckboxContent = ({ bodyText }) => {
6767
+ const DateRangePickerContent = ({ bodyText, isFormDisabled = false }) => {
6768
+ const { displayFormat, label, isRequired, labelOrientation, minDate, maxDate, isDisabled, showMonthYearSelect, } = bodyText;
6769
+ const [startDate, setStartDate] = React.useState(null);
6770
+ const [endDate, setEndDate] = React.useState(null);
6771
+ const chatbotContext = reactRedux.useSelector((state) => state.smartBotReducer.chatbotContext);
6772
+ const dispatch = reactRedux.useDispatch();
6773
+ if (lodash.isEmpty(bodyText))
6774
+ return null;
6775
+ const handleDatesChange = (start, end) => {
6776
+ try {
6777
+ setStartDate(start);
6778
+ setEndDate(end);
6779
+ chatbotContext[bodyText?.paramName] = {
6780
+ ...chatbotContext?.[bodyText?.paramName],
6781
+ [bodyText?.paramName]: {
6782
+ startDate: start ? moment(start).format(displayFormat) : null,
6783
+ endDate: end ? moment(end).format(displayFormat) : null,
6784
+ },
6785
+ updated: true,
6786
+ };
6787
+ dispatch(smartBotActions.setChatbotContext(chatbotContext));
6788
+ }
6789
+ catch (error) {
6790
+ console.error("Error in dateRangePicker handleDatesChange", error);
6791
+ }
6792
+ };
6793
+ return (jsxRuntime.jsx("div", { style: { width: "100%", marginTop: "10px" }, children: jsxRuntime.jsx(impactUiV3.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: () => {
6794
+ setStartDate(null);
6795
+ setEndDate(null);
6796
+ }, onResetClick: () => {
6797
+ setStartDate(null);
6798
+ setEndDate(null);
6799
+ handleDatesChange(null, null);
6800
+ } }) }));
6801
+ };
6802
+
6803
+ const CheckboxContent = ({ bodyText, isFormDisabled = false }) => {
6748
6804
  const { label, checked: checkedValue, required, disabled, } = bodyText;
6749
6805
  const chatbotContext = reactRedux.useSelector((state) => state.smartBotReducer.chatbotContext);
6750
6806
  const dispatch = reactRedux.useDispatch();
@@ -6770,10 +6826,10 @@ const CheckboxContent = ({ bodyText }) => {
6770
6826
  console.error("Error in checkbox handleChange", error);
6771
6827
  }
6772
6828
  };
6773
- return (jsxRuntime.jsx("div", { style: { width: '100%', marginTop: '10px' }, children: jsxRuntime.jsx(impactUiV3.Checkbox, { label: label, checked: checked, required: required, disabled: disabled, onChange: (e) => handleChange(e), variant: "default" }) }));
6829
+ 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" }) }));
6774
6830
  };
6775
6831
 
6776
- const RadioContent = ({ bodyText }) => {
6832
+ const RadioContent = ({ bodyText, isFormDisabled = false }) => {
6777
6833
  const classes = useStyles$6();
6778
6834
  const { label, isDisabled, orientation, options } = bodyText;
6779
6835
  const chatbotContext = reactRedux.useSelector((state) => state.smartBotReducer.chatbotContext);
@@ -6801,10 +6857,10 @@ const RadioContent = ({ bodyText }) => {
6801
6857
  console.error("Error in radio handleChange", error);
6802
6858
  }
6803
6859
  };
6804
- 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, disabled: isDisabled, selectedOption: selectedOption })] }));
6860
+ 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 })] }));
6805
6861
  };
6806
6862
 
6807
- const InputContent = ({ bodyText }) => {
6863
+ const InputContent = ({ bodyText, isFormDisabled = false }) => {
6808
6864
  const { label, placeholder, isRequired, isDisabled, inputType, labelOrientation, defaultValue, maxLength, minLength, } = bodyText;
6809
6865
  const chatbotContext = reactRedux.useSelector((state) => state.smartBotReducer.chatbotContext);
6810
6866
  const dispatch = reactRedux.useDispatch();
@@ -6827,7 +6883,7 @@ const InputContent = ({ bodyText }) => {
6827
6883
  console.error("Error in input handleChange", error);
6828
6884
  }
6829
6885
  };
6830
- return (jsxRuntime.jsx("div", { style: { width: '100%', marginTop: '10px' }, children: jsxRuntime.jsx(impactUiV3.Input, { label: label, placeholder: placeholder, value: value, onChange: handleChange, required: isRequired, disabled: isDisabled, type: inputType || "text", labelOrientation: labelOrientation, maxLength: maxLength, minLength: minLength }) }));
6886
+ return (jsxRuntime.jsx("div", { style: { width: '100%', marginTop: '10px' }, children: jsxRuntime.jsx(impactUiV3.Input, { label: label, placeholder: placeholder, value: value, onChange: handleChange, required: isRequired, isDisabled: isDisabled || isFormDisabled, type: inputType || "text", labelOrientation: labelOrientation, maxLength: maxLength, minLength: minLength }) }));
6831
6887
  };
6832
6888
 
6833
6889
  const ImageContent = ({ bodyText }) => {
@@ -7052,6 +7108,7 @@ const TabularContent = ({ steps, currentTabValue, children, questions = [], ques
7052
7108
  };
7053
7109
 
7054
7110
  const CombinedContent = ({ botData, props }) => {
7111
+ const isFormDisabled = botData?.isFormDisabled || false;
7055
7112
  const isTabEnabled = botData?.utilityData?.isTabEnabled;
7056
7113
  // Get the array of content items from bodyText
7057
7114
  const contentItems = Array.isArray(botData.bodyText) ? botData.bodyText : [];
@@ -7075,19 +7132,21 @@ const CombinedContent = ({ botData, props }) => {
7075
7132
  case "graph":
7076
7133
  return jsxRuntime.jsx(GraphContent, { bodyText: parsedData.bodyText }, key);
7077
7134
  case "slider":
7078
- return jsxRuntime.jsx(SliderContent, { bodyText: parsedData.bodyText }, key);
7135
+ return jsxRuntime.jsx(SliderContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
7079
7136
  case "select":
7080
- return jsxRuntime.jsx(SelectContent, { bodyText: parsedData.bodyText }, key);
7137
+ return jsxRuntime.jsx(SelectContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
7081
7138
  case "datePicker":
7082
- return jsxRuntime.jsx(DatePickerContent, { bodyText: parsedData.bodyText }, key);
7139
+ return jsxRuntime.jsx(DatePickerContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
7140
+ case "dateRangePicker":
7141
+ return jsxRuntime.jsx(DateRangePickerContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
7083
7142
  case "checkbox":
7084
- return jsxRuntime.jsx(CheckboxContent, { bodyText: parsedData.bodyText }, key);
7143
+ return jsxRuntime.jsx(CheckboxContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
7085
7144
  case "radio":
7086
- return jsxRuntime.jsx(RadioContent, { bodyText: parsedData.bodyText }, key);
7145
+ return jsxRuntime.jsx(RadioContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
7087
7146
  case "button":
7088
- return jsxRuntime.jsx(ButtonContent, { bodyText: parsedData.bodyText }, key);
7147
+ return jsxRuntime.jsx(ButtonContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
7089
7148
  case "input":
7090
- return jsxRuntime.jsx(InputContent, { bodyText: parsedData.bodyText }, key);
7149
+ return jsxRuntime.jsx(InputContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
7091
7150
  case "image":
7092
7151
  return jsxRuntime.jsx(ImageContent, { bodyText: parsedData.bodyText }, key);
7093
7152
  default:
@@ -7169,19 +7228,21 @@ const BotMessage = ({ botData, state, handleLikeDislike, props }) => {
7169
7228
  case "graph":
7170
7229
  return jsxRuntime.jsx(GraphContent, { bodyText: botData.bodyText });
7171
7230
  case "slider":
7172
- return jsxRuntime.jsx(SliderContent, { bodyText: botData.bodyText });
7231
+ return jsxRuntime.jsx(SliderContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled });
7173
7232
  case "select":
7174
- return jsxRuntime.jsx(SelectContent, { bodyText: botData.bodyText });
7233
+ return jsxRuntime.jsx(SelectContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled });
7175
7234
  case "datePicker":
7176
- return jsxRuntime.jsx(DatePickerContent, { bodyText: botData.bodyText });
7235
+ return jsxRuntime.jsx(DatePickerContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled });
7236
+ case "dateRangePicker":
7237
+ return jsxRuntime.jsx(DateRangePickerContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled });
7177
7238
  case "checkbox":
7178
- return jsxRuntime.jsx(CheckboxContent, { bodyText: botData.bodyText });
7239
+ return jsxRuntime.jsx(CheckboxContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled });
7179
7240
  case "radio":
7180
- return jsxRuntime.jsx(RadioContent, { bodyText: botData.bodyText });
7241
+ return jsxRuntime.jsx(RadioContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled });
7181
7242
  case "button":
7182
- return jsxRuntime.jsx(ButtonContent, { bodyText: botData.bodyText });
7243
+ return jsxRuntime.jsx(ButtonContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled });
7183
7244
  case "input":
7184
- return jsxRuntime.jsx(InputContent, { bodyText: botData.bodyText });
7245
+ return jsxRuntime.jsx(InputContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled });
7185
7246
  case "image":
7186
7247
  return jsxRuntime.jsx(ImageContent, { bodyText: botData.bodyText });
7187
7248
  case "combined":
@@ -10156,7 +10217,9 @@ const SmartBot = (props) => {
10156
10217
  customChatConfig: customChatConfig,
10157
10218
  loader: loader,
10158
10219
  };
10159
- chatDataInfoRef?.current[currentMode]?.conversations?.[1]?.messages.forEach((message, index) => {
10220
+ const allMessages = chatDataInfoRef?.current[currentMode]?.conversations?.[1]?.messages || [];
10221
+ const lastBotMessageIndex = allMessages.reduce((lastIdx, msg, idx) => msg.userType === "bot" ? idx : lastIdx, -1);
10222
+ allMessages.forEach((message, index) => {
10160
10223
  if (message.userType === "bot") {
10161
10224
  // let BotMessageJsx =
10162
10225
  // <BotMessage
@@ -10166,6 +10229,7 @@ const SmartBot = (props) => {
10166
10229
  // props={properties}
10167
10230
  // />
10168
10231
  // ;
10232
+ message.isFormDisabled = index !== lastBotMessageIndex;
10169
10233
  message.jsx = (jsxRuntime.jsx(BotMessage, { botData: message, state: loadingState, handleLikeDislike: handleLikeDislike, props: properties }));
10170
10234
  message.firstMessage = true;
10171
10235
  // message.enableLikes = true;