impact-chatbot 2.3.86 → 2.3.88
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/ChipsContent.d.ts +3 -1
- package/dist/index.cjs.js +52 -57
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +53 -58
- package/dist/index.esm.js.map +1 -1
- package/dist/services/chatbot-services.d.ts +1 -0
- package/package.json +1 -1
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';
|
|
@@ -85,6 +85,18 @@ const getAgentVisibilityData = () => {
|
|
|
85
85
|
console.error("getSmartBotVisibilityData error", error);
|
|
86
86
|
}
|
|
87
87
|
};
|
|
88
|
+
const getHideNavbotData = async (applicationCode) => {
|
|
89
|
+
try {
|
|
90
|
+
let { data } = await tenantConfigApiCache(applicationCode, {
|
|
91
|
+
attribute_name: "hide_navbot",
|
|
92
|
+
})();
|
|
93
|
+
return data?.data?.[0]?.attribute_value?.value;
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
console.error("getHideNavbotData error", error);
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
};
|
|
88
100
|
const getAgentExceptionUserList = (applicationCode) => {
|
|
89
101
|
try {
|
|
90
102
|
return tenantConfigApiCache(applicationCode, {
|
|
@@ -1132,13 +1144,6 @@ const resolveInternalPath = (href) => {
|
|
|
1132
1144
|
return null;
|
|
1133
1145
|
}
|
|
1134
1146
|
};
|
|
1135
|
-
/**
|
|
1136
|
-
* Minimizes the chat window so the user can see the screen they navigated to.
|
|
1137
|
-
* SmartBot (index.tsx) listens for this event and sets partialClose.
|
|
1138
|
-
*/
|
|
1139
|
-
const minimizeChatBot = () => {
|
|
1140
|
-
window.dispatchEvent(new CustomEvent("smartBotMinimize"));
|
|
1141
|
-
};
|
|
1142
1147
|
/**
|
|
1143
1148
|
* Anchor rendered inside chatbot markdown. Internal links are navigated through
|
|
1144
1149
|
* react-router so the chatbot is not remounted by a full page load.
|
|
@@ -1157,7 +1162,6 @@ const MarkdownLink = ({ href, children, ...props }) => {
|
|
|
1157
1162
|
if (currentPath !== internalPath) {
|
|
1158
1163
|
navigate(internalPath);
|
|
1159
1164
|
}
|
|
1160
|
-
minimizeChatBot();
|
|
1161
1165
|
};
|
|
1162
1166
|
return (jsx("a", { href: href, target: "_self", onClick: handleClick, ...props, children: children }));
|
|
1163
1167
|
};
|
|
@@ -1260,7 +1264,6 @@ const TextRenderer = ({ text, thinking }) => {
|
|
|
1260
1264
|
if (currentPath !== internalPath) {
|
|
1261
1265
|
navigate(internalPath);
|
|
1262
1266
|
}
|
|
1263
|
-
minimizeChatBot();
|
|
1264
1267
|
};
|
|
1265
1268
|
// If the input contains rich HTML, render it directly with DOMPurify sanitization
|
|
1266
1269
|
if (containsRichHtml(text)) {
|
|
@@ -5128,17 +5131,26 @@ const TextContent = ({ bodyText, botData }) => {
|
|
|
5128
5131
|
return (jsx("div", { children: renderTextContent() }));
|
|
5129
5132
|
};
|
|
5130
5133
|
|
|
5131
|
-
const ChipsContent = ({ bodyText, props }) => {
|
|
5134
|
+
const ChipsContent = ({ bodyText, props, botData, isFormDisabled = false }) => {
|
|
5132
5135
|
const classes = useStyles$a();
|
|
5133
5136
|
const globalClasses = globalStyles();
|
|
5134
|
-
|
|
5135
|
-
|
|
5136
|
-
|
|
5137
|
-
|
|
5138
|
-
|
|
5139
|
-
|
|
5140
|
-
|
|
5141
|
-
|
|
5137
|
+
// Suggested-question chips are one-shot: once the user has clicked one of them
|
|
5138
|
+
// or asked a new question the block disappears. isFormDisabled is true for
|
|
5139
|
+
// every bot message except the latest, so it flips exactly when the user
|
|
5140
|
+
// moves past these chips. Only chips that opt in via isQuestionsDisabled
|
|
5141
|
+
// behave this way; all other chips stay visible.
|
|
5142
|
+
if (botData?.isQuestionsDisabled && isFormDisabled) {
|
|
5143
|
+
return null;
|
|
5144
|
+
}
|
|
5145
|
+
const showHeaderTitle = !botData?.noShowHeaderTitle && Boolean(botData?.headerTitle?.length);
|
|
5146
|
+
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) => {
|
|
5147
|
+
const callBack = data.interactable && props
|
|
5148
|
+
? Object.entries(props).filter((entry) => entry[0] === data.actionName)?.[0]?.[1]
|
|
5149
|
+
: null;
|
|
5150
|
+
return (jsx(Typography, { component: "span", variant: "body1", className: `${classes.gptChips} ${data.interactable ? globalClasses.cursorPointer : ""}`, onClick: () => {
|
|
5151
|
+
callBack && callBack(data);
|
|
5152
|
+
}, children: data.displayText }, index));
|
|
5153
|
+
}) })] }));
|
|
5142
5154
|
};
|
|
5143
5155
|
|
|
5144
5156
|
/**
|
|
@@ -6135,7 +6147,8 @@ const TableContent = ({ bodyText }) => {
|
|
|
6135
6147
|
};
|
|
6136
6148
|
|
|
6137
6149
|
const GraphContent = ({ bodyText }) => {
|
|
6138
|
-
const { chartOptions } = bodyText || {};
|
|
6150
|
+
const { chartOptions, title } = bodyText || {};
|
|
6151
|
+
const classes = useStyles$a();
|
|
6139
6152
|
const chartRef = useRef(null);
|
|
6140
6153
|
const handleChartRef = (ref) => {
|
|
6141
6154
|
chartRef.current = ref;
|
|
@@ -6146,7 +6159,7 @@ const GraphContent = ({ bodyText }) => {
|
|
|
6146
6159
|
const options = {
|
|
6147
6160
|
...chartOptions,
|
|
6148
6161
|
};
|
|
6149
|
-
return (
|
|
6162
|
+
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
6163
|
};
|
|
6151
6164
|
|
|
6152
6165
|
const SelectableChips = ({ bodyText, chipType, props, utilityData }) => {
|
|
@@ -7534,7 +7547,6 @@ const STEP_FORM_TIMEOUT_KEY = "__stepFormTimedOut";
|
|
|
7534
7547
|
*/
|
|
7535
7548
|
const StepFormContent = ({ formData, messageIndex = 0, isFormDisabled = false, showSavedFilters = true, preSelectedFilters = null, botProps = null, currentMode = "", agentId = "", sessionId = "", }) => {
|
|
7536
7549
|
const dispatch = useDispatch();
|
|
7537
|
-
const classes = useStyles$a();
|
|
7538
7550
|
const savedFilterSets = useSelector((state) => state.smartBotReducer.savedFilterSets);
|
|
7539
7551
|
const persistedFormValues = useSelector((state) => state.smartBotReducer.persistedFormValues);
|
|
7540
7552
|
const chatbotContext = useSelector((state) => state.smartBotReducer.chatbotContext);
|
|
@@ -7807,13 +7819,13 @@ const StepFormContent = ({ formData, messageIndex = 0, isFormDisabled = false, s
|
|
|
7807
7819
|
case "text":
|
|
7808
7820
|
return jsx(TextContent, { bodyText: parsedData.bodyText, botData: parsedData }, key);
|
|
7809
7821
|
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));
|
|
7822
|
+
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
7823
|
case "questions":
|
|
7812
7824
|
return jsx(QuestionsContent, { bodyText: parsedData.bodyText, props: botProps }, key);
|
|
7813
7825
|
case "html":
|
|
7814
7826
|
return jsx(HtmlContent, { bodyText: parsedData.bodyText }, key);
|
|
7815
7827
|
case "table":
|
|
7816
|
-
return jsx(TableContent, { bodyText: parsedData.bodyText }, key);
|
|
7828
|
+
return jsx(TableContent, { bodyText: parsedData.bodyText }, parsedData.bodyText?.table_name || key);
|
|
7817
7829
|
case "graph":
|
|
7818
7830
|
return jsx(GraphContent, { bodyText: parsedData.bodyText }, key);
|
|
7819
7831
|
case "slider":
|
|
@@ -7848,17 +7860,11 @@ const StepFormContent = ({ formData, messageIndex = 0, isFormDisabled = false, s
|
|
|
7848
7860
|
const body = renderItem(parsedData, index);
|
|
7849
7861
|
if (!body)
|
|
7850
7862
|
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
7863
|
if (parsedData.bodyType === "button") {
|
|
7858
|
-
buttonItems.push(
|
|
7864
|
+
buttonItems.push(body);
|
|
7859
7865
|
}
|
|
7860
7866
|
else {
|
|
7861
|
-
formFields.push(
|
|
7867
|
+
formFields.push(body);
|
|
7862
7868
|
}
|
|
7863
7869
|
}
|
|
7864
7870
|
catch (error) {
|
|
@@ -8368,7 +8374,10 @@ const renderWidgetItem = (item, index, isFormDisabled) => {
|
|
|
8368
8374
|
case "text":
|
|
8369
8375
|
return jsx(TextContent, { bodyText: parsedData.bodyText, botData: parsedData }, key);
|
|
8370
8376
|
case "table":
|
|
8371
|
-
|
|
8377
|
+
// Key on table_name so a different table never reuses a mounted grid.
|
|
8378
|
+
// ag-grid captures its fetch callback once at init, so a reused grid
|
|
8379
|
+
// would keep querying the previous table's table_name.
|
|
8380
|
+
return jsx(TableContent, { bodyText: parsedData.bodyText }, parsedData.bodyText?.table_name || key);
|
|
8372
8381
|
case "graph":
|
|
8373
8382
|
return jsx(GraphContent, { bodyText: parsedData.bodyText }, key);
|
|
8374
8383
|
case "radio":
|
|
@@ -10317,7 +10326,6 @@ let instanceCounter = 0;
|
|
|
10317
10326
|
let activeTabularInstanceId = null;
|
|
10318
10327
|
const TabularContent = ({ steps: initialSteps, currentTabValue, children, questions: initialQuestions = [], questionsStepsMap: initialQuestionsStepsMap = {}, stepFormDataMap: initialStepFormDataMap = {}, isFormDisabled = false, sessionId: propSessionId = "", botProps = null, currentMode = "", agentId = "" }) => {
|
|
10319
10328
|
const dispatch = useDispatch();
|
|
10320
|
-
const chatClasses = useStyles$a();
|
|
10321
10329
|
const stepFormStreamData = useSelector((state) => state.smartBotReducer.stepFormStreamData);
|
|
10322
10330
|
const thinkingContext = useSelector((state) => state.smartBotReducer.thinkingContext);
|
|
10323
10331
|
const streamStartTimeRef = useRef(thinkingContext?.streamStartTime);
|
|
@@ -10406,13 +10414,13 @@ const TabularContent = ({ steps: initialSteps, currentTabValue, children, questi
|
|
|
10406
10414
|
case "text":
|
|
10407
10415
|
return jsx(TextContent, { bodyText: parsedData.bodyText, botData: parsedData }, key);
|
|
10408
10416
|
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));
|
|
10417
|
+
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
10418
|
case "questions":
|
|
10411
10419
|
return jsx(QuestionsContent, { bodyText: parsedData.bodyText, props: botProps }, key);
|
|
10412
10420
|
case "image":
|
|
10413
10421
|
return jsx(ImageContent, { bodyText: parsedData.bodyText }, key);
|
|
10414
10422
|
case "table":
|
|
10415
|
-
return jsx(TableContent, { bodyText: parsedData.bodyText }, key);
|
|
10423
|
+
return jsx(TableContent, { bodyText: parsedData.bodyText }, parsedData.bodyText?.table_name || key);
|
|
10416
10424
|
case "graph":
|
|
10417
10425
|
return jsx(GraphContent, { bodyText: parsedData.bodyText }, key);
|
|
10418
10426
|
case "radio":
|
|
@@ -10443,13 +10451,7 @@ const TabularContent = ({ steps: initialSteps, currentTabValue, children, questi
|
|
|
10443
10451
|
if (!parsedData)
|
|
10444
10452
|
return null;
|
|
10445
10453
|
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}`));
|
|
10454
|
+
return renderWidgetBody(parsedData, key);
|
|
10453
10455
|
}
|
|
10454
10456
|
catch (e) {
|
|
10455
10457
|
console.error("[TabularContent] renderWidget error:", e);
|
|
@@ -10813,19 +10815,10 @@ const resetActiveTabularInstance = () => {
|
|
|
10813
10815
|
};
|
|
10814
10816
|
|
|
10815
10817
|
const CombinedContent = ({ botData, props }) => {
|
|
10816
|
-
const classes = useStyles$a();
|
|
10817
10818
|
const isFormDisabled = botData?.isFormDisabled || false;
|
|
10818
10819
|
const isTabEnabled = botData?.utilityData?.isTabEnabled;
|
|
10819
10820
|
// Get the array of content items from bodyText
|
|
10820
10821
|
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
10822
|
// Function to render individual content based on its type
|
|
10830
10823
|
const renderIndividualContent = (parsedData, index) => {
|
|
10831
10824
|
const key = `combined-content-${index}`;
|
|
@@ -10837,12 +10830,12 @@ const CombinedContent = ({ botData, props }) => {
|
|
|
10837
10830
|
return (jsx(SelectableChips, { bodyText: parsedData.bodyText, chipType: "selectable", utilityData: parsedData.utilityData, props: props }, key));
|
|
10838
10831
|
}
|
|
10839
10832
|
else {
|
|
10840
|
-
return jsx(ChipsContent, { bodyText: parsedData.bodyText, props: props }, key);
|
|
10833
|
+
return (jsx(ChipsContent, { bodyText: parsedData.bodyText, props: props, botData: parsedData, isFormDisabled: isFormDisabled }, key));
|
|
10841
10834
|
}
|
|
10842
10835
|
case "questions":
|
|
10843
10836
|
return jsx(QuestionsContent, { bodyText: parsedData.bodyText, props: props }, key);
|
|
10844
10837
|
case "table":
|
|
10845
|
-
return jsx(TableContent, { bodyText: parsedData.bodyText }, key);
|
|
10838
|
+
return jsx(TableContent, { bodyText: parsedData.bodyText }, parsedData.bodyText?.table_name || key);
|
|
10846
10839
|
case "graph":
|
|
10847
10840
|
return jsx(GraphContent, { bodyText: parsedData.bodyText }, key);
|
|
10848
10841
|
case "slider":
|
|
@@ -10878,8 +10871,8 @@ const CombinedContent = ({ botData, props }) => {
|
|
|
10878
10871
|
if (!parsedData) {
|
|
10879
10872
|
return null;
|
|
10880
10873
|
}
|
|
10881
|
-
// Render the parsed content
|
|
10882
|
-
return
|
|
10874
|
+
// Render the parsed content
|
|
10875
|
+
return renderIndividualContent(parsedData, index);
|
|
10883
10876
|
}
|
|
10884
10877
|
catch (error) {
|
|
10885
10878
|
console.error(`Error parsing combined content item at index ${index}:`, error);
|
|
@@ -15292,9 +15285,11 @@ const SmartBot = (props) => {
|
|
|
15292
15285
|
skipHierarchyCall: true,
|
|
15293
15286
|
})();
|
|
15294
15287
|
let showAgentIcon = await getAgentVisibilityData();
|
|
15288
|
+
let appCode = getApplicationCodeFromURL(applicationName);
|
|
15289
|
+
let hideNavbot = await getHideNavbotData(appCode);
|
|
15290
|
+
const filterNavigationTab = (tabs) => hideNavbot ? tabs.filter((tab) => tab.name !== "Navigation") : tabs;
|
|
15295
15291
|
if (!isEmpty$1(accessDataResponse) &&
|
|
15296
15292
|
showAgentIcon?.data?.data[0]?.attribute_value?.value) {
|
|
15297
|
-
let appCode = getApplicationCodeFromURL(applicationName);
|
|
15298
15293
|
let list = await getAgentExceptionUserList(appCode);
|
|
15299
15294
|
let isWhitelisted = false;
|
|
15300
15295
|
if (list?.data?.data[0]?.attribute_value?.allow_all) {
|
|
@@ -15506,7 +15501,7 @@ const SmartBot = (props) => {
|
|
|
15506
15501
|
icon: jsx(SvgNavigationIcon, {}),
|
|
15507
15502
|
}
|
|
15508
15503
|
];
|
|
15509
|
-
setTabList(tabListData);
|
|
15504
|
+
setTabList(filterNavigationTab(tabListData));
|
|
15510
15505
|
}
|
|
15511
15506
|
else {
|
|
15512
15507
|
setCurrentMode("navigation");
|