@microsoft/omnichannel-chat-widget 0.1.0-main.15c1e2b → 0.1.0-main.18d1166
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/README.md +7 -34
- package/lib/cjs/common/Constants.js +3 -0
- package/lib/cjs/common/telemetry/TelemetryConstants.js +31 -4
- package/lib/cjs/common/utils.js +23 -2
- package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +11 -18
- package/lib/cjs/components/headerstateful/HeaderStateful.js +5 -4
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +139 -0
- package/lib/cjs/components/livechatwidget/common/agentEndConversationHelper.js +36 -0
- package/lib/cjs/components/livechatwidget/common/createAdapter.js +2 -0
- package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +5 -2
- package/lib/cjs/components/livechatwidget/common/endChat.js +43 -63
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +11 -43
- package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +3 -3
- package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +254 -2
- package/lib/cjs/components/livechatwidget/common/startChat.js +35 -50
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +64 -27
- package/lib/cjs/components/loadingpanestateful/LoadingPaneStateful.js +8 -1
- package/lib/cjs/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +3 -1
- package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +1 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware.js +7 -3
- package/lib/cjs/contexts/common/ConversationEndEntity.js +12 -0
- package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +10 -7
- package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +4 -1
- package/lib/cjs/contexts/createReducer.js +28 -2
- package/lib/cjs/hooks/useDebounce.js +28 -0
- package/lib/cjs/hooks/useWindowDimensions.js +30 -0
- package/lib/cjs/plugins/newMessageEventHandler.js +10 -0
- package/lib/esm/common/Constants.js +3 -0
- package/lib/esm/common/telemetry/TelemetryConstants.js +31 -4
- package/lib/esm/common/utils.js +20 -0
- package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +11 -18
- package/lib/esm/components/headerstateful/HeaderStateful.js +5 -4
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +134 -0
- package/lib/esm/components/livechatwidget/common/agentEndConversationHelper.js +30 -0
- package/lib/esm/components/livechatwidget/common/createAdapter.js +2 -0
- package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +5 -2
- package/lib/esm/components/livechatwidget/common/endChat.js +45 -65
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +13 -45
- package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +3 -3
- package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +254 -3
- package/lib/esm/components/livechatwidget/common/startChat.js +35 -50
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +64 -27
- package/lib/esm/components/loadingpanestateful/LoadingPaneStateful.js +8 -1
- package/lib/esm/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +3 -1
- package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +1 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware.js +5 -3
- package/lib/esm/contexts/common/ConversationEndEntity.js +5 -0
- package/lib/esm/contexts/common/LiveChatWidgetActionType.js +10 -7
- package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +4 -1
- package/lib/esm/contexts/createReducer.js +28 -2
- package/lib/esm/hooks/useDebounce.js +22 -0
- package/lib/esm/hooks/useWindowDimensions.js +23 -0
- package/lib/esm/plugins/newMessageEventHandler.js +10 -0
- package/lib/types/common/Constants.d.ts +3 -0
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +27 -6
- package/lib/types/common/utils.d.ts +1 -0
- package/lib/types/components/confirmationpanestateful/interfaces/IConfirmationPaneStatefulParams.d.ts +0 -7
- package/lib/types/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.d.ts +9 -0
- package/lib/types/components/livechatwidget/common/agentEndConversationHelper.d.ts +6 -0
- package/lib/types/components/livechatwidget/common/initWebChatComposer.d.ts +1 -1
- package/lib/types/components/livechatwidget/common/setPostChatContextAndLoadSurvey.d.ts +6 -1
- package/lib/types/components/livechatwidget/common/startChat.d.ts +2 -3
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetControlProps.d.ts +1 -0
- package/lib/types/contexts/common/ConversationEndEntity.d.ts +4 -0
- package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +5 -1
- package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +10 -7
- package/lib/types/hooks/useDebounce.d.ts +3 -0
- package/lib/types/hooks/useWindowDimensions.d.ts +4 -0
- package/package.json +3 -3
|
@@ -87,13 +87,17 @@ const setPreChatAndInitiateChat = async (chatSDK, dispatch, setAdapter, isProact
|
|
|
87
87
|
const optionalParams = {
|
|
88
88
|
isProactiveChat
|
|
89
89
|
};
|
|
90
|
-
await initStartChat(chatSDK,
|
|
90
|
+
await initStartChat(chatSDK, dispatch, setAdapter, props, optionalParams);
|
|
91
91
|
};
|
|
92
92
|
|
|
93
93
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
94
94
|
exports.setPreChatAndInitiateChat = setPreChatAndInitiateChat;
|
|
95
|
-
const initStartChat = async (chatSDK,
|
|
95
|
+
const initStartChat = async (chatSDK, dispatch, setAdapter, props, params, persistedState) => {
|
|
96
|
+
var _props$controlProps2;
|
|
96
97
|
let isStartChatSuccessful = false;
|
|
98
|
+
const chatConfig = props === null || props === void 0 ? void 0 : props.chatConfig;
|
|
99
|
+
const getAuthToken = props === null || props === void 0 ? void 0 : props.getAuthToken;
|
|
100
|
+
const hideErrorUIPane = props === null || props === void 0 ? void 0 : (_props$controlProps2 = props.controlProps) === null || _props$controlProps2 === void 0 ? void 0 : _props$controlProps2.hideErrorUIPane;
|
|
97
101
|
try {
|
|
98
102
|
var _newAdapter$activity$, _TelemetryTimers$Widg;
|
|
99
103
|
//Start widget load timer
|
|
@@ -107,6 +111,10 @@ const initStartChat = async (chatSDK, chatConfig, getAuthToken, dispatch, setAda
|
|
|
107
111
|
// set auth token to chat sdk before start chat
|
|
108
112
|
const authSuccess = await (0, _authHelper.handleAuthentication)(chatSDK, chatConfig, getAuthToken);
|
|
109
113
|
if (!authSuccess) {
|
|
114
|
+
dispatch({
|
|
115
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
116
|
+
payload: _ConversationState.ConversationState.Closed
|
|
117
|
+
});
|
|
110
118
|
return;
|
|
111
119
|
}
|
|
112
120
|
}
|
|
@@ -142,12 +150,6 @@ const initStartChat = async (chatSDK, chatConfig, getAuthToken, dispatch, setAda
|
|
|
142
150
|
}
|
|
143
151
|
});
|
|
144
152
|
isStartChatSuccessful = false;
|
|
145
|
-
// Resetting the widget state to Closed, for recent introduction of OC rate limiting(429 Error)
|
|
146
|
-
// TODO : How to diplay a proper UI message to customer to try after sometime at this point - cool down scenario
|
|
147
|
-
dispatch({
|
|
148
|
-
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
149
|
-
payload: _ConversationState.ConversationState.Closed
|
|
150
|
-
});
|
|
151
153
|
return;
|
|
152
154
|
}
|
|
153
155
|
|
|
@@ -176,12 +178,6 @@ const initStartChat = async (chatSDK, chatConfig, getAuthToken, dispatch, setAda
|
|
|
176
178
|
payload: liveChatContext
|
|
177
179
|
});
|
|
178
180
|
|
|
179
|
-
// Set post chat context in state, no survey load
|
|
180
|
-
(0, _setPostChatContextAndLoadSurvey.setPostChatContextAndLoadSurvey)(chatSDK, dispatch);
|
|
181
|
-
|
|
182
|
-
// Updating chat session detail for telemetry
|
|
183
|
-
await (0, _updateSessionDataForTelemetry.updateSessionDataForTelemetry)(chatSDK, dispatch);
|
|
184
|
-
|
|
185
181
|
// Set app state to Active
|
|
186
182
|
if (isStartChatSuccessful) {
|
|
187
183
|
_ActivityStreamHandler.ActivityStreamHandler.uncork();
|
|
@@ -200,6 +196,12 @@ const initStartChat = async (chatSDK, chatConfig, getAuthToken, dispatch, setAda
|
|
|
200
196
|
Description: "Widget load complete",
|
|
201
197
|
ElapsedTimeInMilliseconds: _TelemetryManager.TelemetryTimers === null || _TelemetryManager.TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$Widg = _TelemetryManager.TelemetryTimers.WidgetLoadTimer) === null || _TelemetryTimers$Widg === void 0 ? void 0 : _TelemetryTimers$Widg.milliSecondsElapsed
|
|
202
198
|
});
|
|
199
|
+
|
|
200
|
+
// Set post chat context in state, no survey load
|
|
201
|
+
(0, _setPostChatContextAndLoadSurvey.setPostChatContextAndLoadSurvey)(chatSDK, dispatch);
|
|
202
|
+
|
|
203
|
+
// Updating chat session detail for telemetry
|
|
204
|
+
await (0, _updateSessionDataForTelemetry.updateSessionDataForTelemetry)(chatSDK, dispatch);
|
|
203
205
|
} catch (ex) {
|
|
204
206
|
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
205
207
|
Event: _TelemetryConstants.TelemetryEvent.WidgetLoadFailed,
|
|
@@ -220,11 +222,17 @@ const initStartChat = async (chatSDK, chatConfig, getAuthToken, dispatch, setAda
|
|
|
220
222
|
});
|
|
221
223
|
return;
|
|
222
224
|
}
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
225
|
+
if (!hideErrorUIPane) {
|
|
226
|
+
// Set app state to failing start chat if hideErrorUI is not turned on
|
|
227
|
+
dispatch({
|
|
228
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_START_CHAT_FAILING,
|
|
229
|
+
payload: true
|
|
230
|
+
});
|
|
231
|
+
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
232
|
+
Event: _TelemetryConstants.TelemetryEvent.ErrorUIPaneLoaded,
|
|
233
|
+
Description: "Error UI Pane Loaded"
|
|
234
|
+
});
|
|
235
|
+
}
|
|
228
236
|
// Show the loading pane in other cases for failure, this will help for both hideStartChatButton case
|
|
229
237
|
dispatch({
|
|
230
238
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
@@ -256,15 +264,15 @@ const forceEndChat = async chatSDK => {
|
|
|
256
264
|
|
|
257
265
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
258
266
|
const canConnectToExistingChat = async (props, chatSDK, state, dispatch, setAdapter) => {
|
|
259
|
-
var _chatSDK$omnichannelC, _chatSDK$omnichannelC2, _props$
|
|
267
|
+
var _chatSDK$omnichannelC, _chatSDK$omnichannelC2, _props$controlProps3, _persistedState$domai6;
|
|
260
268
|
// By pass this function in case of popout chat
|
|
261
269
|
if (state.appStates.hideStartChatButton === true) {
|
|
262
270
|
return false;
|
|
263
271
|
}
|
|
264
|
-
const persistedState = (0, _utils.getStateFromCache)(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC === void 0 ? void 0 : _chatSDK$omnichannelC.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC2 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC2 === void 0 ? void 0 : _chatSDK$omnichannelC2.widgetId, (props === null || props === void 0 ? void 0 : (_props$
|
|
272
|
+
const persistedState = (0, _utils.getStateFromCache)(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC === void 0 ? void 0 : _chatSDK$omnichannelC.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC2 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC2 === void 0 ? void 0 : _chatSDK$omnichannelC2.widgetId, (props === null || props === void 0 ? void 0 : (_props$controlProps3 = props.controlProps) === null || _props$controlProps3 === void 0 ? void 0 : _props$controlProps3.widgetInstanceId) ?? "");
|
|
265
273
|
|
|
266
274
|
//Connect to only active chat session
|
|
267
|
-
if (persistedState && !(0, _utils.isUndefinedOrEmpty)(persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai6 = persistedState.domainStates) === null || _persistedState$domai6 === void 0 ? void 0 : _persistedState$domai6.liveChatContext)
|
|
275
|
+
if (persistedState && !(0, _utils.isUndefinedOrEmpty)(persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai6 = persistedState.domainStates) === null || _persistedState$domai6 === void 0 ? void 0 : _persistedState$domai6.liveChatContext)) {
|
|
268
276
|
var _persistedState$domai7;
|
|
269
277
|
dispatch({
|
|
270
278
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
@@ -273,7 +281,7 @@ const canConnectToExistingChat = async (props, chatSDK, state, dispatch, setAdap
|
|
|
273
281
|
const optionalParams = {
|
|
274
282
|
liveChatContext: persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai7 = persistedState.domainStates) === null || _persistedState$domai7 === void 0 ? void 0 : _persistedState$domai7.liveChatContext
|
|
275
283
|
};
|
|
276
|
-
await initStartChat(chatSDK,
|
|
284
|
+
await initStartChat(chatSDK, dispatch, setAdapter, props, optionalParams, persistedState);
|
|
277
285
|
return true;
|
|
278
286
|
} else {
|
|
279
287
|
return false;
|
|
@@ -303,38 +311,11 @@ const setCustomContextParams = chatSDK => {
|
|
|
303
311
|
}
|
|
304
312
|
};
|
|
305
313
|
|
|
306
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
307
|
-
const handleAuthenticationIfEnabled = async (chatSDK, props) => {
|
|
308
|
-
//For auth chat
|
|
309
|
-
if (props.getAuthToken) {
|
|
310
|
-
const authClientFunction = (0, _authHelper.getAuthClientFunction)(props.chatConfig);
|
|
311
|
-
if (authClientFunction) {
|
|
312
|
-
// set auth token to chat sdk before start chat
|
|
313
|
-
const authSuccess = await (0, _authHelper.handleAuthentication)(chatSDK, props.chatConfig, props.getAuthToken);
|
|
314
|
-
if (!authSuccess) {
|
|
315
|
-
return false;
|
|
316
|
-
}
|
|
317
|
-
return true;
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
return true;
|
|
321
|
-
};
|
|
322
|
-
|
|
323
314
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
324
315
|
const checkIfConversationStillValid = async (chatSDK, props, requestId, dispatch) => {
|
|
325
316
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
326
317
|
let conversationDetails = undefined;
|
|
327
318
|
|
|
328
|
-
// Show Loading screen during auth check and start chat calls
|
|
329
|
-
dispatch({
|
|
330
|
-
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
331
|
-
payload: _ConversationState.ConversationState.Loading
|
|
332
|
-
});
|
|
333
|
-
const authSucceed = await handleAuthenticationIfEnabled(chatSDK, props);
|
|
334
|
-
if (!authSucceed) {
|
|
335
|
-
return false;
|
|
336
|
-
}
|
|
337
|
-
|
|
338
319
|
//Preserve old requestId
|
|
339
320
|
const oldRequestId = chatSDK.requestId;
|
|
340
321
|
try {
|
|
@@ -345,6 +326,10 @@ const checkIfConversationStillValid = async (chatSDK, props, requestId, dispatch
|
|
|
345
326
|
return false;
|
|
346
327
|
}
|
|
347
328
|
if (conversationDetails.state === _Constants.LiveWorkItemState.Closed || conversationDetails.state === _Constants.LiveWorkItemState.WrapUp) {
|
|
329
|
+
dispatch({
|
|
330
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
|
|
331
|
+
payload: undefined
|
|
332
|
+
});
|
|
348
333
|
chatSDK.requestId = oldRequestId;
|
|
349
334
|
return false;
|
|
350
335
|
}
|
|
@@ -50,12 +50,14 @@ var _startProactiveChat = require("../common/startProactiveChat");
|
|
|
50
50
|
var _useChatAdapterStore = _interopRequireDefault(require("../../../hooks/useChatAdapterStore"));
|
|
51
51
|
var _useChatContextStore = _interopRequireDefault(require("../../../hooks/useChatContextStore"));
|
|
52
52
|
var _useChatSDKStore = _interopRequireDefault(require("../../../hooks/useChatSDKStore"));
|
|
53
|
+
var _ConversationEndEntity = require("../../../contexts/common/ConversationEndEntity");
|
|
54
|
+
var _agentEndConversationHelper = require("../common/agentEndConversationHelper");
|
|
53
55
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
54
56
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
55
57
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
56
58
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
57
59
|
const LiveChatWidgetStateful = props => {
|
|
58
|
-
var _props$webChatContain, _props$styleProps, _chatSDK$omnichannelC, _props$controlProps, _props$controlProps2, _props$webChatContain3, _props$webChatContain4, _props$styleProps2, _props$
|
|
60
|
+
var _props$webChatContain, _props$styleProps, _chatSDK$omnichannelC, _props$controlProps, _props$controlProps2, _props$webChatContain3, _props$webChatContain4, _props$styleProps2, _props$controlProps15, _props$controlProps16, _props$componentOverr, _props$controlProps17, _props$componentOverr2, _props$controlProps18, _props$componentOverr3, _props$controlProps19, _props$componentOverr4, _props$controlProps20, _props$componentOverr5, _props$controlProps21, _props$componentOverr6, _props$controlProps22, _props$componentOverr7, _props$controlProps23, _props$controlProps24, _props$componentOverr8, _props$controlProps25, _props$componentOverr9, _props$controlProps26, _props$componentOverr10, _props$componentOverr11, _props$componentOverr12;
|
|
59
61
|
const [state, dispatch] = (0, _useChatContextStore.default)();
|
|
60
62
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
61
63
|
const [adapter, setAdapter] = (0, _useChatAdapterStore.default)();
|
|
@@ -125,7 +127,7 @@ const LiveChatWidgetStateful = props => {
|
|
|
125
127
|
//Check if conversation state is not in wrapup or closed state
|
|
126
128
|
isChatValid = await (0, _startChat.checkIfConversationStillValid)(chatSDK, props, (_state$domainStates3 = state.domainStates) === null || _state$domainStates3 === void 0 ? void 0 : (_state$domainStates3$ = _state$domainStates3.liveChatContext) === null || _state$domainStates3$ === void 0 ? void 0 : _state$domainStates3$.requestId, dispatch);
|
|
127
129
|
if (isChatValid === true) {
|
|
128
|
-
await (0, _startChat.initStartChat)(chatSDK,
|
|
130
|
+
await (0, _startChat.initStartChat)(chatSDK, dispatch, setAdapter, props, optionalParams);
|
|
129
131
|
return;
|
|
130
132
|
}
|
|
131
133
|
}
|
|
@@ -141,8 +143,9 @@ const LiveChatWidgetStateful = props => {
|
|
|
141
143
|
}
|
|
142
144
|
}
|
|
143
145
|
};
|
|
144
|
-
|
|
145
|
-
|
|
146
|
+
|
|
147
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
148
|
+
const setupClientDataStore = () => {
|
|
146
149
|
// Add default localStorage support for widget
|
|
147
150
|
if (props.contextDataStore === undefined) {
|
|
148
151
|
var _props$controlProps3, _chatSDK$omnichannelC2, _chatSDK$omnichannelC3, _props$controlProps4;
|
|
@@ -152,6 +155,10 @@ const LiveChatWidgetStateful = props => {
|
|
|
152
155
|
} else {
|
|
153
156
|
_DataStoreManager.DataStoreManager.clientDataStore = props.contextDataStore;
|
|
154
157
|
}
|
|
158
|
+
};
|
|
159
|
+
(0, _react2.useEffect)(() => {
|
|
160
|
+
var _props$controlProps5, _props$controlProps6, _props$controlProps7, _props$chatConfig, _props$chatConfig$Liv, _props$controlProps9, _props$chatConfig2, _props$chatConfig2$Ch;
|
|
161
|
+
setupClientDataStore();
|
|
155
162
|
(0, _registerTelemetryLoggers.registerTelemetryLoggers)(props, dispatch);
|
|
156
163
|
(0, _createInternetConnectionChangeHandler.createInternetConnectionChangeHandler)();
|
|
157
164
|
dispatch({
|
|
@@ -209,7 +216,7 @@ const LiveChatWidgetStateful = props => {
|
|
|
209
216
|
|
|
210
217
|
// useEffect for custom context
|
|
211
218
|
(0, _react2.useEffect)(() => {
|
|
212
|
-
var _chatSDK$omnichannelC8, _chatSDK$omnichannelC9, _props$
|
|
219
|
+
var _chatSDK$omnichannelC8, _chatSDK$omnichannelC9, _props$controlProps13;
|
|
213
220
|
// Add the custom context on receiving the SetCustomContext event
|
|
214
221
|
_omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.SetCustomContext).subscribe(msg => {
|
|
215
222
|
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
@@ -237,14 +244,33 @@ const LiveChatWidgetStateful = props => {
|
|
|
237
244
|
}
|
|
238
245
|
});
|
|
239
246
|
|
|
247
|
+
// Toggle chat visibility
|
|
248
|
+
_omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.HideChatVisibilityChangeEvent).subscribe(event => {
|
|
249
|
+
var _event$payload;
|
|
250
|
+
if ((event === null || event === void 0 ? void 0 : (_event$payload = event.payload) === null || _event$payload === void 0 ? void 0 : _event$payload.isChatHidden) !== undefined) {
|
|
251
|
+
var _event$payload2, _props$controlProps10;
|
|
252
|
+
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
253
|
+
Event: _TelemetryConstants.TelemetryEvent.ChatVisibilityChanged,
|
|
254
|
+
Description: "Chat visibility changed to " + (event === null || event === void 0 ? void 0 : (_event$payload2 = event.payload) === null || _event$payload2 === void 0 ? void 0 : _event$payload2.isChatHidden)
|
|
255
|
+
});
|
|
256
|
+
if ((_props$controlProps10 = props.controlProps) !== null && _props$controlProps10 !== void 0 && _props$controlProps10.hideStartChatButton) {
|
|
257
|
+
var _event$payload3;
|
|
258
|
+
dispatch({
|
|
259
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_MINIMIZED,
|
|
260
|
+
payload: event === null || event === void 0 ? void 0 : (_event$payload3 = event.payload) === null || _event$payload3 === void 0 ? void 0 : _event$payload3.isChatHidden
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
|
|
240
266
|
// Start chat from SDK Event
|
|
241
267
|
_omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.StartChat).subscribe(() => {
|
|
242
|
-
var _chatSDK$omnichannelC4, _chatSDK$omnichannelC5, _props$
|
|
268
|
+
var _chatSDK$omnichannelC4, _chatSDK$omnichannelC5, _props$controlProps11;
|
|
243
269
|
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
244
270
|
Event: _TelemetryConstants.TelemetryEvent.StartChatEventRecevied,
|
|
245
271
|
Description: "Start chat event received."
|
|
246
272
|
});
|
|
247
|
-
const persistedState = (0, _utils.getStateFromCache)(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC4 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC4 === void 0 ? void 0 : _chatSDK$omnichannelC4.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC5 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC5 === void 0 ? void 0 : _chatSDK$omnichannelC5.widgetId, (props === null || props === void 0 ? void 0 : (_props$
|
|
273
|
+
const persistedState = (0, _utils.getStateFromCache)(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC4 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC4 === void 0 ? void 0 : _chatSDK$omnichannelC4.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC5 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC5 === void 0 ? void 0 : _chatSDK$omnichannelC5.widgetId, (props === null || props === void 0 ? void 0 : (_props$controlProps11 = props.controlProps) === null || _props$controlProps11 === void 0 ? void 0 : _props$controlProps11.widgetInstanceId) ?? "");
|
|
248
274
|
|
|
249
275
|
// Chat not found in cache
|
|
250
276
|
if (persistedState === undefined) {
|
|
@@ -285,9 +311,9 @@ const LiveChatWidgetStateful = props => {
|
|
|
285
311
|
// End chat
|
|
286
312
|
_omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.InitiateEndChat).subscribe(async () => {
|
|
287
313
|
if (state.appStates.hideStartChatButton === false) {
|
|
288
|
-
var _chatSDK$omnichannelC6, _chatSDK$omnichannelC7, _props$
|
|
314
|
+
var _chatSDK$omnichannelC6, _chatSDK$omnichannelC7, _props$controlProps12;
|
|
289
315
|
// This is to ensure to get latest state from cache in multitab
|
|
290
|
-
const persistedState = (0, _utils.getStateFromCache)(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC6 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC6 === void 0 ? void 0 : _chatSDK$omnichannelC6.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC7 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC7 === void 0 ? void 0 : _chatSDK$omnichannelC7.widgetId, (props === null || props === void 0 ? void 0 : (_props$
|
|
316
|
+
const persistedState = (0, _utils.getStateFromCache)(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC6 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC6 === void 0 ? void 0 : _chatSDK$omnichannelC6.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC7 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC7 === void 0 ? void 0 : _chatSDK$omnichannelC7.widgetId, (props === null || props === void 0 ? void 0 : (_props$controlProps12 = props.controlProps) === null || _props$controlProps12 === void 0 ? void 0 : _props$controlProps12.widgetInstanceId) ?? "");
|
|
291
317
|
if (persistedState && persistedState.appStates.conversationState === _ConversationState.ConversationState.Active) {
|
|
292
318
|
(0, _endChat.prepareEndChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state);
|
|
293
319
|
} else {
|
|
@@ -307,14 +333,14 @@ const LiveChatWidgetStateful = props => {
|
|
|
307
333
|
});
|
|
308
334
|
|
|
309
335
|
// Listen to end chat event from other tabs
|
|
310
|
-
const endChatEventName = (0, _utils.getWidgetEndChatEventName)(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC8 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC8 === void 0 ? void 0 : _chatSDK$omnichannelC8.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC9 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC9 === void 0 ? void 0 : _chatSDK$omnichannelC9.widgetId, ((_props$
|
|
336
|
+
const endChatEventName = (0, _utils.getWidgetEndChatEventName)(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC8 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC8 === void 0 ? void 0 : _chatSDK$omnichannelC8.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC9 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC9 === void 0 ? void 0 : _chatSDK$omnichannelC9.widgetId, ((_props$controlProps13 = props.controlProps) === null || _props$controlProps13 === void 0 ? void 0 : _props$controlProps13.widgetInstanceId) ?? "");
|
|
311
337
|
_omnichannelChatComponents.BroadcastService.getMessageByEventName(endChatEventName).subscribe(async () => {
|
|
312
338
|
(0, _endChat.endChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, false, false, false);
|
|
313
339
|
return;
|
|
314
340
|
});
|
|
315
341
|
|
|
316
342
|
// When conversation ended by agent
|
|
317
|
-
if (state.appStates.
|
|
343
|
+
if (state.appStates.conversationEndedBy === _ConversationEndEntity.ConversationEndEntity.Agent) {
|
|
318
344
|
(0, _endChat.endChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter);
|
|
319
345
|
}
|
|
320
346
|
|
|
@@ -412,7 +438,7 @@ const LiveChatWidgetStateful = props => {
|
|
|
412
438
|
|
|
413
439
|
// Publish chat widget state
|
|
414
440
|
(0, _react2.useEffect)(() => {
|
|
415
|
-
var _props$chatSDK, _props$chatSDK$omnich, _props$chatSDK2, _props$chatSDK2$omnic, _props$
|
|
441
|
+
var _props$chatSDK, _props$chatSDK$omnich, _props$chatSDK2, _props$chatSDK2$omnic, _props$controlProps14;
|
|
416
442
|
// Only activate these windows events when conversation state is active and chat widget is in popout mode
|
|
417
443
|
// Ghost chat scenarios
|
|
418
444
|
/* COMMENTING THIS CODE FOR PARITY WITH OLD LCW
|
|
@@ -430,7 +456,7 @@ const LiveChatWidgetStateful = props => {
|
|
|
430
456
|
};
|
|
431
457
|
}*/
|
|
432
458
|
|
|
433
|
-
widgetStateEventName = (0, _utils.getWidgetCacheId)(props === null || props === void 0 ? void 0 : (_props$chatSDK = props.chatSDK) === null || _props$chatSDK === void 0 ? void 0 : (_props$chatSDK$omnich = _props$chatSDK.omnichannelConfig) === null || _props$chatSDK$omnich === void 0 ? void 0 : _props$chatSDK$omnich.orgId, props === null || props === void 0 ? void 0 : (_props$chatSDK2 = props.chatSDK) === null || _props$chatSDK2 === void 0 ? void 0 : (_props$chatSDK2$omnic = _props$chatSDK2.omnichannelConfig) === null || _props$chatSDK2$omnic === void 0 ? void 0 : _props$chatSDK2$omnic.widgetId, (props === null || props === void 0 ? void 0 : (_props$
|
|
459
|
+
widgetStateEventName = (0, _utils.getWidgetCacheId)(props === null || props === void 0 ? void 0 : (_props$chatSDK = props.chatSDK) === null || _props$chatSDK === void 0 ? void 0 : (_props$chatSDK$omnich = _props$chatSDK.omnichannelConfig) === null || _props$chatSDK$omnich === void 0 ? void 0 : _props$chatSDK$omnich.orgId, props === null || props === void 0 ? void 0 : (_props$chatSDK2 = props.chatSDK) === null || _props$chatSDK2 === void 0 ? void 0 : (_props$chatSDK2$omnic = _props$chatSDK2.omnichannelConfig) === null || _props$chatSDK2$omnic === void 0 ? void 0 : _props$chatSDK2$omnic.widgetId, (props === null || props === void 0 ? void 0 : (_props$controlProps14 = props.controlProps) === null || _props$controlProps14 === void 0 ? void 0 : _props$controlProps14.widgetInstanceId) ?? "");
|
|
434
460
|
const chatWidgetStateChangeEvent = {
|
|
435
461
|
eventName: widgetStateEventName,
|
|
436
462
|
payload: {
|
|
@@ -439,6 +465,20 @@ const LiveChatWidgetStateful = props => {
|
|
|
439
465
|
};
|
|
440
466
|
_omnichannelChatComponents.BroadcastService.postMessage(chatWidgetStateChangeEvent);
|
|
441
467
|
}, [state]);
|
|
468
|
+
|
|
469
|
+
// Initiate End chat from a single point
|
|
470
|
+
(0, _react2.useEffect)(() => {
|
|
471
|
+
if (state.appStates.conversationEndedBy !== undefined) {
|
|
472
|
+
(0, _endChat.prepareEndChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state);
|
|
473
|
+
}
|
|
474
|
+
}, [state.appStates.conversationEndedBy]);
|
|
475
|
+
|
|
476
|
+
// Handle Agent end conversation cases
|
|
477
|
+
(0, _react2.useEffect)(() => {
|
|
478
|
+
if (state.appStates.conversationEndedByAgentEventReceived) {
|
|
479
|
+
(0, _agentEndConversationHelper.handleAgentEndConversation)(props, state, dispatch);
|
|
480
|
+
}
|
|
481
|
+
}, [state.appStates.conversationEndedByAgentEventReceived]);
|
|
442
482
|
const initiateEndChatOnBrowserUnload = () => {
|
|
443
483
|
var _DataStoreManager$cli;
|
|
444
484
|
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
@@ -458,15 +498,13 @@ const LiveChatWidgetStateful = props => {
|
|
|
458
498
|
eventName: _TelemetryConstants.BroadcastEvent.ClosePopoutWindow
|
|
459
499
|
});
|
|
460
500
|
};
|
|
461
|
-
const webChatProps = (0, _initWebChatComposer.initWebChatComposer)(props, chatSDK, state, dispatch, setWebChatStyles);
|
|
501
|
+
const webChatProps = (0, _initWebChatComposer.initWebChatComposer)(props, chatSDK, setAdapter, state, dispatch, adapter, setWebChatStyles);
|
|
462
502
|
const setPostChatContextRelay = () => (0, _setPostChatContextAndLoadSurvey.setPostChatContextAndLoadSurvey)(chatSDK, dispatch);
|
|
463
503
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
464
504
|
const endChatRelay = (adapter, skipEndChatSDK, skipCloseChat, postMessageToOtherTab) => (0, _endChat.endChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, skipEndChatSDK, skipCloseChat, postMessageToOtherTab);
|
|
465
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
466
|
-
const prepareEndChatRelay = (adapter, state) => (0, _endChat.prepareEndChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state);
|
|
467
505
|
const prepareStartChatRelay = () => (0, _startChat.prepareStartChat)(props, chatSDK, state, dispatch, setAdapter);
|
|
468
506
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
469
|
-
const initStartChatRelay = (optionalParams, persistedState) => (0, _startChat.initStartChat)(chatSDK,
|
|
507
|
+
const initStartChatRelay = (optionalParams, persistedState) => (0, _startChat.initStartChat)(chatSDK, dispatch, setAdapter, props, optionalParams, persistedState);
|
|
470
508
|
const confirmationPaneProps = (0, _initConfirmationPropsComposer.initConfirmationPropsComposer)(props);
|
|
471
509
|
return /*#__PURE__*/_react2.default.createElement(_react2.default.Fragment, null, /*#__PURE__*/_react2.default.createElement("style", null, `
|
|
472
510
|
::-webkit-scrollbar {
|
|
@@ -492,29 +530,28 @@ const LiveChatWidgetStateful = props => {
|
|
|
492
530
|
id: widgetElementId,
|
|
493
531
|
styles: generalStyles,
|
|
494
532
|
className: (_props$styleProps2 = props.styleProps) === null || _props$styleProps2 === void 0 ? void 0 : _props$styleProps2.className
|
|
495
|
-
}, !((_props$
|
|
533
|
+
}, !((_props$controlProps15 = props.controlProps) !== null && _props$controlProps15 !== void 0 && _props$controlProps15.hideChatButton) && !((_props$controlProps16 = props.controlProps) !== null && _props$controlProps16 !== void 0 && _props$controlProps16.hideStartChatButton) && (0, _componentController.shouldShowChatButton)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr = props.componentOverrides) === null || _props$componentOverr === void 0 ? void 0 : _props$componentOverr.chatButton) || /*#__PURE__*/_react2.default.createElement(_ChatButtonStateful.default, {
|
|
496
534
|
buttonProps: props.chatButtonProps,
|
|
497
535
|
outOfOfficeButtonProps: props.outOfOfficeChatButtonProps,
|
|
498
536
|
startChat: prepareStartChatRelay
|
|
499
|
-
})), !((_props$
|
|
537
|
+
})), !((_props$controlProps17 = props.controlProps) !== null && _props$controlProps17 !== void 0 && _props$controlProps17.hideProactiveChatPane) && (0, _componentController.shouldShowProactiveChatPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr2 = props.componentOverrides) === null || _props$componentOverr2 === void 0 ? void 0 : _props$componentOverr2.proactiveChatPane) || /*#__PURE__*/_react2.default.createElement(_ProactiveChatPaneStateful.default, {
|
|
500
538
|
proactiveChatProps: props.proactiveChatPaneProps,
|
|
501
539
|
startChat: prepareStartChatRelay
|
|
502
|
-
})), !((_props$
|
|
540
|
+
})), !((_props$controlProps18 = props.controlProps) !== null && _props$controlProps18 !== void 0 && _props$controlProps18.hideHeader) && (0, _componentController.shouldShowHeader)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr3 = props.componentOverrides) === null || _props$componentOverr3 === void 0 ? void 0 : _props$componentOverr3.header) || /*#__PURE__*/_react2.default.createElement(_HeaderStateful.default, {
|
|
503
541
|
headerProps: props.headerProps,
|
|
504
542
|
outOfOfficeHeaderProps: props.outOfOfficeHeaderProps,
|
|
505
543
|
endChat: endChatRelay
|
|
506
|
-
})), !((_props$
|
|
544
|
+
})), !((_props$controlProps19 = props.controlProps) !== null && _props$controlProps19 !== void 0 && _props$controlProps19.hideLoadingPane) && (0, _componentController.shouldShowLoadingPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr4 = props.componentOverrides) === null || _props$componentOverr4 === void 0 ? void 0 : _props$componentOverr4.loadingPane) || /*#__PURE__*/_react2.default.createElement(_LoadingPaneStateful.default, props.loadingPaneProps)), !((_props$controlProps20 = props.controlProps) !== null && _props$controlProps20 !== void 0 && _props$controlProps20.hideOutOfOfficeHoursPane) && (0, _componentController.shouldShowOutOfOfficeHoursPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr5 = props.componentOverrides) === null || _props$componentOverr5 === void 0 ? void 0 : _props$componentOverr5.outOfOfficeHoursPane) || /*#__PURE__*/_react2.default.createElement(_OOOHPaneStateful.default, props.outOfOfficeHoursPaneProps)), !((_props$controlProps21 = props.controlProps) !== null && _props$controlProps21 !== void 0 && _props$controlProps21.hideReconnectChatPane) && (0, _componentController.shouldShowReconnectChatPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr6 = props.componentOverrides) === null || _props$componentOverr6 === void 0 ? void 0 : _props$componentOverr6.reconnectChatPane) || /*#__PURE__*/_react2.default.createElement(_ReconnectChatPaneStateful.default, {
|
|
507
545
|
reconnectChatProps: props.reconnectChatPaneProps,
|
|
508
546
|
initStartChat: initStartChatRelay
|
|
509
|
-
})), !((_props$
|
|
547
|
+
})), !((_props$controlProps22 = props.controlProps) !== null && _props$controlProps22 !== void 0 && _props$controlProps22.hidePreChatSurveyPane) && (0, _componentController.shouldShowPreChatSurveyPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr7 = props.componentOverrides) === null || _props$componentOverr7 === void 0 ? void 0 : _props$componentOverr7.preChatSurveyPane) || /*#__PURE__*/_react2.default.createElement(_PreChatSurveyPaneStateful.default, {
|
|
510
548
|
surveyProps: props.preChatSurveyPaneProps,
|
|
511
549
|
initStartChat: initStartChatRelay
|
|
512
|
-
})), !((_props$
|
|
550
|
+
})), !((_props$controlProps23 = props.controlProps) !== null && _props$controlProps23 !== void 0 && _props$controlProps23.hideCallingContainer) && (0, _componentController.shouldShowCallingContainer)(state) && /*#__PURE__*/_react2.default.createElement(_CallingContainerStateful.default, _extends({
|
|
513
551
|
voiceVideoCallingSdk: voiceVideoCallingSDK
|
|
514
|
-
}, props.callingContainerProps)), !((_props$
|
|
515
|
-
setPostChatContext: setPostChatContextRelay
|
|
516
|
-
|
|
517
|
-
}))), !((_props$controlProps25 = props.controlProps) !== null && _props$controlProps25 !== void 0 && _props$controlProps25.hidePostChatLoadingPane) && (0, _componentController.shouldShowPostChatLoadingPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr10 = props.componentOverrides) === null || _props$componentOverr10 === void 0 ? void 0 : _props$componentOverr10.postChatLoadingPane) || /*#__PURE__*/_react2.default.createElement(_PostChatLoadingPaneStateful.default, props.postChatLoadingPaneProps)), (0, _componentController.shouldShowPostChatSurveyPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr11 = props.componentOverrides) === null || _props$componentOverr11 === void 0 ? void 0 : _props$componentOverr11.postChatSurveyPane) || /*#__PURE__*/_react2.default.createElement(_PostChatSurveyPaneStateful.default, _extends({}, props.postChatSurveyPaneProps, props.chatSDK))), (0, _createFooter.createFooter)(props, state), (0, _componentController.shouldShowEmailTranscriptPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr12 = props.componentOverrides) === null || _props$componentOverr12 === void 0 ? void 0 : _props$componentOverr12.emailTranscriptPane) || /*#__PURE__*/_react2.default.createElement(_EmailTranscriptPaneStateful.default, props.emailTranscriptPane)))));
|
|
552
|
+
}, props.callingContainerProps)), !((_props$controlProps24 = props.controlProps) !== null && _props$controlProps24 !== void 0 && _props$controlProps24.hideWebChatContainer) && (0, _componentController.shouldShowWebChatContainer)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr8 = props.componentOverrides) === null || _props$componentOverr8 === void 0 ? void 0 : _props$componentOverr8.webChatContainer) || /*#__PURE__*/_react2.default.createElement(_WebChatContainerStateful.default, props.webChatContainerProps)), !((_props$controlProps25 = props.controlProps) !== null && _props$controlProps25 !== void 0 && _props$controlProps25.hideConfirmationPane) && (0, _componentController.shouldShowConfirmationPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr9 = props.componentOverrides) === null || _props$componentOverr9 === void 0 ? void 0 : _props$componentOverr9.confirmationPane) || /*#__PURE__*/_react2.default.createElement(_ConfirmationPaneStateful.default, _extends({}, confirmationPaneProps, {
|
|
553
|
+
setPostChatContext: setPostChatContextRelay
|
|
554
|
+
}))), !((_props$controlProps26 = props.controlProps) !== null && _props$controlProps26 !== void 0 && _props$controlProps26.hidePostChatLoadingPane) && (0, _componentController.shouldShowPostChatLoadingPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr10 = props.componentOverrides) === null || _props$componentOverr10 === void 0 ? void 0 : _props$componentOverr10.postChatLoadingPane) || /*#__PURE__*/_react2.default.createElement(_PostChatLoadingPaneStateful.default, props.postChatLoadingPaneProps)), (0, _componentController.shouldShowPostChatSurveyPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr11 = props.componentOverrides) === null || _props$componentOverr11 === void 0 ? void 0 : _props$componentOverr11.postChatSurveyPane) || /*#__PURE__*/_react2.default.createElement(_PostChatSurveyPaneStateful.default, _extends({}, props.postChatSurveyPaneProps, props.chatSDK))), (0, _createFooter.createFooter)(props, state), (0, _componentController.shouldShowEmailTranscriptPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr12 = props.componentOverrides) === null || _props$componentOverr12 === void 0 ? void 0 : _props$componentOverr12.emailTranscriptPane) || /*#__PURE__*/_react2.default.createElement(_EmailTranscriptPaneStateful.default, props.emailTranscriptPane)))));
|
|
518
555
|
};
|
|
519
556
|
exports.LiveChatWidgetStateful = LiveChatWidgetStateful;
|
|
520
557
|
var _default = LiveChatWidgetStateful;
|
|
@@ -11,6 +11,7 @@ var _TelemetryHelper = require("../../common/telemetry/TelemetryHelper");
|
|
|
11
11
|
var _defaultgeneralLoadingPaneStyleProps = require("./common/defaultStyleProps/defaultgeneralLoadingPaneStyleProps");
|
|
12
12
|
var _utils = require("../../common/utils");
|
|
13
13
|
var _useChatContextStore = _interopRequireDefault(require("../../hooks/useChatContextStore"));
|
|
14
|
+
var _useWindowDimensions = _interopRequireDefault(require("../../hooks/useWindowDimensions"));
|
|
14
15
|
var _errorUILoadingPaneStyleProps = require("./common/errorUIStyleProps/errorUILoadingPaneStyleProps");
|
|
15
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
17
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
@@ -40,6 +41,10 @@ const LoadingPaneStateful = props => {
|
|
|
40
41
|
hideSpinnerText: true,
|
|
41
42
|
...props.controlProps
|
|
42
43
|
};
|
|
44
|
+
const {
|
|
45
|
+
height,
|
|
46
|
+
width
|
|
47
|
+
} = (0, _useWindowDimensions.default)();
|
|
43
48
|
|
|
44
49
|
// Move focus to the first button
|
|
45
50
|
(0, _react.useEffect)(() => {
|
|
@@ -55,7 +60,9 @@ const LoadingPaneStateful = props => {
|
|
|
55
60
|
return /*#__PURE__*/_react.default.createElement(_omnichannelChatComponents.LoadingPane, {
|
|
56
61
|
componentOverrides: props.componentOverrides,
|
|
57
62
|
controlProps: state.appStates.isStartChatFailing ? errorUIControlProps : controlProps,
|
|
58
|
-
styleProps: state.appStates.isStartChatFailing ? errorUIStyleProps : styleProps
|
|
63
|
+
styleProps: state.appStates.isStartChatFailing ? errorUIStyleProps : styleProps,
|
|
64
|
+
windowWidth: width,
|
|
65
|
+
windowHeight: height
|
|
59
66
|
});
|
|
60
67
|
};
|
|
61
68
|
exports.LoadingPaneStateful = LoadingPaneStateful;
|
|
@@ -24,7 +24,9 @@ const PostChatSurveyPaneStateful = props => {
|
|
|
24
24
|
display: state.appStates.isMinimized ? "none" : ""
|
|
25
25
|
});
|
|
26
26
|
let surveyInviteLink = "";
|
|
27
|
-
if (state.domainStates.postChatContext.
|
|
27
|
+
if (state.appStates.shouldUseBotSurvey && state.domainStates.postChatContext.botSurveyInviteLink) {
|
|
28
|
+
surveyInviteLink = state.domainStates.postChatContext.botSurveyInviteLink + "&embed=" + (postChatSurveyMode === _PostChatSurveyMode.PostChatSurveyMode.Embed).toString() + "&compact=" + (props.isCustomerVoiceSurveyCompact ?? true).toString() + "&lang=" + (state.domainStates.postChatContext.formsProLocale ?? "en") + "&showmultilingual=false";
|
|
29
|
+
} else {
|
|
28
30
|
surveyInviteLink = state.domainStates.postChatContext.surveyInviteLink + "&embed=" + (postChatSurveyMode === _PostChatSurveyMode.PostChatSurveyMode.Embed).toString() + "&compact=" + (props.isCustomerVoiceSurveyCompact ?? true).toString() + "&lang=" + (state.domainStates.postChatContext.formsProLocale ?? "en") + "&showmultilingual=false";
|
|
29
31
|
}
|
|
30
32
|
const styleProps = {
|
|
@@ -120,7 +120,7 @@ const PreChatSurveyPaneStateful = props => {
|
|
|
120
120
|
}
|
|
121
121
|
if (current && current.tagName.toLowerCase() == _Constants.HtmlAttributeNames.div && current.childElementCount > 0) {
|
|
122
122
|
const input = current.children[0].children;
|
|
123
|
-
if (input
|
|
123
|
+
if ((input === null || input === void 0 ? void 0 : input.length) > 0 && input[0].className != _Constants.HtmlAttributeNames.adaptiveCardToggleInputClassName && input[0].className != _Constants.HtmlAttributeNames.adaptiveCardActionSetClassName) {
|
|
124
124
|
input[0].setAttribute(_Constants.HtmlAttributeNames.ariaLabel, value);
|
|
125
125
|
}
|
|
126
126
|
}
|
|
@@ -4,18 +4,21 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.typingIndicatorMiddleware = void 0;
|
|
7
|
-
var _react =
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _DirectLineSenderRole = require("../../enums/DirectLineSenderRole");
|
|
9
9
|
var _defaultMiddlewareLocalizedTexts = require("../../../common/defaultProps/defaultMiddlewareLocalizedTexts");
|
|
10
10
|
var _defaultTypingIndicatorBubbleStyles = require("./defaultStyles/defaultTypingIndicatorBubbleStyles");
|
|
11
11
|
var _defaultTypingIndicatorContainerStyles = require("./defaultStyles/defaultTypingIndicatorContainerStyles");
|
|
12
12
|
var _defaultTypingIndicatorMessageStyles = require("./defaultStyles/defaultTypingIndicatorMessageStyles");
|
|
13
13
|
var _ = require("../../../../..");
|
|
14
|
+
var _utils = require("../../../../../common/utils");
|
|
14
15
|
var _useChatSDKStore = _interopRequireDefault(require("../../../../../hooks/useChatSDKStore"));
|
|
15
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
18
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
16
19
|
/******
|
|
17
20
|
* TypingIndicatorMiddleware
|
|
18
|
-
*
|
|
21
|
+
*
|
|
19
22
|
* This middleware changes the component that shows who's actively typing. It uses the default Microsoft LiveChatWidget styles.
|
|
20
23
|
******/
|
|
21
24
|
|
|
@@ -29,6 +32,7 @@ const TypingIndicator = _ref => {
|
|
|
29
32
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
30
33
|
const chatSDK = (0, _useChatSDKStore.default)();
|
|
31
34
|
const [state] = (0, _.useChatContextStore)();
|
|
35
|
+
const debounceTyping = (0, _react.useCallback)((0, _utils.debounceLeading)(() => chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.sendTypingEvent()), []);
|
|
32
36
|
if (!activeTyping || Object.keys(activeTyping).length === 0 || ((_state$domainStates$l = state.domainStates.liveChatConfig) === null || _state$domainStates$l === void 0 ? void 0 : _state$domainStates$l.LiveChatVersion) === 1 && !visible) {
|
|
33
37
|
return null;
|
|
34
38
|
}
|
|
@@ -38,7 +42,7 @@ const TypingIndicator = _ref => {
|
|
|
38
42
|
var _state$domainStates$l2;
|
|
39
43
|
//visible is set to false if the current user is typing, in which case, we just send typing indicator to OC
|
|
40
44
|
if (((_state$domainStates$l2 = state.domainStates.liveChatConfig) === null || _state$domainStates$l2 === void 0 ? void 0 : _state$domainStates$l2.LiveChatVersion) === 2 && !visible) {
|
|
41
|
-
|
|
45
|
+
debounceTyping();
|
|
42
46
|
return null;
|
|
43
47
|
}
|
|
44
48
|
activeTyping.splice(i, 1);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ConversationEndEntity = void 0;
|
|
7
|
+
let ConversationEndEntity;
|
|
8
|
+
exports.ConversationEndEntity = ConversationEndEntity;
|
|
9
|
+
(function (ConversationEndEntity) {
|
|
10
|
+
ConversationEndEntity[ConversationEndEntity["Customer"] = 0] = "Customer";
|
|
11
|
+
ConversationEndEntity[ConversationEndEntity["Agent"] = 1] = "Agent";
|
|
12
|
+
})(ConversationEndEntity || (exports.ConversationEndEntity = ConversationEndEntity = {}));
|
|
@@ -36,11 +36,14 @@ exports.LiveChatWidgetActionType = LiveChatWidgetActionType;
|
|
|
36
36
|
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_RECONNECT_ID"] = 26] = "SET_RECONNECT_ID";
|
|
37
37
|
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_UNREAD_MESSAGE_COUNT"] = 27] = "SET_UNREAD_MESSAGE_COUNT";
|
|
38
38
|
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_FOCUS_CHAT_BUTTON"] = 28] = "SET_FOCUS_CHAT_BUTTON";
|
|
39
|
-
LiveChatWidgetActionType[LiveChatWidgetActionType["
|
|
40
|
-
LiveChatWidgetActionType[LiveChatWidgetActionType["
|
|
41
|
-
LiveChatWidgetActionType[LiveChatWidgetActionType["
|
|
42
|
-
LiveChatWidgetActionType[LiveChatWidgetActionType["
|
|
43
|
-
LiveChatWidgetActionType[LiveChatWidgetActionType["
|
|
44
|
-
LiveChatWidgetActionType[LiveChatWidgetActionType["
|
|
45
|
-
LiveChatWidgetActionType[LiveChatWidgetActionType["
|
|
39
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_CONVERSATION_ENDED_BY_AGENT_EVENT_RECEIVED"] = 29] = "SET_CONVERSATION_ENDED_BY_AGENT_EVENT_RECEIVED";
|
|
40
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_CONVERSATION_ENDED_BY"] = 30] = "SET_CONVERSATION_ENDED_BY";
|
|
41
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_WIDGET_STATE"] = 31] = "SET_WIDGET_STATE";
|
|
42
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_LIVE_CHAT_CONTEXT"] = 32] = "SET_LIVE_CHAT_CONTEXT";
|
|
43
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_BOT_OAUTH_SIGNIN_ID"] = 33] = "SET_BOT_OAUTH_SIGNIN_ID";
|
|
44
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_WIDGET_SIZE"] = 34] = "SET_WIDGET_SIZE";
|
|
45
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_WIDGET_INSTANCE_ID"] = 35] = "SET_WIDGET_INSTANCE_ID";
|
|
46
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_LIVE_CHAT_CONFIG"] = 36] = "SET_LIVE_CHAT_CONFIG";
|
|
47
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_POST_CHAT_WORKFLOW_IN_PROGRESS"] = 37] = "SET_POST_CHAT_WORKFLOW_IN_PROGRESS";
|
|
48
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_SHOULD_USE_BOT_SURVEY"] = 38] = "SET_SHOULD_USE_BOT_SURVEY";
|
|
46
49
|
})(LiveChatWidgetActionType || (exports.LiveChatWidgetActionType = LiveChatWidgetActionType = {}));
|
|
@@ -51,7 +51,10 @@ const getLiveChatWidgetContextInitialState = props => {
|
|
|
51
51
|
},
|
|
52
52
|
e2vvEnabled: false,
|
|
53
53
|
unreadMessageCount: 0,
|
|
54
|
-
|
|
54
|
+
conversationEndedByAgentEventReceived: false,
|
|
55
|
+
conversationEndedBy: undefined,
|
|
56
|
+
postChatWorkflowInProgress: false,
|
|
57
|
+
shouldUseBotSurvey: false
|
|
55
58
|
},
|
|
56
59
|
uiStates: {
|
|
57
60
|
showConfirmationPane: false,
|
|
@@ -264,12 +264,20 @@ const createReducer = () => {
|
|
|
264
264
|
return {
|
|
265
265
|
...action.payload
|
|
266
266
|
};
|
|
267
|
-
case _LiveChatWidgetActionType.LiveChatWidgetActionType.
|
|
267
|
+
case _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_ENDED_BY_AGENT_EVENT_RECEIVED:
|
|
268
268
|
return {
|
|
269
269
|
...state,
|
|
270
270
|
appStates: {
|
|
271
271
|
...state.appStates,
|
|
272
|
-
|
|
272
|
+
conversationEndedByAgentEventReceived: action.payload
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
case _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_ENDED_BY:
|
|
276
|
+
return {
|
|
277
|
+
...state,
|
|
278
|
+
appStates: {
|
|
279
|
+
...state.appStates,
|
|
280
|
+
conversationEndedBy: action.payload
|
|
273
281
|
}
|
|
274
282
|
};
|
|
275
283
|
case _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_WIDGET_SIZE:
|
|
@@ -299,6 +307,24 @@ const createReducer = () => {
|
|
|
299
307
|
liveChatConfig: action.payload
|
|
300
308
|
}
|
|
301
309
|
};
|
|
310
|
+
case _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_POST_CHAT_WORKFLOW_IN_PROGRESS:
|
|
311
|
+
return {
|
|
312
|
+
...state,
|
|
313
|
+
appStates: {
|
|
314
|
+
...state.appStates,
|
|
315
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
316
|
+
postChatWorkflowInProgress: action.payload
|
|
317
|
+
}
|
|
318
|
+
};
|
|
319
|
+
case _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_SHOULD_USE_BOT_SURVEY:
|
|
320
|
+
return {
|
|
321
|
+
...state,
|
|
322
|
+
appStates: {
|
|
323
|
+
...state.appStates,
|
|
324
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
325
|
+
shouldUseBotSurvey: action.payload
|
|
326
|
+
}
|
|
327
|
+
};
|
|
302
328
|
default:
|
|
303
329
|
return state;
|
|
304
330
|
}
|