@microsoft/omnichannel-chat-widget 1.3.1-main.a91ba9b → 1.3.1-main.cb0a057
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/lib/cjs/assets/Icons.js +8 -2
- package/lib/cjs/common/telemetry/loggers/ariaTelemetryLogger.js +2 -22
- package/lib/cjs/components/livechatwidget/common/createAdapter.js +5 -0
- package/lib/cjs/components/livechatwidget/common/endChat.js +61 -4
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +6 -0
- package/lib/cjs/components/livechatwidget/common/startChat.js +1 -1
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +30 -5
- package/lib/cjs/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +5 -2
- package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +13 -7
- package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts.js +4 -3
- package/lib/cjs/components/webchatcontainerstateful/common/mockchatsdk.js +3 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +40 -101
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/Attachment.js +92 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/AttachmentContent.js +17 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/AttachmentIcon.js +21 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/DownloadBlockedAttachment.js +36 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/FileScanStatus.js +14 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/MaliciousAttachment.js +24 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/ScanInProgressAttachment.js +24 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/Spinner.js +41 -0
- package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +1 -0
- package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +2 -1
- package/lib/cjs/contexts/createReducer.js +8 -0
- package/lib/esm/assets/Icons.js +4 -1
- package/lib/esm/common/telemetry/loggers/ariaTelemetryLogger.js +2 -22
- package/lib/esm/components/livechatwidget/common/createAdapter.js +5 -0
- package/lib/esm/components/livechatwidget/common/endChat.js +60 -4
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +6 -0
- package/lib/esm/components/livechatwidget/common/startChat.js +1 -1
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +30 -5
- package/lib/esm/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +6 -3
- package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +13 -7
- package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts.js +4 -3
- package/lib/esm/components/webchatcontainerstateful/common/mockchatsdk.js +3 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +36 -96
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/Attachment.js +84 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/AttachmentContent.js +9 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/AttachmentIcon.js +13 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/DownloadBlockedAttachment.js +28 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/FileScanStatus.js +7 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/MaliciousAttachment.js +16 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/ScanInProgressAttachment.js +16 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/Spinner.js +33 -0
- package/lib/esm/contexts/common/LiveChatWidgetActionType.js +1 -0
- package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +2 -1
- package/lib/esm/contexts/createReducer.js +8 -0
- package/lib/types/assets/Icons.d.ts +3 -0
- package/lib/types/components/livechatwidget/common/endChat.d.ts +1 -0
- package/lib/types/components/webchatcontainerstateful/common/mockchatsdk.d.ts +1 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/Attachment.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/AttachmentContent.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/AttachmentIcon.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/DownloadBlockedAttachment.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/FileScanStatus.d.ts +6 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/MaliciousAttachment.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/ScanInProgressAttachment.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/Spinner.d.ts +2 -0
- package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +2 -1
- package/lib/types/contexts/common/ILiveChatWidgetLocalizedTexts.d.ts +7 -0
- package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +2 -1
- package/package.json +4 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ConfirmationState, Constants, ConversationEndEntity } from "../../../common/Constants";
|
|
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
4
|
import { getConversationDetailsCall, getWidgetEndChatEventName, isNullOrEmptyString } from "../../../common/utils";
|
|
@@ -14,20 +14,30 @@ import { defaultWebChatContainerStatefulProps } from "../../webchatcontainerstat
|
|
|
14
14
|
const prepareEndChat = async (props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, uwid) => {
|
|
15
15
|
try {
|
|
16
16
|
var _conversationDetails$, _state$domainStates, _state$domainStates2;
|
|
17
|
+
// Use Case: If call is ongoing, end the call by simulating end call button click
|
|
18
|
+
endVoiceVideoCallIfOngoing(chatSDK, dispatch);
|
|
17
19
|
const conversationDetails = await getConversationDetailsCall(chatSDK);
|
|
18
20
|
|
|
19
|
-
// Use Case
|
|
21
|
+
// Use Case: When post chat is not configured
|
|
20
22
|
if ((conversationDetails === null || conversationDetails === void 0 ? void 0 : (_conversationDetails$ = conversationDetails.canRenderPostChat) === null || _conversationDetails$ === void 0 ? void 0 : _conversationDetails$.toLowerCase()) === Constants.false) {
|
|
21
23
|
var _state$appStates;
|
|
22
24
|
// If ended by customer, just close chat
|
|
23
25
|
if ((state === null || state === void 0 ? void 0 : (_state$appStates = state.appStates) === null || _state$appStates === void 0 ? void 0 : _state$appStates.conversationEndedBy) === ConversationEndEntity.Customer) {
|
|
24
26
|
await endChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, false, true, uwid);
|
|
25
27
|
}
|
|
26
|
-
//Use Case: If ended by Agent, stay chat in InActive state
|
|
28
|
+
// Use Case: If ended by Agent, stay chat in InActive state
|
|
27
29
|
return;
|
|
28
30
|
}
|
|
29
31
|
|
|
30
|
-
//
|
|
32
|
+
// Register post chat participant type
|
|
33
|
+
if ((conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.participantType) === ParticipantType.Bot || (conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.participantType) === ParticipantType.User) {
|
|
34
|
+
dispatch({
|
|
35
|
+
type: LiveChatWidgetActionType.SET_POST_CHAT_PARTICIPANT_TYPE,
|
|
36
|
+
payload: conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.participantType
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Use Case: Can render post chat scenarios
|
|
31
41
|
await getPostChatContext(chatSDK, state, dispatch);
|
|
32
42
|
|
|
33
43
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -135,6 +145,28 @@ const endChat = async function (props, chatSDK, state, dispatch, setAdapter, set
|
|
|
135
145
|
});
|
|
136
146
|
}
|
|
137
147
|
};
|
|
148
|
+
const callingStateCleanUp = async dispatch => {
|
|
149
|
+
dispatch({
|
|
150
|
+
type: LiveChatWidgetActionType.SHOW_CALLING_CONTAINER,
|
|
151
|
+
payload: false
|
|
152
|
+
});
|
|
153
|
+
dispatch({
|
|
154
|
+
type: LiveChatWidgetActionType.SET_INCOMING_CALL,
|
|
155
|
+
payload: true
|
|
156
|
+
});
|
|
157
|
+
dispatch({
|
|
158
|
+
type: LiveChatWidgetActionType.DISABLE_VIDEO_CALL,
|
|
159
|
+
payload: true
|
|
160
|
+
});
|
|
161
|
+
dispatch({
|
|
162
|
+
type: LiveChatWidgetActionType.DISABLE_LOCAL_VIDEO,
|
|
163
|
+
payload: true
|
|
164
|
+
});
|
|
165
|
+
dispatch({
|
|
166
|
+
type: LiveChatWidgetActionType.DISABLE_REMOTE_VIDEO,
|
|
167
|
+
payload: true
|
|
168
|
+
});
|
|
169
|
+
};
|
|
138
170
|
const endChatStateCleanUp = async dispatch => {
|
|
139
171
|
// Need to clear these states immediately when chat ended from OC.
|
|
140
172
|
dispatch({
|
|
@@ -185,6 +217,30 @@ const closeChatStateCleanUp = async dispatch => {
|
|
|
185
217
|
}
|
|
186
218
|
});
|
|
187
219
|
};
|
|
220
|
+
|
|
221
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
222
|
+
export const endVoiceVideoCallIfOngoing = async (chatSDK, dispatch) => {
|
|
223
|
+
let callId = "";
|
|
224
|
+
try {
|
|
225
|
+
const voiceVideoCallingSdk = await chatSDK.getVoiceVideoCalling();
|
|
226
|
+
if (voiceVideoCallingSdk && voiceVideoCallingSdk.isInACall()) {
|
|
227
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
228
|
+
callId = voiceVideoCallingSdk.callId;
|
|
229
|
+
voiceVideoCallingSdk.stopCall();
|
|
230
|
+
TelemetryHelper.logCallingEvent(LogLevel.INFO, {
|
|
231
|
+
Event: TelemetryEvent.EndCallButtonClick
|
|
232
|
+
}, callId);
|
|
233
|
+
callingStateCleanUp(dispatch);
|
|
234
|
+
}
|
|
235
|
+
} catch (error) {
|
|
236
|
+
TelemetryHelper.logCallingEvent(LogLevel.ERROR, {
|
|
237
|
+
Event: TelemetryEvent.EndCallButtonClickException,
|
|
238
|
+
ExceptionDetails: {
|
|
239
|
+
exception: `Failed to End Call: ${error}`
|
|
240
|
+
}
|
|
241
|
+
}, callId);
|
|
242
|
+
}
|
|
243
|
+
};
|
|
188
244
|
const closeChatWidget = (dispatch, props, state) => {
|
|
189
245
|
var _state$appStates3;
|
|
190
246
|
if (state !== null && state !== void 0 && (_state$appStates3 = state.appStates) !== null && _state$appStates3 !== void 0 && _state$appStates3.hideStartChatButton) {
|
|
@@ -63,6 +63,12 @@ export const initWebChatComposer = (props, state, dispatch, chatSDK, endChat) =>
|
|
|
63
63
|
payload: ConversationEndEntity.Agent
|
|
64
64
|
});
|
|
65
65
|
}
|
|
66
|
+
if ((conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.participantType) === ParticipantType.Bot || (conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.participantType) === ParticipantType.User) {
|
|
67
|
+
dispatch({
|
|
68
|
+
type: LiveChatWidgetActionType.SET_POST_CHAT_PARTICIPANT_TYPE,
|
|
69
|
+
payload: conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.participantType
|
|
70
|
+
});
|
|
71
|
+
}
|
|
66
72
|
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
67
73
|
Event: TelemetryEvent.ConversationEndedThreadEventReceived,
|
|
68
74
|
Description: "Conversation end by agent side or by timeout event received."
|
|
@@ -50,7 +50,7 @@ const prepareStartChat = async (props, chatSDK, state, dispatch, setAdapter) =>
|
|
|
50
50
|
const isPreChatEnabledInProactiveChat = state.appStates.proactiveChatStates.proactiveChatEnablePrechat;
|
|
51
51
|
|
|
52
52
|
//Setting PreChat and intiate chat
|
|
53
|
-
await setPreChatAndInitiateChat(chatSDK, dispatch, setAdapter, isProactiveChat, isPreChatEnabledInProactiveChat,
|
|
53
|
+
await setPreChatAndInitiateChat(chatSDK, dispatch, setAdapter, isProactiveChat, isPreChatEnabledInProactiveChat, state, props);
|
|
54
54
|
};
|
|
55
55
|
|
|
56
56
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -50,8 +50,9 @@ import { startProactiveChat } from "../common/startProactiveChat";
|
|
|
50
50
|
import useChatAdapterStore from "../../../hooks/useChatAdapterStore";
|
|
51
51
|
import useChatContextStore from "../../../hooks/useChatContextStore";
|
|
52
52
|
import useChatSDKStore from "../../../hooks/useChatSDKStore";
|
|
53
|
+
import { defaultAdaptiveCardStyles } from "../../webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles";
|
|
53
54
|
export const LiveChatWidgetStateful = props => {
|
|
54
|
-
var _props$webChatContain, _props$styleProps, _chatSDK$omnichannelC, _props$controlProps, _props$controlProps2, _state$appStates7, _props$webChatContain5, _state$appStates14, _props$webChatContain6, _props$controlProps11, _props$draggableChatW, _props$draggableChatW2, _props$draggableChatW3, _props$draggableChatW4, _props$draggableChatW5, _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;
|
|
55
|
+
var _props$webChatContain, _props$styleProps, _chatSDK$omnichannelC, _props$controlProps, _props$controlProps2, _state$appStates7, _props$webChatContain5, _state$appStates14, _props$webChatContain6, _props$controlProps11, _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;
|
|
55
56
|
const [state, dispatch] = useChatContextStore();
|
|
56
57
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
57
58
|
const [adapter, setAdapter] = useChatAdapterStore();
|
|
@@ -318,7 +319,27 @@ export const LiveChatWidgetStateful = props => {
|
|
|
318
319
|
});
|
|
319
320
|
|
|
320
321
|
// Start chat from SDK Event
|
|
321
|
-
BroadcastService.getMessageByEventName(BroadcastEvent.StartChat).subscribe(
|
|
322
|
+
BroadcastService.getMessageByEventName(BroadcastEvent.StartChat).subscribe(msg => {
|
|
323
|
+
var _msg$payload4;
|
|
324
|
+
let stateWithUpdatedContext = state;
|
|
325
|
+
if (msg !== null && msg !== void 0 && (_msg$payload4 = msg.payload) !== null && _msg$payload4 !== void 0 && _msg$payload4.customContext) {
|
|
326
|
+
var _msg$payload5, _msg$payload6;
|
|
327
|
+
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
328
|
+
Event: TelemetryEvent.CustomContextReceived,
|
|
329
|
+
Description: "CustomContext received through startChat event."
|
|
330
|
+
});
|
|
331
|
+
dispatch({
|
|
332
|
+
type: LiveChatWidgetActionType.SET_CUSTOM_CONTEXT,
|
|
333
|
+
payload: msg === null || msg === void 0 ? void 0 : (_msg$payload5 = msg.payload) === null || _msg$payload5 === void 0 ? void 0 : _msg$payload5.customContext
|
|
334
|
+
});
|
|
335
|
+
stateWithUpdatedContext = {
|
|
336
|
+
...state,
|
|
337
|
+
domainStates: {
|
|
338
|
+
...state.domainStates,
|
|
339
|
+
customContext: msg === null || msg === void 0 ? void 0 : (_msg$payload6 = msg.payload) === null || _msg$payload6 === void 0 ? void 0 : _msg$payload6.customContext
|
|
340
|
+
}
|
|
341
|
+
};
|
|
342
|
+
}
|
|
322
343
|
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
323
344
|
Event: TelemetryEvent.StartChatEventRecevied,
|
|
324
345
|
Description: "Start chat event received."
|
|
@@ -332,7 +353,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
332
353
|
BroadcastService.postMessage({
|
|
333
354
|
eventName: BroadcastEvent.ChatInitiated
|
|
334
355
|
});
|
|
335
|
-
prepareStartChat(props, chatSDK,
|
|
356
|
+
prepareStartChat(props, chatSDK, stateWithUpdatedContext, dispatch, setAdapter);
|
|
336
357
|
return;
|
|
337
358
|
}
|
|
338
359
|
|
|
@@ -344,7 +365,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
344
365
|
BroadcastService.postMessage({
|
|
345
366
|
eventName: BroadcastEvent.ChatInitiated
|
|
346
367
|
});
|
|
347
|
-
prepareStartChat(props, chatSDK,
|
|
368
|
+
prepareStartChat(props, chatSDK, stateWithUpdatedContext, dispatch, setAdapter);
|
|
348
369
|
return;
|
|
349
370
|
}
|
|
350
371
|
|
|
@@ -648,7 +669,11 @@ export const LiveChatWidgetStateful = props => {
|
|
|
648
669
|
background: ${scrollbarProps.thumbHoverColor};
|
|
649
670
|
}
|
|
650
671
|
`), /*#__PURE__*/React.createElement(DraggableChatWidget, chatWidgetDraggableConfig, /*#__PURE__*/React.createElement(Composer, _extends({}, webChatProps, {
|
|
651
|
-
styleOptions:
|
|
672
|
+
styleOptions: {
|
|
673
|
+
...webChatStyles,
|
|
674
|
+
bubbleBackground: ((_props$webChatContain7 = props.webChatContainerProps) === null || _props$webChatContain7 === void 0 ? void 0 : (_props$webChatContain8 = _props$webChatContain7.adaptiveCardStyles) === null || _props$webChatContain8 === void 0 ? void 0 : _props$webChatContain8.background) ?? defaultAdaptiveCardStyles.background,
|
|
675
|
+
bubbleTextColor: ((_props$webChatContain9 = props.webChatContainerProps) === null || _props$webChatContain9 === void 0 ? void 0 : (_props$webChatContain10 = _props$webChatContain9.adaptiveCardStyles) === null || _props$webChatContain10 === void 0 ? void 0 : _props$webChatContain10.color) ?? defaultAdaptiveCardStyles.color
|
|
676
|
+
},
|
|
652
677
|
directLine: ((_livechatProps$webCha = livechatProps.webChatContainerProps) === null || _livechatProps$webCha === void 0 ? void 0 : _livechatProps$webCha.directLine) ?? adapter ?? defaultWebChatContainerStatefulProps.directLine
|
|
653
678
|
}), /*#__PURE__*/React.createElement(Stack, {
|
|
654
679
|
id: widgetElementId,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { LogLevel, TelemetryEvent } from "../../common/telemetry/TelemetryConstants";
|
|
2
2
|
import React, { useEffect } from "react";
|
|
3
|
-
import {
|
|
3
|
+
import { ParticipantType } from "../../common/Constants";
|
|
4
4
|
import { CustomerVoiceEvents } from "./enums/CustomerVoiceEvents";
|
|
5
5
|
import { PostChatSurveyMode } from "./enums/PostChatSurveyMode";
|
|
6
6
|
import { PostChatSurveyPane } from "@microsoft/omnichannel-chat-components";
|
|
@@ -18,14 +18,17 @@ const generateSurveyInviteLink = function (surveyInviteLink, isEmbed, locale, co
|
|
|
18
18
|
return surveyLink;
|
|
19
19
|
};
|
|
20
20
|
export const PostChatSurveyPaneStateful = props => {
|
|
21
|
-
var _props$styleProps, _state$appStates,
|
|
21
|
+
var _props$styleProps, _state$appStates, _props$controlProps;
|
|
22
22
|
const [state] = useChatContextStore();
|
|
23
23
|
const generalStyleProps = Object.assign({}, defaultGeneralPostChatSurveyPaneStyleProps, (_props$styleProps = props.styleProps) === null || _props$styleProps === void 0 ? void 0 : _props$styleProps.generalStyleProps, {
|
|
24
24
|
display: state.appStates.isMinimized ? "none" : "contents"
|
|
25
25
|
});
|
|
26
26
|
let surveyInviteLink = "";
|
|
27
27
|
const surveyMode = (state === null || state === void 0 ? void 0 : (_state$appStates = state.appStates) === null || _state$appStates === void 0 ? void 0 : _state$appStates.selectedSurveyMode) === PostChatSurveyMode.Embed;
|
|
28
|
-
if (
|
|
28
|
+
if (state.domainStates.postChatContext.botSurveyInviteLink &&
|
|
29
|
+
// Bot survey enabled
|
|
30
|
+
state.appStates.postChatParticipantType === ParticipantType.Bot) {
|
|
31
|
+
// Only Bot has engaged
|
|
29
32
|
surveyInviteLink = generateSurveyInviteLink(state.domainStates.postChatContext.botSurveyInviteLink, surveyMode, state.domainStates.postChatContext.botFormsProLocale, props.isCustomerVoiceSurveyCompact ?? true);
|
|
30
33
|
} else {
|
|
31
34
|
surveyInviteLink = generateSurveyInviteLink(state.domainStates.postChatContext.surveyInviteLink, surveyMode, state.domainStates.postChatContext.formsProLocale, props.isCustomerVoiceSurveyCompact ?? true);
|
|
@@ -47,7 +47,7 @@ const createMagicCodeSuccessResponse = signin => {
|
|
|
47
47
|
};
|
|
48
48
|
};
|
|
49
49
|
export const WebChatContainerStateful = props => {
|
|
50
|
-
var _webChatContainerProp, _webChatContainerProp2, _webChatContainerProp3, _webChatContainerProp4, _webChatContainerProp5, _webChatContainerProp6, _webChatContainerProp7, _webChatContainerProp8, _webChatContainerProp9, _webChatContainerProp10, _webChatContainerProp11, _webChatContainerProp12, _webChatContainerProp13, _webChatContainerProp14
|
|
50
|
+
var _webChatContainerProp, _webChatContainerProp2, _webChatContainerProp3, _webChatContainerProp4, _webChatContainerProp5, _webChatContainerProp6, _props$webChatContain3, _props$webChatContain4, _defaultWebChatContai, _props$webChatContain5, _props$webChatContain6, _defaultWebChatContai2, _webChatContainerProp7, _webChatContainerProp8, _webChatContainerProp9, _webChatContainerProp10, _webChatContainerProp11, _webChatContainerProp12, _webChatContainerProp13, _webChatContainerProp14;
|
|
51
51
|
const {
|
|
52
52
|
BasicWebChat
|
|
53
53
|
} = Components;
|
|
@@ -145,21 +145,27 @@ export const WebChatContainerStateful = props => {
|
|
|
145
145
|
}
|
|
146
146
|
|
|
147
147
|
div[class="ac-textBlock"] *,
|
|
148
|
-
div[class="ac-input-container"] * {
|
|
148
|
+
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.textWhiteSpace}}
|
|
149
|
+
|
|
150
|
+
.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 {
|
|
151
|
+
background-color: ${((_props$webChatContain3 = props.webChatContainerProps) === null || _props$webChatContain3 === void 0 ? void 0 : (_props$webChatContain4 = _props$webChatContain3.webChatStyles) === null || _props$webChatContain4 === void 0 ? void 0 : _props$webChatContain4.bubbleBackground) ?? ((_defaultWebChatContai = defaultWebChatContainerStatefulProps.webChatStyles) === null || _defaultWebChatContai === void 0 ? void 0 : _defaultWebChatContai.bubbleBackground)};
|
|
152
|
+
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.bubbleTextColor) ?? ((_defaultWebChatContai2 = defaultWebChatContainerStatefulProps.webChatStyles) === null || _defaultWebChatContai2 === void 0 ? void 0 : _defaultWebChatContai2.bubbleTextColor)};
|
|
153
|
+
}
|
|
154
|
+
|
|
149
155
|
div[class="ac-textBlock"] a:link,
|
|
150
156
|
div[class="ac-textBlock"] a:visited,
|
|
151
157
|
div[class="ac-textBlock"] a:hover,
|
|
152
158
|
div[class="ac-textBlock"] a:active {
|
|
153
|
-
color: ${(webChatContainerProps === null || webChatContainerProps === void 0 ? void 0 : (
|
|
159
|
+
color: ${(webChatContainerProps === null || webChatContainerProps === void 0 ? void 0 : (_webChatContainerProp7 = webChatContainerProps.adaptiveCardStyles) === null || _webChatContainerProp7 === void 0 ? void 0 : _webChatContainerProp7.anchorColor) ?? defaultAdaptiveCardStyles.anchorColor};
|
|
154
160
|
}
|
|
155
161
|
|
|
156
|
-
.webchat__stacked-layout__content .ac-actionSet > .ac-pushButton > div {white-space: ${(webChatContainerProps === null || webChatContainerProps === void 0 ? void 0 : (
|
|
162
|
+
.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.buttonWhiteSpace} !important;}
|
|
157
163
|
|
|
158
164
|
.ms_lcw_webchat_received_message img.webchat__markdown__external-link-icon {
|
|
159
165
|
background-image : url(data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIzIDMgMTggMTgiICB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxwYXRoIGQ9Ik03LjI1MDEgNC41MDAxN0gxMC43NDk1QzExLjE2MzcgNC41MDAxNyAxMS40OTk1IDQuODM1OTYgMTEuNDk5NSA1LjI1MDE3QzExLjQ5OTUgNS42Mjk4NiAxMS4yMTczIDUuOTQzNjYgMTAuODUxMyA1Ljk5MzMyTDEwLjc0OTUgNi4wMDAxN0g3LjI0OTc0QzYuMDcwNzkgNS45OTk2MSA1LjEwMzQ5IDYuOTA2NTYgNS4wMDc4NiA4LjA2MTEyTDUuMDAwMjggOC4yMjAwM0w1LjAwMzEyIDE2Ljc1MDdDNS4wMDM0MyAxNy45NDE1IDUuOTI4ODUgMTguOTE2MSA3LjA5OTY2IDE4Ljk5NDlMNy4yNTM3MSAxOS4wMDAxTDE1Ljc1MTggMTguOTg4NEMxNi45NDE1IDE4Ljk4NjggMTcuOTE0NSAxOC4wNjIgMTcuOTkzNSAxNi44OTIzTDE3Ljk5ODcgMTYuNzM4NFYxMy4yMzIxQzE3Ljk5ODcgMTIuODE3OSAxOC4zMzQ1IDEyLjQ4MjEgMTguNzQ4NyAxMi40ODIxQzE5LjEyODQgMTIuNDgyMSAxOS40NDIyIDEyLjc2NDMgMTkuNDkxOCAxMy4xMzAzTDE5LjQ5ODcgMTMuMjMyMVYxNi43Mzg0QzE5LjQ5ODcgMTguNzQwNyAxNy45MjkzIDIwLjM3NjkgMTUuOTUyOCAyMC40ODI5TDE1Ljc1MzggMjAuNDg4NEw3LjI1ODI3IDIwLjUwMDFMNy4wNTQ5NSAyMC40OTQ5QzUuMTQyMzkgMjAuMzk1NCAzLjYwODk1IDE4Ljg2MjcgMy41MDgzNyAxNi45NTAyTDMuNTAzMTIgMTYuNzUxMUwzLjUwMDg5IDguMjUyN0wzLjUwNTI5IDguMDUwMkMzLjYwNTM5IDYuMTM3NDkgNS4xMzg2NyA0LjYwNDQ5IDcuMDUwOTYgNC41MDUyN0w3LjI1MDEgNC41MDAxN0gxMC43NDk1SDcuMjUwMVpNMTMuNzQ4MSAzLjAwMTQ2TDIwLjMwMTggMy4wMDE5N0wyMC40MDE0IDMuMDE1NzVMMjAuNTAyMiAzLjA0MzkzTDIwLjU1OSAzLjA2ODAzQzIwLjYxMjIgMy4wOTEyMiAyMC42NjM0IDMuMTIxNjMgMjAuNzExMSAzLjE1ODg1TDIwLjc4MDQgMy4yMjE1NkwyMC44NjQxIDMuMzIwMTRMMjAuOTE4MyAzLjQxMDI1TDIwLjk1NyAzLjUwMDU3TDIwLjk3NjIgMy41NjQ3NkwyMC45ODk4IDMuNjI4NjJMMjAuOTk5MiAzLjcyMjgyTDIwLjk5OTcgMTAuMjU1NEMyMC45OTk3IDEwLjY2OTYgMjAuNjYzOSAxMS4wMDU0IDIwLjI0OTcgMTEuMDA1NEMxOS44NyAxMS4wMDU0IDE5LjU1NjIgMTAuNzIzMiAxOS41MDY1IDEwLjM1NzFMMTkuNDk5NyAxMC4yNTU0TDE5LjQ5ODkgNS41NjE0N0wxMi4yNzk3IDEyLjc4NDdDMTIuMDEzNCAxMy4wNTEgMTEuNTk2OCAxMy4wNzUzIDExLjMwMzEgMTIuODU3NUwxMS4yMTkgMTIuNzg0OUMxMC45NTI3IDEyLjUxODcgMTAuOTI4NCAxMi4xMDIxIDExLjE0NjIgMTEuODA4NEwxMS4yMTg4IDExLjcyNDNMMTguNDM2OSA0LjUwMTQ2SDEzLjc0ODFDMTMuMzY4NCA0LjUwMTQ2IDEzLjA1NDYgNC4yMTkzMSAxMy4wMDUgMy44NTMyNEwxMi45OTgxIDMuNzUxNDZDMTIuOTk4MSAzLjM3MTc3IDEzLjI4MDMgMy4wNTc5NyAxMy42NDY0IDMuMDA4MzFMMTMuNzQ4MSAzLjAwMTQ2WiIgZmlsbD0iI0ZGRkZGRiIgLz48L3N2Zz4) !important;
|
|
160
166
|
height: '.75em';
|
|
161
167
|
marginLeft: '.25em';
|
|
162
|
-
filter:${(webChatContainerProps === null || webChatContainerProps === void 0 ? void 0 : (
|
|
168
|
+
filter:${(webChatContainerProps === null || webChatContainerProps === void 0 ? void 0 : (_webChatContainerProp9 = webChatContainerProps.renderingMiddlewareProps) === null || _webChatContainerProp9 === void 0 ? void 0 : (_webChatContainerProp10 = _webChatContainerProp9.receivedMessageAnchorStyles) === null || _webChatContainerProp10 === void 0 ? void 0 : _webChatContainerProp10.filter) ?? (defaultReceivedMessageAnchorStyles === null || defaultReceivedMessageAnchorStyles === void 0 ? void 0 : defaultReceivedMessageAnchorStyles.filter)};
|
|
163
169
|
}
|
|
164
170
|
pre {
|
|
165
171
|
white-space: pre-wrap;
|
|
@@ -172,13 +178,13 @@ export const WebChatContainerStateful = props => {
|
|
|
172
178
|
.ms_lcw_webchat_received_message a:visited,
|
|
173
179
|
.ms_lcw_webchat_received_message a:hover,
|
|
174
180
|
.ms_lcw_webchat_received_message a:active {
|
|
175
|
-
color: ${(webChatContainerProps === null || webChatContainerProps === void 0 ? void 0 : (
|
|
181
|
+
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 === null || defaultReceivedMessageAnchorStyles === void 0 ? void 0 : defaultReceivedMessageAnchorStyles.color)};
|
|
176
182
|
}
|
|
177
183
|
.ms_lcw_webchat_sent_message a:link,
|
|
178
184
|
.ms_lcw_webchat_sent_message a:visited,
|
|
179
185
|
.ms_lcw_webchat_sent_message a:hover,
|
|
180
186
|
.ms_lcw_webchat_sent_message a:active {
|
|
181
|
-
color: ${(webChatContainerProps === null || webChatContainerProps === void 0 ? void 0 : (
|
|
187
|
+
color: ${(webChatContainerProps === null || webChatContainerProps === void 0 ? void 0 : (_webChatContainerProp13 = webChatContainerProps.renderingMiddlewareProps) === null || _webChatContainerProp13 === void 0 ? void 0 : (_webChatContainerProp14 = _webChatContainerProp13.sentMessageAnchorStyles) === null || _webChatContainerProp14 === void 0 ? void 0 : _webChatContainerProp14.color) ?? (defaultSentMessageAnchorStyles === null || defaultSentMessageAnchorStyles === void 0 ? void 0 : defaultSentMessageAnchorStyles.color)};
|
|
182
188
|
}
|
|
183
189
|
`), /*#__PURE__*/React.createElement(Stack, {
|
|
184
190
|
styles: containerStyles
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
/*
|
|
1
|
+
/*
|
|
2
2
|
MIDDLEWARE_BANNER_FILE parameters:
|
|
3
3
|
{0} = File limit size
|
|
4
4
|
{1} = File extension
|
|
5
|
-
{2} = File name
|
|
5
|
+
{2} = File name
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
export const defaultMiddlewareLocalizedTexts = {
|
|
@@ -25,5 +25,6 @@ export const defaultMiddlewareLocalizedTexts = {
|
|
|
25
25
|
MIDDLEWARE_MESSAGE_NOT_DELIVERED: "Not Delivered",
|
|
26
26
|
MIDDLEWARE_MESSAGE_RETRY: "Retry",
|
|
27
27
|
MIDDLEWARE_BANNER_CHAT_DISCONNECT: "Your conversation has been disconnected. For additional assistance, please start a new chat.",
|
|
28
|
-
THIRD_PARTY_COOKIES_BLOCKED_ALERT_MESSAGE: "Third party cookies are blocked. Reloading this page will start a new conversation."
|
|
28
|
+
THIRD_PARTY_COOKIES_BLOCKED_ALERT_MESSAGE: "Third party cookies are blocked. Reloading this page will start a new conversation.",
|
|
29
|
+
MIDDLEWARE_BANNER_FILE_IS_MALICIOUS: "{0} has been blocked because the file may contain a malware."
|
|
29
30
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
2
|
/******
|
|
3
3
|
* AttachmentMiddleware
|
|
4
|
-
*
|
|
4
|
+
*
|
|
5
5
|
* Handles attachment downloading.
|
|
6
6
|
******/
|
|
7
7
|
|
|
@@ -12,99 +12,15 @@ import { BroadcastEvent } from "../../../../../common/telemetry/TelemetryConstan
|
|
|
12
12
|
import { BroadcastService } from "@microsoft/omnichannel-chat-components";
|
|
13
13
|
import { WebChatActionType } from "../../enums/WebChatActionType";
|
|
14
14
|
import { defaultAttachmentAdaptiveCardStyles } from "./defaultStyles/defaultAtttachmentAdaptiveCardStyles";
|
|
15
|
-
import { defaultAttachmentContentStyles } from "./defaultStyles/defaultAttachmentContentStyles";
|
|
16
|
-
import { defaultAttachmentDividerStyles } from "./defaultStyles/defaultAttachmentDividerStyles";
|
|
17
|
-
import { defaultAttachmentDownloadIconStyles } from "./defaultStyles/defaultAttachmentDownloadIconStyles";
|
|
18
|
-
import { defaultAttachmentFileNameStyles } from "./defaultStyles/defaultAttachmentFileNameStyles";
|
|
19
|
-
import { defaultAttachmentIconStyles } from "./defaultStyles/defaultAtttachmentIconStyles";
|
|
20
15
|
import { defaultAttachmentProps } from "../../../common/defaultProps/defaultAttachmentProps";
|
|
21
|
-
import { defaultAttachmentSizeStyles } from "./defaultStyles/defaultAttachmentSizeStyles";
|
|
22
|
-
import { defaultAttachmentStyles } from "./defaultStyles/defaultAtttachmentStyles";
|
|
23
16
|
import { useChatContextStore } from "../../../../..";
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
32
|
-
id: props.id,
|
|
33
|
-
style: props.style
|
|
34
|
-
}, /*#__PURE__*/React.createElement("img", {
|
|
35
|
-
src: props.src ?? getFileAttachmentIconData("txt")
|
|
36
|
-
}));
|
|
37
|
-
};
|
|
38
|
-
const Attachment = props => {
|
|
39
|
-
var _state$domainStates$r, _state$domainStates$r2, _state$domainStates$r3, _state$domainStates$r4, _state$domainStates$r5, _state$domainStates$r6, _state$domainStates$r7, _state$domainStates$r8, _state$domainStates$r9;
|
|
40
|
-
const {
|
|
41
|
-
iconData,
|
|
42
|
-
imageCard,
|
|
43
|
-
textCard,
|
|
44
|
-
renderer
|
|
45
|
-
} = props;
|
|
46
|
-
const [state] = useChatContextStore();
|
|
47
|
-
const attachmentId = ((_state$domainStates$r = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r === void 0 ? void 0 : (_state$domainStates$r2 = _state$domainStates$r.attachmentProps) === null || _state$domainStates$r2 === void 0 ? void 0 : _state$domainStates$r2.webChatAttachmentId) ?? defaultAttachmentProps.webChatAttachmentId;
|
|
48
|
-
const attachmentDividerStyles = {
|
|
49
|
-
...defaultAttachmentDividerStyles,
|
|
50
|
-
...((_state$domainStates$r3 = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r3 === void 0 ? void 0 : _state$domainStates$r3.attachmentDividerStyles)
|
|
51
|
-
};
|
|
52
|
-
const attachmentIconStyles = {
|
|
53
|
-
...defaultAttachmentIconStyles,
|
|
54
|
-
...((_state$domainStates$r4 = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r4 === void 0 ? void 0 : _state$domainStates$r4.attachmentIconStyles)
|
|
55
|
-
};
|
|
56
|
-
const attachmentStyles = {
|
|
57
|
-
...defaultAttachmentStyles,
|
|
58
|
-
...((_state$domainStates$r5 = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r5 === void 0 ? void 0 : _state$domainStates$r5.attachmentStyles)
|
|
59
|
-
};
|
|
60
|
-
const attachmentSizeStylesString = Object.entries({
|
|
61
|
-
...defaultAttachmentSizeStyles,
|
|
62
|
-
...((_state$domainStates$r6 = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r6 === void 0 ? void 0 : _state$domainStates$r6.attachmentSizeStyles)
|
|
63
|
-
}).map(_ref => {
|
|
64
|
-
let [k, v] = _ref;
|
|
65
|
-
return `${k.replace(/[A-Z]/g, match => `-${match.toLowerCase()}`)}:${v}`;
|
|
66
|
-
}).join(";");
|
|
67
|
-
const attachmentContentStylesString = Object.entries({
|
|
68
|
-
...defaultAttachmentContentStyles,
|
|
69
|
-
...((_state$domainStates$r7 = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r7 === void 0 ? void 0 : _state$domainStates$r7.attachmentContentStyles)
|
|
70
|
-
}).map(_ref2 => {
|
|
71
|
-
let [k, v] = _ref2;
|
|
72
|
-
return `${k.replace(/[A-Z]/g, match => `-${match.toLowerCase()}`)}:${v}`;
|
|
73
|
-
}).join(";");
|
|
74
|
-
const attachmentFileNameStylesString = Object.entries({
|
|
75
|
-
...defaultAttachmentFileNameStyles,
|
|
76
|
-
...((_state$domainStates$r8 = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r8 === void 0 ? void 0 : _state$domainStates$r8.attachmentFileNameStyles)
|
|
77
|
-
}).map(_ref3 => {
|
|
78
|
-
let [k, v] = _ref3;
|
|
79
|
-
return `${k.replace(/[A-Z]/g, match => `-${match.toLowerCase()}`)}:${v}`;
|
|
80
|
-
}).join(";");
|
|
81
|
-
const attachmentDownloadIconStylesString = Object.entries({
|
|
82
|
-
...defaultAttachmentDownloadIconStyles,
|
|
83
|
-
...((_state$domainStates$r9 = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r9 === void 0 ? void 0 : _state$domainStates$r9.attachmentDownloadIconStyles)
|
|
84
|
-
}).map(_ref4 => {
|
|
85
|
-
let [k, v] = _ref4;
|
|
86
|
-
return `${k.replace(/[A-Z]/g, match => `-${match.toLowerCase()}`)}:${v}`;
|
|
87
|
-
}).join(";");
|
|
88
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("style", null, `
|
|
89
|
-
.webchat__fileContent__size { ${attachmentSizeStylesString} }
|
|
90
|
-
.webchat__fileContent { ${attachmentContentStylesString} }
|
|
91
|
-
.webchat__fileContent__fileName { ${attachmentFileNameStylesString} }
|
|
92
|
-
.webchat__fileContent__downloadIcon { ${attachmentDownloadIconStylesString} }
|
|
93
|
-
`), /*#__PURE__*/React.createElement("div", {
|
|
94
|
-
dir: state.domainStates.globalDir
|
|
95
|
-
}, imageCard && renderer(imageCard), imageCard && /*#__PURE__*/React.createElement("hr", {
|
|
96
|
-
id: attachmentId + "-divider",
|
|
97
|
-
style: attachmentDividerStyles
|
|
98
|
-
}), /*#__PURE__*/React.createElement(AttachmentContent, {
|
|
99
|
-
attachment: textCard.attachment,
|
|
100
|
-
id: attachmentId,
|
|
101
|
-
style: attachmentStyles
|
|
102
|
-
}, /*#__PURE__*/React.createElement(AttachmentIcon, {
|
|
103
|
-
src: iconData,
|
|
104
|
-
id: attachmentId + "-icon",
|
|
105
|
-
style: attachmentIconStyles
|
|
106
|
-
}), textCard && renderer(textCard))));
|
|
107
|
-
};
|
|
17
|
+
import { NotificationHandler } from "../../notification/NotificationHandler";
|
|
18
|
+
import { NotificationScenarios } from "../../enums/NotificationScenarios";
|
|
19
|
+
import { defaultMiddlewareLocalizedTexts } from "../../../common/defaultProps/defaultMiddlewareLocalizedTexts";
|
|
20
|
+
import Attachment from "./attachments/Attachment";
|
|
21
|
+
import ScanInProgressAttachment from "./attachments/ScanInProgressAttachment";
|
|
22
|
+
import MaliciousAttachment from "./attachments/MaliciousAttachment";
|
|
23
|
+
import FileScanStatus from "./attachments/FileScanStatus";
|
|
108
24
|
|
|
109
25
|
/**
|
|
110
26
|
* Patch card with different attachment data.
|
|
@@ -140,9 +56,9 @@ const genPreviewCardWithAttachment = (card, iconData, next) => {
|
|
|
140
56
|
});
|
|
141
57
|
};
|
|
142
58
|
const createAttachmentMiddleware = enableInlinePlaying => {
|
|
143
|
-
// eslint-disable-next-line react/display-name
|
|
59
|
+
// eslint-disable-next-line react/display-name
|
|
144
60
|
const attachmentMiddleware = () => next => function () {
|
|
145
|
-
var _state$domainStates$
|
|
61
|
+
var _state$domainStates$r, _state$domainStates$r2, _state$domainStates$r3, _card$activity$channe;
|
|
146
62
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
147
63
|
args[_key] = arguments[_key];
|
|
148
64
|
}
|
|
@@ -192,10 +108,10 @@ const createAttachmentMiddleware = enableInlinePlaying => {
|
|
|
192
108
|
}
|
|
193
109
|
}
|
|
194
110
|
const [state] = useChatContextStore();
|
|
195
|
-
const attachmentId = ((_state$domainStates$
|
|
111
|
+
const attachmentId = ((_state$domainStates$r = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r === void 0 ? void 0 : (_state$domainStates$r2 = _state$domainStates$r.attachmentProps) === null || _state$domainStates$r2 === void 0 ? void 0 : _state$domainStates$r2.adaptiveCardAttachmentId) ?? defaultAttachmentProps.adaptiveCardAttachmentId;
|
|
196
112
|
const atttachmentAdaptiveCardStyles = {
|
|
197
113
|
...defaultAttachmentAdaptiveCardStyles,
|
|
198
|
-
...((_state$domainStates$
|
|
114
|
+
...((_state$domainStates$r3 = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r3 === void 0 ? void 0 : _state$domainStates$r3.attachmentAdaptiveCardStyles)
|
|
199
115
|
};
|
|
200
116
|
if (type === WebChatMiddlewareConstants.adaptiveCard || Constants.supportedAdaptiveCardContentTypes.indexOf(contentType) >= 0) {
|
|
201
117
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -213,6 +129,30 @@ const createAttachmentMiddleware = enableInlinePlaying => {
|
|
|
213
129
|
if (!attachment.name) {
|
|
214
130
|
return next(...args);
|
|
215
131
|
}
|
|
132
|
+
if (card.activity.channelData && card.activity.channelData.fileScan) {
|
|
133
|
+
const index = attachments.findIndex(attachment => attachment.name === card.attachment.name);
|
|
134
|
+
const {
|
|
135
|
+
activity: {
|
|
136
|
+
channelData: {
|
|
137
|
+
fileScan
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
} = card;
|
|
141
|
+
const scanResult = fileScan[index];
|
|
142
|
+
if ((scanResult === null || scanResult === void 0 ? void 0 : scanResult.status) === FileScanStatus.INPROGRESS) {
|
|
143
|
+
return /*#__PURE__*/React.createElement(ScanInProgressAttachment, {
|
|
144
|
+
textCard: card
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
if ((scanResult === null || scanResult === void 0 ? void 0 : scanResult.status) === FileScanStatus.MALWARE) {
|
|
148
|
+
var _state$domainStates$m;
|
|
149
|
+
const localizedText = ((_state$domainStates$m = state.domainStates.middlewareLocalizedTexts) === null || _state$domainStates$m === void 0 ? void 0 : _state$domainStates$m.MIDDLEWARE_BANNER_FILE_IS_MALICIOUS) ?? defaultMiddlewareLocalizedTexts.MIDDLEWARE_BANNER_FILE_IS_MALICIOUS;
|
|
150
|
+
NotificationHandler.notifyError(NotificationScenarios.AttachmentError, localizedText.replace("{0}", attachment.name));
|
|
151
|
+
return /*#__PURE__*/React.createElement(MaliciousAttachment, {
|
|
152
|
+
textCard: card
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
}
|
|
216
156
|
const fileExtension = attachment.name.substring(attachment.name.lastIndexOf(".") + 1, attachment.name.length) || attachment.name;
|
|
217
157
|
const imageExtension = Constants.imageRegex.test(attachment.name);
|
|
218
158
|
const audioExtension = Constants.audioMediaRegex.test(attachment.name);
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import useChatContextStore from "../../../../../../hooks/useChatContextStore";
|
|
3
|
+
import { defaultAttachmentProps } from "../../../../common/defaultProps/defaultAttachmentProps";
|
|
4
|
+
import { defaultAttachmentContentStyles } from "../defaultStyles/defaultAttachmentContentStyles";
|
|
5
|
+
import { defaultAttachmentDividerStyles } from "../defaultStyles/defaultAttachmentDividerStyles";
|
|
6
|
+
import { defaultAttachmentDownloadIconStyles } from "../defaultStyles/defaultAttachmentDownloadIconStyles";
|
|
7
|
+
import { defaultAttachmentFileNameStyles } from "../defaultStyles/defaultAttachmentFileNameStyles";
|
|
8
|
+
import { defaultAttachmentSizeStyles } from "../defaultStyles/defaultAttachmentSizeStyles";
|
|
9
|
+
import { defaultAttachmentIconStyles } from "../defaultStyles/defaultAtttachmentIconStyles";
|
|
10
|
+
import { defaultAttachmentStyles } from "../defaultStyles/defaultAtttachmentStyles";
|
|
11
|
+
import AttachmentContent from "./AttachmentContent";
|
|
12
|
+
import AttachmentIcon from "./AttachmentIcon";
|
|
13
|
+
const Attachment = props => {
|
|
14
|
+
var _state$domainStates$r, _state$domainStates$r2, _state$domainStates$r3, _state$domainStates$r4, _state$domainStates$r5, _state$domainStates$r6, _state$domainStates$r7, _state$domainStates$r8, _state$domainStates$r9;
|
|
15
|
+
// eslint-disable-line @typescript-eslint/no-explicit-any
|
|
16
|
+
const {
|
|
17
|
+
iconData,
|
|
18
|
+
imageCard,
|
|
19
|
+
textCard,
|
|
20
|
+
renderer
|
|
21
|
+
} = props;
|
|
22
|
+
const [state] = useChatContextStore();
|
|
23
|
+
const attachmentId = ((_state$domainStates$r = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r === void 0 ? void 0 : (_state$domainStates$r2 = _state$domainStates$r.attachmentProps) === null || _state$domainStates$r2 === void 0 ? void 0 : _state$domainStates$r2.webChatAttachmentId) ?? defaultAttachmentProps.webChatAttachmentId;
|
|
24
|
+
const attachmentDividerStyles = {
|
|
25
|
+
...defaultAttachmentDividerStyles,
|
|
26
|
+
...((_state$domainStates$r3 = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r3 === void 0 ? void 0 : _state$domainStates$r3.attachmentDividerStyles)
|
|
27
|
+
};
|
|
28
|
+
const attachmentIconStyles = {
|
|
29
|
+
...defaultAttachmentIconStyles,
|
|
30
|
+
...((_state$domainStates$r4 = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r4 === void 0 ? void 0 : _state$domainStates$r4.attachmentIconStyles)
|
|
31
|
+
};
|
|
32
|
+
const attachmentStyles = {
|
|
33
|
+
...defaultAttachmentStyles,
|
|
34
|
+
...((_state$domainStates$r5 = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r5 === void 0 ? void 0 : _state$domainStates$r5.attachmentStyles)
|
|
35
|
+
};
|
|
36
|
+
const attachmentSizeStylesString = Object.entries({
|
|
37
|
+
...defaultAttachmentSizeStyles,
|
|
38
|
+
...((_state$domainStates$r6 = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r6 === void 0 ? void 0 : _state$domainStates$r6.attachmentSizeStyles)
|
|
39
|
+
}).map(_ref => {
|
|
40
|
+
let [k, v] = _ref;
|
|
41
|
+
return `${k.replace(/[A-Z]/g, match => `-${match.toLowerCase()}`)}:${v}`;
|
|
42
|
+
}).join(";");
|
|
43
|
+
const attachmentContentStylesString = Object.entries({
|
|
44
|
+
...defaultAttachmentContentStyles,
|
|
45
|
+
...((_state$domainStates$r7 = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r7 === void 0 ? void 0 : _state$domainStates$r7.attachmentContentStyles)
|
|
46
|
+
}).map(_ref2 => {
|
|
47
|
+
let [k, v] = _ref2;
|
|
48
|
+
return `${k.replace(/[A-Z]/g, match => `-${match.toLowerCase()}`)}:${v}`;
|
|
49
|
+
}).join(";");
|
|
50
|
+
const attachmentFileNameStylesString = Object.entries({
|
|
51
|
+
...defaultAttachmentFileNameStyles,
|
|
52
|
+
...((_state$domainStates$r8 = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r8 === void 0 ? void 0 : _state$domainStates$r8.attachmentFileNameStyles)
|
|
53
|
+
}).map(_ref3 => {
|
|
54
|
+
let [k, v] = _ref3;
|
|
55
|
+
return `${k.replace(/[A-Z]/g, match => `-${match.toLowerCase()}`)}:${v}`;
|
|
56
|
+
}).join(";");
|
|
57
|
+
const attachmentDownloadIconStylesString = Object.entries({
|
|
58
|
+
...defaultAttachmentDownloadIconStyles,
|
|
59
|
+
...((_state$domainStates$r9 = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r9 === void 0 ? void 0 : _state$domainStates$r9.attachmentDownloadIconStyles)
|
|
60
|
+
}).map(_ref4 => {
|
|
61
|
+
let [k, v] = _ref4;
|
|
62
|
+
return `${k.replace(/[A-Z]/g, match => `-${match.toLowerCase()}`)}:${v}`;
|
|
63
|
+
}).join(";");
|
|
64
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("style", null, `
|
|
65
|
+
.webchat__fileContent__size { ${attachmentSizeStylesString} }
|
|
66
|
+
.webchat__fileContent { ${attachmentContentStylesString} }
|
|
67
|
+
.webchat__fileContent__fileName { ${attachmentFileNameStylesString} }
|
|
68
|
+
.webchat__fileContent__downloadIcon { ${attachmentDownloadIconStylesString} }
|
|
69
|
+
`), /*#__PURE__*/React.createElement("div", {
|
|
70
|
+
dir: state.domainStates.globalDir
|
|
71
|
+
}, imageCard && renderer(imageCard), imageCard && /*#__PURE__*/React.createElement("hr", {
|
|
72
|
+
id: attachmentId + "-divider",
|
|
73
|
+
style: attachmentDividerStyles
|
|
74
|
+
}), /*#__PURE__*/React.createElement(AttachmentContent, {
|
|
75
|
+
attachment: textCard.attachment,
|
|
76
|
+
id: attachmentId,
|
|
77
|
+
style: attachmentStyles
|
|
78
|
+
}, /*#__PURE__*/React.createElement(AttachmentIcon, {
|
|
79
|
+
src: iconData,
|
|
80
|
+
id: attachmentId + "-icon",
|
|
81
|
+
style: attachmentIconStyles
|
|
82
|
+
}), textCard && renderer(textCard))));
|
|
83
|
+
};
|
|
84
|
+
export default Attachment;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
const AttachmentContent = props => {
|
|
3
|
+
// eslint-disable-line @typescript-eslint/no-explicit-any
|
|
4
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
5
|
+
id: props.id,
|
|
6
|
+
style: props.style
|
|
7
|
+
}, props.children);
|
|
8
|
+
};
|
|
9
|
+
export default AttachmentContent;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { getFileAttachmentIconData } from "../../../../common/utils/FileAttachmentIconManager";
|
|
3
|
+
const AttachmentIcon = props => {
|
|
4
|
+
// eslint-disable-line @typescript-eslint/no-explicit-any
|
|
5
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
6
|
+
id: props.id,
|
|
7
|
+
style: props.style
|
|
8
|
+
}, /*#__PURE__*/React.createElement("img", {
|
|
9
|
+
src: props.src ?? getFileAttachmentIconData("txt"),
|
|
10
|
+
alt: "attachment icon"
|
|
11
|
+
}));
|
|
12
|
+
};
|
|
13
|
+
export default AttachmentIcon;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
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); }
|
|
2
|
+
import React from "react";
|
|
3
|
+
import Attachment from "./Attachment";
|
|
4
|
+
const DownloadBlockedAttachment = props => {
|
|
5
|
+
// eslint-disable-line @typescript-eslint/no-explicit-any
|
|
6
|
+
const renderer = () => /*#__PURE__*/React.createElement("div", {
|
|
7
|
+
style: {
|
|
8
|
+
display: "flex",
|
|
9
|
+
padding: "10px 10px 10px 8px",
|
|
10
|
+
width: "100%"
|
|
11
|
+
}
|
|
12
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
13
|
+
style: {
|
|
14
|
+
fontSize: 12,
|
|
15
|
+
fontFamily: "Segoe UI, Arial, sans-serif"
|
|
16
|
+
}
|
|
17
|
+
}, " ", props.textCard.attachment.name, " "), /*#__PURE__*/React.createElement("div", {
|
|
18
|
+
style: {
|
|
19
|
+
marginLeft: "auto",
|
|
20
|
+
paddingRight: "10px"
|
|
21
|
+
}
|
|
22
|
+
}, props.extraContent && props.extraContent));
|
|
23
|
+
return /*#__PURE__*/React.createElement(Attachment, _extends({}, props, {
|
|
24
|
+
imageCard: undefined,
|
|
25
|
+
renderer: renderer
|
|
26
|
+
}));
|
|
27
|
+
};
|
|
28
|
+
export default DownloadBlockedAttachment;
|