@microsoft/omnichannel-chat-widget 1.4.1-main.f29a6ae → 1.5.1-main.132e1c6
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 +1 -1
- package/lib/cjs/common/utils.js +19 -2
- package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +8 -11
- package/lib/cjs/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +4 -1
- package/lib/cjs/components/livechatwidget/common/chatDisconnectHelper.js +3 -2
- package/lib/cjs/components/livechatwidget/common/endChat.js +18 -15
- package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +1 -3
- package/lib/cjs/components/livechatwidget/common/renderSurveyHelpers.js +11 -9
- package/lib/cjs/components/livechatwidget/common/startChat.js +36 -16
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +46 -32
- package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +22 -9
- package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts.js +3 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios.js +1 -0
- package/lib/esm/common/utils.js +16 -0
- package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +8 -11
- package/lib/esm/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +5 -2
- package/lib/esm/components/livechatwidget/common/chatDisconnectHelper.js +3 -2
- package/lib/esm/components/livechatwidget/common/endChat.js +18 -18
- package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +1 -3
- package/lib/esm/components/livechatwidget/common/renderSurveyHelpers.js +11 -9
- package/lib/esm/components/livechatwidget/common/startChat.js +37 -17
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +49 -35
- package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +22 -9
- package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts.js +3 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios.js +1 -0
- package/lib/types/common/utils.d.ts +9 -0
- package/lib/types/components/livechatwidget/common/endChat.d.ts +5 -2
- package/lib/types/components/livechatwidget/common/renderSurveyHelpers.d.ts +1 -1
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetControlProps.d.ts +1 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios.d.ts +1 -0
- package/lib/types/contexts/common/ILiveChatWidgetLocalizedTexts.d.ts +9 -0
- package/package.json +3 -3
|
@@ -55,12 +55,13 @@ var _useChatAdapterStore = _interopRequireDefault(require("../../../hooks/useCha
|
|
|
55
55
|
var _useChatContextStore = _interopRequireDefault(require("../../../hooks/useChatContextStore"));
|
|
56
56
|
var _useChatSDKStore = _interopRequireDefault(require("../../../hooks/useChatSDKStore"));
|
|
57
57
|
var _defaultAdaptiveCardStyles = require("../../webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles");
|
|
58
|
+
var _omnichannelChatSdk = require("@microsoft/omnichannel-chat-sdk");
|
|
58
59
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
59
60
|
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); }
|
|
60
61
|
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; }
|
|
61
62
|
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); }
|
|
62
63
|
const LiveChatWidgetStateful = props => {
|
|
63
|
-
var _props$webChatContain, _props$styleProps,
|
|
64
|
+
var _props$webChatContain, _props$styleProps, _props$controlProps, _props$controlProps3, _state$appStates7, _props$webChatContain5, _state$appStates14, _props$webChatContain6, _props$controlProps12, _props$draggableChatW, _props$draggableChatW2, _props$draggableChatW3, _props$draggableChatW4, _props$draggableChatW5, _props$webChatContain7, _props$webChatContain8, _props$webChatContain9, _props$webChatContain10, _livechatProps$webCha, _livechatProps$styleP, _livechatProps$contro, _livechatProps$contro2, _livechatProps$compon, _livechatProps$contro3, _livechatProps$compon2, _livechatProps$contro4, _livechatProps$compon3, _livechatProps$contro5, _livechatProps$compon4, _livechatProps$contro6, _livechatProps$compon5, _livechatProps$contro7, _livechatProps$compon6, _livechatProps$contro8, _livechatProps$compon7, _livechatProps$contro9, _livechatProps$contro10, _livechatProps$compon8, _livechatProps$contro11, _livechatProps$compon9, _livechatProps$contro12, _livechatProps$compon10, _livechatProps$compon11, _livechatProps$compon12;
|
|
64
65
|
const [state, dispatch] = (0, _useChatContextStore.default)();
|
|
65
66
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
66
67
|
const [adapter, setAdapter] = (0, _useChatAdapterStore.default)();
|
|
@@ -84,17 +85,20 @@ const LiveChatWidgetStateful = props => {
|
|
|
84
85
|
|
|
85
86
|
//Scrollbar styles
|
|
86
87
|
const scrollbarProps = Object.assign({}, _defaultScrollBarProps.defaultScrollBarProps, props === null || props === void 0 ? void 0 : props.scrollBarProps);
|
|
87
|
-
|
|
88
|
-
|
|
88
|
+
|
|
89
|
+
// In case the broadcast channel is already initialized elsewhere; One tab can only hold 1 instance
|
|
90
|
+
if ((props === null || props === void 0 ? void 0 : (_props$controlProps = props.controlProps) === null || _props$controlProps === void 0 ? void 0 : _props$controlProps.skipBroadcastChannelInit) !== true) {
|
|
91
|
+
var _chatSDK$omnichannelC, _props$controlProps2;
|
|
92
|
+
const broadcastServiceChannelName = (0, _utils.getBroadcastChannelName)(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC === void 0 ? void 0 : _chatSDK$omnichannelC.widgetId, ((_props$controlProps2 = props.controlProps) === null || _props$controlProps2 === void 0 ? void 0 : _props$controlProps2.widgetInstanceId) ?? "");
|
|
93
|
+
(0, _omnichannelChatComponents.BroadcastServiceInitialize)(broadcastServiceChannelName);
|
|
94
|
+
}
|
|
89
95
|
_TelemetryManager.TelemetryTimers.LcwLoadToChatButtonTimer = (0, _utils.createTimer)();
|
|
90
|
-
const widgetElementId = ((_props$
|
|
96
|
+
const widgetElementId = ((_props$controlProps3 = props.controlProps) === null || _props$controlProps3 === void 0 ? void 0 : _props$controlProps3.id) || "oc-lcw";
|
|
91
97
|
const currentMessageCountRef = (0, _react2.useRef)(0);
|
|
92
98
|
let widgetStateEventId = "";
|
|
93
99
|
const lastLWICheckTimeRef = (0, _react2.useRef)(0);
|
|
94
100
|
let optionalParams;
|
|
95
101
|
let activeCachedChatExist = false;
|
|
96
|
-
const uwid = (0, _react2.useRef)(""); // its an uniqueid per chatr instance
|
|
97
|
-
|
|
98
102
|
const setOptionalParams = () => {
|
|
99
103
|
var _state$appStates, _state$domainStates, _state$appStates3;
|
|
100
104
|
if (!(0, _utils.isUndefinedOrEmpty)((_state$appStates = state.appStates) === null || _state$appStates === void 0 ? void 0 : _state$appStates.reconnectId)) {
|
|
@@ -179,8 +183,8 @@ const LiveChatWidgetStateful = props => {
|
|
|
179
183
|
// Add default localStorage support for widget
|
|
180
184
|
const widgetCacheId = (0, _utils.getWidgetCacheIdfromProps)(props);
|
|
181
185
|
if (props.contextDataStore === undefined) {
|
|
182
|
-
var _props$
|
|
183
|
-
const cacheTtlInMins = (props === null || props === void 0 ? void 0 : (_props$
|
|
186
|
+
var _props$controlProps4;
|
|
187
|
+
const cacheTtlInMins = (props === null || props === void 0 ? void 0 : (_props$controlProps4 = props.controlProps) === null || _props$controlProps4 === void 0 ? void 0 : _props$controlProps4.cacheTtlInMins) ?? _Constants.Constants.CacheTtlInMinutes;
|
|
184
188
|
const storageType = (props === null || props === void 0 ? void 0 : props.useSessionStorage) === true ? _Constants.StorageType.sessionStorage : _Constants.StorageType.localStorage;
|
|
185
189
|
_DataStoreManager.DataStoreManager.clientDataStore = (0, _defaultClientDataStoreProvider.defaultClientDataStoreProvider)(cacheTtlInMins, storageType);
|
|
186
190
|
(0, _defaultCacheManager.registerBroadcastServiceForStorage)(widgetCacheId, cacheTtlInMins, storageType);
|
|
@@ -189,30 +193,29 @@ const LiveChatWidgetStateful = props => {
|
|
|
189
193
|
}
|
|
190
194
|
};
|
|
191
195
|
(0, _react2.useEffect)(() => {
|
|
192
|
-
var _props$
|
|
196
|
+
var _props$controlProps5, _props$controlProps6, _props$controlProps7, _props$chatConfig, _props$chatConfig$Liv, _props$controlProps9, _props$chatConfig2, _props$chatConfig2$Ch, _state$appStates5;
|
|
193
197
|
state.domainStates.confirmationPaneConfirmedOptionClicked = false;
|
|
194
198
|
state.domainStates.confirmationState = _Constants.ConfirmationState.NotSet;
|
|
195
199
|
setupClientDataStore();
|
|
196
200
|
(0, _registerTelemetryLoggers.registerTelemetryLoggers)(props, dispatch);
|
|
197
201
|
(0, _createInternetConnectionChangeHandler.createInternetConnectionChangeHandler)();
|
|
198
|
-
uwid.current = (0, _utils.newGuid)();
|
|
199
202
|
dispatch({
|
|
200
203
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_WIDGET_ELEMENT_ID,
|
|
201
204
|
payload: widgetElementId
|
|
202
205
|
});
|
|
203
206
|
dispatch({
|
|
204
207
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_START_CHAT_BUTTON_DISPLAY,
|
|
205
|
-
payload: ((_props$
|
|
208
|
+
payload: ((_props$controlProps5 = props.controlProps) === null || _props$controlProps5 === void 0 ? void 0 : _props$controlProps5.hideStartChatButton) || false
|
|
206
209
|
});
|
|
207
210
|
dispatch({
|
|
208
211
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_E2VV_ENABLED,
|
|
209
212
|
payload: false
|
|
210
213
|
});
|
|
211
|
-
if ((_props$
|
|
212
|
-
var _props$
|
|
214
|
+
if ((_props$controlProps6 = props.controlProps) !== null && _props$controlProps6 !== void 0 && _props$controlProps6.widgetInstanceId && !(0, _utils.isNullOrEmptyString)((_props$controlProps7 = props.controlProps) === null || _props$controlProps7 === void 0 ? void 0 : _props$controlProps7.widgetInstanceId)) {
|
|
215
|
+
var _props$controlProps8;
|
|
213
216
|
dispatch({
|
|
214
217
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_WIDGET_INSTANCE_ID,
|
|
215
|
-
payload: (_props$
|
|
218
|
+
payload: (_props$controlProps8 = props.controlProps) === null || _props$controlProps8 === void 0 ? void 0 : _props$controlProps8.widgetInstanceId
|
|
216
219
|
});
|
|
217
220
|
}
|
|
218
221
|
if (((_props$chatConfig = props.chatConfig) === null || _props$chatConfig === void 0 ? void 0 : (_props$chatConfig$Liv = _props$chatConfig.LiveWSAndLiveChatEngJoin) === null || _props$chatConfig$Liv === void 0 ? void 0 : _props$chatConfig$Liv.msdyn_callingoptions) !== _Constants.E2VVOptions.NoCalling) {
|
|
@@ -231,7 +234,7 @@ const LiveChatWidgetStateful = props => {
|
|
|
231
234
|
}
|
|
232
235
|
|
|
233
236
|
// Initialize global dir
|
|
234
|
-
const globalDir = ((_props$
|
|
237
|
+
const globalDir = ((_props$controlProps9 = props.controlProps) === null || _props$controlProps9 === void 0 ? void 0 : _props$controlProps9.dir) ?? (0, _utils.getLocaleDirection)((_props$chatConfig2 = props.chatConfig) === null || _props$chatConfig2 === void 0 ? void 0 : (_props$chatConfig2$Ch = _props$chatConfig2.ChatWidgetLanguage) === null || _props$chatConfig2$Ch === void 0 ? void 0 : _props$chatConfig2$Ch.msdyn_localeid);
|
|
235
238
|
dispatch({
|
|
236
239
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_GLOBAL_DIR,
|
|
237
240
|
payload: globalDir
|
|
@@ -267,7 +270,7 @@ const LiveChatWidgetStateful = props => {
|
|
|
267
270
|
|
|
268
271
|
// useEffect for custom context
|
|
269
272
|
(0, _react2.useEffect)(() => {
|
|
270
|
-
var _chatSDK$omnichannelC2, _chatSDK$omnichannelC3, _props$
|
|
273
|
+
var _chatSDK$omnichannelC2, _chatSDK$omnichannelC3, _props$controlProps11;
|
|
271
274
|
// Add the custom context on receiving the SetCustomContext event
|
|
272
275
|
_omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.SetCustomContext).subscribe(msg => {
|
|
273
276
|
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
@@ -300,8 +303,8 @@ const LiveChatWidgetStateful = props => {
|
|
|
300
303
|
_omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.HideChatVisibilityChangeEvent).subscribe(async event => {
|
|
301
304
|
var _event$payload;
|
|
302
305
|
if ((event === null || event === void 0 ? void 0 : (_event$payload = event.payload) === null || _event$payload === void 0 ? void 0 : _event$payload.isChatHidden) !== undefined) {
|
|
303
|
-
var _props$
|
|
304
|
-
if ((_props$
|
|
306
|
+
var _props$controlProps10;
|
|
307
|
+
if ((_props$controlProps10 = props.controlProps) !== null && _props$controlProps10 !== void 0 && _props$controlProps10.hideStartChatButton) {
|
|
305
308
|
var _event$payload2;
|
|
306
309
|
dispatch({
|
|
307
310
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_MINIMIZED,
|
|
@@ -328,23 +331,27 @@ const LiveChatWidgetStateful = props => {
|
|
|
328
331
|
|
|
329
332
|
// Start chat from SDK Event
|
|
330
333
|
_omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.StartChat).subscribe(msg => {
|
|
331
|
-
var _msg$payload4;
|
|
334
|
+
var _msg$payload4, _msg$payload5, _msg$payload6;
|
|
335
|
+
// If the startChat event is not initiated by the same tab. Ignore the call
|
|
336
|
+
if (!(0, _utils.isNullOrUndefined)(msg === null || msg === void 0 ? void 0 : (_msg$payload4 = msg.payload) === null || _msg$payload4 === void 0 ? void 0 : _msg$payload4.runtimeId) && (msg === null || msg === void 0 ? void 0 : (_msg$payload5 = msg.payload) === null || _msg$payload5 === void 0 ? void 0 : _msg$payload5.runtimeId) !== _TelemetryManager.TelemetryManager.InternalTelemetryData.lcwRuntimeId) {
|
|
337
|
+
return;
|
|
338
|
+
}
|
|
332
339
|
let stateWithUpdatedContext = state;
|
|
333
|
-
if (msg !== null && msg !== void 0 && (_msg$
|
|
334
|
-
var _msg$
|
|
340
|
+
if (msg !== null && msg !== void 0 && (_msg$payload6 = msg.payload) !== null && _msg$payload6 !== void 0 && _msg$payload6.customContext) {
|
|
341
|
+
var _msg$payload7, _msg$payload8;
|
|
335
342
|
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
336
343
|
Event: _TelemetryConstants.TelemetryEvent.CustomContextReceived,
|
|
337
344
|
Description: "CustomContext received through startChat event."
|
|
338
345
|
});
|
|
339
346
|
dispatch({
|
|
340
347
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CUSTOM_CONTEXT,
|
|
341
|
-
payload: msg === null || msg === void 0 ? void 0 : (_msg$
|
|
348
|
+
payload: msg === null || msg === void 0 ? void 0 : (_msg$payload7 = msg.payload) === null || _msg$payload7 === void 0 ? void 0 : _msg$payload7.customContext
|
|
342
349
|
});
|
|
343
350
|
stateWithUpdatedContext = {
|
|
344
351
|
...state,
|
|
345
352
|
domainStates: {
|
|
346
353
|
...state.domainStates,
|
|
347
|
-
customContext: msg === null || msg === void 0 ? void 0 : (_msg$
|
|
354
|
+
customContext: msg === null || msg === void 0 ? void 0 : (_msg$payload8 = msg.payload) === null || _msg$payload8 === void 0 ? void 0 : _msg$payload8.customContext
|
|
348
355
|
}
|
|
349
356
|
};
|
|
350
357
|
}
|
|
@@ -420,11 +427,18 @@ const LiveChatWidgetStateful = props => {
|
|
|
420
427
|
});
|
|
421
428
|
|
|
422
429
|
// Listen to end chat event from other tabs
|
|
423
|
-
const endChatEventName = (0, _utils.getWidgetEndChatEventName)(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC2 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC2 === void 0 ? void 0 : _chatSDK$omnichannelC2.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC3 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC3 === void 0 ? void 0 : _chatSDK$omnichannelC3.widgetId, ((_props$
|
|
430
|
+
const endChatEventName = (0, _utils.getWidgetEndChatEventName)(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC2 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC2 === void 0 ? void 0 : _chatSDK$omnichannelC2.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC3 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC3 === void 0 ? void 0 : _chatSDK$omnichannelC3.widgetId, ((_props$controlProps11 = props.controlProps) === null || _props$controlProps11 === void 0 ? void 0 : _props$controlProps11.widgetInstanceId) ?? "");
|
|
424
431
|
_omnichannelChatComponents.BroadcastService.getMessageByEventName(endChatEventName).subscribe(msg => {
|
|
425
|
-
|
|
426
|
-
if (msg.payload !==
|
|
432
|
+
var _msg$payload9;
|
|
433
|
+
if ((msg === null || msg === void 0 ? void 0 : (_msg$payload9 = msg.payload) === null || _msg$payload9 === void 0 ? void 0 : _msg$payload9.runtimeId) !== _TelemetryManager.TelemetryManager.InternalTelemetryData.lcwRuntimeId) {
|
|
427
434
|
(0, _endChat.endChat)(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, true, false, false);
|
|
435
|
+
(0, _endChat.endChatStateCleanUp)(dispatch);
|
|
436
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
437
|
+
chatSDK.requestId = (0, _omnichannelChatSdk.uuidv4)();
|
|
438
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
439
|
+
chatSDK.chatToken = {};
|
|
440
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
441
|
+
chatSDK.reconnectId = null;
|
|
428
442
|
return;
|
|
429
443
|
}
|
|
430
444
|
});
|
|
@@ -552,13 +566,13 @@ const LiveChatWidgetStateful = props => {
|
|
|
552
566
|
|
|
553
567
|
// If start chat failed, and C2 is trying to close chat widget
|
|
554
568
|
if (state !== null && state !== void 0 && (_state$appStates9 = state.appStates) !== null && _state$appStates9 !== void 0 && _state$appStates9.startChatFailed || (state === null || state === void 0 ? void 0 : (_state$appStates10 = state.appStates) === null || _state$appStates10 === void 0 ? void 0 : _state$appStates10.conversationState) === _ConversationState.ConversationState.Postchat) {
|
|
555
|
-
(0, _endChat.endChat)(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, true, false, true
|
|
569
|
+
(0, _endChat.endChat)(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, true, false, true);
|
|
556
570
|
return;
|
|
557
571
|
}
|
|
558
572
|
|
|
559
573
|
// Scenario -> Chat was InActive and closing the chat (Refresh scenario on post chat)
|
|
560
574
|
if ((state === null || state === void 0 ? void 0 : (_state$appStates11 = state.appStates) === null || _state$appStates11 === void 0 ? void 0 : _state$appStates11.conversationState) === _ConversationState.ConversationState.InActive) {
|
|
561
|
-
(0, _endChat.endChat)(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, false, true
|
|
575
|
+
(0, _endChat.endChat)(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, false, true);
|
|
562
576
|
return;
|
|
563
577
|
}
|
|
564
578
|
if ((state === null || state === void 0 ? void 0 : (_state$appStates12 = state.appStates) === null || _state$appStates12 === void 0 ? void 0 : _state$appStates12.conversationEndedBy) === _Constants.ConversationEndEntity.Agent || (state === null || state === void 0 ? void 0 : (_state$appStates13 = state.appStates) === null || _state$appStates13 === void 0 ? void 0 : _state$appStates13.conversationEndedBy) === _Constants.ConversationEndEntity.Bot) {
|
|
@@ -569,7 +583,7 @@ const LiveChatWidgetStateful = props => {
|
|
|
569
583
|
}
|
|
570
584
|
|
|
571
585
|
// All other cases
|
|
572
|
-
(0, _endChat.prepareEndChat)(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter
|
|
586
|
+
(0, _endChat.prepareEndChat)(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter);
|
|
573
587
|
}, [state === null || state === void 0 ? void 0 : (_state$appStates14 = state.appStates) === null || _state$appStates14 === void 0 ? void 0 : _state$appStates14.conversationEndedBy]);
|
|
574
588
|
|
|
575
589
|
// Publish chat widget state
|
|
@@ -627,13 +641,13 @@ const LiveChatWidgetStateful = props => {
|
|
|
627
641
|
};
|
|
628
642
|
const setPostChatContextRelay = () => (0, _setPostChatContextAndLoadSurvey.setPostChatContextAndLoadSurvey)(chatSDK, dispatch);
|
|
629
643
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
630
|
-
const endChatRelay = (adapter, skipEndChatSDK, skipCloseChat, postMessageToOtherTab) => (0, _endChat.endChat)(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, skipEndChatSDK, skipCloseChat, postMessageToOtherTab
|
|
644
|
+
const endChatRelay = (adapter, skipEndChatSDK, skipCloseChat, postMessageToOtherTab) => (0, _endChat.endChat)(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, skipEndChatSDK, skipCloseChat, postMessageToOtherTab);
|
|
631
645
|
const prepareStartChatRelay = () => (0, _startChat.prepareStartChat)(props, chatSDK, state, dispatch, setAdapter);
|
|
632
646
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
633
647
|
const initStartChatRelay = (optionalParams, persistedState) => (0, _startChat.initStartChat)(chatSDK, dispatch, setAdapter, state, props, optionalParams, persistedState);
|
|
634
648
|
const confirmationPaneProps = (0, _initConfirmationPropsComposer.initConfirmationPropsComposer)(props);
|
|
635
649
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
636
|
-
const prepareEndChatRelay = () => (0, _endChat.prepareEndChat)(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter
|
|
650
|
+
const prepareEndChatRelay = () => (0, _endChat.prepareEndChat)(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter);
|
|
637
651
|
const webChatProps = (0, _initWebChatComposer.initWebChatComposer)(props, state, dispatch, chatSDK, endChatRelay);
|
|
638
652
|
const downloadTranscriptProps = (0, _createDownloadTranscriptProps.default)(props.downloadTranscriptProps, {
|
|
639
653
|
...(_defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps === null || _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps === void 0 ? void 0 : _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.webChatStyles),
|
|
@@ -645,7 +659,7 @@ const LiveChatWidgetStateful = props => {
|
|
|
645
659
|
};
|
|
646
660
|
const chatWidgetDraggableConfig = {
|
|
647
661
|
elementId: widgetElementId,
|
|
648
|
-
channel: ((_props$
|
|
662
|
+
channel: ((_props$controlProps12 = props.controlProps) === null || _props$controlProps12 === void 0 ? void 0 : _props$controlProps12.widgetInstanceId) ?? "lcw",
|
|
649
663
|
disabled: ((_props$draggableChatW = props.draggableChatWidgetProps) === null || _props$draggableChatW === void 0 ? void 0 : _props$draggableChatW.disabled) === true ?? false // Draggable by default, unless explicitly disabled
|
|
650
664
|
};
|
|
651
665
|
|
|
@@ -55,13 +55,11 @@ const createMagicCodeSuccessResponse = signin => {
|
|
|
55
55
|
};
|
|
56
56
|
};
|
|
57
57
|
const WebChatContainerStateful = props => {
|
|
58
|
-
var _webChatContainerProp, _webChatContainerProp2, _webChatContainerProp3, _webChatContainerProp4, _webChatContainerProp5, _webChatContainerProp6, _props$
|
|
58
|
+
var _webChatContainerProp, _webChatContainerProp2, _webChatContainerProp3, _webChatContainerProp4, _webChatContainerProp5, _webChatContainerProp6, _props$webChatContain5, _props$webChatContain6, _defaultWebChatContai, _props$webChatContain7, _props$webChatContain8, _defaultWebChatContai2, _webChatContainerProp7, _webChatContainerProp8, _webChatContainerProp9, _webChatContainerProp10, _webChatContainerProp11, _webChatContainerProp12, _webChatContainerProp13, _webChatContainerProp14;
|
|
59
59
|
const {
|
|
60
60
|
BasicWebChat
|
|
61
61
|
} = _botframeworkWebchat.Components;
|
|
62
62
|
const [state, dispatch] = (0, _.useChatContextStore)();
|
|
63
|
-
const magicCodeBroadcastChannel = new window.BroadcastChannel(_Constants.Constants.magicCodeBroadcastChannel); // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
64
|
-
const magicCodeResponseBroadcastChannel = new window.BroadcastChannel(_Constants.Constants.magicCodeResponseBroadcastChannel); // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
65
63
|
const {
|
|
66
64
|
webChatContainerProps,
|
|
67
65
|
contextDataStore
|
|
@@ -69,7 +67,7 @@ const WebChatContainerStateful = props => {
|
|
|
69
67
|
const containerStyles = {
|
|
70
68
|
root: Object.assign({}, _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.containerStyles, webChatContainerProps === null || webChatContainerProps === void 0 ? void 0 : webChatContainerProps.containerStyles, {
|
|
71
69
|
display: state.appStates.isMinimized ? "none" : ""
|
|
72
|
-
}) // Use this instead of removing WebChat from the picture so that the activity observer inside the adapter is not invoked
|
|
70
|
+
}) // Use this instead of removing WebChat from the picture so that the activity observer inside the adapter is not invoked
|
|
73
71
|
};
|
|
74
72
|
|
|
75
73
|
const localizedTexts = {
|
|
@@ -103,6 +101,21 @@ const WebChatContainerStateful = props => {
|
|
|
103
101
|
}
|
|
104
102
|
}, []);
|
|
105
103
|
(0, _react2.useEffect)(() => {
|
|
104
|
+
var _props$webChatContain3, _props$webChatContain4;
|
|
105
|
+
if (!((_props$webChatContain3 = props.webChatContainerProps) !== null && _props$webChatContain3 !== void 0 && (_props$webChatContain4 = _props$webChatContain3.botMagicCode) !== null && _props$webChatContain4 !== void 0 && _props$webChatContain4.disabled)) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
if (!window.BroadcastChannel) {
|
|
109
|
+
// eslint-disable-line @typescript-eslint/no-explicit-any
|
|
110
|
+
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
111
|
+
Event: _TelemetryConstants.TelemetryEvent.SuppressBotMagicCodeFailed,
|
|
112
|
+
Description: "BroadcastChannel not supported by default on current browser"
|
|
113
|
+
});
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
const magicCodeBroadcastChannel = new window.BroadcastChannel(_Constants.Constants.magicCodeBroadcastChannel); // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
117
|
+
const magicCodeResponseBroadcastChannel = new window.BroadcastChannel(_Constants.Constants.magicCodeResponseBroadcastChannel); // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
118
|
+
|
|
106
119
|
const eventListener = event => {
|
|
107
120
|
// eslint-disable-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-empty-function
|
|
108
121
|
const {
|
|
@@ -156,8 +169,8 @@ const WebChatContainerStateful = props => {
|
|
|
156
169
|
div[class="ac-input-container"] * {white-space:${(webChatContainerProps === null || webChatContainerProps === void 0 ? void 0 : (_webChatContainerProp6 = webChatContainerProps.adaptiveCardStyles) === null || _webChatContainerProp6 === void 0 ? void 0 : _webChatContainerProp6.textWhiteSpace) ?? _defaultAdaptiveCardStyles.defaultAdaptiveCardStyles.textWhiteSpace}}
|
|
157
170
|
|
|
158
171
|
.ms_lcw_webchat_received_message>div.webchat__stacked-layout>div.webchat__stacked-layout__main>div.webchat__stacked-layout__content>div.webchat__stacked-layout__message-row>[class^=webchat]:not(.webchat__bubble--from-user)>.webchat__bubble__content {
|
|
159
|
-
background-color: ${((_props$
|
|
160
|
-
color:${((_props$
|
|
172
|
+
background-color: ${((_props$webChatContain5 = props.webChatContainerProps) === null || _props$webChatContain5 === void 0 ? void 0 : (_props$webChatContain6 = _props$webChatContain5.webChatStyles) === null || _props$webChatContain6 === void 0 ? void 0 : _props$webChatContain6.bubbleBackground) ?? ((_defaultWebChatContai = _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.webChatStyles) === null || _defaultWebChatContai === void 0 ? void 0 : _defaultWebChatContai.bubbleBackground)};
|
|
173
|
+
color:${((_props$webChatContain7 = props.webChatContainerProps) === null || _props$webChatContain7 === void 0 ? void 0 : (_props$webChatContain8 = _props$webChatContain7.webChatStyles) === null || _props$webChatContain8 === void 0 ? void 0 : _props$webChatContain8.bubbleTextColor) ?? ((_defaultWebChatContai2 = _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.webChatStyles) === null || _defaultWebChatContai2 === void 0 ? void 0 : _defaultWebChatContai2.bubbleTextColor)};
|
|
161
174
|
}
|
|
162
175
|
|
|
163
176
|
div[class="ac-textBlock"] a:link,
|
|
@@ -165,11 +178,11 @@ const WebChatContainerStateful = props => {
|
|
|
165
178
|
div[class="ac-textBlock"] a:hover,
|
|
166
179
|
div[class="ac-textBlock"] a:active {
|
|
167
180
|
color: ${(webChatContainerProps === null || webChatContainerProps === void 0 ? void 0 : (_webChatContainerProp7 = webChatContainerProps.adaptiveCardStyles) === null || _webChatContainerProp7 === void 0 ? void 0 : _webChatContainerProp7.anchorColor) ?? _defaultAdaptiveCardStyles.defaultAdaptiveCardStyles.anchorColor};
|
|
168
|
-
}
|
|
181
|
+
}
|
|
169
182
|
|
|
170
183
|
.webchat__stacked-layout__content .ac-actionSet > .ac-pushButton > div {white-space: ${(webChatContainerProps === null || webChatContainerProps === void 0 ? void 0 : (_webChatContainerProp8 = webChatContainerProps.adaptiveCardStyles) === null || _webChatContainerProp8 === void 0 ? void 0 : _webChatContainerProp8.buttonWhiteSpace) ?? _defaultAdaptiveCardStyles.defaultAdaptiveCardStyles.buttonWhiteSpace} !important;}
|
|
171
184
|
|
|
172
|
-
.ms_lcw_webchat_received_message img.webchat__markdown__external-link-icon {
|
|
185
|
+
.ms_lcw_webchat_received_message img.webchat__markdown__external-link-icon {
|
|
173
186
|
background-image : url(data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIzIDMgMTggMTgiICB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxwYXRoIGQ9Ik03LjI1MDEgNC41MDAxN0gxMC43NDk1QzExLjE2MzcgNC41MDAxNyAxMS40OTk1IDQuODM1OTYgMTEuNDk5NSA1LjI1MDE3QzExLjQ5OTUgNS42Mjk4NiAxMS4yMTczIDUuOTQzNjYgMTAuODUxMyA1Ljk5MzMyTDEwLjc0OTUgNi4wMDAxN0g3LjI0OTc0QzYuMDcwNzkgNS45OTk2MSA1LjEwMzQ5IDYuOTA2NTYgNS4wMDc4NiA4LjA2MTEyTDUuMDAwMjggOC4yMjAwM0w1LjAwMzEyIDE2Ljc1MDdDNS4wMDM0MyAxNy45NDE1IDUuOTI4ODUgMTguOTE2MSA3LjA5OTY2IDE4Ljk5NDlMNy4yNTM3MSAxOS4wMDAxTDE1Ljc1MTggMTguOTg4NEMxNi45NDE1IDE4Ljk4NjggMTcuOTE0NSAxOC4wNjIgMTcuOTkzNSAxNi44OTIzTDE3Ljk5ODcgMTYuNzM4NFYxMy4yMzIxQzE3Ljk5ODcgMTIuODE3OSAxOC4zMzQ1IDEyLjQ4MjEgMTguNzQ4NyAxMi40ODIxQzE5LjEyODQgMTIuNDgyMSAxOS40NDIyIDEyLjc2NDMgMTkuNDkxOCAxMy4xMzAzTDE5LjQ5ODcgMTMuMjMyMVYxNi43Mzg0QzE5LjQ5ODcgMTguNzQwNyAxNy45MjkzIDIwLjM3NjkgMTUuOTUyOCAyMC40ODI5TDE1Ljc1MzggMjAuNDg4NEw3LjI1ODI3IDIwLjUwMDFMNy4wNTQ5NSAyMC40OTQ5QzUuMTQyMzkgMjAuMzk1NCAzLjYwODk1IDE4Ljg2MjcgMy41MDgzNyAxNi45NTAyTDMuNTAzMTIgMTYuNzUxMUwzLjUwMDg5IDguMjUyN0wzLjUwNTI5IDguMDUwMkMzLjYwNTM5IDYuMTM3NDkgNS4xMzg2NyA0LjYwNDQ5IDcuMDUwOTYgNC41MDUyN0w3LjI1MDEgNC41MDAxN0gxMC43NDk1SDcuMjUwMVpNMTMuNzQ4MSAzLjAwMTQ2TDIwLjMwMTggMy4wMDE5N0wyMC40MDE0IDMuMDE1NzVMMjAuNTAyMiAzLjA0MzkzTDIwLjU1OSAzLjA2ODAzQzIwLjYxMjIgMy4wOTEyMiAyMC42NjM0IDMuMTIxNjMgMjAuNzExMSAzLjE1ODg1TDIwLjc4MDQgMy4yMjE1NkwyMC44NjQxIDMuMzIwMTRMMjAuOTE4MyAzLjQxMDI1TDIwLjk1NyAzLjUwMDU3TDIwLjk3NjIgMy41NjQ3NkwyMC45ODk4IDMuNjI4NjJMMjAuOTk5MiAzLjcyMjgyTDIwLjk5OTcgMTAuMjU1NEMyMC45OTk3IDEwLjY2OTYgMjAuNjYzOSAxMS4wMDU0IDIwLjI0OTcgMTEuMDA1NEMxOS44NyAxMS4wMDU0IDE5LjU1NjIgMTAuNzIzMiAxOS41MDY1IDEwLjM1NzFMMTkuNDk5NyAxMC4yNTU0TDE5LjQ5ODkgNS41NjE0N0wxMi4yNzk3IDEyLjc4NDdDMTIuMDEzNCAxMy4wNTEgMTEuNTk2OCAxMy4wNzUzIDExLjMwMzEgMTIuODU3NUwxMS4yMTkgMTIuNzg0OUMxMC45NTI3IDEyLjUxODcgMTAuOTI4NCAxMi4xMDIxIDExLjE0NjIgMTEuODA4NEwxMS4yMTg4IDExLjcyNDNMMTguNDM2OSA0LjUwMTQ2SDEzLjc0ODFDMTMuMzY4NCA0LjUwMTQ2IDEzLjA1NDYgNC4yMTkzMSAxMy4wMDUgMy44NTMyNEwxMi45OTgxIDMuNzUxNDZDMTIuOTk4MSAzLjM3MTc3IDEzLjI4MDMgMy4wNTc5NyAxMy42NDY0IDMuMDA4MzFMMTMuNzQ4MSAzLjAwMTQ2WiIgZmlsbD0iI0ZGRkZGRiIgLz48L3N2Zz4) !important;
|
|
174
187
|
height: '.75em';
|
|
175
188
|
marginLeft: '.25em';
|
|
@@ -187,7 +200,7 @@ const WebChatContainerStateful = props => {
|
|
|
187
200
|
.ms_lcw_webchat_received_message a:hover,
|
|
188
201
|
.ms_lcw_webchat_received_message a:active {
|
|
189
202
|
color: ${(webChatContainerProps === null || webChatContainerProps === void 0 ? void 0 : (_webChatContainerProp11 = webChatContainerProps.renderingMiddlewareProps) === null || _webChatContainerProp11 === void 0 ? void 0 : (_webChatContainerProp12 = _webChatContainerProp11.receivedMessageAnchorStyles) === null || _webChatContainerProp12 === void 0 ? void 0 : _webChatContainerProp12.color) ?? (_defaultReceivedMessageAnchorStyles.defaultReceivedMessageAnchorStyles === null || _defaultReceivedMessageAnchorStyles.defaultReceivedMessageAnchorStyles === void 0 ? void 0 : _defaultReceivedMessageAnchorStyles.defaultReceivedMessageAnchorStyles.color)};
|
|
190
|
-
}
|
|
203
|
+
}
|
|
191
204
|
.ms_lcw_webchat_sent_message a:link,
|
|
192
205
|
.ms_lcw_webchat_sent_message a:visited,
|
|
193
206
|
.ms_lcw_webchat_sent_message a:hover,
|
|
@@ -32,6 +32,8 @@ const defaultMiddlewareLocalizedTexts = {
|
|
|
32
32
|
MIDDLEWARE_MESSAGE_RETRY: "Retry",
|
|
33
33
|
MIDDLEWARE_BANNER_CHAT_DISCONNECT: "Your conversation has been disconnected. For additional assistance, please start a new chat.",
|
|
34
34
|
THIRD_PARTY_COOKIES_BLOCKED_ALERT_MESSAGE: "Third party cookies are blocked. Reloading this page will start a new conversation.",
|
|
35
|
-
MIDDLEWARE_BANNER_FILE_IS_MALICIOUS: "{0} has been blocked because the file may contain a malware."
|
|
35
|
+
MIDDLEWARE_BANNER_FILE_IS_MALICIOUS: "{0} has been blocked because the file may contain a malware.",
|
|
36
|
+
MIDDLEWARE_BANNER_FILE_EMAIL_ADDRESS_RECORDED_SUCCESS: "Email will be sent after chat ends!",
|
|
37
|
+
MIDDLEWARE_BANNER_FILE_EMAIL_ADDRESS_RECORDED_ERROR: "Email {0} could not be saved, try again later."
|
|
36
38
|
};
|
|
37
39
|
exports.defaultMiddlewareLocalizedTexts = defaultMiddlewareLocalizedTexts;
|
package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios.js
CHANGED
|
@@ -10,6 +10,7 @@ exports.NotificationScenarios = NotificationScenarios;
|
|
|
10
10
|
NotificationScenarios["Connection"] = "connection";
|
|
11
11
|
NotificationScenarios["DownloadTranscriptError"] = "download transcript";
|
|
12
12
|
NotificationScenarios["EmailTranscriptError"] = "email transcript";
|
|
13
|
+
NotificationScenarios["EmailAddressSaved"] = "email address saved";
|
|
13
14
|
NotificationScenarios["AttachmentError"] = "attachment";
|
|
14
15
|
NotificationScenarios["InternetConnection"] = "internet connection";
|
|
15
16
|
NotificationScenarios["MaxSizeError"] = "max size";
|
package/lib/esm/common/utils.js
CHANGED
|
@@ -396,4 +396,20 @@ export const createFileAndDownload = (fileName, blobData, mimeType) => {
|
|
|
396
396
|
document.body.appendChild(aElement);
|
|
397
397
|
aElement.click();
|
|
398
398
|
document.body.removeChild(aElement);
|
|
399
|
+
};
|
|
400
|
+
|
|
401
|
+
/**
|
|
402
|
+
*
|
|
403
|
+
* Replace placeholders with format {0}..{n} , in a string with values
|
|
404
|
+
*
|
|
405
|
+
* @param template String with placeholders to be replaced
|
|
406
|
+
* @param values array of values to replace the placeholders
|
|
407
|
+
* @returns formatted string with replaced values
|
|
408
|
+
*/
|
|
409
|
+
// use of any for values as array of any type is passed
|
|
410
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
411
|
+
export const formatTemplateString = (templateMessage, values) => {
|
|
412
|
+
return templateMessage.replace(/{(\d+)}/g, (match, index) => {
|
|
413
|
+
return typeof values[index] !== "undefined" ? values[index] : match;
|
|
414
|
+
});
|
|
399
415
|
};
|
|
@@ -56,17 +56,14 @@ export const ChatButtonStateful = props => {
|
|
|
56
56
|
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
57
57
|
Event: TelemetryEvent.LCWChatButtonClicked
|
|
58
58
|
});
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
payload: ConversationState.OutOfOffice
|
|
68
|
-
});
|
|
69
|
-
}
|
|
59
|
+
state.appStates.isMinimized && dispatch({
|
|
60
|
+
type: LiveChatWidgetActionType.SET_MINIMIZED,
|
|
61
|
+
payload: false
|
|
62
|
+
});
|
|
63
|
+
dispatch({
|
|
64
|
+
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
65
|
+
payload: ConversationState.OutOfOffice
|
|
66
|
+
});
|
|
70
67
|
},
|
|
71
68
|
unreadMessageString: (_props$buttonProps3 = props.buttonProps) === null || _props$buttonProps3 === void 0 ? void 0 : (_props$buttonProps3$c = _props$buttonProps3.controlProps) === null || _props$buttonProps3$c === void 0 ? void 0 : _props$buttonProps3$c.unreadMessageString,
|
|
72
69
|
...(outOfOfficeButtonProps === null || outOfOfficeButtonProps === void 0 ? void 0 : outOfOfficeButtonProps.controlProps)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { LogLevel, TelemetryEvent } from "../../common/telemetry/TelemetryConstants";
|
|
2
2
|
import React, { useEffect, useState } from "react";
|
|
3
|
-
import { findAllFocusableElement, findParentFocusableElementsWithoutChildContainer, preventFocusToMoveOutOfElement, setFocusOnElement, setFocusOnSendBox, setTabIndices } from "../../common/utils";
|
|
3
|
+
import { findAllFocusableElement, findParentFocusableElementsWithoutChildContainer, formatTemplateString, preventFocusToMoveOutOfElement, setFocusOnElement, setFocusOnSendBox, setTabIndices } from "../../common/utils";
|
|
4
4
|
import { DimLayer } from "../dimlayer/DimLayer";
|
|
5
5
|
import { InputValidationPane } from "@microsoft/omnichannel-chat-components";
|
|
6
6
|
import { LiveChatWidgetActionType } from "../../contexts/common/LiveChatWidgetActionType";
|
|
@@ -10,6 +10,7 @@ import { Regex } from "../../common/Constants";
|
|
|
10
10
|
import { TelemetryHelper } from "../../common/telemetry/TelemetryHelper";
|
|
11
11
|
import useChatContextStore from "../../hooks/useChatContextStore";
|
|
12
12
|
import useChatSDKStore from "../../hooks/useChatSDKStore";
|
|
13
|
+
import { defaultMiddlewareLocalizedTexts } from "../webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts";
|
|
13
14
|
export const EmailTranscriptPaneStateful = props => {
|
|
14
15
|
var _props$controlProps;
|
|
15
16
|
const initialTabIndexMap = new Map();
|
|
@@ -46,6 +47,7 @@ export const EmailTranscriptPaneStateful = props => {
|
|
|
46
47
|
};
|
|
47
48
|
try {
|
|
48
49
|
await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.emailLiveChatTranscript(chatTranscriptBody));
|
|
50
|
+
NotificationHandler.notifySuccess(NotificationScenarios.EmailAddressSaved, defaultMiddlewareLocalizedTexts === null || defaultMiddlewareLocalizedTexts === void 0 ? void 0 : defaultMiddlewareLocalizedTexts.MIDDLEWARE_BANNER_FILE_EMAIL_ADDRESS_RECORDED_SUCCESS);
|
|
49
51
|
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
50
52
|
Event: TelemetryEvent.EmailTranscriptSent,
|
|
51
53
|
Description: "Transcript sent to email successfully."
|
|
@@ -57,7 +59,8 @@ export const EmailTranscriptPaneStateful = props => {
|
|
|
57
59
|
exception: ex
|
|
58
60
|
}
|
|
59
61
|
});
|
|
60
|
-
|
|
62
|
+
const message = formatTemplateString(defaultMiddlewareLocalizedTexts.MIDDLEWARE_BANNER_FILE_EMAIL_ADDRESS_RECORDED_ERROR, [email]);
|
|
63
|
+
NotificationHandler.notifyError(NotificationScenarios.EmailTranscriptError, (props === null || props === void 0 ? void 0 : props.bannerMessageOnError) ?? message);
|
|
61
64
|
}
|
|
62
65
|
},
|
|
63
66
|
onCancel: () => {
|
|
@@ -7,7 +7,8 @@ import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
|
7
7
|
const handleChatDisconnect = (props, state, setWebChatStyles) => {
|
|
8
8
|
var _state$appStates;
|
|
9
9
|
if (state !== null && state !== void 0 && (_state$appStates = state.appStates) !== null && _state$appStates !== void 0 && _state$appStates.chatDisconnectEventReceived) {
|
|
10
|
-
var _props$webChatContain, _props$webChatContain2;
|
|
10
|
+
var _state$domainStates, _state$domainStates$m, _props$webChatContain, _props$webChatContain2;
|
|
11
|
+
const chatDisconnectMessage = (state === null || state === void 0 ? void 0 : (_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : (_state$domainStates$m = _state$domainStates.middlewareLocalizedTexts) === null || _state$domainStates$m === void 0 ? void 0 : _state$domainStates$m.MIDDLEWARE_BANNER_CHAT_DISCONNECT) ?? defaultMiddlewareLocalizedTexts.MIDDLEWARE_BANNER_CHAT_DISCONNECT;
|
|
11
12
|
if ((props === null || props === void 0 ? void 0 : (_props$webChatContain = props.webChatContainerProps) === null || _props$webChatContain === void 0 ? void 0 : (_props$webChatContain2 = _props$webChatContain.renderingMiddlewareProps) === null || _props$webChatContain2 === void 0 ? void 0 : _props$webChatContain2.hideSendboxOnConversationEnd) !== false) {
|
|
12
13
|
setWebChatStyles(styles => {
|
|
13
14
|
return {
|
|
@@ -16,7 +17,7 @@ const handleChatDisconnect = (props, state, setWebChatStyles) => {
|
|
|
16
17
|
};
|
|
17
18
|
});
|
|
18
19
|
}
|
|
19
|
-
NotificationHandler.notifyWarning(NotificationScenarios.ChatDisconnect,
|
|
20
|
+
NotificationHandler.notifyWarning(NotificationScenarios.ChatDisconnect, chatDisconnectMessage);
|
|
20
21
|
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
21
22
|
Event: TelemetryEvent.ChatDisconnectThreadEventReceived,
|
|
22
23
|
Description: "Chat disconnected due to timeout, left or removed."
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ConfirmationState, Constants, ConversationEndEntity, ParticipantType } from "../../../common/Constants";
|
|
2
2
|
import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
3
3
|
import { getAuthClientFunction, handleAuthentication } from "./authHelper";
|
|
4
|
-
import { getConversationDetailsCall, getWidgetEndChatEventName
|
|
4
|
+
import { getConversationDetailsCall, getWidgetEndChatEventName } from "../../../common/utils";
|
|
5
5
|
import { getPostChatContext, initiatePostChat } from "./renderSurveyHelpers";
|
|
6
6
|
import { BroadcastService } from "@microsoft/omnichannel-chat-components";
|
|
7
7
|
import { ConversationState } from "../../../contexts/common/ConversationState";
|
|
@@ -9,11 +9,12 @@ import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidge
|
|
|
9
9
|
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
10
10
|
import { WebChatStoreLoader } from "../../webchatcontainerstateful/webchatcontroller/WebChatStoreLoader";
|
|
11
11
|
import { defaultWebChatContainerStatefulProps } from "../../webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps";
|
|
12
|
+
import { TelemetryManager } from "../../../common/telemetry/TelemetryManager";
|
|
12
13
|
|
|
13
14
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
14
|
-
const prepareEndChat = async (props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter
|
|
15
|
+
const prepareEndChat = async (props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter) => {
|
|
15
16
|
try {
|
|
16
|
-
var _conversationDetails$, _state$domainStates
|
|
17
|
+
var _conversationDetails$, _state$domainStates;
|
|
17
18
|
// Use Case: If call is ongoing, end the call by simulating end call button click
|
|
18
19
|
endVoiceVideoCallIfOngoing(chatSDK, dispatch);
|
|
19
20
|
const conversationDetails = await getConversationDetailsCall(chatSDK);
|
|
@@ -23,7 +24,7 @@ const prepareEndChat = async (props, chatSDK, state, dispatch, setAdapter, setWe
|
|
|
23
24
|
var _state$appStates;
|
|
24
25
|
// If ended by customer, just close chat
|
|
25
26
|
if ((state === null || state === void 0 ? void 0 : (_state$appStates = state.appStates) === null || _state$appStates === void 0 ? void 0 : _state$appStates.conversationEndedBy) === ConversationEndEntity.Customer) {
|
|
26
|
-
await endChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, false, true
|
|
27
|
+
await endChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, false, true);
|
|
27
28
|
}
|
|
28
29
|
// Use Case: If ended by Agent, stay chat in InActive state
|
|
29
30
|
return;
|
|
@@ -38,15 +39,13 @@ const prepareEndChat = async (props, chatSDK, state, dispatch, setAdapter, setWe
|
|
|
38
39
|
}
|
|
39
40
|
|
|
40
41
|
// Use Case: Can render post chat scenarios
|
|
41
|
-
await getPostChatContext(chatSDK, state, dispatch);
|
|
42
|
-
|
|
43
42
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
44
|
-
const postchatContext = state === null || state === void 0 ? void 0 : (_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : _state$domainStates.postChatContext;
|
|
43
|
+
const postchatContext = (await getPostChatContext(chatSDK, state, dispatch)) ?? (state === null || state === void 0 ? void 0 : (_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : _state$domainStates.postChatContext);
|
|
45
44
|
if (postchatContext === undefined) {
|
|
46
45
|
var _state$appStates2;
|
|
47
46
|
// For Customer intiated conversations, just close chat widget
|
|
48
47
|
if ((state === null || state === void 0 ? void 0 : (_state$appStates2 = state.appStates) === null || _state$appStates2 === void 0 ? void 0 : _state$appStates2.conversationEndedBy) === ConversationEndEntity.Customer) {
|
|
49
|
-
await endChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, false, true
|
|
48
|
+
await endChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, false, true);
|
|
50
49
|
return;
|
|
51
50
|
}
|
|
52
51
|
|
|
@@ -57,10 +56,10 @@ const prepareEndChat = async (props, chatSDK, state, dispatch, setAdapter, setWe
|
|
|
57
56
|
});
|
|
58
57
|
return;
|
|
59
58
|
}
|
|
60
|
-
endChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, true, true
|
|
59
|
+
endChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, true, true);
|
|
61
60
|
|
|
62
61
|
// Initiate post chat render
|
|
63
|
-
if (
|
|
62
|
+
if (postchatContext) {
|
|
64
63
|
await initiatePostChat(props, conversationDetails, state, dispatch, postchatContext);
|
|
65
64
|
return;
|
|
66
65
|
}
|
|
@@ -75,7 +74,7 @@ const prepareEndChat = async (props, chatSDK, state, dispatch, setAdapter, setWe
|
|
|
75
74
|
|
|
76
75
|
//Close chat widget for any failure in embedded to allow to show start chat button
|
|
77
76
|
if (((_props$controlProps = props.controlProps) === null || _props$controlProps === void 0 ? void 0 : _props$controlProps.hideStartChatButton) === false) {
|
|
78
|
-
await endChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, false, true
|
|
77
|
+
await endChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, false, true);
|
|
79
78
|
}
|
|
80
79
|
} finally {
|
|
81
80
|
//Chat token clean up
|
|
@@ -84,8 +83,7 @@ const prepareEndChat = async (props, chatSDK, state, dispatch, setAdapter, setWe
|
|
|
84
83
|
};
|
|
85
84
|
|
|
86
85
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
87
|
-
const endChat = async
|
|
88
|
-
let uwid = arguments.length > 10 && arguments[10] !== undefined ? arguments[10] : "";
|
|
86
|
+
const endChat = async (props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, skipEndChatSDK, skipCloseChat, postMessageToOtherTab) => {
|
|
89
87
|
if (!skipEndChatSDK && chatSDK.conversation) {
|
|
90
88
|
try {
|
|
91
89
|
TelemetryHelper.logSDKEvent(LogLevel.INFO, {
|
|
@@ -137,15 +135,17 @@ const endChat = async function (props, chatSDK, state, dispatch, setAdapter, set
|
|
|
137
135
|
closeChatWidget(dispatch, props, state);
|
|
138
136
|
}
|
|
139
137
|
}
|
|
140
|
-
if (postMessageToOtherTab
|
|
138
|
+
if (postMessageToOtherTab) {
|
|
141
139
|
const endChatEventName = await getEndChatEventName(chatSDK, props);
|
|
142
140
|
BroadcastService.postMessage({
|
|
143
141
|
eventName: endChatEventName,
|
|
144
|
-
payload:
|
|
142
|
+
payload: {
|
|
143
|
+
runtimeId: TelemetryManager.InternalTelemetryData.lcwRuntimeId
|
|
144
|
+
}
|
|
145
145
|
});
|
|
146
146
|
}
|
|
147
147
|
};
|
|
148
|
-
const callingStateCleanUp = async dispatch => {
|
|
148
|
+
export const callingStateCleanUp = async dispatch => {
|
|
149
149
|
dispatch({
|
|
150
150
|
type: LiveChatWidgetActionType.SHOW_CALLING_CONTAINER,
|
|
151
151
|
payload: false
|
|
@@ -167,7 +167,7 @@ const callingStateCleanUp = async dispatch => {
|
|
|
167
167
|
payload: true
|
|
168
168
|
});
|
|
169
169
|
};
|
|
170
|
-
const endChatStateCleanUp = async dispatch => {
|
|
170
|
+
export const endChatStateCleanUp = async dispatch => {
|
|
171
171
|
// Need to clear these states immediately when chat ended from OC.
|
|
172
172
|
dispatch({
|
|
173
173
|
type: LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
|
|
@@ -182,7 +182,7 @@ const endChatStateCleanUp = async dispatch => {
|
|
|
182
182
|
payload: false
|
|
183
183
|
});
|
|
184
184
|
};
|
|
185
|
-
const closeChatStateCleanUp = async dispatch => {
|
|
185
|
+
export const closeChatStateCleanUp = async dispatch => {
|
|
186
186
|
dispatch({
|
|
187
187
|
type: LiveChatWidgetActionType.SET_CHAT_TOKEN,
|
|
188
188
|
payload: undefined
|
|
@@ -12,15 +12,13 @@ import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
|
12
12
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
13
13
|
const handleChatReconnect = async (chatSDK, props, dispatch, setAdapter, initStartChat, state) => {
|
|
14
14
|
var _props$chatConfig, _props$chatConfig$Liv;
|
|
15
|
-
if (!isReconnectEnabled(props.chatConfig) || isPersistentEnabled(props.chatConfig)) return false;
|
|
16
|
-
|
|
17
15
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
18
16
|
const isAuthenticatedChat = (_props$chatConfig = props.chatConfig) !== null && _props$chatConfig !== void 0 && (_props$chatConfig$Liv = _props$chatConfig.LiveChatConfigAuthSettings) !== null && _props$chatConfig$Liv !== void 0 && _props$chatConfig$Liv.msdyn_javascriptclientfunction ? true : false;
|
|
19
17
|
|
|
20
18
|
// Get chat reconnect context
|
|
21
19
|
const reconnectChatContext = await getChatReconnectContext(chatSDK, props.chatConfig, props, isAuthenticatedChat);
|
|
22
20
|
|
|
23
|
-
//Redirect if enabled
|
|
21
|
+
// Redirect if enabled
|
|
24
22
|
if (reconnectChatContext !== null && reconnectChatContext !== void 0 && reconnectChatContext.redirectURL) {
|
|
25
23
|
var _props$reconnectChatP;
|
|
26
24
|
redirectPage(reconnectChatContext.redirectURL, (_props$reconnectChatP = props.reconnectChatPaneProps) === null || _props$reconnectChatP === void 0 ? void 0 : _props$reconnectChatP.redirectInSameWindow);
|