impact-chatbot 2.3.88 → 2.3.90
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/components/message-template/components/message-content/CheckboxGroupContent.d.ts +6 -0
- package/dist/components/message-template/components/message-content/tabular-content/components/Steps.d.ts +3 -1
- package/dist/components/message-template/components/message-content/tabular-content/index.d.ts +2 -1
- package/dist/components/message-template/components/message-types/streamed-content/steps-response-tab/components/Steps.d.ts +2 -1
- package/dist/index.cjs.js +179 -23
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +179 -23
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -542,6 +542,26 @@ const parseResponse = (data, type, agentId = "", currentMode = "", disableTimeAn
|
|
|
542
542
|
paramName: data?.data?.param_name
|
|
543
543
|
}
|
|
544
544
|
};
|
|
545
|
+
case "checkboxGroup":
|
|
546
|
+
return {
|
|
547
|
+
...data,
|
|
548
|
+
timeStamp: timeString,
|
|
549
|
+
userType: "bot",
|
|
550
|
+
userName: userName,
|
|
551
|
+
headerTitle: data?.data?.label || "",
|
|
552
|
+
bodyType: "checkboxGroup",
|
|
553
|
+
bodyText: {
|
|
554
|
+
label: data?.data?.label,
|
|
555
|
+
orientation: data?.data?.orientation,
|
|
556
|
+
options: data?.data?.options,
|
|
557
|
+
defaultSelected: data?.data?.defaultSelected,
|
|
558
|
+
minOptions: data?.data?.minOptions,
|
|
559
|
+
maxOptions: data?.data?.maxOptions,
|
|
560
|
+
isRequired: data?.data?.isRequired,
|
|
561
|
+
isDisabled: data?.data?.isDisabled,
|
|
562
|
+
paramName: data?.data?.param_name
|
|
563
|
+
}
|
|
564
|
+
};
|
|
545
565
|
case "button":
|
|
546
566
|
return {
|
|
547
567
|
...data,
|
|
@@ -4194,10 +4214,11 @@ const useStyles$a = makeStyles((theme) => ({
|
|
|
4194
4214
|
},
|
|
4195
4215
|
hideBotStyle: {
|
|
4196
4216
|
"& .chatbot-component-container": {
|
|
4197
|
-
width: "0px",
|
|
4198
|
-
height: "0px",
|
|
4199
|
-
opacity: "0",
|
|
4200
|
-
position: "fixed",
|
|
4217
|
+
width: "0px !important",
|
|
4218
|
+
height: "0px !important",
|
|
4219
|
+
opacity: "0 !important",
|
|
4220
|
+
position: "fixed !important",
|
|
4221
|
+
pointerEvents: "none !important",
|
|
4201
4222
|
}
|
|
4202
4223
|
},
|
|
4203
4224
|
radioGrpLabel: {
|
|
@@ -7447,6 +7468,61 @@ const CheckboxContent = ({ bodyText, isFormDisabled = false, messageIndex }) =>
|
|
|
7447
7468
|
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" }) }));
|
|
7448
7469
|
};
|
|
7449
7470
|
|
|
7471
|
+
const CheckboxGroupContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
|
|
7472
|
+
const formKey = `${messageIndex}_${bodyText?.paramName}`;
|
|
7473
|
+
const classes = useStyles$a();
|
|
7474
|
+
const { label, orientation, options = [], defaultSelected, minOptions, maxOptions, isRequired, isDisabled, } = bodyText || {};
|
|
7475
|
+
const min = minOptions ?? 1;
|
|
7476
|
+
const max = maxOptions ?? options.length;
|
|
7477
|
+
const chatbotContext = useSelector((state) => state.smartBotReducer.chatbotContext);
|
|
7478
|
+
const chatbotContextRef = useRef(chatbotContext);
|
|
7479
|
+
chatbotContextRef.current = chatbotContext;
|
|
7480
|
+
const persistedFormValues = useSelector((state) => state.smartBotReducer.persistedFormValues);
|
|
7481
|
+
const dispatch = useDispatch();
|
|
7482
|
+
const [selected, setSelected] = useState(() => {
|
|
7483
|
+
const persisted = persistedFormValues?.[formKey];
|
|
7484
|
+
if (Array.isArray(persisted))
|
|
7485
|
+
return persisted;
|
|
7486
|
+
return Array.isArray(defaultSelected) ? defaultSelected : [];
|
|
7487
|
+
});
|
|
7488
|
+
if (isEmpty$1(bodyText))
|
|
7489
|
+
return null;
|
|
7490
|
+
const groupDisabled = isDisabled || isFormDisabled;
|
|
7491
|
+
const dispatchSelection = (newValues) => {
|
|
7492
|
+
const latestContext = chatbotContextRef.current;
|
|
7493
|
+
dispatch(setChatbotContext({
|
|
7494
|
+
...latestContext,
|
|
7495
|
+
[bodyText?.paramName]: {
|
|
7496
|
+
...latestContext?.[bodyText?.paramName],
|
|
7497
|
+
[bodyText?.paramName]: newValues,
|
|
7498
|
+
updated: true,
|
|
7499
|
+
},
|
|
7500
|
+
}));
|
|
7501
|
+
dispatch(setPersistedFormValues({ [formKey]: newValues }));
|
|
7502
|
+
};
|
|
7503
|
+
const handleChange = (optionValue, isChecked) => {
|
|
7504
|
+
try {
|
|
7505
|
+
const newValues = isChecked
|
|
7506
|
+
? [...selected, optionValue]
|
|
7507
|
+
: selected.filter((val) => val !== optionValue);
|
|
7508
|
+
setSelected(newValues);
|
|
7509
|
+
dispatchSelection(newValues);
|
|
7510
|
+
}
|
|
7511
|
+
catch (error) {
|
|
7512
|
+
console.error("Error in checkboxGroup handleChange", error);
|
|
7513
|
+
}
|
|
7514
|
+
};
|
|
7515
|
+
const isRow = orientation === "row";
|
|
7516
|
+
const overMax = selected.length > max;
|
|
7517
|
+
const belowMin = isRequired && selected.length < min;
|
|
7518
|
+
return (jsxs("div", { style: { width: "100%", marginTop: "10px" }, children: [label && (jsxs("p", { className: classes.radioGrpLabel, children: [label, isRequired ? " *" : ""] })), jsx("div", { style: {
|
|
7519
|
+
display: "flex",
|
|
7520
|
+
flexDirection: isRow ? "row" : "column",
|
|
7521
|
+
flexWrap: isRow ? "wrap" : "nowrap",
|
|
7522
|
+
gap: isRow ? "16px" : "8px",
|
|
7523
|
+
}, children: options.map((option) => (jsx(Checkbox, { label: option.label, checked: selected.includes(option.value), disabled: option.disabled || groupDisabled, onChange: (e) => handleChange(option.value, e?.currentTarget?.checked), variant: "default" }, option.value))) }), overMax && (jsx("p", { className: classes.radioGrpLabel, style: { margin: "8px 0 0 0", color: "red" }, children: `Select at most ${max} option${max > 1 ? "s" : ""}` })), !overMax && belowMin && (jsx("p", { className: classes.radioGrpLabel, style: { margin: "8px 0 0 0", color: "red" }, children: `Select at least ${min} option${min > 1 ? "s" : ""}` }))] }));
|
|
7524
|
+
};
|
|
7525
|
+
|
|
7450
7526
|
const RadioContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
|
|
7451
7527
|
const formKey = `${messageIndex}_${bodyText?.paramName}`;
|
|
7452
7528
|
const classes = useStyles$a();
|
|
@@ -7730,6 +7806,38 @@ const StepFormContent = ({ formData, messageIndex = 0, isFormDisabled = false, s
|
|
|
7730
7806
|
return false;
|
|
7731
7807
|
});
|
|
7732
7808
|
}, [formData, chatbotContext, persistedFormValues, messageIndex]);
|
|
7809
|
+
// Validate checkboxGroup fields against their minOptions/maxOptions bounds.
|
|
7810
|
+
// A required group must have selectedCount within [min, max]; any group (even
|
|
7811
|
+
// non-required) must not exceed max. Blocks submit when out of bounds.
|
|
7812
|
+
const checkboxGroupsValid = useMemo(() => {
|
|
7813
|
+
if (!formData || !Array.isArray(formData))
|
|
7814
|
+
return true;
|
|
7815
|
+
const groups = formData.filter((item) => item?.type === "checkboxGroup");
|
|
7816
|
+
return groups.every((item) => {
|
|
7817
|
+
const data = item.data || {};
|
|
7818
|
+
const param = data.param_name;
|
|
7819
|
+
const options = data.options || [];
|
|
7820
|
+
const min = data.minOptions ?? 1;
|
|
7821
|
+
const max = data.maxOptions ?? options.length;
|
|
7822
|
+
// Resolve current selection: chatbotContext first, then persistedFormValues
|
|
7823
|
+
let selectedValues = [];
|
|
7824
|
+
const ctx = chatbotContext?.[param];
|
|
7825
|
+
if (ctx && ctx.updated && Array.isArray(ctx[param])) {
|
|
7826
|
+
selectedValues = ctx[param];
|
|
7827
|
+
}
|
|
7828
|
+
else {
|
|
7829
|
+
const persisted = persistedFormValues?.[`${messageIndex}_${param}`];
|
|
7830
|
+
if (Array.isArray(persisted))
|
|
7831
|
+
selectedValues = persisted;
|
|
7832
|
+
}
|
|
7833
|
+
const count = selectedValues.length;
|
|
7834
|
+
if (count > max)
|
|
7835
|
+
return false;
|
|
7836
|
+
if (data.isRequired && count < min)
|
|
7837
|
+
return false;
|
|
7838
|
+
return true;
|
|
7839
|
+
});
|
|
7840
|
+
}, [formData, chatbotContext, persistedFormValues, messageIndex]);
|
|
7733
7841
|
// Extract select-type filter configs from formData for cross-filter cascading
|
|
7734
7842
|
// and sort them based on the filters_hierarchy_order from tenant config
|
|
7735
7843
|
const crossFilterConfigs = useMemo(() => {
|
|
@@ -7838,10 +7946,12 @@ const StepFormContent = ({ formData, messageIndex = 0, isFormDisabled = false, s
|
|
|
7838
7946
|
return jsx(DateRangePickerContent, { bodyText: parsedData.bodyText, isFormDisabled: formFieldsDisabled, messageIndex: messageIndex }, key);
|
|
7839
7947
|
case "checkbox":
|
|
7840
7948
|
return jsx(CheckboxContent, { bodyText: parsedData.bodyText, isFormDisabled: formFieldsDisabled, messageIndex: messageIndex }, key);
|
|
7949
|
+
case "checkboxGroup":
|
|
7950
|
+
return jsx(CheckboxGroupContent, { bodyText: parsedData.bodyText, isFormDisabled: formFieldsDisabled, messageIndex: messageIndex }, key);
|
|
7841
7951
|
case "radio":
|
|
7842
7952
|
return jsx(RadioContent, { bodyText: parsedData.bodyText, isFormDisabled: formFieldsDisabled, messageIndex: messageIndex }, key);
|
|
7843
7953
|
case "button":
|
|
7844
|
-
return jsx(ButtonContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled || isFormSubmitted || isTimedOut, isStepFormSubmit: true, isFormValid: requiredFieldsFilled, formParamNames: formParamNames, messageIndex: messageIndex }, key);
|
|
7954
|
+
return jsx(ButtonContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled || isFormSubmitted || isTimedOut, isStepFormSubmit: true, isFormValid: requiredFieldsFilled && checkboxGroupsValid, formParamNames: formParamNames, messageIndex: messageIndex }, key);
|
|
7845
7955
|
case "input":
|
|
7846
7956
|
return jsx(InputContent, { bodyText: parsedData.bodyText, isFormDisabled: formFieldsDisabled, messageIndex: messageIndex }, key);
|
|
7847
7957
|
case "image":
|
|
@@ -8237,7 +8347,7 @@ const getQuestionStatus$1 = (questionSteps) => {
|
|
|
8237
8347
|
/**
|
|
8238
8348
|
* Renders a single progress bar item (main point + sub-items)
|
|
8239
8349
|
*/
|
|
8240
|
-
const ProgressBarItem$1 = ({ question, questionSteps, isLast, classes, formData, showSavedFilters = true, preSelectedFilters = null, isFormDisabled, onAllSubItemsAnimated = undefined, botProps = null, currentMode = "", agentId = "", sessionId = "" }) => {
|
|
8350
|
+
const ProgressBarItem$1 = ({ question, questionSteps, isLast, classes, formData, showSavedFilters = true, preSelectedFilters = null, isFormDisabled, onAllSubItemsAnimated = undefined, botProps = null, currentMode = "", agentId = "", sessionId = "", index = 0, chatSessionId = "" }) => {
|
|
8241
8351
|
const status = getQuestionStatus$1(questionSteps);
|
|
8242
8352
|
const animatedCountRef = useRef(0);
|
|
8243
8353
|
const [isExpanded, setIsExpanded] = useState(true);
|
|
@@ -8271,9 +8381,9 @@ const ProgressBarItem$1 = ({ question, questionSteps, isLast, classes, formData,
|
|
|
8271
8381
|
if (animatedCountRef.current >= arr.length && onAllSubItemsAnimated) {
|
|
8272
8382
|
onAllSubItemsAnimated();
|
|
8273
8383
|
}
|
|
8274
|
-
} }) }, idx))) })), formData && isExpanded && (jsx("div", { className: classes.stepFormContainer, children: jsx(StepFormContent, { formData: formData, isFormDisabled: isFormDisabled, showSavedFilters: showSavedFilters, preSelectedFilters: preSelectedFilters, botProps: botProps, currentMode: currentMode, agentId: agentId, sessionId: sessionId }) }))] })] }));
|
|
8384
|
+
} }) }, idx))) })), formData && isExpanded && (jsx("div", { className: classes.stepFormContainer, children: jsx(StepFormContent, { formData: formData, isFormDisabled: isFormDisabled, showSavedFilters: showSavedFilters, preSelectedFilters: preSelectedFilters, botProps: botProps, currentMode: currentMode, agentId: agentId, sessionId: sessionId, messageIndex: `${String(chatSessionId)}_${index}` }) }))] })] }));
|
|
8275
8385
|
};
|
|
8276
|
-
const Steps$1 = ({ steps, setSteps, done, setTabValue, setDone, finalStepDone, setFinalStepDone, stepChange, currentMode, questions = [], questionsStepsMap = {}, stepFormDataMap = {}, isFormDisabled = false, botProps = null, agentId = "", sessionId = "", }) => {
|
|
8386
|
+
const Steps$1 = ({ steps, setSteps, done, setTabValue, setDone, finalStepDone, setFinalStepDone, stepChange, currentMode, questions = [], questionsStepsMap = {}, stepFormDataMap = {}, isFormDisabled = false, botProps = null, agentId = "", sessionId = "", chatSessionId = "", }) => {
|
|
8277
8387
|
const classes = useStyles$4();
|
|
8278
8388
|
useState(false);
|
|
8279
8389
|
const [showThinking, setShowThinking] = useState(false);
|
|
@@ -8356,7 +8466,7 @@ const Steps$1 = ({ steps, setSteps, done, setTabValue, setDone, finalStepDone, s
|
|
|
8356
8466
|
const showSavedFilters = formEntry && !Array.isArray(formEntry) ? formEntry.showSavedFilters : true;
|
|
8357
8467
|
const preSelectedFilters = formEntry && !Array.isArray(formEntry) ? formEntry.preSelectedFilters : null;
|
|
8358
8468
|
const isLast = index === questions.length - 1;
|
|
8359
|
-
return (jsx(ProgressBarItem$1, { question: question, questionSteps: questionSteps, isLast: isLast && !showThinking, classes: classes, formData: formData, isFormDisabled: isFormDisabled, showSavedFilters: showSavedFilters, preSelectedFilters: preSelectedFilters, botProps: botProps, currentMode: currentMode, agentId: agentId, sessionId: sessionId, onAllSubItemsAnimated: isLast && lastQuestionCompleted && !done
|
|
8469
|
+
return (jsx(ProgressBarItem$1, { question: question, questionSteps: questionSteps, isLast: isLast && !showThinking, classes: classes, formData: formData, isFormDisabled: isFormDisabled, showSavedFilters: showSavedFilters, preSelectedFilters: preSelectedFilters, botProps: botProps, currentMode: currentMode, agentId: agentId, sessionId: sessionId, index: index, chatSessionId: chatSessionId, onAllSubItemsAnimated: isLast && lastQuestionCompleted && !done
|
|
8360
8470
|
? () => setShowThinking(true)
|
|
8361
8471
|
: undefined }, index));
|
|
8362
8472
|
}), showThinking && !done && (jsx("div", { style: {
|
|
@@ -8384,6 +8494,8 @@ const renderWidgetItem = (item, index, isFormDisabled) => {
|
|
|
8384
8494
|
return jsx(RadioContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
|
|
8385
8495
|
case "checkbox":
|
|
8386
8496
|
return jsx(CheckboxContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
|
|
8497
|
+
case "checkboxGroup":
|
|
8498
|
+
return jsx(CheckboxGroupContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
|
|
8387
8499
|
case "select":
|
|
8388
8500
|
return jsx(SelectContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
|
|
8389
8501
|
case "slider":
|
|
@@ -8418,7 +8530,7 @@ const AgentResponse$1 = (props) => {
|
|
|
8418
8530
|
};
|
|
8419
8531
|
|
|
8420
8532
|
const StepsResponseTab = (props) => {
|
|
8421
|
-
const { steps, setSteps, stepsDone, setStepsDone, finalStepDone, setFinalStepDone, content, isStreaming, stepChange, currentMode, questions, questionsStepsMap, stepFormDataMap, isFormDisabled, streamingWidgetData, isRetrying, botProps, agentId, sessionId, } = props;
|
|
8533
|
+
const { steps, setSteps, stepsDone, setStepsDone, finalStepDone, setFinalStepDone, content, isStreaming, stepChange, currentMode, questions, questionsStepsMap, stepFormDataMap, isFormDisabled, streamingWidgetData, isRetrying, botProps, agentId, sessionId, chatSessionId, } = props;
|
|
8422
8534
|
const dispatch = useDispatch();
|
|
8423
8535
|
const thinkingContext = useSelector((state) => state.smartBotReducer.thinkingContext);
|
|
8424
8536
|
const streamStartTimeRef = useRef(thinkingContext?.streamStartTime);
|
|
@@ -8482,7 +8594,7 @@ const StepsResponseTab = (props) => {
|
|
|
8482
8594
|
icon: jsx(PsychologyOutlinedIcon, { fontSize: "large" }),
|
|
8483
8595
|
},
|
|
8484
8596
|
], tabPanels: [
|
|
8485
|
-
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, botProps: botProps, agentId: agentId, sessionId: sessionId }),
|
|
8597
|
+
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, botProps: botProps, agentId: agentId, sessionId: sessionId, chatSessionId: chatSessionId }),
|
|
8486
8598
|
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: "" }) }))] }),
|
|
8487
8599
|
], value: tabValue }) }));
|
|
8488
8600
|
};
|
|
@@ -10054,7 +10166,7 @@ const StreamedContent = ({ botData, botProps }) => {
|
|
|
10054
10166
|
* @returns {JSX.Element} Rendered content with optional blinking cursor
|
|
10055
10167
|
*/
|
|
10056
10168
|
const renderContent = () => {
|
|
10057
|
-
return (jsxs("div", { className: classes.streamContainer, children: [jsx(StepsResponseTab, { steps: steps, stepChange: stepChange, setSteps: setSteps, stepsDone: stepsDone, setStepsDone: setStepsDone, finalStepDone: finalStepDone, setFinalStepDone: setFinalStepDone, content: content, isStreaming: isStreaming, currentMode: currentMode, questions: questions, questionsStepsMap: questionsStepsMap, stepFormDataMap: stepFormDataMap, isFormDisabled: botData?.isFormDisabled || false, streamingWidgetData: streamingWidgetData, isRetrying: isRetrying, botProps: botProps, agentId: botData?.inputBody?.agent_id || "", sessionId: messageToStoreRef.current?.sessionId || "" }), isRetrying && (jsx("div", { className: classes.retryContainer, children: jsx(TextRenderer, { text: `Auto re-trying in ${retryCountdown}s`, thinking: "" }) }))] }));
|
|
10169
|
+
return (jsxs("div", { className: classes.streamContainer, children: [jsx(StepsResponseTab, { steps: steps, stepChange: stepChange, setSteps: setSteps, stepsDone: stepsDone, setStepsDone: setStepsDone, finalStepDone: finalStepDone, setFinalStepDone: setFinalStepDone, content: content, isStreaming: isStreaming, currentMode: currentMode, questions: questions, questionsStepsMap: questionsStepsMap, stepFormDataMap: stepFormDataMap, isFormDisabled: botData?.isFormDisabled || false, streamingWidgetData: streamingWidgetData, isRetrying: isRetrying, botProps: botProps, agentId: botData?.inputBody?.agent_id || "", sessionId: messageToStoreRef.current?.sessionId || "", chatSessionId: messageToStoreRef.current?.chatSessionId || botData?.chatSessionId || "" }), isRetrying && (jsx("div", { className: classes.retryContainer, children: jsx(TextRenderer, { text: `Auto re-trying in ${retryCountdown}s`, thinking: "" }) }))] }));
|
|
10058
10170
|
};
|
|
10059
10171
|
if (currentMode === "agent") {
|
|
10060
10172
|
return renderContent();
|
|
@@ -10250,7 +10362,7 @@ const getQuestionStatus = (questionSteps) => {
|
|
|
10250
10362
|
/**
|
|
10251
10363
|
* Renders a single progress bar item (main point + sub-items)
|
|
10252
10364
|
*/
|
|
10253
|
-
const ProgressBarItem = ({ question, questionSteps, isLast, classes, formData, isFormDisabled, isRestreaming = false, showSavedFilters = true, preSelectedFilters = null }) => {
|
|
10365
|
+
const ProgressBarItem = ({ question, questionSteps, isLast, classes, formData, isFormDisabled, isRestreaming = false, showSavedFilters = true, preSelectedFilters = null, sessionId = "", index = 0, chatSessionId = "" }) => {
|
|
10254
10366
|
const baseStatus = getQuestionStatus(questionSteps);
|
|
10255
10367
|
// When restreaming and this is the last item, show as in-progress
|
|
10256
10368
|
const status = (isRestreaming && isLast) ? "in-progress" : baseStatus;
|
|
@@ -10280,9 +10392,9 @@ const ProgressBarItem = ({ question, questionSteps, isLast, classes, formData, i
|
|
|
10280
10392
|
setIsExpanded(true);
|
|
10281
10393
|
}
|
|
10282
10394
|
}, [status, formData]);
|
|
10283
|
-
return (jsxs("div", { className: classes.progressItem, children: [jsxs("div", { className: classes.progressTrack, children: [jsx("div", { className: `${classes.progressDot} ${dotClass}` }), !isLast && jsx("div", { className: `${classes.progressLine} ${lineClass}` })] }), jsxs("div", { className: classes.progressContent, children: [jsxs("div", { className: classes.progressHeader, onClick: handleToggle, children: [jsx("span", { className: `${classes.progressHeaderText} ${textClass}`, children: question }), hasSubItems && (jsx(ChevronRightIcon$1, { className: `${classes.progressChevron} ${textClass} ${isExpanded ? "expanded" : ""}` }))] }), hasSubItems && isExpanded && status === "in-progress" && (jsxs("div", { className: classes.reasoningLabel, children: [jsx(SvgReasoningIcon, {}), "Working on the next step..."] })), hasSubItems && isExpanded && !isProcessingRequest && (jsx("div", { className: classes.progressSubItems, style: { maxHeight: isExpanded ? "500px" : "0", opacity: isExpanded ? 1 : 0 }, children: questionSteps.map((step, idx) => (jsx("div", { className: classes.progressSubItem, children: jsx(SubStepRenderer, { text: `${step.header}${step.sub_header ? ` - ${step.sub_header}` : ""}` }) }, idx))) })), formData && isExpanded && (jsx("div", { className: classes.stepFormContainer, children: jsx(StepFormContent, { formData: formData, isFormDisabled: isFormDisabled, showSavedFilters: showSavedFilters, preSelectedFilters: preSelectedFilters }) }))] })] }));
|
|
10395
|
+
return (jsxs("div", { className: classes.progressItem, children: [jsxs("div", { className: classes.progressTrack, children: [jsx("div", { className: `${classes.progressDot} ${dotClass}` }), !isLast && jsx("div", { className: `${classes.progressLine} ${lineClass}` })] }), jsxs("div", { className: classes.progressContent, children: [jsxs("div", { className: classes.progressHeader, onClick: handleToggle, children: [jsx("span", { className: `${classes.progressHeaderText} ${textClass}`, children: question }), hasSubItems && (jsx(ChevronRightIcon$1, { className: `${classes.progressChevron} ${textClass} ${isExpanded ? "expanded" : ""}` }))] }), hasSubItems && isExpanded && status === "in-progress" && (jsxs("div", { className: classes.reasoningLabel, children: [jsx(SvgReasoningIcon, {}), "Working on the next step..."] })), hasSubItems && isExpanded && !isProcessingRequest && (jsx("div", { className: classes.progressSubItems, style: { maxHeight: isExpanded ? "500px" : "0", opacity: isExpanded ? 1 : 0 }, children: questionSteps.map((step, idx) => (jsx("div", { className: classes.progressSubItem, children: jsx(SubStepRenderer, { text: `${step.header}${step.sub_header ? ` - ${step.sub_header}` : ""}` }) }, idx))) })), formData && isExpanded && (jsx("div", { className: classes.stepFormContainer, children: jsx(StepFormContent, { formData: formData, isFormDisabled: isFormDisabled, showSavedFilters: showSavedFilters, preSelectedFilters: preSelectedFilters, messageIndex: `${String(chatSessionId)}_${index}` }) }))] })] }));
|
|
10284
10396
|
};
|
|
10285
|
-
const Steps = ({ steps, questions = [], questionsStepsMap = {}, stepFormDataMap = {}, isFormDisabled = false, activeFormIntent = null, isRestreaming = false }) => {
|
|
10397
|
+
const Steps = ({ steps, questions = [], questionsStepsMap = {}, stepFormDataMap = {}, isFormDisabled = false, activeFormIntent = null, isRestreaming = false, sessionId = "", chatSessionId = "" }) => {
|
|
10286
10398
|
const classes = useStyles$3();
|
|
10287
10399
|
useState(false);
|
|
10288
10400
|
const hasQuestions = questions.length > 0;
|
|
@@ -10311,7 +10423,7 @@ const Steps = ({ steps, questions = [], questionsStepsMap = {}, stepFormDataMap
|
|
|
10311
10423
|
const formDisabledForThis = activeFormIntent
|
|
10312
10424
|
? question !== activeFormIntent
|
|
10313
10425
|
: isFormDisabled;
|
|
10314
|
-
return (jsx(ProgressBarItem, { question: question, questionSteps: questionSteps, isLast: index === questions.length - 1, classes: classes, formData: formData, isFormDisabled: formDisabledForThis, isRestreaming: isRestreaming, showSavedFilters: showSavedFilters, preSelectedFilters: preSelectedFilters }, index));
|
|
10426
|
+
return (jsx(ProgressBarItem, { question: question, questionSteps: questionSteps, isLast: index === questions.length - 1, classes: classes, formData: formData, isFormDisabled: formDisabledForThis, isRestreaming: isRestreaming, showSavedFilters: showSavedFilters, preSelectedFilters: preSelectedFilters, sessionId: sessionId, index: index, chatSessionId: chatSessionId }, index));
|
|
10315
10427
|
}) }));
|
|
10316
10428
|
};
|
|
10317
10429
|
|
|
@@ -10324,7 +10436,7 @@ const AgentResponse = ({ children }) => {
|
|
|
10324
10436
|
// Only the active instance should process stepFormStreamData from Redux.
|
|
10325
10437
|
let instanceCounter = 0;
|
|
10326
10438
|
let activeTabularInstanceId = null;
|
|
10327
|
-
const TabularContent = ({ steps: initialSteps, currentTabValue, children, questions: initialQuestions = [], questionsStepsMap: initialQuestionsStepsMap = {}, stepFormDataMap: initialStepFormDataMap = {}, isFormDisabled = false, sessionId: propSessionId = "", botProps = null, currentMode = "", agentId = "" }) => {
|
|
10439
|
+
const TabularContent = ({ steps: initialSteps, currentTabValue, children, questions: initialQuestions = [], questionsStepsMap: initialQuestionsStepsMap = {}, stepFormDataMap: initialStepFormDataMap = {}, isFormDisabled = false, sessionId: propSessionId = "", chatSessionId = "", botProps = null, currentMode = "", agentId = "" }) => {
|
|
10328
10440
|
const dispatch = useDispatch();
|
|
10329
10441
|
const stepFormStreamData = useSelector((state) => state.smartBotReducer.stepFormStreamData);
|
|
10330
10442
|
const thinkingContext = useSelector((state) => state.smartBotReducer.thinkingContext);
|
|
@@ -10805,7 +10917,7 @@ const TabularContent = ({ steps: initialSteps, currentTabValue, children, questi
|
|
|
10805
10917
|
icon: jsx(PsychologyOutlinedIcon, { fontSize: "large" }),
|
|
10806
10918
|
},
|
|
10807
10919
|
], tabPanels: [
|
|
10808
|
-
jsx(Steps, { steps: stepsState, questions: questionsState, questionsStepsMap: questionsStepsMapState, stepFormDataMap: stepFormDataMapState, isFormDisabled: (isFormDisabled && !isRestreaming) || stepFormSubmitted || isTimedOut, activeFormIntent: hasNewStepFormFromRestream ? activeFormIntent : null, isRestreaming: isRestreaming }),
|
|
10920
|
+
jsx(Steps, { steps: stepsState, questions: questionsState, questionsStepsMap: questionsStepsMapState, stepFormDataMap: stepFormDataMapState, isFormDisabled: (isFormDisabled && !isRestreaming) || stepFormSubmitted || isTimedOut, activeFormIntent: hasNewStepFormFromRestream ? activeFormIntent : null, isRestreaming: isRestreaming, sessionId: propSessionId, chatSessionId: chatSessionId, agentId: agentId }),
|
|
10809
10921
|
jsxs(AgentResponse, { children: [children, renderedWidgets.length > 0 && (jsx("div", { className: "restream-widget-content", children: renderedWidgets })), retryCountdown > 0 && (jsx("div", { style: { marginTop: "8px" }, children: jsx(TextRenderer, { text: `Auto re-trying in ${retryCountdown}s`, thinking: "" }) })), timeoutMessage && (jsx("div", { style: { marginTop: "8px" }, children: jsx(TextRenderer, { text: timeoutMessage, thinking: "" }) }))] }),
|
|
10810
10922
|
], value: tabValue }) }));
|
|
10811
10923
|
};
|
|
@@ -10848,6 +10960,8 @@ const CombinedContent = ({ botData, props }) => {
|
|
|
10848
10960
|
return jsx(DateRangePickerContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled, messageIndex: botData.messageIndex }, key);
|
|
10849
10961
|
case "checkbox":
|
|
10850
10962
|
return jsx(CheckboxContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled, messageIndex: botData.messageIndex }, key);
|
|
10963
|
+
case "checkboxGroup":
|
|
10964
|
+
return jsx(CheckboxGroupContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled, messageIndex: botData.messageIndex }, key);
|
|
10851
10965
|
case "radio":
|
|
10852
10966
|
return jsx(RadioContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled, messageIndex: botData.messageIndex }, key);
|
|
10853
10967
|
case "button":
|
|
@@ -10883,7 +10997,7 @@ const CombinedContent = ({ botData, props }) => {
|
|
|
10883
10997
|
const validContent = renderedContent.filter(content => content !== null);
|
|
10884
10998
|
const renderCombinedContent = () => (jsx("div", { className: "combined-content-container", children: validContent.length > 0 ? (validContent.map((content, index) => (jsx("div", { className: "combined-content-item", children: content }, `wrapper-${index}`)))) : (jsx("div", { children: "No valid content to display" })) }));
|
|
10885
10999
|
if (isTabEnabled) {
|
|
10886
|
-
return (jsx(TabularContent, { steps: botData?.utilityData?.steps || [], currentTabValue: botData?.utilityData?.currentTabValue || "steps", questions: botData?.utilityData?.questions || [], questionsStepsMap: botData?.utilityData?.questionsStepsMap || {}, stepFormDataMap: botData?.utilityData?.stepFormDataMap || {}, isFormDisabled: isFormDisabled, sessionId: botData?.sessionId || "", botProps: props, currentMode: botData?.currentMode || "", agentId: botData?.agentId || "", children: renderCombinedContent() }));
|
|
11000
|
+
return (jsx(TabularContent, { steps: botData?.utilityData?.steps || [], currentTabValue: botData?.utilityData?.currentTabValue || "steps", questions: botData?.utilityData?.questions || [], questionsStepsMap: botData?.utilityData?.questionsStepsMap || {}, stepFormDataMap: botData?.utilityData?.stepFormDataMap || {}, isFormDisabled: isFormDisabled, sessionId: botData?.sessionId || "", chatSessionId: botData?.chatSessionId || "", botProps: props, currentMode: botData?.currentMode || "", agentId: botData?.agentId || "", children: renderCombinedContent() }));
|
|
10887
11001
|
}
|
|
10888
11002
|
return renderCombinedContent();
|
|
10889
11003
|
};
|
|
@@ -10946,6 +11060,8 @@ const BotMessage = ({ botData, state, handleLikeDislike, props }) => {
|
|
|
10946
11060
|
return jsx(DateRangePickerContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled, messageIndex: botData.messageIndex });
|
|
10947
11061
|
case "checkbox":
|
|
10948
11062
|
return jsx(CheckboxContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled, messageIndex: botData.messageIndex });
|
|
11063
|
+
case "checkboxGroup":
|
|
11064
|
+
return jsx(CheckboxGroupContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled, messageIndex: botData.messageIndex });
|
|
10949
11065
|
case "radio":
|
|
10950
11066
|
return jsx(RadioContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled, messageIndex: botData.messageIndex });
|
|
10951
11067
|
case "button":
|
|
@@ -13584,9 +13700,9 @@ const ChatbotInput = (props) => {
|
|
|
13584
13700
|
}, [showAnswerModeMenu]);
|
|
13585
13701
|
const ANSWER_MODE_OPTIONS = [
|
|
13586
13702
|
{ value: "fast", label: "Fast", description: "Speed over depth" },
|
|
13587
|
-
{ value: "auto", label: "
|
|
13703
|
+
{ value: "auto", label: "Deep Analysis", description: "Adapts depth, detail, and visuals" },
|
|
13588
13704
|
];
|
|
13589
|
-
const selectedModeOption = ANSWER_MODE_OPTIONS.find((opt) => opt.value === answerMode) || ANSWER_MODE_OPTIONS[
|
|
13705
|
+
const selectedModeOption = ANSWER_MODE_OPTIONS.find((opt) => opt.value === answerMode) || ANSWER_MODE_OPTIONS[0];
|
|
13590
13706
|
return (jsx("div", { className: "chat-input-container", ref: chatInputContainerRef, onClick: (e) => {
|
|
13591
13707
|
// Focus editor when clicking anywhere in the input container
|
|
13592
13708
|
// unless clicking on a button or interactive element
|
|
@@ -15079,7 +15195,7 @@ const SmartBot = (props) => {
|
|
|
15079
15195
|
const [filterOptions, setFilterOptions] = useState([]);
|
|
15080
15196
|
const [savedFilterSets, setSavedFilterSets$1] = useState([]);
|
|
15081
15197
|
const [selectedFilterSet, setSelectedFilterSet] = useState(null);
|
|
15082
|
-
const [answerMode, setAnswerMode] = useState("
|
|
15198
|
+
const [answerMode, setAnswerMode] = useState("fast");
|
|
15083
15199
|
const [chatBotWidth, setChatBotWidth] = useState(null);
|
|
15084
15200
|
const [tabList, setTabList] = useState([]);
|
|
15085
15201
|
useRef(0);
|
|
@@ -16081,10 +16197,50 @@ const SmartBot = (props) => {
|
|
|
16081
16197
|
}
|
|
16082
16198
|
fetchConversations(null, "agent");
|
|
16083
16199
|
}, [renameConversation, deleteConversation, fetchConversations]);
|
|
16200
|
+
// Ref to the SmartBot wrapper so we can scope outside-click detection and the
|
|
16201
|
+
// collapse-button query to this (local) chatbot instance only.
|
|
16202
|
+
const smartBotWrapperRef = useRef(null);
|
|
16203
|
+
// Collapse the expanded/docked chatbot into the small draggable panel by
|
|
16204
|
+
// triggering impact-ui's header "Collapse chatbot" control. That button is
|
|
16205
|
+
// only present while expanded (its label becomes "Expand chatbot" once
|
|
16206
|
+
// collapsed), so this is a safe no-op when already collapsed.
|
|
16207
|
+
const collapseChatBotIfExpanded = useCallback(() => {
|
|
16208
|
+
const root = smartBotWrapperRef.current;
|
|
16209
|
+
if (!root)
|
|
16210
|
+
return;
|
|
16211
|
+
const collapseBtn = root.querySelector('button[aria-label="Collapse chatbot"]');
|
|
16212
|
+
if (collapseBtn)
|
|
16213
|
+
collapseBtn.click();
|
|
16214
|
+
}, []);
|
|
16215
|
+
// Auto-collapse to draggable mode when the user interacts outside the bot.
|
|
16216
|
+
useEffect(() => {
|
|
16217
|
+
const handleOutsideInteraction = (e) => {
|
|
16218
|
+
const root = smartBotWrapperRef.current;
|
|
16219
|
+
if (!root)
|
|
16220
|
+
return;
|
|
16221
|
+
if (root.contains(e.target))
|
|
16222
|
+
return; // interaction inside the bot → ignore
|
|
16223
|
+
collapseChatBotIfExpanded();
|
|
16224
|
+
};
|
|
16225
|
+
document.addEventListener("mousedown", handleOutsideInteraction, true);
|
|
16226
|
+
return () => {
|
|
16227
|
+
document.removeEventListener("mousedown", handleOutsideInteraction, true);
|
|
16228
|
+
};
|
|
16229
|
+
}, [collapseChatBotIfExpanded]);
|
|
16230
|
+
// Auto-collapse on route changes (skip the initial mount so freshly opening
|
|
16231
|
+
// the bot doesn't immediately collapse it).
|
|
16232
|
+
const hasMountedForCollapseRef = useRef(false);
|
|
16233
|
+
useEffect(() => {
|
|
16234
|
+
if (!hasMountedForCollapseRef.current) {
|
|
16235
|
+
hasMountedForCollapseRef.current = true;
|
|
16236
|
+
return;
|
|
16237
|
+
}
|
|
16238
|
+
collapseChatBotIfExpanded();
|
|
16239
|
+
}, [location.pathname, collapseChatBotIfExpanded]);
|
|
16084
16240
|
return (jsxs(Fragment, { children: [partialClose && (minimizedStreamData?.isStreaming || minimizedStreamData?.stepStatus === "step_form") && (jsx(MinimizedChatWidget, { onExpand: () => {
|
|
16085
16241
|
setShowModal(true);
|
|
16086
16242
|
setPartialClose(false);
|
|
16087
|
-
} })), jsxs("div", { className: `${classes.agentStyleOverride} ${partialClose ? classes.hideBotStyle : ""} `, children: [jsx(MemoryModal, { isModalOpen: isModalOpen, setIsModalOpen: setIsModalOpen, displaySnackMessages: displaySnackMessages }), jsx(UploadModal, { isUploadModalOpen: isUploadModalOpen, setIsUploadModalOpen: setIsUploadModalOpen, displaySnackMessages: displaySnackMessages }), jsx(ChatBotComponent, { isFullWidth: forceOpen, userName: userName, showHistoryPanel: false, customInputComponent: currentMode === "agent" && !showSavedFilters ? (jsx(ChatbotInput, { newChatScreen: newChatScreen, inputValue: userInput, setInputValue: setUserInput, isStopIcon: isStop, onSendIconClick: onSendIconClick, onStopIconClick: onStopIconClick, currentMode: currentMode, filterOptions: filterOptions,
|
|
16243
|
+
} })), jsxs("div", { ref: smartBotWrapperRef, className: `${classes.agentStyleOverride} ${partialClose || !(showModal || forceOpen) ? classes.hideBotStyle : ""} `, children: [jsx(MemoryModal, { isModalOpen: isModalOpen, setIsModalOpen: setIsModalOpen, displaySnackMessages: displaySnackMessages }), jsx(UploadModal, { isUploadModalOpen: isUploadModalOpen, setIsUploadModalOpen: setIsUploadModalOpen, displaySnackMessages: displaySnackMessages }), jsx(ChatBotComponent, { isFullWidth: forceOpen, userName: userName, showHistoryPanel: false, customInputComponent: currentMode === "agent" && !showSavedFilters ? (jsx(ChatbotInput, { newChatScreen: newChatScreen, inputValue: userInput, setInputValue: setUserInput, isStopIcon: isStop, onSendIconClick: onSendIconClick, onStopIconClick: onStopIconClick, currentMode: currentMode, filterOptions: filterOptions,
|
|
16088
16244
|
// onSaveClick={saveCurrentChat}
|
|
16089
16245
|
savedFilterSets: savedFilterSets, selectedFilterSet: selectedFilterSet, onFilterSetSelect: (filterSet) => setSelectedFilterSet(filterSet), onClearFilterSet: () => setSelectedFilterSet(null), onTriggerRefresh: triggerRefreshAction, answerMode: answerMode, setAnswerMode: setAnswerMode })) : showSavedFilters ? jsx(Fragment, {}) : null, isChatBotOpen: showModal || forceOpen, historyPanelData: historyPanelData, onHistorySearchChange: (params) => { console.log("History Search Change", params); }, onHistorySelectConversation: (params) => {
|
|
16090
16246
|
console.log("History Select Conversation", params);
|