impact-chatbot 2.3.86 → 2.3.87
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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
2
2
|
import { cloneDeep, isEmpty as isEmpty$1, isNull, isArray as isArray$1, isObject, throttle } from 'lodash';
|
|
3
3
|
import * as React from 'react';
|
|
4
|
-
import { useCallback, useState, useEffect, useRef, createContext, useContext, useMemo
|
|
4
|
+
import { useCallback, useState, useEffect, useRef, Fragment as Fragment$1, createContext, useContext, useMemo } from 'react';
|
|
5
5
|
import { COMBINED_CROSS_DIMENSIONAL_API, BASE_API } from 'config/api';
|
|
6
6
|
import axiosInstance from 'core/Utils/axios';
|
|
7
7
|
import { tenantConfigApiCache } from 'core/actions/tenantConfigActions';
|
|
@@ -5128,17 +5128,26 @@ const TextContent = ({ bodyText, botData }) => {
|
|
|
5128
5128
|
return (jsx("div", { children: renderTextContent() }));
|
|
5129
5129
|
};
|
|
5130
5130
|
|
|
5131
|
-
const ChipsContent = ({ bodyText, props }) => {
|
|
5131
|
+
const ChipsContent = ({ bodyText, props, botData, isFormDisabled = false }) => {
|
|
5132
5132
|
const classes = useStyles$a();
|
|
5133
5133
|
const globalClasses = globalStyles();
|
|
5134
|
-
|
|
5135
|
-
|
|
5136
|
-
|
|
5137
|
-
|
|
5138
|
-
|
|
5139
|
-
|
|
5140
|
-
|
|
5141
|
-
|
|
5134
|
+
// Suggested-question chips are one-shot: once the user has clicked one of them
|
|
5135
|
+
// or asked a new question the block disappears. isFormDisabled is true for
|
|
5136
|
+
// every bot message except the latest, so it flips exactly when the user
|
|
5137
|
+
// moves past these chips. Only chips that opt in via isQuestionsDisabled
|
|
5138
|
+
// behave this way; all other chips stay visible.
|
|
5139
|
+
if (botData?.isQuestionsDisabled && isFormDisabled) {
|
|
5140
|
+
return null;
|
|
5141
|
+
}
|
|
5142
|
+
const showHeaderTitle = !botData?.noShowHeaderTitle && Boolean(botData?.headerTitle?.length);
|
|
5143
|
+
return (jsxs(Fragment$1, { children: [showHeaderTitle && (jsx("div", { className: `${classes.chatbotText} ${classes.boldText} ${classes.combinedBlockHeaderTitle}`, children: botData.headerTitle })), jsx("div", { className: `${globalClasses.flexRow} ${globalClasses.flexWrap} ${globalClasses.gap} ${globalClasses.verticalAlignCenter}`, children: bodyText.map((data, index) => {
|
|
5144
|
+
const callBack = data.interactable && props
|
|
5145
|
+
? Object.entries(props).filter((entry) => entry[0] === data.actionName)?.[0]?.[1]
|
|
5146
|
+
: null;
|
|
5147
|
+
return (jsx(Typography, { component: "span", variant: "body1", className: `${classes.gptChips} ${data.interactable ? globalClasses.cursorPointer : ""}`, onClick: () => {
|
|
5148
|
+
callBack && callBack(data);
|
|
5149
|
+
}, children: data.displayText }, index));
|
|
5150
|
+
}) })] }));
|
|
5142
5151
|
};
|
|
5143
5152
|
|
|
5144
5153
|
/**
|
|
@@ -6135,7 +6144,8 @@ const TableContent = ({ bodyText }) => {
|
|
|
6135
6144
|
};
|
|
6136
6145
|
|
|
6137
6146
|
const GraphContent = ({ bodyText }) => {
|
|
6138
|
-
const { chartOptions } = bodyText || {};
|
|
6147
|
+
const { chartOptions, title } = bodyText || {};
|
|
6148
|
+
const classes = useStyles$a();
|
|
6139
6149
|
const chartRef = useRef(null);
|
|
6140
6150
|
const handleChartRef = (ref) => {
|
|
6141
6151
|
chartRef.current = ref;
|
|
@@ -6146,7 +6156,7 @@ const GraphContent = ({ bodyText }) => {
|
|
|
6146
6156
|
const options = {
|
|
6147
6157
|
...chartOptions,
|
|
6148
6158
|
};
|
|
6149
|
-
return (
|
|
6159
|
+
return (jsxs(Grid, { container: true, children: [Boolean(title?.length) && (jsx(Grid, { item: true, xs: 12, children: jsx("div", { className: `${classes.chatbotText} ${classes.boldText} ${classes.combinedBlockHeaderTitle}`, children: title }) })), jsx(Grid, { item: true, xs: 12, children: jsx(CoreChart, { options: options, handleChartRef: handleChartRef }) })] }));
|
|
6150
6160
|
};
|
|
6151
6161
|
|
|
6152
6162
|
const SelectableChips = ({ bodyText, chipType, props, utilityData }) => {
|
|
@@ -7534,7 +7544,6 @@ const STEP_FORM_TIMEOUT_KEY = "__stepFormTimedOut";
|
|
|
7534
7544
|
*/
|
|
7535
7545
|
const StepFormContent = ({ formData, messageIndex = 0, isFormDisabled = false, showSavedFilters = true, preSelectedFilters = null, botProps = null, currentMode = "", agentId = "", sessionId = "", }) => {
|
|
7536
7546
|
const dispatch = useDispatch();
|
|
7537
|
-
const classes = useStyles$a();
|
|
7538
7547
|
const savedFilterSets = useSelector((state) => state.smartBotReducer.savedFilterSets);
|
|
7539
7548
|
const persistedFormValues = useSelector((state) => state.smartBotReducer.persistedFormValues);
|
|
7540
7549
|
const chatbotContext = useSelector((state) => state.smartBotReducer.chatbotContext);
|
|
@@ -7807,13 +7816,13 @@ const StepFormContent = ({ formData, messageIndex = 0, isFormDisabled = false, s
|
|
|
7807
7816
|
case "text":
|
|
7808
7817
|
return jsx(TextContent, { bodyText: parsedData.bodyText, botData: parsedData }, key);
|
|
7809
7818
|
case "chips":
|
|
7810
|
-
return parsedData.isMultiSelect ? (jsx(SelectableChips, { bodyText: parsedData.bodyText, chipType: "selectable", utilityData: parsedData.utilityData, props: botProps }, key)) : (jsx(ChipsContent, { bodyText: parsedData.bodyText, props: botProps }, key));
|
|
7819
|
+
return parsedData.isMultiSelect ? (jsx(SelectableChips, { bodyText: parsedData.bodyText, chipType: "selectable", utilityData: parsedData.utilityData, props: botProps }, key)) : (jsx(ChipsContent, { bodyText: parsedData.bodyText, props: botProps, botData: parsedData, isFormDisabled: isFormDisabled }, key));
|
|
7811
7820
|
case "questions":
|
|
7812
7821
|
return jsx(QuestionsContent, { bodyText: parsedData.bodyText, props: botProps }, key);
|
|
7813
7822
|
case "html":
|
|
7814
7823
|
return jsx(HtmlContent, { bodyText: parsedData.bodyText }, key);
|
|
7815
7824
|
case "table":
|
|
7816
|
-
return jsx(TableContent, { bodyText: parsedData.bodyText }, key);
|
|
7825
|
+
return jsx(TableContent, { bodyText: parsedData.bodyText }, parsedData.bodyText?.table_name || key);
|
|
7817
7826
|
case "graph":
|
|
7818
7827
|
return jsx(GraphContent, { bodyText: parsedData.bodyText }, key);
|
|
7819
7828
|
case "slider":
|
|
@@ -7848,17 +7857,11 @@ const StepFormContent = ({ formData, messageIndex = 0, isFormDisabled = false, s
|
|
|
7848
7857
|
const body = renderItem(parsedData, index);
|
|
7849
7858
|
if (!body)
|
|
7850
7859
|
return;
|
|
7851
|
-
// Skip the block header when it is just a repeat of the label the widget
|
|
7852
|
-
// renders itself (parseResponse derives headerTitle from label for inputs).
|
|
7853
|
-
const showHeaderTitle = !parsedData?.noShowHeaderTitle &&
|
|
7854
|
-
Boolean(parsedData?.headerTitle?.length) &&
|
|
7855
|
-
parsedData.headerTitle !== parsedData?.bodyText?.label;
|
|
7856
|
-
const rendered = showHeaderTitle ? (jsxs(Fragment$1, { children: [jsx("div", { className: `${classes.chatbotText} ${classes.boldText} ${classes.combinedBlockHeaderTitle}`, children: parsedData.headerTitle }), body] }, `step-form-block-${index}`)) : (body);
|
|
7857
7860
|
if (parsedData.bodyType === "button") {
|
|
7858
|
-
buttonItems.push(
|
|
7861
|
+
buttonItems.push(body);
|
|
7859
7862
|
}
|
|
7860
7863
|
else {
|
|
7861
|
-
formFields.push(
|
|
7864
|
+
formFields.push(body);
|
|
7862
7865
|
}
|
|
7863
7866
|
}
|
|
7864
7867
|
catch (error) {
|
|
@@ -8368,7 +8371,10 @@ const renderWidgetItem = (item, index, isFormDisabled) => {
|
|
|
8368
8371
|
case "text":
|
|
8369
8372
|
return jsx(TextContent, { bodyText: parsedData.bodyText, botData: parsedData }, key);
|
|
8370
8373
|
case "table":
|
|
8371
|
-
|
|
8374
|
+
// Key on table_name so a different table never reuses a mounted grid.
|
|
8375
|
+
// ag-grid captures its fetch callback once at init, so a reused grid
|
|
8376
|
+
// would keep querying the previous table's table_name.
|
|
8377
|
+
return jsx(TableContent, { bodyText: parsedData.bodyText }, parsedData.bodyText?.table_name || key);
|
|
8372
8378
|
case "graph":
|
|
8373
8379
|
return jsx(GraphContent, { bodyText: parsedData.bodyText }, key);
|
|
8374
8380
|
case "radio":
|
|
@@ -10317,7 +10323,6 @@ let instanceCounter = 0;
|
|
|
10317
10323
|
let activeTabularInstanceId = null;
|
|
10318
10324
|
const TabularContent = ({ steps: initialSteps, currentTabValue, children, questions: initialQuestions = [], questionsStepsMap: initialQuestionsStepsMap = {}, stepFormDataMap: initialStepFormDataMap = {}, isFormDisabled = false, sessionId: propSessionId = "", botProps = null, currentMode = "", agentId = "" }) => {
|
|
10319
10325
|
const dispatch = useDispatch();
|
|
10320
|
-
const chatClasses = useStyles$a();
|
|
10321
10326
|
const stepFormStreamData = useSelector((state) => state.smartBotReducer.stepFormStreamData);
|
|
10322
10327
|
const thinkingContext = useSelector((state) => state.smartBotReducer.thinkingContext);
|
|
10323
10328
|
const streamStartTimeRef = useRef(thinkingContext?.streamStartTime);
|
|
@@ -10406,13 +10411,13 @@ const TabularContent = ({ steps: initialSteps, currentTabValue, children, questi
|
|
|
10406
10411
|
case "text":
|
|
10407
10412
|
return jsx(TextContent, { bodyText: parsedData.bodyText, botData: parsedData }, key);
|
|
10408
10413
|
case "chips":
|
|
10409
|
-
return parsedData.isMultiSelect ? (jsx(SelectableChips, { bodyText: parsedData.bodyText, chipType: "selectable", utilityData: parsedData.utilityData, props: botProps }, key)) : (jsx(ChipsContent, { bodyText: parsedData.bodyText, props: botProps }, key));
|
|
10414
|
+
return parsedData.isMultiSelect ? (jsx(SelectableChips, { bodyText: parsedData.bodyText, chipType: "selectable", utilityData: parsedData.utilityData, props: botProps }, key)) : (jsx(ChipsContent, { bodyText: parsedData.bodyText, props: botProps, botData: parsedData, isFormDisabled: isFormDisabled }, key));
|
|
10410
10415
|
case "questions":
|
|
10411
10416
|
return jsx(QuestionsContent, { bodyText: parsedData.bodyText, props: botProps }, key);
|
|
10412
10417
|
case "image":
|
|
10413
10418
|
return jsx(ImageContent, { bodyText: parsedData.bodyText }, key);
|
|
10414
10419
|
case "table":
|
|
10415
|
-
return jsx(TableContent, { bodyText: parsedData.bodyText }, key);
|
|
10420
|
+
return jsx(TableContent, { bodyText: parsedData.bodyText }, parsedData.bodyText?.table_name || key);
|
|
10416
10421
|
case "graph":
|
|
10417
10422
|
return jsx(GraphContent, { bodyText: parsedData.bodyText }, key);
|
|
10418
10423
|
case "radio":
|
|
@@ -10443,13 +10448,7 @@ const TabularContent = ({ steps: initialSteps, currentTabValue, children, questi
|
|
|
10443
10448
|
if (!parsedData)
|
|
10444
10449
|
return null;
|
|
10445
10450
|
const key = `restream-widget-${index}`;
|
|
10446
|
-
|
|
10447
|
-
if (!body)
|
|
10448
|
-
return null;
|
|
10449
|
-
const showHeaderTitle = !parsedData?.noShowHeaderTitle && Boolean(parsedData?.headerTitle?.length);
|
|
10450
|
-
if (!showHeaderTitle)
|
|
10451
|
-
return body;
|
|
10452
|
-
return (jsxs(Fragment$1, { children: [jsx("div", { className: `${chatClasses.chatbotText} ${chatClasses.boldText} ${chatClasses.combinedBlockHeaderTitle}`, children: parsedData.headerTitle }), body] }, `restream-widget-block-${index}`));
|
|
10451
|
+
return renderWidgetBody(parsedData, key);
|
|
10453
10452
|
}
|
|
10454
10453
|
catch (e) {
|
|
10455
10454
|
console.error("[TabularContent] renderWidget error:", e);
|
|
@@ -10813,19 +10812,10 @@ const resetActiveTabularInstance = () => {
|
|
|
10813
10812
|
};
|
|
10814
10813
|
|
|
10815
10814
|
const CombinedContent = ({ botData, props }) => {
|
|
10816
|
-
const classes = useStyles$a();
|
|
10817
10815
|
const isFormDisabled = botData?.isFormDisabled || false;
|
|
10818
10816
|
const isTabEnabled = botData?.utilityData?.isTabEnabled;
|
|
10819
10817
|
// Get the array of content items from bodyText
|
|
10820
10818
|
const contentItems = Array.isArray(botData.bodyText) ? botData.bodyText : [];
|
|
10821
|
-
// Renders the optional block-level header title above a content item.
|
|
10822
|
-
const renderHeaderTitle = (parsedData) => {
|
|
10823
|
-
const showHeaderTitle = !parsedData?.noShowHeaderTitle &&
|
|
10824
|
-
Boolean(parsedData?.headerTitle?.length);
|
|
10825
|
-
if (!showHeaderTitle)
|
|
10826
|
-
return null;
|
|
10827
|
-
return (jsx("div", { className: `${classes.chatbotText} ${classes.boldText} ${classes.combinedBlockHeaderTitle}`, children: parsedData.headerTitle }));
|
|
10828
|
-
};
|
|
10829
10819
|
// Function to render individual content based on its type
|
|
10830
10820
|
const renderIndividualContent = (parsedData, index) => {
|
|
10831
10821
|
const key = `combined-content-${index}`;
|
|
@@ -10837,12 +10827,12 @@ const CombinedContent = ({ botData, props }) => {
|
|
|
10837
10827
|
return (jsx(SelectableChips, { bodyText: parsedData.bodyText, chipType: "selectable", utilityData: parsedData.utilityData, props: props }, key));
|
|
10838
10828
|
}
|
|
10839
10829
|
else {
|
|
10840
|
-
return jsx(ChipsContent, { bodyText: parsedData.bodyText, props: props }, key);
|
|
10830
|
+
return (jsx(ChipsContent, { bodyText: parsedData.bodyText, props: props, botData: parsedData, isFormDisabled: isFormDisabled }, key));
|
|
10841
10831
|
}
|
|
10842
10832
|
case "questions":
|
|
10843
10833
|
return jsx(QuestionsContent, { bodyText: parsedData.bodyText, props: props }, key);
|
|
10844
10834
|
case "table":
|
|
10845
|
-
return jsx(TableContent, { bodyText: parsedData.bodyText }, key);
|
|
10835
|
+
return jsx(TableContent, { bodyText: parsedData.bodyText }, parsedData.bodyText?.table_name || key);
|
|
10846
10836
|
case "graph":
|
|
10847
10837
|
return jsx(GraphContent, { bodyText: parsedData.bodyText }, key);
|
|
10848
10838
|
case "slider":
|
|
@@ -10878,8 +10868,8 @@ const CombinedContent = ({ botData, props }) => {
|
|
|
10878
10868
|
if (!parsedData) {
|
|
10879
10869
|
return null;
|
|
10880
10870
|
}
|
|
10881
|
-
// Render the parsed content
|
|
10882
|
-
return
|
|
10871
|
+
// Render the parsed content
|
|
10872
|
+
return renderIndividualContent(parsedData, index);
|
|
10883
10873
|
}
|
|
10884
10874
|
catch (error) {
|
|
10885
10875
|
console.error(`Error parsing combined content item at index ${index}:`, error);
|