impact-chatbot 2.3.76 → 2.3.77

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
@@ -5699,6 +5699,10 @@ const ButtonContent = ({ bodyText, isFormDisabled = false, isStepFormSubmit = fa
5699
5699
  stepFormStreamControl.uniqueChatId = data?.chat_id ? data.chat_id : "";
5700
5700
  // Clear sessionStorage so stale session_id isn't picked up by future non-init calls
5701
5701
  sessionStorage.setItem("stepForm_sessionId", "");
5702
+ // Notify SmartBot to update its initValue/sessionId state
5703
+ window.dispatchEvent(new CustomEvent("stepFormInitStateUpdate", {
5704
+ detail: { initValue: true, sessionId: "", uniqueChatId: data?.chat_id || "" },
5705
+ }));
5702
5706
  }
5703
5707
  // Stream ended — dispatch all collected chunks at once
5704
5708
  stepFormStreamControl.isStreaming = false;
@@ -8092,7 +8096,7 @@ const Steps$1 = ({ steps, setSteps, done, setTabValue, setDone, finalStepDone, s
8092
8096
  }, children: jsx(ProgressBarItem$1, { question: "Thinking", questionSteps: [{ header: "", sub_header: "", step_status: "not-completed" }], isLast: true, classes: classes, formData: null, isFormDisabled: isFormDisabled }) }))] }));
8093
8097
  };
8094
8098
 
8095
- const renderWidgetItem = (item, index) => {
8099
+ const renderWidgetItem = (item, index, isFormDisabled) => {
8096
8100
  try {
8097
8101
  const parsedData = parseResponse(item, item.type, "", "", true);
8098
8102
  if (!parsedData)
@@ -8105,6 +8109,22 @@ const renderWidgetItem = (item, index) => {
8105
8109
  return jsx(TableContent, { bodyText: parsedData.bodyText }, key);
8106
8110
  case "graph":
8107
8111
  return jsx(GraphContent, { bodyText: parsedData.bodyText }, key);
8112
+ case "radio":
8113
+ return jsx(RadioContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
8114
+ case "checkbox":
8115
+ return jsx(CheckboxContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
8116
+ case "select":
8117
+ return jsx(SelectContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
8118
+ case "slider":
8119
+ return jsx(SliderContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
8120
+ case "button":
8121
+ return jsx(ButtonContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
8122
+ case "input":
8123
+ return jsx(InputContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
8124
+ case "datePicker":
8125
+ return jsx(DatePickerContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
8126
+ case "dateRangePicker":
8127
+ return jsx(DateRangePickerContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
8108
8128
  default:
8109
8129
  return null;
8110
8130
  }
@@ -8115,11 +8135,11 @@ const renderWidgetItem = (item, index) => {
8115
8135
  }
8116
8136
  };
8117
8137
  const AgentResponse$1 = (props) => {
8118
- const { content, isStreaming, streamingWidgetData = [] } = props;
8138
+ const { content, isStreaming, streamingWidgetData = [], isFormDisabled = false } = props;
8119
8139
  const classes = useStyles$6();
8120
8140
  const chatClasses = useStyles$9();
8121
8141
  const renderedWidgets = streamingWidgetData
8122
- .map((item, index) => renderWidgetItem(item, index))
8142
+ .map((item, index) => renderWidgetItem(item, index, isFormDisabled))
8123
8143
  .filter(Boolean);
8124
8144
  return (jsxs("div", { className: chatClasses.agentResponseContainer, children: [content ? (jsxs(Typography, { className: chatClasses.bodyTextStyling, children: [jsx(TextRenderer, { text: content }), isStreaming && renderedWidgets.length === 0 && jsx("span", { className: classes.cursor })] })) : null, renderedWidgets.length > 0 && (jsx("div", { className: "streaming-widget-content", children: renderedWidgets })), isStreaming && (renderedWidgets.length > 0 || !content) && (jsx("span", { className: classes.cursor }))] }));
8125
8145
  };
@@ -8190,7 +8210,7 @@ const StepsResponseTab = (props) => {
8190
8210
  },
8191
8211
  ], tabPanels: [
8192
8212
  jsx(Steps$1, { steps: steps, setSteps: setSteps, done: stepsDone, setDone: setStepsDone, setTabValue: setTabValue, finalStepDone: finalStepDone, setFinalStepDone: setFinalStepDone, stepChange: stepChange, currentMode: currentMode, questions: questions, questionsStepsMap: questionsStepsMap, stepFormDataMap: stepFormDataMap, isFormDisabled: isFormDisabled || isTimedOut }),
8193
- jsxs(Fragment, { children: [jsx(AgentResponse$1, { content: content, isStreaming: isStreaming, streamingWidgetData: streamingWidgetData }), timeoutMessage && (jsx("div", { style: { marginTop: "8px", padding: "0 8px" }, children: jsx(TextRenderer, { text: timeoutMessage, thinking: "" }) }))] }),
8213
+ jsxs(Fragment, { children: [jsx(AgentResponse$1, { content: content, isStreaming: isStreaming, streamingWidgetData: streamingWidgetData, isFormDisabled: isFormDisabled || isTimedOut }), timeoutMessage && (jsx("div", { style: { marginTop: "8px", padding: "0 8px" }, children: jsx(TextRenderer, { text: timeoutMessage, thinking: "" }) }))] }),
8194
8214
  ], value: tabValue }) }));
8195
8215
  };
8196
8216
 
@@ -9335,6 +9355,16 @@ const StreamedContent = ({ botData }) => {
9335
9355
  ];
9336
9356
  botData.utilityObject.setInitValue(messageToStoreRef.current.initValue);
9337
9357
  botData.utilityObject.setSessionId(messageToStoreRef.current.sessionId);
9358
+ // Also update currentSessionId via event so the send button uses the correct session_id
9359
+ if (messageToStoreRef.current.status === "completed" || messageToStoreRef.current.status === "follow-up") {
9360
+ window.dispatchEvent(new CustomEvent("stepFormInitStateUpdate", {
9361
+ detail: {
9362
+ initValue: messageToStoreRef.current.initValue,
9363
+ sessionId: messageToStoreRef.current.sessionId,
9364
+ uniqueChatId: messageToStoreRef.current.uniqueChatId,
9365
+ },
9366
+ }));
9367
+ }
9338
9368
  botData.utilityObject.setAdditionalArgs(!isEmpty(messageToStoreRef.current.additionalArgs)
9339
9369
  ? messageToStoreRef.current.additionalArgs
9340
9370
  : {});
@@ -10096,6 +10126,22 @@ const TabularContent = ({ steps: initialSteps, currentTabValue, children, questi
10096
10126
  return jsx(TableContent, { bodyText: parsedData.bodyText }, key);
10097
10127
  case "graph":
10098
10128
  return jsx(GraphContent, { bodyText: parsedData.bodyText }, key);
10129
+ case "radio":
10130
+ return jsx(RadioContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
10131
+ case "checkbox":
10132
+ return jsx(CheckboxContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
10133
+ case "select":
10134
+ return jsx(SelectContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
10135
+ case "slider":
10136
+ return jsx(SliderContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
10137
+ case "button":
10138
+ return jsx(ButtonContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
10139
+ case "input":
10140
+ return jsx(InputContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
10141
+ case "datePicker":
10142
+ return jsx(DatePickerContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
10143
+ case "dateRangePicker":
10144
+ return jsx(DateRangePickerContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
10099
10145
  default:
10100
10146
  return null;
10101
10147
  }
@@ -10396,6 +10442,29 @@ const TabularContent = ({ steps: initialSteps, currentTabValue, children, questi
10396
10442
  setQuestionsStepsMapState(cloneDeep(newQuestionsStepsMap));
10397
10443
  setStepFormDataMapState(cloneDeep(newStepFormDataMap));
10398
10444
  if (newWidgets.length > 0) {
10445
+ // If widget data contains form components (radio, select, checkbox, etc.),
10446
+ // append a Submit button so the user can submit their selection
10447
+ const formTypes = ["radio", "select", "checkbox", "slider", "input", "datePicker", "dateRangePicker"];
10448
+ const hasFormWidget = newWidgets.some((item) => formTypes.includes(item?.type));
10449
+ const hasStepForm = chunks.some((c) => c.status === "step_form");
10450
+ if (hasFormWidget && !hasStepForm) {
10451
+ const sendButton = document.getElementById("chat-input-send-button");
10452
+ newWidgets.push({
10453
+ type: "button",
10454
+ data: {
10455
+ message: "",
10456
+ buttons: [
10457
+ {
10458
+ label: "Submit",
10459
+ variant: "primary",
10460
+ size: "medium",
10461
+ disabled: false,
10462
+ onClick: () => sendButton?.click(),
10463
+ },
10464
+ ],
10465
+ },
10466
+ });
10467
+ }
10399
10468
  // Replace (not append) to avoid duplicates from real-time widget_chunk dispatches
10400
10469
  setWidgetContent(newWidgets);
10401
10470
  }
@@ -14777,11 +14846,25 @@ const SmartBot = (props) => {
14777
14846
  console.error("Error updating timestamp after step form stream:", e);
14778
14847
  }
14779
14848
  };
14849
+ // Update SmartBot-level initValue/sessionId when ButtonContent's stream receives completed/follow-up
14850
+ const handleStepFormInitStateUpdate = (e) => {
14851
+ const { initValue: newInitValue, sessionId: newSessionId, uniqueChatId: newChatId } = e.detail || {};
14852
+ if (newInitValue !== undefined)
14853
+ setInitValue(newInitValue);
14854
+ if (newSessionId !== undefined) {
14855
+ setSessionId(newSessionId);
14856
+ setCurrentSessionId(newSessionId);
14857
+ }
14858
+ if (newChatId !== undefined)
14859
+ setUniqueChatId(newChatId);
14860
+ };
14780
14861
  window.addEventListener("stepFormStreamStart", handleStepFormStreamStart);
14781
14862
  window.addEventListener("stepFormStreamEnd", handleStepFormStreamEnd);
14863
+ window.addEventListener("stepFormInitStateUpdate", handleStepFormInitStateUpdate);
14782
14864
  return () => {
14783
14865
  window.removeEventListener("stepFormStreamStart", handleStepFormStreamStart);
14784
14866
  window.removeEventListener("stepFormStreamEnd", handleStepFormStreamEnd);
14867
+ window.removeEventListener("stepFormInitStateUpdate", handleStepFormInitStateUpdate);
14785
14868
  };
14786
14869
  }, []);
14787
14870
  const fetchCustomBotConfigurations = async () => {