impact-chatbot 2.3.79 → 2.3.82
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/hooks/useChatFlow.d.ts +1 -1
- package/dist/index.cjs.js +30 -8
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +31 -9
- package/dist/index.esm.js.map +1 -1
- 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 } from 'react';
|
|
4
|
+
import { useCallback, useState, useEffect, useRef, createContext, useContext, useMemo, Fragment as Fragment$1 } 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';
|
|
@@ -1151,8 +1151,8 @@ const preprocessMarkdown = (content) => {
|
|
|
1151
1151
|
* Custom components for markdown rendering
|
|
1152
1152
|
*/
|
|
1153
1153
|
const markdownComponents = {
|
|
1154
|
-
// Custom link component
|
|
1155
|
-
a: ({ href, children, ...props }) => (jsx("a", { href: href, target: "
|
|
1154
|
+
// Custom link component that opens in the same tab
|
|
1155
|
+
a: ({ href, children, ...props }) => (jsx("a", { href: href, target: "_self", ...props, children: children })),
|
|
1156
1156
|
// Custom code component
|
|
1157
1157
|
code: ({ children, className, ...props }) => (jsx("code", { className: `markdown-code ${className || ''}`, ...props, children: children })),
|
|
1158
1158
|
// Custom pre component for code blocks
|
|
@@ -2179,11 +2179,17 @@ const useAgentFlow = (dateFormat, chatDataRef, currentMode, setShowChatPlacehold
|
|
|
2179
2179
|
};
|
|
2180
2180
|
};
|
|
2181
2181
|
|
|
2182
|
-
const useChatFlow = (chatDataRef, setLoader, setFlowType, setScreenName, setUserInput, setQuestionIndex, setCurrentAppLink, flowType, screenName, questionIndex, userInput, dateFormat, currentMode, activeConversationId, setIsModuleChanged, chatBodyRef, filterReducerState, dispatch, navigate, setShowChatPlaceholder, baseUrl, setChatDataState, setCurrentSessionId, customChatConfig, chatDataInfoRef, chatbotContext, setInitValue, setSessionId, thinkingContent, setThinkingContent, isThinking, setIsThinking, chatId, setChatId, isStop, setIsStop, functionsRef, functionsState, setFunctionsState, thinkingHeaderMessage, setThinkingHeaderMessage, uniqueChatId, initValue, sessionId, fieldNumber, setFieldNumber, additionalArgs, setActiveConversationId, navSessionId, setNavSessionId) => {
|
|
2182
|
+
const useChatFlow = (chatDataRef, setLoader, setFlowType, setScreenName, setUserInput, setQuestionIndex, setCurrentAppLink, flowType, screenName, questionIndex, userInput, dateFormat, currentMode, activeConversationId, setIsModuleChanged, chatBodyRef, filterReducerState, dispatch, navigate, setShowChatPlaceholder, baseUrl, setChatDataState, setCurrentSessionId, customChatConfig, chatDataInfoRef, chatbotContext, setInitValue, setSessionId, thinkingContent, setThinkingContent, isThinking, setIsThinking, chatId, setChatId, isStop, setIsStop, functionsRef, functionsState, setFunctionsState, thinkingHeaderMessage, setThinkingHeaderMessage, uniqueChatId, initValue, sessionId, fieldNumber, setFieldNumber, additionalArgs, setActiveConversationId, navSessionId, setNavSessionId, setUniqueChatId, setAdditionalArgs) => {
|
|
2183
2183
|
const navSessionIdRef = useRef(navSessionId);
|
|
2184
2184
|
useEffect(() => {
|
|
2185
2185
|
navSessionIdRef.current = navSessionId;
|
|
2186
2186
|
}, [navSessionId]);
|
|
2187
|
+
// Keep a fresh reference to uniqueChatId so callbacks memoized with narrow
|
|
2188
|
+
// deps (e.g. handleUserAction) don't send a stale/empty chat_id on follow-ups.
|
|
2189
|
+
const uniqueChatIdRef = useRef(uniqueChatId);
|
|
2190
|
+
useEffect(() => {
|
|
2191
|
+
uniqueChatIdRef.current = uniqueChatId;
|
|
2192
|
+
}, [uniqueChatId]);
|
|
2187
2193
|
const { prepareDataAndSendToAgent, setAgentFlow, processResponse, } = useAgentFlow(dateFormat, chatDataRef, currentMode, setShowChatPlaceholder, setLoader, baseUrl, setCurrentSessionId, customChatConfig, chatDataInfoRef, {
|
|
2188
2194
|
setChatDataState,
|
|
2189
2195
|
activeConversationId,
|
|
@@ -2206,9 +2212,10 @@ const useChatFlow = (chatDataRef, setLoader, setFlowType, setScreenName, setUser
|
|
|
2206
2212
|
thinkingHeaderMessage,
|
|
2207
2213
|
setThinkingHeaderMessage,
|
|
2208
2214
|
uniqueChatId,
|
|
2215
|
+
setUniqueChatId,
|
|
2209
2216
|
fieldNumber,
|
|
2210
2217
|
setFieldNumber,
|
|
2211
|
-
setAdditionalArgs: () => { },
|
|
2218
|
+
setAdditionalArgs: setAdditionalArgs || (() => { }),
|
|
2212
2219
|
});
|
|
2213
2220
|
const getCurrentDateTimeString = () => {
|
|
2214
2221
|
return moment().format(dateFormat);
|
|
@@ -2371,7 +2378,7 @@ const useChatFlow = (chatDataRef, setLoader, setFlowType, setScreenName, setUser
|
|
|
2371
2378
|
sessionId: sessionId,
|
|
2372
2379
|
setSessionId: setSessionId,
|
|
2373
2380
|
setInitValue: setInitValue,
|
|
2374
|
-
uniqueChatId:
|
|
2381
|
+
uniqueChatId: uniqueChatIdRef.current,
|
|
2375
2382
|
additionalArgs: additionalArgs,
|
|
2376
2383
|
});
|
|
2377
2384
|
}
|
|
@@ -3591,6 +3598,9 @@ const useStyles$a = makeStyles((theme) => ({
|
|
|
3591
3598
|
boldText: {
|
|
3592
3599
|
fontWeight: 600,
|
|
3593
3600
|
},
|
|
3601
|
+
combinedBlockHeaderTitle: {
|
|
3602
|
+
marginBottom: "0.5rem",
|
|
3603
|
+
},
|
|
3594
3604
|
botViewHeader: {
|
|
3595
3605
|
color: theme.palette.textColours.botDateChipText,
|
|
3596
3606
|
},
|
|
@@ -10623,10 +10633,22 @@ const resetActiveTabularInstance = () => {
|
|
|
10623
10633
|
};
|
|
10624
10634
|
|
|
10625
10635
|
const CombinedContent = ({ botData, props }) => {
|
|
10636
|
+
const classes = useStyles$a();
|
|
10626
10637
|
const isFormDisabled = botData?.isFormDisabled || false;
|
|
10627
10638
|
const isTabEnabled = botData?.utilityData?.isTabEnabled;
|
|
10628
10639
|
// Get the array of content items from bodyText
|
|
10629
10640
|
const contentItems = Array.isArray(botData.bodyText) ? botData.bodyText : [];
|
|
10641
|
+
// Renders the optional block-level header title above a content item.
|
|
10642
|
+
// Text blocks are skipped because their heading is the echoed user query
|
|
10643
|
+
// (response_heading), which we don't want to duplicate in the response.
|
|
10644
|
+
const renderHeaderTitle = (parsedData) => {
|
|
10645
|
+
const showHeaderTitle = parsedData?.bodyType !== "text" &&
|
|
10646
|
+
!parsedData?.noShowHeaderTitle &&
|
|
10647
|
+
Boolean(parsedData?.headerTitle?.length);
|
|
10648
|
+
if (!showHeaderTitle)
|
|
10649
|
+
return null;
|
|
10650
|
+
return (jsx("div", { className: `${classes.chatbotText} ${classes.boldText} ${classes.combinedBlockHeaderTitle}`, children: parsedData.headerTitle }));
|
|
10651
|
+
};
|
|
10630
10652
|
// Function to render individual content based on its type
|
|
10631
10653
|
const renderIndividualContent = (parsedData, index) => {
|
|
10632
10654
|
const key = `combined-content-${index}`;
|
|
@@ -10679,8 +10701,8 @@ const CombinedContent = ({ botData, props }) => {
|
|
|
10679
10701
|
if (!parsedData) {
|
|
10680
10702
|
return null;
|
|
10681
10703
|
}
|
|
10682
|
-
// Render the parsed content
|
|
10683
|
-
return renderIndividualContent(parsedData, index);
|
|
10704
|
+
// Render the parsed content, preceded by the block's header title when present
|
|
10705
|
+
return (jsxs(Fragment$1, { children: [renderHeaderTitle(parsedData), renderIndividualContent(parsedData, index)] }, `combined-block-${index}`));
|
|
10684
10706
|
}
|
|
10685
10707
|
catch (error) {
|
|
10686
10708
|
console.error(`Error parsing combined content item at index ${index}:`, error);
|
|
@@ -14891,7 +14913,7 @@ const SmartBot = (props) => {
|
|
|
14891
14913
|
const [chatBotWidth, setChatBotWidth] = useState(null);
|
|
14892
14914
|
const [tabList, setTabList] = useState([]);
|
|
14893
14915
|
useRef(0);
|
|
14894
|
-
const { setUserFlow, setUserScreenAndFlow, fetchUserResultsFromQuery, getCurrentDateTimeString, setLink, } = useChatFlow(chatDataRef, setLoader, setFlowType, setScreenName, setUserInput, setQuestionIndex, setCurrentAppLink, flowType, screenName, questionIndex, userInput, dateFormat, currentMode, activeConversationId, setIsModuleChanged, chatBodyRef, filterReducerState, dispatch, navigate, setShowChatPlaceholder, baseUrl, setChatDataState, setCurrentSessionId, customChatConfig, chatDataInfoRef, chatbotContext, setInitValue, setSessionId, thinkingContent, setThinkingContent, isThinking, setIsThinking, chatId, setChatId, isStop, setIsStop, functionsRef, functionsState, setFunctionsState, thinkingHeaderMessage, setThinkingHeaderMessage, uniqueChatId, initValue, sessionId, fieldNumber, setFieldNumber, additionalArgs, setActiveConversationId, navSessionId, setNavSessionId);
|
|
14916
|
+
const { setUserFlow, setUserScreenAndFlow, fetchUserResultsFromQuery, getCurrentDateTimeString, setLink, } = useChatFlow(chatDataRef, setLoader, setFlowType, setScreenName, setUserInput, setQuestionIndex, setCurrentAppLink, flowType, screenName, questionIndex, userInput, dateFormat, currentMode, activeConversationId, setIsModuleChanged, chatBodyRef, filterReducerState, dispatch, navigate, setShowChatPlaceholder, baseUrl, setChatDataState, setCurrentSessionId, customChatConfig, chatDataInfoRef, chatbotContext, setInitValue, setSessionId, thinkingContent, setThinkingContent, isThinking, setIsThinking, chatId, setChatId, isStop, setIsStop, functionsRef, functionsState, setFunctionsState, thinkingHeaderMessage, setThinkingHeaderMessage, uniqueChatId, initValue, sessionId, fieldNumber, setFieldNumber, additionalArgs, setActiveConversationId, navSessionId, setNavSessionId, setUniqueChatId, setAdditionalArgs);
|
|
14895
14917
|
const { parseSavedFlow, saveCurrentChanges, endCurrentSession, clearChatSession, initiateNewChat, hasUnsavedChanges, } = useChatSession(chatDataRef, setFlowType, setScreenName, setUserInput, setTemplateData, chatDataScreenLinkRef, setShowModal, setMinimizedMode, setSelectedModule, setChatDataState, currentMode, setUserFlow, getCurrentDateTimeString, setCurrentAppLink, selectedModule, fetchUserResultsFromQuery, props.closeBot, activeConversationId, setActiveConversationId, setShowChatPlaceholder);
|
|
14896
14918
|
const { refreshAndUpdateUserManual, configureBotActions, displaySnackMessages, } = useBotConfiguration(setRefreshLoader, setEnableRefreshAction, dispatch);
|
|
14897
14919
|
const { prepareDataAndSendToAgent, processResponse } = useAgentFlow(dateFormat, chatDataRef, currentMode, setShowChatPlaceholder, setLoader, baseUrl, setCurrentSessionId, customChatConfig, chatDataInfoRef, {
|