@microsoft/omnichannel-chat-widget 1.7.6-main.dca3f60 → 1.7.7-main.37d9c4a
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/common/Constants.js +3 -0
- package/lib/cjs/common/facades/FacadeChatSDK.js +76 -21
- package/lib/cjs/common/utils.js +14 -2
- package/lib/cjs/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +15 -0
- package/lib/cjs/components/livechatwidget/LiveChatWidget.js +3 -2
- package/lib/cjs/components/livechatwidget/common/createMarkdown.js +4 -3
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +27 -22
- package/lib/cjs/components/livechatwidget/interfaces/IFeatureConfigProps.js +1 -0
- package/lib/cjs/components/livechatwidget/interfaces/ISendBox.js +1 -0
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +19 -13
- package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +10 -5
- package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +13 -1
- package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps.js +2 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/markdownrenderers/HyperlinkTextOverrideRenderer.js +3 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/DeliveredTimestamp.js +15 -2
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlTextMiddleware.js +8 -7
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/sanitizationMiddleware.js +3 -1
- package/lib/esm/common/Constants.js +3 -0
- package/lib/esm/common/facades/FacadeChatSDK.js +76 -21
- package/lib/esm/common/utils.js +11 -1
- package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +15 -0
- package/lib/esm/components/livechatwidget/LiveChatWidget.js +3 -2
- package/lib/esm/components/livechatwidget/common/createMarkdown.js +4 -3
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +28 -22
- package/lib/esm/components/livechatwidget/interfaces/IFeatureConfigProps.js +1 -0
- package/lib/esm/components/livechatwidget/interfaces/ISendBox.js +1 -0
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +19 -13
- package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +10 -5
- package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +15 -3
- package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps.js +2 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/markdownrenderers/HyperlinkTextOverrideRenderer.js +3 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/DeliveredTimestamp.js +15 -2
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlTextMiddleware.js +8 -7
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/sanitizationMiddleware.js +3 -1
- package/lib/types/common/Constants.d.ts +3 -0
- package/lib/types/common/facades/FacadeChatSDK.d.ts +5 -2
- package/lib/types/common/utils.d.ts +1 -0
- package/lib/types/components/livechatwidget/common/createMarkdown.d.ts +1 -1
- package/lib/types/components/livechatwidget/interfaces/IFeatureConfigProps.d.ts +3 -0
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +9 -7
- package/lib/types/components/livechatwidget/interfaces/ISendBox.d.ts +12 -0
- package/lib/types/components/webchatcontainerstateful/interfaces/IWebChatContainerStatefulProps.d.ts +5 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlTextMiddleware.d.ts +1 -1
- package/package.json +2 -2
|
@@ -31,15 +31,28 @@ const DeliveredTimestamp = _ref => {
|
|
|
31
31
|
timestamp
|
|
32
32
|
}
|
|
33
33
|
} = args;
|
|
34
|
+
const getTimeElement = timestamp => {
|
|
35
|
+
const timeString = (0, _utils.getTimestampHourMinute)(timestamp);
|
|
36
|
+
const isAmPmFormat = timeString.toLowerCase().includes("am") || timeString.toLowerCase().includes("pm");
|
|
37
|
+
|
|
38
|
+
// For clients that use languages that are written right-to-left, but still use AM/PM time format, we need to
|
|
39
|
+
// make sure the "rtl" direction doesn't produce "PM 1:23", but remains "1:23 PM"
|
|
40
|
+
if (dir === "rtl" && isAmPmFormat) {
|
|
41
|
+
return /*#__PURE__*/_react.default.createElement("span", {
|
|
42
|
+
dir: "ltr"
|
|
43
|
+
}, (0, _utils.getTimestampHourMinute)(timestamp));
|
|
44
|
+
}
|
|
45
|
+
return timeString;
|
|
46
|
+
};
|
|
34
47
|
return /*#__PURE__*/_react.default.createElement(_react2.Stack, {
|
|
35
48
|
style: contentStyles,
|
|
36
49
|
dir: dir
|
|
37
50
|
}, role === _DirectLineSenderRole.DirectLineSenderRole.Bot && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("span", {
|
|
38
51
|
dir: dir,
|
|
39
52
|
"aria-hidden": "false"
|
|
40
|
-
}, name, " - ", (
|
|
53
|
+
}, name, " - ", getTimeElement(timestamp))), role === _DirectLineSenderRole.DirectLineSenderRole.User && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("span", {
|
|
41
54
|
"aria-hidden": "false",
|
|
42
55
|
dir: dir
|
|
43
|
-
}, " ", (
|
|
56
|
+
}, " ", getTimeElement(timestamp), " - ", ((_state$domainStates$m = state.domainStates.middlewareLocalizedTexts) === null || _state$domainStates$m === void 0 ? void 0 : _state$domainStates$m.MIDDLEWARE_MESSAGE_DELIVERED) ?? _defaultMiddlewareLocalizedTexts.defaultMiddlewareLocalizedTexts.MIDDLEWARE_MESSAGE_DELIVERED)));
|
|
44
57
|
};
|
|
45
58
|
exports.DeliveredTimestamp = DeliveredTimestamp;
|
|
@@ -22,8 +22,9 @@ const convertTextToHtmlNode = text => {
|
|
|
22
22
|
if (!text) return "";
|
|
23
23
|
const element = document.createElement(_Constants.HtmlAttributeNames.div);
|
|
24
24
|
try {
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
text = _dompurify.default.sanitize(text, {
|
|
26
|
+
ADD_ATTR: ["target"]
|
|
27
|
+
});
|
|
27
28
|
element.innerHTML = text;
|
|
28
29
|
} catch (e) {
|
|
29
30
|
const errorMessage = `Failed to purify and set innertHTML with text: ${text}`;
|
|
@@ -39,7 +40,7 @@ const convertTextToHtmlNode = text => {
|
|
|
39
40
|
};
|
|
40
41
|
|
|
41
42
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
42
|
-
const processHTMLText = (action, text) => {
|
|
43
|
+
const processHTMLText = (action, text, honorsTargetInHTMLLinks) => {
|
|
43
44
|
const htmlNode = convertTextToHtmlNode(text);
|
|
44
45
|
const aNodes = htmlNode.getElementsByTagName(_Constants.HtmlAttributeNames.aTagName);
|
|
45
46
|
if ((aNodes === null || aNodes === void 0 ? void 0 : aNodes.length) > 0) {
|
|
@@ -52,8 +53,8 @@ const processHTMLText = (action, text) => {
|
|
|
52
53
|
continue;
|
|
53
54
|
}
|
|
54
55
|
|
|
55
|
-
// Add target to 'a' node if target is missing or
|
|
56
|
-
if (!aNode.target ||
|
|
56
|
+
// Add target to 'a' node if target is missing or if honorsTargetInHTMLLinks is false
|
|
57
|
+
if (!aNode.target || !honorsTargetInHTMLLinks) {
|
|
57
58
|
aNode.target = _Constants.Constants.blank;
|
|
58
59
|
}
|
|
59
60
|
|
|
@@ -92,7 +93,7 @@ const processHTMLText = (action, text) => {
|
|
|
92
93
|
};
|
|
93
94
|
|
|
94
95
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
|
|
95
|
-
const htmlTextMiddleware = _ref => {
|
|
96
|
+
const htmlTextMiddleware = honorsTargetInHTMLLinks => _ref => {
|
|
96
97
|
let {
|
|
97
98
|
dispatch
|
|
98
99
|
} = _ref;
|
|
@@ -102,7 +103,7 @@ const htmlTextMiddleware = _ref => {
|
|
|
102
103
|
var _action$payload, _action$payload$activ;
|
|
103
104
|
const text = (_action$payload = action.payload) === null || _action$payload === void 0 ? void 0 : (_action$payload$activ = _action$payload.activity) === null || _action$payload$activ === void 0 ? void 0 : _action$payload$activ.text;
|
|
104
105
|
if (text) {
|
|
105
|
-
action = processHTMLText(action, text);
|
|
106
|
+
action = processHTMLText(action, text, honorsTargetInHTMLLinks ?? false);
|
|
106
107
|
}
|
|
107
108
|
} catch (e) {
|
|
108
109
|
let errorMessage = "Failed to validate action.";
|
|
@@ -26,7 +26,9 @@ const sanitizationMiddleware = _ref => {
|
|
|
26
26
|
var _action$payload;
|
|
27
27
|
let text = (_action$payload = action.payload) === null || _action$payload === void 0 ? void 0 : _action$payload.text;
|
|
28
28
|
if (text) {
|
|
29
|
-
text = _dompurify.default.sanitize(text
|
|
29
|
+
text = _dompurify.default.sanitize(text, {
|
|
30
|
+
ADD_ATTR: ["target"]
|
|
31
|
+
}) ?? " ";
|
|
30
32
|
}
|
|
31
33
|
} catch (e) {
|
|
32
34
|
const copyDataForTelemetry = {
|
|
@@ -92,6 +92,8 @@ _defineProperty(Constants, "Zero", "zero");
|
|
|
92
92
|
_defineProperty(Constants, "Title", "title");
|
|
93
93
|
_defineProperty(Constants, "Target", "target");
|
|
94
94
|
_defineProperty(Constants, "Blank", "_blank");
|
|
95
|
+
_defineProperty(Constants, "TargetSelf", "_self");
|
|
96
|
+
_defineProperty(Constants, "TargetTop", "_top");
|
|
95
97
|
_defineProperty(Constants, "TargetRelationship", "rel");
|
|
96
98
|
_defineProperty(Constants, "TargetRelationshipAttributes", "noopener noreferrer");
|
|
97
99
|
// Markdown icons
|
|
@@ -120,6 +122,7 @@ _defineProperty(HtmlIdNames, "MSLiveChatWidget", "MSLiveChatWidget");
|
|
|
120
122
|
export class HtmlClassNames {}
|
|
121
123
|
_defineProperty(HtmlClassNames, "webChatBannerCloseButton", "webchat__toast__dismissButton");
|
|
122
124
|
_defineProperty(HtmlClassNames, "webChatBannerExpandButton", "webchat__toaster__expandIcon");
|
|
125
|
+
_defineProperty(HtmlClassNames, "webChatHistoryContainer", "webchat__basic-transcript");
|
|
123
126
|
export class HtmlElementSelectors {}
|
|
124
127
|
_defineProperty(HtmlElementSelectors, "sendBoxSelector", "textarea[data-id=\"webchat-sendbox-input\"]");
|
|
125
128
|
export class HtmlAttributeNames {}
|
|
@@ -20,7 +20,7 @@ export class FacadeChatSDK {
|
|
|
20
20
|
isTokenSet() {
|
|
21
21
|
return !isNullOrEmptyString(this.token);
|
|
22
22
|
}
|
|
23
|
-
constructor(input) {
|
|
23
|
+
constructor(input, disableReauthentication) {
|
|
24
24
|
_defineProperty(this, "chatSDK", void 0);
|
|
25
25
|
_defineProperty(this, "chatConfig", void 0);
|
|
26
26
|
_defineProperty(this, "token", "");
|
|
@@ -28,11 +28,13 @@ export class FacadeChatSDK {
|
|
|
28
28
|
_defineProperty(this, "isAuthenticated", void 0);
|
|
29
29
|
_defineProperty(this, "getAuthToken", void 0);
|
|
30
30
|
_defineProperty(this, "sdkMocked", void 0);
|
|
31
|
+
_defineProperty(this, "disableReauthentication", void 0);
|
|
31
32
|
this.chatSDK = input.chatSDK;
|
|
32
33
|
this.chatConfig = input.chatConfig;
|
|
33
34
|
this.getAuthToken = input.getAuthToken;
|
|
34
35
|
this.isAuthenticated = input.isAuthenticated;
|
|
35
36
|
this.sdkMocked = input.isSDKMocked;
|
|
37
|
+
this.disableReauthentication = disableReauthentication;
|
|
36
38
|
}
|
|
37
39
|
|
|
38
40
|
//set default expiration to zero, for undefined or missed exp in jwt
|
|
@@ -56,32 +58,75 @@ export class FacadeChatSDK {
|
|
|
56
58
|
|
|
57
59
|
// compare expiration time with current time
|
|
58
60
|
if (now > this.expiration) {
|
|
59
|
-
console.
|
|
61
|
+
console.error("Token is expired", now, this.expiration, now > this.expiration);
|
|
60
62
|
return true;
|
|
61
63
|
}
|
|
62
64
|
return false;
|
|
63
65
|
}
|
|
66
|
+
enforceBase64Encoding(payload) {
|
|
67
|
+
//base64url when present, switches the "-" and "_" characters with "+" and "/"
|
|
68
|
+
const base64Payload = payload.replace(/-/g, "+").replace(/_/g, "/");
|
|
69
|
+
// since base64 encoding requires padding, we need to add padding to the payload
|
|
70
|
+
return base64Payload.padEnd(base64Payload.length + (4 - base64Payload.length % 4) % 4, "=");
|
|
71
|
+
}
|
|
72
|
+
extractExpFromToken(token) {
|
|
73
|
+
const tokenParts = token.split(".");
|
|
74
|
+
const last3digits = token.slice(-3);
|
|
75
|
+
|
|
76
|
+
// token must have 3 parts as JWT format
|
|
77
|
+
if (tokenParts.length !== 3) {
|
|
78
|
+
TelemetryHelper.logFacadeChatSDKEvent(LogLevel.ERROR, {
|
|
79
|
+
Event: TelemetryEvent.NewTokenFailed,
|
|
80
|
+
Description: "Invalid token format",
|
|
81
|
+
ExceptionDetails: {
|
|
82
|
+
message: "Invalid token format, must be in JWT format",
|
|
83
|
+
token: last3digits
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
throw new Error("Invalid token format, must be in JWT format");
|
|
87
|
+
}
|
|
88
|
+
try {
|
|
89
|
+
const payload = this.enforceBase64Encoding(tokenParts[1]);
|
|
90
|
+
// decode payload
|
|
91
|
+
const decodedPayload = atob(payload);
|
|
92
|
+
const jsonPayload = JSON.parse(decodedPayload);
|
|
93
|
+
// check if exp is present in payload
|
|
94
|
+
if (jsonPayload) {
|
|
95
|
+
if (jsonPayload.exp) {
|
|
96
|
+
return jsonPayload.exp;
|
|
97
|
+
}
|
|
98
|
+
return 0;
|
|
99
|
+
}
|
|
100
|
+
TelemetryHelper.logFacadeChatSDKEvent(LogLevel.ERROR, {
|
|
101
|
+
Event: TelemetryEvent.NewTokenFailed,
|
|
102
|
+
Description: "Invalid token payload",
|
|
103
|
+
ExceptionDetails: {
|
|
104
|
+
message: "Token payload is not valid JSON",
|
|
105
|
+
token: last3digits
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
throw new Error("Invalid token payload, payload is not valid JSON");
|
|
109
|
+
} catch (e) {
|
|
110
|
+
console.error("Failed to decode token", e);
|
|
111
|
+
TelemetryHelper.logFacadeChatSDKEvent(LogLevel.ERROR, {
|
|
112
|
+
Event: TelemetryEvent.NewTokenFailed,
|
|
113
|
+
Description: "Failed to decode token",
|
|
114
|
+
ExceptionDetails: {
|
|
115
|
+
message: "Failed to decode token",
|
|
116
|
+
token: last3digits
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
throw new Error("Failed to decode token");
|
|
120
|
+
}
|
|
121
|
+
}
|
|
64
122
|
async setToken(token) {
|
|
65
123
|
// token must be not null, and must be new
|
|
66
124
|
if (!isNullOrEmptyString(token) && token !== this.token) {
|
|
67
|
-
|
|
125
|
+
const last3digits = token.slice(-3);
|
|
68
126
|
const instant = Math.floor(Date.now() / 1000);
|
|
69
127
|
this.token = token;
|
|
70
|
-
// decompose token
|
|
71
|
-
const tokenParts = (_this$token = this.token) === null || _this$token === void 0 ? void 0 : _this$token.split(".");
|
|
72
|
-
if (!tokenParts || tokenParts.length <= 1) {
|
|
73
|
-
TelemetryHelper.logFacadeChatSDKEvent(LogLevel.ERROR, {
|
|
74
|
-
Event: TelemetryEvent.NewTokenFailed,
|
|
75
|
-
Description: "Invalid token format",
|
|
76
|
-
ExceptionDetails: "Token must be in JWT format"
|
|
77
|
-
});
|
|
78
|
-
throw new Error("Invalid token format, must be in JWT format");
|
|
79
|
-
}
|
|
80
|
-
// decode token
|
|
81
|
-
const tokenDecoded = JSON.parse(atob(tokenParts[1]));
|
|
82
128
|
// calculate expiration time
|
|
83
|
-
this.expiration = this.convertExpiration(
|
|
84
|
-
|
|
129
|
+
this.expiration = this.convertExpiration(this.extractExpFromToken(token) || 0);
|
|
85
130
|
// this is a control , in case the getAuthToken function returns same token
|
|
86
131
|
if (this.expiration > 0 && this.expiration < instant) {
|
|
87
132
|
TelemetryHelper.logFacadeChatSDKEvent(LogLevel.ERROR, {
|
|
@@ -89,14 +134,23 @@ export class FacadeChatSDK {
|
|
|
89
134
|
Description: "New token is already expired",
|
|
90
135
|
ExceptionDetails: {
|
|
91
136
|
"Instant": instant,
|
|
92
|
-
"Expiration": this.expiration
|
|
137
|
+
"Expiration": this.expiration,
|
|
138
|
+
"Token": last3digits
|
|
93
139
|
}
|
|
94
140
|
});
|
|
95
|
-
throw new Error(
|
|
141
|
+
throw new Error(`New token is already expired, with epoch time ${this.expiration} , last 3 digits of token: ${last3digits}`);
|
|
96
142
|
}
|
|
97
143
|
}
|
|
98
144
|
}
|
|
99
145
|
async tokenRing() {
|
|
146
|
+
if (this.disableReauthentication === true) {
|
|
147
|
+
// facade feature is disabled, so we are bypassing the re authentication and let it fail.
|
|
148
|
+
return {
|
|
149
|
+
result: true,
|
|
150
|
+
message: "Facade is disabled"
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
|
|
100
154
|
// this is needed for storybooks, specifically for reconnect pane which requires authentication bypass
|
|
101
155
|
if (this.sdkMocked === true) {
|
|
102
156
|
return {
|
|
@@ -148,7 +202,6 @@ export class FacadeChatSDK {
|
|
|
148
202
|
};
|
|
149
203
|
} else {
|
|
150
204
|
var _ring$error, _ring$error2;
|
|
151
|
-
console.error("Failed to get token", ring);
|
|
152
205
|
TelemetryHelper.logFacadeChatSDKEvent(LogLevel.ERROR, {
|
|
153
206
|
Event: TelemetryEvent.NewTokenFailed,
|
|
154
207
|
Description: (_ring$error = ring.error) === null || _ring$error === void 0 ? void 0 : _ring$error.message,
|
|
@@ -241,7 +294,9 @@ export class FacadeChatSDK {
|
|
|
241
294
|
return this.validateAndExecuteCall("sendMessage", () => this.chatSDK.sendMessage(message));
|
|
242
295
|
}
|
|
243
296
|
async onNewMessage(onNewMessageCallback) {
|
|
244
|
-
let optionalParams = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
|
297
|
+
let optionalParams = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
|
298
|
+
disablePolling: false
|
|
299
|
+
};
|
|
245
300
|
return this.validateAndExecuteCall("onNewMessage", () => this.chatSDK.onNewMessage(onNewMessageCallback, optionalParams));
|
|
246
301
|
}
|
|
247
302
|
async sendTypingEvent() {
|
package/lib/esm/common/utils.js
CHANGED
|
@@ -440,4 +440,14 @@ export const setOcUserAgent = chatSDK => {
|
|
|
440
440
|
console.warn(error);
|
|
441
441
|
}
|
|
442
442
|
}
|
|
443
|
-
};
|
|
443
|
+
};
|
|
444
|
+
export function getDeviceType() {
|
|
445
|
+
const userAgent = navigator.userAgent.toLowerCase();
|
|
446
|
+
if (/android/.test(userAgent)) {
|
|
447
|
+
return "android";
|
|
448
|
+
} else if (/iphone|ipad|ipod/.test(userAgent)) {
|
|
449
|
+
return "ios";
|
|
450
|
+
} else {
|
|
451
|
+
return "standard";
|
|
452
|
+
}
|
|
453
|
+
}
|
package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js
CHANGED
|
@@ -8,6 +8,8 @@ import { NotificationScenarios } from "../../webchatcontainerstateful/webchatcon
|
|
|
8
8
|
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
9
9
|
import createChatTranscript from "../../../plugins/createChatTranscript";
|
|
10
10
|
import { executeReducer } from "../../../contexts/createReducer";
|
|
11
|
+
import { uuidv4 } from "@microsoft/omnichannel-chat-sdk";
|
|
12
|
+
import { ConversationState } from "../../../contexts/common/ConversationState";
|
|
11
13
|
const processDisplayName = displayName => {
|
|
12
14
|
// if displayname matches "teamsvisitor:<some alphanumeric string>", we replace it with "Customer"
|
|
13
15
|
const displayNameRegex = ".+:.+";
|
|
@@ -161,11 +163,24 @@ export const downloadTranscript = async (facadeChatSDK, downloadTranscriptProps,
|
|
|
161
163
|
// Need to keep existing live chat context for scenarios when transcript is downloaded after endchat
|
|
162
164
|
let liveChatContext = state === null || state === void 0 ? void 0 : (_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : _state$domainStates.liveChatContext;
|
|
163
165
|
if (!liveChatContext) {
|
|
166
|
+
var _inMemoryState$appSta;
|
|
164
167
|
const inMemoryState = executeReducer(state, {
|
|
165
168
|
type: LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
|
|
166
169
|
payload: null
|
|
167
170
|
});
|
|
168
171
|
liveChatContext = inMemoryState.domainStates.liveChatContext;
|
|
172
|
+
if ((inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$appSta = inMemoryState.appStates) === null || _inMemoryState$appSta === void 0 ? void 0 : _inMemoryState$appSta.conversationState) !== ConversationState.Active && !liveChatContext) {
|
|
173
|
+
var _state$domainStates2;
|
|
174
|
+
const chatToken = (state === null || state === void 0 ? void 0 : (_state$domainStates2 = state.domainStates) === null || _state$domainStates2 === void 0 ? void 0 : _state$domainStates2.chatToken) || inMemoryState.domainStates.chatToken;
|
|
175
|
+
if (chatToken && Object.keys(chatToken).length > 0) {
|
|
176
|
+
liveChatContext = {
|
|
177
|
+
chatToken: chatToken,
|
|
178
|
+
requestId: chatToken.requestId || uuidv4()
|
|
179
|
+
};
|
|
180
|
+
} else {
|
|
181
|
+
liveChatContext = await (facadeChatSDK === null || facadeChatSDK === void 0 ? void 0 : facadeChatSDK.getCurrentLiveChatContext());
|
|
182
|
+
}
|
|
183
|
+
}
|
|
169
184
|
}
|
|
170
185
|
let data = await (facadeChatSDK === null || facadeChatSDK === void 0 ? void 0 : facadeChatSDK.getLiveChatTranscript({
|
|
171
186
|
liveChatContext
|
|
@@ -11,13 +11,14 @@ import { getMockChatSDKIfApplicable } from "./common/getMockChatSDKIfApplicable"
|
|
|
11
11
|
import { isNullOrUndefined } from "../../common/utils";
|
|
12
12
|
import overridePropsOnMockIfApplicable from "./common/overridePropsOnMockIfApplicable";
|
|
13
13
|
export const LiveChatWidget = props => {
|
|
14
|
-
var _props$mock, _props$chatConfig, _props$chatConfig$Liv;
|
|
14
|
+
var _props$mock, _props$featureConfigP, _props$chatConfig, _props$chatConfig$Liv;
|
|
15
15
|
const reducer = createReducer();
|
|
16
16
|
const [state, dispatch] = useReducer(reducer, getLiveChatWidgetContextInitialState(props));
|
|
17
17
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
18
18
|
const [adapter, setAdapter] = useState(undefined);
|
|
19
19
|
const [facadeChatSDK, setFacadeChatSDK] = useState(undefined);
|
|
20
20
|
const chatSDK = getMockChatSDKIfApplicable(props.chatSDK, props === null || props === void 0 ? void 0 : (_props$mock = props.mock) === null || _props$mock === void 0 ? void 0 : _props$mock.type);
|
|
21
|
+
const disableReauthentication = ((_props$featureConfigP = props.featureConfigProps) === null || _props$featureConfigP === void 0 ? void 0 : _props$featureConfigP.disableReauthentication) === true;
|
|
21
22
|
overridePropsOnMockIfApplicable(props);
|
|
22
23
|
if (!props.chatConfig) {
|
|
23
24
|
throw new Error("chatConfig is required");
|
|
@@ -34,7 +35,7 @@ export const LiveChatWidget = props => {
|
|
|
34
35
|
"getAuthToken": props === null || props === void 0 ? void 0 : props.getAuthToken,
|
|
35
36
|
//when type is not undefined, it means the SDK is mocked
|
|
36
37
|
"isSDKMocked": !isNullOrUndefined(props === null || props === void 0 ? void 0 : (_props$mock2 = props.mock) === null || _props$mock2 === void 0 ? void 0 : _props$mock2.type)
|
|
37
|
-
}));
|
|
38
|
+
}, disableReauthentication));
|
|
38
39
|
}
|
|
39
40
|
return /*#__PURE__*/React.createElement(FacadeChatSDKStore.Provider, {
|
|
40
41
|
value: [facadeChatSDK, setFacadeChatSDK]
|
|
@@ -5,7 +5,7 @@ import { defaultMarkdownLocalizedTexts } from "../../webchatcontainerstateful/co
|
|
|
5
5
|
import { addSlackMarkdownIt } from "./helpers/markdownHelper";
|
|
6
6
|
|
|
7
7
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
8
|
-
export const createMarkdown = (disableMarkdownMessageFormatting, disableNewLineMarkdownSupport) => {
|
|
8
|
+
export const createMarkdown = (disableMarkdownMessageFormatting, disableNewLineMarkdownSupport, opensMarkdownLinksInSameTab) => {
|
|
9
9
|
let markdown;
|
|
10
10
|
if (!disableMarkdownMessageFormatting) {
|
|
11
11
|
markdown = new MarkdownIt(Constants.Default, {
|
|
@@ -39,10 +39,11 @@ export const createMarkdown = (disableMarkdownMessageFormatting, disableNewLineM
|
|
|
39
39
|
const targetAttrIndex = tokens[idx].attrIndex(Constants.Target);
|
|
40
40
|
// Put a transparent pixel instead of the "open in new window" icon, so developers can easily modify the icon in CSS.
|
|
41
41
|
const TRANSPARENT_GIF = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";
|
|
42
|
+
const targetValue = opensMarkdownLinksInSameTab ? Constants.TargetTop : Constants.Blank;
|
|
42
43
|
if (~targetAttrIndex) {
|
|
43
|
-
tokens[idx].attrs[targetAttrIndex][1] =
|
|
44
|
+
tokens[idx].attrs[targetAttrIndex][1] = targetValue;
|
|
44
45
|
} else {
|
|
45
|
-
tokens[idx].attrPush([Constants.Target,
|
|
46
|
+
tokens[idx].attrPush([Constants.Target, targetValue]);
|
|
46
47
|
}
|
|
47
48
|
const relAttrIndex = tokens[idx].attrIndex(Constants.TargetRelationship);
|
|
48
49
|
if (~relAttrIndex) {
|
|
@@ -31,10 +31,11 @@ import htmlPlayerMiddleware from "../../webchatcontainerstateful/webchatcontroll
|
|
|
31
31
|
import htmlTextMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlTextMiddleware";
|
|
32
32
|
import preProcessingMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/preProcessingMiddleware";
|
|
33
33
|
import sanitizationMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/sanitizationMiddleware";
|
|
34
|
+
import { Constants } from "../../../common/Constants";
|
|
34
35
|
|
|
35
36
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
36
37
|
export const initWebChatComposer = (props, state, dispatch, facadeChatSDK, endChat) => {
|
|
37
|
-
var _props$webChatContain, _props$webChatContain2, _props$webChatContain3, _props$webChatContain4, _state$domainStates$l4, _state$domainStates$l5, _props$
|
|
38
|
+
var _props$webChatContain, _props$webChatContain2, _props$webChatContain3, _props$webChatContain4, _props$webChatContain5, _props$webChatContain6, _state$domainStates$l4, _state$domainStates$l5, _props$webChatContain11, _props$webChatContain12, _state$domainStates$r, _state$domainStates$r2, _props$webChatContain13, _props$webChatContain14, _state$domainStates$r3, _state$domainStates$r4, _props$webChatContain15, _props$webChatContain16, _defaultWebChatContai, _props$webChatContain17, _props$webChatContain18, _props$webChatContain19, _props$webChatContain20, _state$domainStates$r5, _state$domainStates$r6, _props$webChatContain21, _props$webChatContain22, _defaultWebChatContai2, _props$webChatContain23, _props$webChatContain24, _defaultWebChatContai3, _props$webChatContain25, _props$webChatContain26;
|
|
38
39
|
// Add a hook to make all links open a new window
|
|
39
40
|
postDomPurifyActivities();
|
|
40
41
|
const localizedTexts = {
|
|
@@ -44,12 +45,14 @@ export const initWebChatComposer = (props, state, dispatch, facadeChatSDK, endCh
|
|
|
44
45
|
const hyperlinkTextOverride = ((_props$webChatContain2 = props.webChatContainerProps) === null || _props$webChatContain2 === void 0 ? void 0 : _props$webChatContain2.hyperlinkTextOverride) ?? defaultWebChatContainerStatefulProps.hyperlinkTextOverride;
|
|
45
46
|
const disableNewLineMarkdownSupport = ((_props$webChatContain3 = props.webChatContainerProps) === null || _props$webChatContain3 === void 0 ? void 0 : _props$webChatContain3.disableNewLineMarkdownSupport) ?? defaultWebChatContainerStatefulProps.disableNewLineMarkdownSupport;
|
|
46
47
|
const disableMarkdownMessageFormatting = ((_props$webChatContain4 = props.webChatContainerProps) === null || _props$webChatContain4 === void 0 ? void 0 : _props$webChatContain4.disableMarkdownMessageFormatting) ?? defaultWebChatContainerStatefulProps.disableMarkdownMessageFormatting;
|
|
48
|
+
const opensMarkdownLinksInSameTab = (_props$webChatContain5 = props.webChatContainerProps) === null || _props$webChatContain5 === void 0 ? void 0 : _props$webChatContain5.opensMarkdownLinksInSameTab;
|
|
49
|
+
const honorsTargetInHTMLLinks = (_props$webChatContain6 = props.webChatContainerProps) === null || _props$webChatContain6 === void 0 ? void 0 : _props$webChatContain6.honorsTargetInHTMLLinks;
|
|
47
50
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
48
|
-
const markdown = createMarkdown(disableMarkdownMessageFormatting, disableNewLineMarkdownSupport);
|
|
51
|
+
const markdown = createMarkdown(disableMarkdownMessageFormatting, disableNewLineMarkdownSupport, opensMarkdownLinksInSameTab);
|
|
49
52
|
// Initialize Web Chat's redux store
|
|
50
53
|
let webChatStore = WebChatStoreLoader.store;
|
|
51
54
|
if (!webChatStore) {
|
|
52
|
-
var _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _props$
|
|
55
|
+
var _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _props$webChatContain7;
|
|
53
56
|
const conversationEndCallback = async () => {
|
|
54
57
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
55
58
|
const conversationDetails = await getConversationDetailsCall(facadeChatSDK);
|
|
@@ -81,18 +84,18 @@ export const initWebChatComposer = (props, state, dispatch, facadeChatSDK, endCh
|
|
|
81
84
|
};
|
|
82
85
|
webChatStore = createStore({},
|
|
83
86
|
//initial state
|
|
84
|
-
preProcessingMiddleware, attachmentProcessingMiddleware, createAttachmentUploadValidatorMiddleware((_state$domainStates$l = state.domainStates.liveChatConfig) === null || _state$domainStates$l === void 0 ? void 0 : _state$domainStates$l.allowedFileExtensions, (_state$domainStates$l2 = state.domainStates.liveChatConfig) === null || _state$domainStates$l2 === void 0 ? void 0 : _state$domainStates$l2.maxUploadFileSize, localizedTexts), channelDataMiddleware, createConversationEndMiddleware(conversationEndCallback), createDataMaskingMiddleware((_state$domainStates$l3 = state.domainStates.liveChatConfig) === null || _state$domainStates$l3 === void 0 ? void 0 : _state$domainStates$l3.DataMaskingInfo), createMessageTimeStampMiddleware, createMessageSequenceIdOverrideMiddleware, gifUploadMiddleware, htmlPlayerMiddleware, htmlTextMiddleware, createMaxMessageSizeValidator(localizedTexts), sanitizationMiddleware,
|
|
87
|
+
preProcessingMiddleware, attachmentProcessingMiddleware, createAttachmentUploadValidatorMiddleware((_state$domainStates$l = state.domainStates.liveChatConfig) === null || _state$domainStates$l === void 0 ? void 0 : _state$domainStates$l.allowedFileExtensions, (_state$domainStates$l2 = state.domainStates.liveChatConfig) === null || _state$domainStates$l2 === void 0 ? void 0 : _state$domainStates$l2.maxUploadFileSize, localizedTexts), channelDataMiddleware, createConversationEndMiddleware(conversationEndCallback), createDataMaskingMiddleware((_state$domainStates$l3 = state.domainStates.liveChatConfig) === null || _state$domainStates$l3 === void 0 ? void 0 : _state$domainStates$l3.DataMaskingInfo), createMessageTimeStampMiddleware, createMessageSequenceIdOverrideMiddleware, gifUploadMiddleware, htmlPlayerMiddleware, htmlTextMiddleware(honorsTargetInHTMLLinks), createMaxMessageSizeValidator(localizedTexts), sanitizationMiddleware,
|
|
85
88
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
86
|
-
...(((_props$
|
|
89
|
+
...(((_props$webChatContain7 = props.webChatContainerProps) === null || _props$webChatContain7 === void 0 ? void 0 : _props$webChatContain7.storeMiddlewares) ?? []));
|
|
87
90
|
WebChatStoreLoader.store = webChatStore;
|
|
88
91
|
}
|
|
89
92
|
const hyperlinkTextOverrideRenderer = new HyperlinkTextOverrideRenderer(hyperlinkTextOverride);
|
|
90
93
|
const markdownRenderers = [hyperlinkTextOverrideRenderer];
|
|
91
94
|
const renderMarkdown = text => {
|
|
92
|
-
var _props$
|
|
93
|
-
if ((_props$
|
|
94
|
-
var _props$
|
|
95
|
-
text = (_props$
|
|
95
|
+
var _props$webChatContain8, _props$webChatContain9;
|
|
96
|
+
if ((_props$webChatContain8 = props.webChatContainerProps) !== null && _props$webChatContain8 !== void 0 && (_props$webChatContain9 = _props$webChatContain8.webChatProps) !== null && _props$webChatContain9 !== void 0 && _props$webChatContain9.renderMarkdown) {
|
|
97
|
+
var _props$webChatContain10;
|
|
98
|
+
text = (_props$webChatContain10 = props.webChatContainerProps) === null || _props$webChatContain10 === void 0 ? void 0 : _props$webChatContain10.webChatProps.renderMarkdown(text);
|
|
96
99
|
} else {
|
|
97
100
|
const render = disableMarkdownMessageFormatting ? markdown.renderInline.bind(markdown) : markdown.render.bind(markdown);
|
|
98
101
|
text = render(text);
|
|
@@ -102,16 +105,19 @@ export const initWebChatComposer = (props, state, dispatch, facadeChatSDK, endCh
|
|
|
102
105
|
});
|
|
103
106
|
const config = {
|
|
104
107
|
FORBID_TAGS: ["form", "button", "script", "div", "input"],
|
|
105
|
-
FORBID_ATTR: ["action"]
|
|
108
|
+
FORBID_ATTR: ["action"],
|
|
109
|
+
ADD_ATTR: ["target"]
|
|
106
110
|
};
|
|
107
111
|
text = DOMPurify.sanitize(text, config);
|
|
108
112
|
return text;
|
|
109
113
|
};
|
|
110
114
|
function postDomPurifyActivities() {
|
|
111
115
|
DOMPurify.addHook("afterSanitizeAttributes", function (node) {
|
|
112
|
-
|
|
113
|
-
if (
|
|
114
|
-
node.setAttribute(
|
|
116
|
+
const target = node.getAttribute(Constants.Target);
|
|
117
|
+
if (target === Constants.TargetSelf) {
|
|
118
|
+
node.setAttribute(Constants.Target, Constants.TargetTop);
|
|
119
|
+
} else if (!target) {
|
|
120
|
+
node.setAttribute(Constants.Target, Constants.Blank);
|
|
115
121
|
}
|
|
116
122
|
});
|
|
117
123
|
}
|
|
@@ -121,18 +127,18 @@ export const initWebChatComposer = (props, state, dispatch, facadeChatSDK, endCh
|
|
|
121
127
|
dir: state.domainStates.globalDir,
|
|
122
128
|
locale: changeLanguageCodeFormatForWebChat(getLocaleStringFromId((_state$domainStates$l4 = state.domainStates.liveChatConfig) === null || _state$domainStates$l4 === void 0 ? void 0 : (_state$domainStates$l5 = _state$domainStates$l4.ChatWidgetLanguage) === null || _state$domainStates$l5 === void 0 ? void 0 : _state$domainStates$l5.msdyn_localeid)),
|
|
123
129
|
store: webChatStore,
|
|
124
|
-
activityMiddleware: (_props$
|
|
125
|
-
attachmentMiddleware: (_props$
|
|
126
|
-
activityStatusMiddleware: (_props$
|
|
127
|
-
toastMiddleware: (_props$
|
|
130
|
+
activityMiddleware: (_props$webChatContain11 = props.webChatContainerProps) !== null && _props$webChatContain11 !== void 0 && (_props$webChatContain12 = _props$webChatContain11.renderingMiddlewareProps) !== null && _props$webChatContain12 !== void 0 && _props$webChatContain12.disableActivityMiddleware ? undefined : createActivityMiddleware(renderMarkdown, (_state$domainStates$r = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r === void 0 ? void 0 : _state$domainStates$r.systemMessageStyleProps, (_state$domainStates$r2 = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r2 === void 0 ? void 0 : _state$domainStates$r2.userMessageStyleProps),
|
|
131
|
+
attachmentMiddleware: (_props$webChatContain13 = props.webChatContainerProps) !== null && _props$webChatContain13 !== void 0 && (_props$webChatContain14 = _props$webChatContain13.renderingMiddlewareProps) !== null && _props$webChatContain14 !== void 0 && _props$webChatContain14.disableAttachmentMiddleware ? undefined : createAttachmentMiddleware(((_state$domainStates$r3 = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r3 === void 0 ? void 0 : (_state$domainStates$r4 = _state$domainStates$r3.attachmentProps) === null || _state$domainStates$r4 === void 0 ? void 0 : _state$domainStates$r4.enableInlinePlaying) ?? defaultAttachmentProps.enableInlinePlaying),
|
|
132
|
+
activityStatusMiddleware: (_props$webChatContain15 = props.webChatContainerProps) !== null && _props$webChatContain15 !== void 0 && (_props$webChatContain16 = _props$webChatContain15.renderingMiddlewareProps) !== null && _props$webChatContain16 !== void 0 && _props$webChatContain16.disableActivityStatusMiddleware ? undefined : (_defaultWebChatContai = defaultWebChatContainerStatefulProps.webChatProps) === null || _defaultWebChatContai === void 0 ? void 0 : _defaultWebChatContai.activityStatusMiddleware,
|
|
133
|
+
toastMiddleware: (_props$webChatContain17 = props.webChatContainerProps) !== null && _props$webChatContain17 !== void 0 && (_props$webChatContain18 = _props$webChatContain17.renderingMiddlewareProps) !== null && _props$webChatContain18 !== void 0 && _props$webChatContain18.disableToastMiddleware ? undefined : createToastMiddleware(props.notificationPaneProps, endChat),
|
|
128
134
|
renderMarkdown,
|
|
129
|
-
avatarMiddleware: (_props$
|
|
130
|
-
groupActivitiesMiddleware: (_props$
|
|
131
|
-
typingIndicatorMiddleware: (_props$
|
|
135
|
+
avatarMiddleware: (_props$webChatContain19 = props.webChatContainerProps) !== null && _props$webChatContain19 !== void 0 && (_props$webChatContain20 = _props$webChatContain19.renderingMiddlewareProps) !== null && _props$webChatContain20 !== void 0 && _props$webChatContain20.disableAvatarMiddleware ? undefined : createAvatarMiddleware((_state$domainStates$r5 = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r5 === void 0 ? void 0 : _state$domainStates$r5.avatarStyleProps, (_state$domainStates$r6 = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r6 === void 0 ? void 0 : _state$domainStates$r6.avatarTextStyleProps),
|
|
136
|
+
groupActivitiesMiddleware: (_props$webChatContain21 = props.webChatContainerProps) !== null && _props$webChatContain21 !== void 0 && (_props$webChatContain22 = _props$webChatContain21.renderingMiddlewareProps) !== null && _props$webChatContain22 !== void 0 && _props$webChatContain22.disableGroupActivitiesMiddleware ? undefined : (_defaultWebChatContai2 = defaultWebChatContainerStatefulProps.webChatProps) === null || _defaultWebChatContai2 === void 0 ? void 0 : _defaultWebChatContai2.groupActivitiesMiddleware,
|
|
137
|
+
typingIndicatorMiddleware: (_props$webChatContain23 = props.webChatContainerProps) !== null && _props$webChatContain23 !== void 0 && (_props$webChatContain24 = _props$webChatContain23.renderingMiddlewareProps) !== null && _props$webChatContain24 !== void 0 && _props$webChatContain24.disableTypingIndicatorMiddleware ? undefined : (_defaultWebChatContai3 = defaultWebChatContainerStatefulProps.webChatProps) === null || _defaultWebChatContai3 === void 0 ? void 0 : _defaultWebChatContai3.typingIndicatorMiddleware,
|
|
132
138
|
onTelemetry: createWebChatTelemetry(),
|
|
133
|
-
cardActionMiddleware: createCardActionMiddleware(((_props$
|
|
139
|
+
cardActionMiddleware: createCardActionMiddleware(((_props$webChatContain25 = props.webChatContainerProps) === null || _props$webChatContain25 === void 0 ? void 0 : _props$webChatContain25.botMagicCode) || undefined),
|
|
134
140
|
sendTypingIndicator: true,
|
|
135
|
-
...((_props$
|
|
141
|
+
...((_props$webChatContain26 = props.webChatContainerProps) === null || _props$webChatContain26 === void 0 ? void 0 : _props$webChatContain26.webChatProps)
|
|
136
142
|
};
|
|
137
143
|
return webChatProps;
|
|
138
144
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -56,7 +56,7 @@ import useChatContextStore from "../../../hooks/useChatContextStore";
|
|
|
56
56
|
import useFacadeSDKStore from "../../../hooks/useFacadeChatSDKStore";
|
|
57
57
|
let uiTimer;
|
|
58
58
|
export const LiveChatWidgetStateful = props => {
|
|
59
|
-
var _props$webChatContain, _props$styleProps, _props$controlProps, _props$controlProps3, _state$appStates7, _props$
|
|
59
|
+
var _props$webChatContain, _props$styleProps, _props$webChatContain2, _props$webChatContain3, _props$controlProps, _props$controlProps3, _state$appStates7, _props$webChatContain7, _state$appStates14, _props$webChatContain9, _props$webChatContain10, _props$controlProps12, _props$draggableChatW, _props$draggableChatW2, _props$draggableChatW3, _props$draggableChatW4, _props$draggableChatW5, _livechatProps$webCha, _props$webChatContain11, _props$webChatContain12, _props$webChatContain13, _props$webChatContain14, _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$compon8, _livechatProps$contro10, _livechatProps$contro11, _livechatProps$compon9, _livechatProps$contro12, _livechatProps$compon10, _livechatProps$contro13, _livechatProps$compon11, _livechatProps$compon12, _livechatProps$compon13;
|
|
60
60
|
useEffect(() => {
|
|
61
61
|
uiTimer = createTimer();
|
|
62
62
|
TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
|
|
@@ -86,6 +86,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
86
86
|
|
|
87
87
|
//Scrollbar styles
|
|
88
88
|
const scrollbarProps = Object.assign({}, defaultScrollBarProps, props === null || props === void 0 ? void 0 : props.scrollBarProps);
|
|
89
|
+
const sendBoxTextArea = props === null || props === void 0 ? void 0 : (_props$webChatContain2 = props.webChatContainerProps) === null || _props$webChatContain2 === void 0 ? void 0 : (_props$webChatContain3 = _props$webChatContain2.sendBoxTextBox) === null || _props$webChatContain3 === void 0 ? void 0 : _props$webChatContain3.textarea;
|
|
89
90
|
|
|
90
91
|
// In case the broadcast channel is already initialized elsewhere; One tab can only hold 1 instance
|
|
91
92
|
if ((props === null || props === void 0 ? void 0 : (_props$controlProps = props.controlProps) === null || _props$controlProps === void 0 ? void 0 : _props$controlProps.skipBroadcastChannelInit) !== true) {
|
|
@@ -580,6 +581,8 @@ export const LiveChatWidgetStateful = props => {
|
|
|
580
581
|
BroadcastService.postMessage({
|
|
581
582
|
eventName: BroadcastEvent.NewMessageNotification
|
|
582
583
|
});
|
|
584
|
+
}, {
|
|
585
|
+
disablePolling: true
|
|
583
586
|
});
|
|
584
587
|
facadeChatSDK === null || facadeChatSDK === void 0 ? void 0 : facadeChatSDK.onAgentEndSession(event => {
|
|
585
588
|
var _inMemoryState$appSta6;
|
|
@@ -603,8 +606,8 @@ export const LiveChatWidgetStateful = props => {
|
|
|
603
606
|
});
|
|
604
607
|
}
|
|
605
608
|
if (state.appStates.conversationState === ConversationState.InActive) {
|
|
606
|
-
var _props$
|
|
607
|
-
if ((props === null || props === void 0 ? void 0 : (_props$
|
|
609
|
+
var _props$webChatContain4, _props$webChatContain5;
|
|
610
|
+
if ((props === null || props === void 0 ? void 0 : (_props$webChatContain4 = props.webChatContainerProps) === null || _props$webChatContain4 === void 0 ? void 0 : (_props$webChatContain5 = _props$webChatContain4.renderingMiddlewareProps) === null || _props$webChatContain5 === void 0 ? void 0 : _props$webChatContain5.hideSendboxOnConversationEnd) !== false) {
|
|
608
611
|
setWebChatStyles(styles => {
|
|
609
612
|
return {
|
|
610
613
|
...styles,
|
|
@@ -648,12 +651,12 @@ export const LiveChatWidgetStateful = props => {
|
|
|
648
651
|
}
|
|
649
652
|
}, [state.appStates.unreadMessageCount]);
|
|
650
653
|
useEffect(() => {
|
|
651
|
-
var _props$
|
|
654
|
+
var _props$webChatContain6;
|
|
652
655
|
setWebChatStyles({
|
|
653
656
|
...webChatStyles,
|
|
654
|
-
...((_props$
|
|
657
|
+
...((_props$webChatContain6 = props.webChatContainerProps) === null || _props$webChatContain6 === void 0 ? void 0 : _props$webChatContain6.webChatStyles)
|
|
655
658
|
});
|
|
656
|
-
}, [(_props$
|
|
659
|
+
}, [(_props$webChatContain7 = props.webChatContainerProps) === null || _props$webChatContain7 === void 0 ? void 0 : _props$webChatContain7.webChatStyles]);
|
|
657
660
|
useEffect(() => {
|
|
658
661
|
//Confirmation pane dismissing through OK option, so proceed with end chat
|
|
659
662
|
if (state.domainStates.confirmationState === ConfirmationState.Ok) {
|
|
@@ -752,12 +755,12 @@ export const LiveChatWidgetStateful = props => {
|
|
|
752
755
|
|
|
753
756
|
// if props state gets updates we need to update the renderingMiddlewareProps in the state
|
|
754
757
|
useEffect(() => {
|
|
755
|
-
var _props$
|
|
758
|
+
var _props$webChatContain8;
|
|
756
759
|
dispatch({
|
|
757
760
|
type: LiveChatWidgetActionType.SET_RENDERING_MIDDLEWARE_PROPS,
|
|
758
|
-
payload: (_props$
|
|
761
|
+
payload: (_props$webChatContain8 = props.webChatContainerProps) === null || _props$webChatContain8 === void 0 ? void 0 : _props$webChatContain8.renderingMiddlewareProps
|
|
759
762
|
});
|
|
760
|
-
}, [(_props$
|
|
763
|
+
}, [(_props$webChatContain9 = props.webChatContainerProps) === null || _props$webChatContain9 === void 0 ? void 0 : _props$webChatContain9.renderingMiddlewareProps]);
|
|
761
764
|
useEffect(() => {
|
|
762
765
|
TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
|
|
763
766
|
Event: TelemetryEvent.UXLivechatwidgetCompleted,
|
|
@@ -799,7 +802,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
799
802
|
const webChatProps = initWebChatComposer(props, state, dispatch, facadeChatSDK, endChatRelay);
|
|
800
803
|
const downloadTranscriptProps = createDownloadTranscriptProps(props.downloadTranscriptProps, {
|
|
801
804
|
...(defaultWebChatContainerStatefulProps === null || defaultWebChatContainerStatefulProps === void 0 ? void 0 : defaultWebChatContainerStatefulProps.webChatStyles),
|
|
802
|
-
...((_props$
|
|
805
|
+
...((_props$webChatContain10 = props.webChatContainerProps) === null || _props$webChatContain10 === void 0 ? void 0 : _props$webChatContain10.webChatStyles)
|
|
803
806
|
}, props.webChatContainerProps);
|
|
804
807
|
const livechatProps = {
|
|
805
808
|
...props,
|
|
@@ -857,13 +860,16 @@ export const LiveChatWidgetStateful = props => {
|
|
|
857
860
|
height: .75em;
|
|
858
861
|
margin-left: .25em;
|
|
859
862
|
}
|
|
860
|
-
|
|
863
|
+
${(sendBoxTextArea === null || sendBoxTextArea === void 0 ? void 0 : sendBoxTextArea.minHeight) && `
|
|
864
|
+
textarea.webchat__send-box-text-box__html-text-area {
|
|
865
|
+
min-height: ${sendBoxTextArea === null || sendBoxTextArea === void 0 ? void 0 : sendBoxTextArea.minHeight};
|
|
866
|
+
}`}
|
|
861
867
|
`), /*#__PURE__*/React.createElement(DraggableChatWidget, chatWidgetDraggableConfig, /*#__PURE__*/React.createElement(Composer, _extends({}, webChatProps, {
|
|
862
868
|
userID: userID,
|
|
863
869
|
styleOptions: {
|
|
864
870
|
...webChatStyles,
|
|
865
|
-
bubbleBackground: ((_props$
|
|
866
|
-
bubbleTextColor: ((_props$
|
|
871
|
+
bubbleBackground: ((_props$webChatContain11 = props.webChatContainerProps) === null || _props$webChatContain11 === void 0 ? void 0 : (_props$webChatContain12 = _props$webChatContain11.adaptiveCardStyles) === null || _props$webChatContain12 === void 0 ? void 0 : _props$webChatContain12.background) ?? defaultAdaptiveCardStyles.background,
|
|
872
|
+
bubbleTextColor: ((_props$webChatContain13 = props.webChatContainerProps) === null || _props$webChatContain13 === void 0 ? void 0 : (_props$webChatContain14 = _props$webChatContain13.adaptiveCardStyles) === null || _props$webChatContain14 === void 0 ? void 0 : _props$webChatContain14.color) ?? defaultAdaptiveCardStyles.color
|
|
867
873
|
},
|
|
868
874
|
directLine: directLine
|
|
869
875
|
}), /*#__PURE__*/React.createElement(Stack, {
|