@xapp/chat-widget 1.36.8 → 1.37.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/CancelButton/CancelButton.d.ts +7 -0
- package/dist/components/CancelButton/index.d.ts +1 -0
- package/dist/components/MinimizeButton/MinimizeButton.d.ts +1 -0
- package/dist/components/StatusContainer/StatusContainer.d.ts +2 -0
- package/dist/index.css +1 -1
- package/dist/index.es.js +80 -32
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +80 -32
- package/dist/index.js.map +1 -1
- package/dist/store/ChatState.d.ts +7 -0
- package/dist/store/actions/index.d.ts +1 -0
- package/dist/store/actions/resetAction.d.ts +1 -1
- package/dist/xapp/ChatServer.d.ts +29 -0
- package/dist/xapp/ChatServerMessage.d.ts +8 -0
- package/dist/xapp/StentorDirectChat.d.ts +1 -0
- package/package.json +8 -8
- package/dist/components/IconButton/IconButton.d.ts +0 -9
- package/dist/components/IconButton/index.d.ts +0 -1
- package/dist/components/Storybook/messages.d.ts +0 -5
- package/dist/components/Suggestions/SuggestionsGroupItem.d.ts +0 -16
- package/dist/components/Suggestions/SuggestionsItem.d.ts +0 -11
- package/dist/components/Suggestions/data.test.d.ts +0 -1
- package/dist/store/Reset.d.ts +0 -1
- package/dist/utils/__tests__/url-utils.test.d.ts +0 -1
- package/dist/utils/url-utils.d.ts +0 -8
- package/dist/utils/useJsonFetch.d.ts +0 -20
- package/dist/utils/uuid.d.ts +0 -7
- package/dist/utils/uuid.test.d.ts +0 -1
package/dist/index.js
CHANGED
|
@@ -1898,6 +1898,9 @@ function throwBadKind$1(x) {
|
|
|
1898
1898
|
|
|
1899
1899
|
function execute(url, behavior) {
|
|
1900
1900
|
var type = behavior.type;
|
|
1901
|
+
if (get("opened")) {
|
|
1902
|
+
set("opened", false);
|
|
1903
|
+
}
|
|
1901
1904
|
switch (type) {
|
|
1902
1905
|
case "newWindow":
|
|
1903
1906
|
window.open(url, "callout-option", "toolbar=0,status=0,width=".concat(behavior.width || 1000, ",height=").concat(behavior.height || 700));
|
|
@@ -1906,6 +1909,10 @@ function execute(url, behavior) {
|
|
|
1906
1909
|
window.open(url, "_blank");
|
|
1907
1910
|
break;
|
|
1908
1911
|
case "sameWindow":
|
|
1912
|
+
// For reopen widget after move on same window
|
|
1913
|
+
if (get("visible")) {
|
|
1914
|
+
set("opened", true);
|
|
1915
|
+
}
|
|
1909
1916
|
window.open(url, "_self");
|
|
1910
1917
|
break;
|
|
1911
1918
|
default:
|
|
@@ -1934,7 +1941,8 @@ function writeMessage(msg, user) {
|
|
|
1934
1941
|
|
|
1935
1942
|
function executeAction(text, token) {
|
|
1936
1943
|
return function (chatServer) { return function (dispatch, getState) {
|
|
1937
|
-
|
|
1944
|
+
var attributes = getState().attributes;
|
|
1945
|
+
chatServer.sendChatMsg({ text: text, token: token, attributes: attributes }, function (err) {
|
|
1938
1946
|
if (err) {
|
|
1939
1947
|
log("Error sending message", err);
|
|
1940
1948
|
return;
|
|
@@ -2070,6 +2078,12 @@ function setConnectionStatus(status) {
|
|
|
2070
2078
|
};
|
|
2071
2079
|
}
|
|
2072
2080
|
|
|
2081
|
+
function reset() {
|
|
2082
|
+
return {
|
|
2083
|
+
type: "reset"
|
|
2084
|
+
};
|
|
2085
|
+
}
|
|
2086
|
+
|
|
2073
2087
|
function useChatDispatch() {
|
|
2074
2088
|
return reactRedux.useDispatch();
|
|
2075
2089
|
}
|
|
@@ -2971,6 +2985,7 @@ var StentorDirectChat = /** @class */ (function () {
|
|
|
2971
2985
|
this._userId = "";
|
|
2972
2986
|
this._sessionId = "";
|
|
2973
2987
|
this._accessToken = "";
|
|
2988
|
+
this._attributes = {};
|
|
2974
2989
|
this.config = config;
|
|
2975
2990
|
this.options = options;
|
|
2976
2991
|
this.isNewSession = false;
|
|
@@ -3117,8 +3132,10 @@ var StentorDirectChat = /** @class */ (function () {
|
|
|
3117
3132
|
};
|
|
3118
3133
|
StentorDirectChat.prototype.setVisitorInfo = function (visitorInfo, cb) {
|
|
3119
3134
|
this.visitorInfo = visitorInfo;
|
|
3135
|
+
this._attributes = this.visitorInfo.attributes;
|
|
3120
3136
|
this._accessToken = this.visitorInfo.accessToken;
|
|
3121
3137
|
this.startSession();
|
|
3138
|
+
// This is for the bot
|
|
3122
3139
|
this.userJoined({
|
|
3123
3140
|
user: this.getBot(undefined),
|
|
3124
3141
|
token: ""
|
|
@@ -3139,23 +3156,27 @@ var StentorDirectChat = /** @class */ (function () {
|
|
|
3139
3156
|
StentorDirectChat.prototype.postMessage = function (message) {
|
|
3140
3157
|
var _a, _b, _c, _d;
|
|
3141
3158
|
return __awaiter$1(this, void 0, void 0, function () {
|
|
3142
|
-
var request, accessToken, now, permissionRequest, expired, text, granted, userProfile, isEmail, botResponse, responseMessage;
|
|
3159
|
+
var request, userId, sessionId, accessToken, attributes, now, permissionRequest, expired, text, granted, userProfile, isEmail, botResponse, responseMessage;
|
|
3143
3160
|
return __generator$1(this, function (_e) {
|
|
3144
3161
|
switch (_e.label) {
|
|
3145
3162
|
case 0:
|
|
3163
|
+
userId = this._userId;
|
|
3164
|
+
sessionId = this._sessionId;
|
|
3146
3165
|
accessToken = this._accessToken;
|
|
3166
|
+
attributes = this._attributes || {};
|
|
3147
3167
|
now = new Date().getTime();
|
|
3148
3168
|
if (this.isNewSession && !((_a = message === null || message === void 0 ? void 0 : message.msg) === null || _a === void 0 ? void 0 : _a.text)) {
|
|
3149
3169
|
request = {
|
|
3150
3170
|
type: "LAUNCH_REQUEST",
|
|
3151
3171
|
rawQuery: (_b = message === null || message === void 0 ? void 0 : message.msg) === null || _b === void 0 ? void 0 : _b.text,
|
|
3152
|
-
sessionId:
|
|
3153
|
-
userId:
|
|
3172
|
+
sessionId: sessionId,
|
|
3173
|
+
userId: userId,
|
|
3154
3174
|
isNewSession: true,
|
|
3155
3175
|
intentId: "LaunchRequest",
|
|
3156
3176
|
platform: "stentor-platform",
|
|
3157
3177
|
channel: "widget",
|
|
3158
|
-
accessToken: accessToken
|
|
3178
|
+
accessToken: accessToken,
|
|
3179
|
+
attributes: attributes
|
|
3159
3180
|
};
|
|
3160
3181
|
}
|
|
3161
3182
|
else {
|
|
@@ -3165,7 +3186,7 @@ var StentorDirectChat = /** @class */ (function () {
|
|
|
3165
3186
|
expired = now - permissionRequest.time > PERMISSION_QUESTION_EXPIRATION_MS;
|
|
3166
3187
|
text = (_d = message.msg.text) === null || _d === void 0 ? void 0 : _d.toLowerCase();
|
|
3167
3188
|
granted = !expired;
|
|
3168
|
-
userProfile = {};
|
|
3189
|
+
userProfile = { id: this._userId };
|
|
3169
3190
|
if (!expired) {
|
|
3170
3191
|
if (permissionRequest.type === "EMAIL") {
|
|
3171
3192
|
isEmail = looksLikeEmail(text);
|
|
@@ -3195,7 +3216,8 @@ var StentorDirectChat = /** @class */ (function () {
|
|
|
3195
3216
|
intentId: "PermissionGrant",
|
|
3196
3217
|
platform: "stentor-platform",
|
|
3197
3218
|
channel: "widget",
|
|
3198
|
-
accessToken: accessToken
|
|
3219
|
+
accessToken: accessToken,
|
|
3220
|
+
attributes: attributes
|
|
3199
3221
|
};
|
|
3200
3222
|
}
|
|
3201
3223
|
else if (message.type === "custom") {
|
|
@@ -3203,7 +3225,7 @@ var StentorDirectChat = /** @class */ (function () {
|
|
|
3203
3225
|
// token: message.msg.token,
|
|
3204
3226
|
sessionId: this._sessionId, userId: this._userId, isNewSession: false,
|
|
3205
3227
|
// intentId: "OptionSelect",
|
|
3206
|
-
platform: "stentor-platform", channel: "widget", accessToken: accessToken });
|
|
3228
|
+
platform: "stentor-platform", channel: "widget", accessToken: accessToken, attributes: attributes });
|
|
3207
3229
|
}
|
|
3208
3230
|
else if (message.msg.token) {
|
|
3209
3231
|
request = {
|
|
@@ -3215,7 +3237,8 @@ var StentorDirectChat = /** @class */ (function () {
|
|
|
3215
3237
|
intentId: "OptionSelect",
|
|
3216
3238
|
platform: "stentor-platform",
|
|
3217
3239
|
channel: "widget",
|
|
3218
|
-
accessToken: accessToken
|
|
3240
|
+
accessToken: accessToken,
|
|
3241
|
+
attributes: attributes
|
|
3219
3242
|
};
|
|
3220
3243
|
}
|
|
3221
3244
|
else {
|
|
@@ -3228,7 +3251,8 @@ var StentorDirectChat = /** @class */ (function () {
|
|
|
3228
3251
|
intentId: "NLU_RESULT_PLACEHOLDER",
|
|
3229
3252
|
platform: "stentor-platform",
|
|
3230
3253
|
channel: "widget",
|
|
3231
|
-
accessToken: accessToken
|
|
3254
|
+
accessToken: accessToken,
|
|
3255
|
+
attributes: attributes
|
|
3232
3256
|
};
|
|
3233
3257
|
}
|
|
3234
3258
|
}
|
|
@@ -3269,7 +3293,7 @@ var StentorDirectChat = /** @class */ (function () {
|
|
|
3269
3293
|
};
|
|
3270
3294
|
StentorDirectChat.prototype.startSession = function () {
|
|
3271
3295
|
if (this.visitorInfo.visitorId) {
|
|
3272
|
-
this._userId = "
|
|
3296
|
+
this._userId = "".concat(this.visitorInfo.visitorId);
|
|
3273
3297
|
}
|
|
3274
3298
|
else if (this.visitorInfo.email) {
|
|
3275
3299
|
this._userId = "stentor-widget-user-".concat(this.visitorInfo.email);
|
|
@@ -3278,6 +3302,7 @@ var StentorDirectChat = /** @class */ (function () {
|
|
|
3278
3302
|
this._userId = "stentor-widget-user-".concat(uuid_1());
|
|
3279
3303
|
}
|
|
3280
3304
|
this._sessionId = "stentor-widget-session-".concat(uuid_1());
|
|
3305
|
+
// This is a flag that is cleared after the first message is sent
|
|
3281
3306
|
this.isNewSession = true;
|
|
3282
3307
|
};
|
|
3283
3308
|
Object.defineProperty(StentorDirectChat.prototype, "userId", {
|
|
@@ -7507,11 +7532,14 @@ function useChatServerVisitorId() {
|
|
|
7507
7532
|
return state.visitorId || state.userId;
|
|
7508
7533
|
});
|
|
7509
7534
|
var visitorAccessToken = reactRedux.useSelector(function (state) { return state.accessToken; });
|
|
7535
|
+
var attributes = reactRedux.useSelector(function (state) { return state.attributes; });
|
|
7510
7536
|
return React$1.useMemo(function () { return ({
|
|
7511
7537
|
dispatch: dispatch,
|
|
7512
7538
|
visitorId: clientVisitorId,
|
|
7513
|
-
accessToken: visitorAccessToken
|
|
7514
|
-
|
|
7539
|
+
accessToken: visitorAccessToken,
|
|
7540
|
+
userId: clientVisitorId,
|
|
7541
|
+
attributes: attributes
|
|
7542
|
+
}); }, [dispatch, clientVisitorId, visitorAccessToken, attributes]);
|
|
7515
7543
|
}
|
|
7516
7544
|
//send whenever server settings or visitor id changes
|
|
7517
7545
|
function useGreeting(active) {
|
|
@@ -7525,7 +7553,9 @@ function useGreeting(active) {
|
|
|
7525
7553
|
curr.dispatch(sendVisitorInfo({
|
|
7526
7554
|
name: "Visitor",
|
|
7527
7555
|
visitorId: curr.visitorId,
|
|
7528
|
-
|
|
7556
|
+
userId: curr.userId,
|
|
7557
|
+
accessToken: curr.accessToken,
|
|
7558
|
+
attributes: curr.attributes
|
|
7529
7559
|
}));
|
|
7530
7560
|
var timeoutId_1 = setTimeout(function () {
|
|
7531
7561
|
var greetingAction = sendGreeting();
|
|
@@ -8136,8 +8166,12 @@ var ServerOffline = function () {
|
|
|
8136
8166
|
React__default$1["default"].createElement("h3", null, "Server is offline"));
|
|
8137
8167
|
};
|
|
8138
8168
|
|
|
8169
|
+
var CancelButton = function (props) {
|
|
8170
|
+
return React__default$1["default"].createElement("div", { className: "cancel-button", onClick: props.onClick });
|
|
8171
|
+
};
|
|
8172
|
+
|
|
8139
8173
|
var MinimizeButton = function (props) {
|
|
8140
|
-
return React__default$1["default"].createElement("div", { className: "minimize-button", onClick: props.onClick });
|
|
8174
|
+
return (React__default$1["default"].createElement("div", { className: "minimize-button ".concat(props.showInRight ? "positionRight" : ""), onClick: props.onClick }));
|
|
8141
8175
|
};
|
|
8142
8176
|
|
|
8143
8177
|
var DEFAULT_STATUS_CONFIG = {
|
|
@@ -8163,12 +8197,14 @@ var StatusContainer = function (props) {
|
|
|
8163
8197
|
React__default$1["default"].createElement("div", { className: "status-text" },
|
|
8164
8198
|
React__default$1["default"].createElement("span", null, getStatusText(props.accountStatus, (_a = props.config) === null || _a === void 0 ? void 0 : _a.status))),
|
|
8165
8199
|
props.canMinimize &&
|
|
8166
|
-
React__default$1["default"].createElement(MinimizeButton, { onClick: props.minimizeOnClick })
|
|
8200
|
+
React__default$1["default"].createElement(MinimizeButton, { onClick: props.minimizeOnClick, showInRight: !props.canCancel }),
|
|
8201
|
+
props.canCancel &&
|
|
8202
|
+
React__default$1["default"].createElement(CancelButton, { onClick: props.cancelOnClick })));
|
|
8167
8203
|
};
|
|
8168
8204
|
|
|
8169
8205
|
function buildStyleContent(theme) {
|
|
8170
8206
|
var _a, _b, _c, _d;
|
|
8171
|
-
return "\n:root {\n".concat(buildVariables(withPrefix("\t--xapp-", union(single("primary-color", theme === null || theme === void 0 ? void 0 : theme.primaryColor), withPrefix("widget-", union(getSize(theme === null || theme === void 0 ? void 0 : theme.size), getMargins(theme === null || theme === void 0 ? void 0 : theme.margin), getBorderStyle(theme === null || theme === void 0 ? void 0 : theme.border))), getChatButtonStyle(theme === null || theme === void 0 ? void 0 : theme.chatButton), withPrefix("header-", getHeaderStyle(theme === null || theme === void 0 ? void 0 : theme.header)), withPrefix("footer-", getFooterStyle(theme === null || theme === void 0 ? void 0 : theme.footer)), withPrefix("content-", union(getBackgroundStyle((_a = theme === null || theme === void 0 ? void 0 : theme.content) === null || _a === void 0 ? void 0 : _a.background))), withPrefix("messages-", getMessagesStyle(theme === null || theme === void 0 ? void 0 : theme.messages)), withPrefix("send-", getButtonStyle(theme === null || theme === void 0 ? void 0 : theme.sendButton)), withPrefix("menu-", getButtonStyle(theme === null || theme === void 0 ? void 0 : theme.menuButton)), withPrefix("menu-", getMenuStyle(theme === null || theme === void 0 ? void 0 : theme.menu)), withPrefix("minimize-", getButtonStyle(theme === null || theme === void 0 ? void 0 : theme.minimizeButton)), withPrefix("carousel-", union(withPrefix("title-", getTextStyle((_b = theme === null || theme === void 0 ? void 0 : theme.carousel) === null || _b === void 0 ? void 0 : _b.title)), withPrefix("subtitle-", getTextStyle((_c = theme === null || theme === void 0 ? void 0 : theme.carousel) === null || _c === void 0 ? void 0 : _c.subtitle)), withPrefix("action-", getButtonStyle((_d = theme === null || theme === void 0 ? void 0 : theme.carousel) === null || _d === void 0 ? void 0 : _d.button)))), withPrefix("input-", getInputStyle(theme === null || theme === void 0 ? void 0 : theme.input)), withPrefix("cta-", getCtaStyle(theme === null || theme === void 0 ? void 0 : theme.cta))))), "\n}");
|
|
8207
|
+
return "\n:root {\n".concat(buildVariables(withPrefix("\t--xapp-", union(single("primary-color", theme === null || theme === void 0 ? void 0 : theme.primaryColor), withPrefix("widget-", union(getSize(theme === null || theme === void 0 ? void 0 : theme.size), getMargins(theme === null || theme === void 0 ? void 0 : theme.margin), getBorderStyle(theme === null || theme === void 0 ? void 0 : theme.border))), getChatButtonStyle(theme === null || theme === void 0 ? void 0 : theme.chatButton), withPrefix("header-", getHeaderStyle(theme === null || theme === void 0 ? void 0 : theme.header)), withPrefix("footer-", getFooterStyle(theme === null || theme === void 0 ? void 0 : theme.footer)), withPrefix("content-", union(getBackgroundStyle((_a = theme === null || theme === void 0 ? void 0 : theme.content) === null || _a === void 0 ? void 0 : _a.background))), withPrefix("messages-", getMessagesStyle(theme === null || theme === void 0 ? void 0 : theme.messages)), withPrefix("send-", getButtonStyle(theme === null || theme === void 0 ? void 0 : theme.sendButton)), withPrefix("menu-", getButtonStyle(theme === null || theme === void 0 ? void 0 : theme.menuButton)), withPrefix("menu-", getMenuStyle(theme === null || theme === void 0 ? void 0 : theme.menu)), withPrefix("minimize-", getButtonStyle(theme === null || theme === void 0 ? void 0 : theme.minimizeButton)), withPrefix("cancel-", getButtonStyle(theme === null || theme === void 0 ? void 0 : theme.cancelButton)), withPrefix("carousel-", union(withPrefix("title-", getTextStyle((_b = theme === null || theme === void 0 ? void 0 : theme.carousel) === null || _b === void 0 ? void 0 : _b.title)), withPrefix("subtitle-", getTextStyle((_c = theme === null || theme === void 0 ? void 0 : theme.carousel) === null || _c === void 0 ? void 0 : _c.subtitle)), withPrefix("action-", getButtonStyle((_d = theme === null || theme === void 0 ? void 0 : theme.carousel) === null || _d === void 0 ? void 0 : _d.button)))), withPrefix("input-", getInputStyle(theme === null || theme === void 0 ? void 0 : theme.input)), withPrefix("cta-", getCtaStyle(theme === null || theme === void 0 ? void 0 : theme.cta))))), "\n}");
|
|
8172
8208
|
}
|
|
8173
8209
|
function WidgetStylesheet(props) {
|
|
8174
8210
|
var theme = props.theme;
|
|
@@ -8441,7 +8477,7 @@ var ChatWidgetWrapper = function (props) {
|
|
|
8441
8477
|
React__default$1["default"].createElement(ChatWidget, __assign({}, props)))));
|
|
8442
8478
|
};
|
|
8443
8479
|
var ChatWidget = function (props) {
|
|
8444
|
-
var _a, _b, _c, _d, _e, _f;
|
|
8480
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
8445
8481
|
var innerDispatch = useChatDispatch();
|
|
8446
8482
|
var dispatch = useChatServerDispatch();
|
|
8447
8483
|
// From Redux
|
|
@@ -8450,18 +8486,25 @@ var ChatWidget = function (props) {
|
|
|
8450
8486
|
var dockedMode = mode === "docked";
|
|
8451
8487
|
var staticMode = mode === "static";
|
|
8452
8488
|
var modeClass = "widget-container--".concat(mode);
|
|
8453
|
-
var canMinimize = !dockedMode && !staticMode;
|
|
8489
|
+
var canMinimize = !dockedMode && !staticMode && ((_b = props.config.header) === null || _b === void 0 ? void 0 : _b.actions.minimize);
|
|
8490
|
+
var canCancel = !dockedMode && !staticMode && ((_c = props.config.header) === null || _c === void 0 ? void 0 : _c.actions.cancel);
|
|
8454
8491
|
// Our state - pull from storage
|
|
8455
|
-
var
|
|
8456
|
-
var
|
|
8492
|
+
var _j = React$1.useState(!canMinimize || !!get("visible)") || (((_d = props.config) === null || _d === void 0 ? void 0 : _d.autoOpenOnWidth) && window.matchMedia("(min-width: ".concat((_e = props.config) === null || _e === void 0 ? void 0 : _e.autoOpenOnWidth, ")")).matches)), visible = _j[0], setVisibleState = _j[1];
|
|
8493
|
+
var _k = React$1.useState(false), typing = _k[0], setTypingState = _k[1]; // false initially
|
|
8457
8494
|
var chatServer = React$1.useContext(ChatServerContext);
|
|
8458
|
-
|
|
8495
|
+
var setVisible = React$1.useCallback(function (newVisible) {
|
|
8459
8496
|
if (staticMode) {
|
|
8460
8497
|
return;
|
|
8461
8498
|
}
|
|
8462
8499
|
setVisibleState(newVisible);
|
|
8463
8500
|
set("visible", newVisible);
|
|
8464
|
-
}
|
|
8501
|
+
}, [staticMode]);
|
|
8502
|
+
React$1.useEffect(function () {
|
|
8503
|
+
// For reopen widget after move on same window
|
|
8504
|
+
if (get("opened")) {
|
|
8505
|
+
setVisible(true);
|
|
8506
|
+
}
|
|
8507
|
+
}, [setVisible]);
|
|
8465
8508
|
function handleOnChange() {
|
|
8466
8509
|
if (!typing) {
|
|
8467
8510
|
dispatch(sendTyping(true));
|
|
@@ -8510,6 +8553,10 @@ var ChatWidget = function (props) {
|
|
|
8510
8553
|
function minimizeOnClick() {
|
|
8511
8554
|
setVisible(false);
|
|
8512
8555
|
}
|
|
8556
|
+
function cancelOnClick() {
|
|
8557
|
+
innerDispatch(reset());
|
|
8558
|
+
setVisible(false);
|
|
8559
|
+
}
|
|
8513
8560
|
function chatButtonOnClick() {
|
|
8514
8561
|
setVisible(true);
|
|
8515
8562
|
}
|
|
@@ -8553,17 +8600,17 @@ var ChatWidget = function (props) {
|
|
|
8553
8600
|
onConnectionStatusChange(connectionStatus);
|
|
8554
8601
|
}
|
|
8555
8602
|
}, [connectionStatus, onConnectionStatusChange]);
|
|
8556
|
-
useExternalScript((
|
|
8603
|
+
useExternalScript((_f = props.config) === null || _f === void 0 ? void 0 : _f.middlewareUrl);
|
|
8557
8604
|
return (React__default$1["default"].createElement(React__default$1["default"].Fragment, null,
|
|
8558
8605
|
React__default$1["default"].createElement("div", { className: "widget-container ".concat(modeClass, " ").concat(getVisibilityClass()) },
|
|
8559
8606
|
React__default$1["default"].createElement(WidgetStylesheet, { theme: config === null || config === void 0 ? void 0 : config.theme }),
|
|
8560
|
-
React__default$1["default"].createElement(StatusContainer, { accountStatus: chatState.accountStatus, minimizeOnClick: minimizeOnClick, agent: (
|
|
8607
|
+
React__default$1["default"].createElement(StatusContainer, { accountStatus: chatState.accountStatus, minimizeOnClick: minimizeOnClick, cancelOnClick: cancelOnClick, agent: (_g = chatState.agents["agent:robot"]) === null || _g === void 0 ? void 0 : _g.user, canMinimize: canMinimize, canCancel: canCancel, config: config === null || config === void 0 ? void 0 : config.header }),
|
|
8561
8608
|
React__default$1["default"].createElement(MessageList, { visible: visible, queuePosition: chatState.queuePosition, isChatting: chatState.isChatting, isOffline: isOffline, messages: messages, agents: chatState.agents, lastRatingRequestTimestamp: chatState.lastRatingRequestTimestamp, hasRating: chatState.hasRating, visitorId: chatState.visitorId, messageMiddleware: props.messageMiddleware, onSend: handleSendMessage, onWrite: handleWriteMessage, onOpenUrl: handleOpenUrl }),
|
|
8562
8609
|
React__default$1["default"].createElement("div", { className: "spinner-container ".concat(visible && connectionStatus === "pending" ? "visible" : "") },
|
|
8563
8610
|
React__default$1["default"].createElement("div", { className: "spinner" })),
|
|
8564
8611
|
connectionStatus === "offline" && React__default$1["default"].createElement(ServerOffline, null),
|
|
8565
8612
|
React__default$1["default"].createElement(ChatFooter, { isChatting: chatState.isChatting, onChange: handleOnChange, onSubmit: handleOnSubmit, onFileUpload: handleFileUpload })),
|
|
8566
|
-
React__default$1["default"].createElement(ChatButton, { addClass: getVisibilityClass(), onClick: chatButtonOnClick, config: (
|
|
8613
|
+
React__default$1["default"].createElement(ChatButton, { addClass: getVisibilityClass(), onClick: chatButtonOnClick, config: (_h = props.config) === null || _h === void 0 ? void 0 : _h.cta, visible: visible })));
|
|
8567
8614
|
};
|
|
8568
8615
|
|
|
8569
8616
|
function tryParseJson(str) {
|
|
@@ -8798,7 +8845,7 @@ function createChatStore(config, dataStorage) {
|
|
|
8798
8845
|
if (dataStorage === void 0) { dataStorage = sessionStorage; }
|
|
8799
8846
|
var connection = config.connection;
|
|
8800
8847
|
var storage = new BrowserStateStorage(dataStorage, "xappchat.".concat(connection.serverUrl, ".").concat(connection.accountKey));
|
|
8801
|
-
var defaultState = createDefaultState({ accessToken: config.accessToken, userId: config.userId });
|
|
8848
|
+
var defaultState = createDefaultState({ accessToken: config.accessToken, userId: config.userId, attributes: config.attributes });
|
|
8802
8849
|
var chatReducer = persistStateReducer(storage, defaultState, storeHandler);
|
|
8803
8850
|
var middlewares = [
|
|
8804
8851
|
thunk__default["default"]
|
|
@@ -8808,18 +8855,19 @@ function createChatStore(config, dataStorage) {
|
|
|
8808
8855
|
}
|
|
8809
8856
|
|
|
8810
8857
|
var ChatWidgetContainer = function (props) {
|
|
8811
|
-
var _a, _b, _c;
|
|
8858
|
+
var _a, _b, _c, _d;
|
|
8812
8859
|
var messageMiddleware = useStandardMiddleware();
|
|
8813
8860
|
var connection = useServerConfig(props.config);
|
|
8814
8861
|
var chatStore = React$1.useMemo(function () {
|
|
8815
|
-
var _a, _b;
|
|
8862
|
+
var _a, _b, _c;
|
|
8816
8863
|
return createChatStore({
|
|
8817
8864
|
connection: connection,
|
|
8818
8865
|
userId: (_a = props.config) === null || _a === void 0 ? void 0 : _a.userId,
|
|
8819
|
-
accessToken: (_b = props.config) === null || _b === void 0 ? void 0 : _b.accessToken
|
|
8866
|
+
accessToken: (_b = props.config) === null || _b === void 0 ? void 0 : _b.accessToken,
|
|
8867
|
+
attributes: (_c = props.config) === null || _c === void 0 ? void 0 : _c.attributes,
|
|
8820
8868
|
});
|
|
8821
|
-
}, [connection, (_a = props.config) === null || _a === void 0 ? void 0 : _a.userId, (_b = props.config) === null || _b === void 0 ? void 0 : _b.accessToken]);
|
|
8822
|
-
if ((
|
|
8869
|
+
}, [connection, (_a = props.config) === null || _a === void 0 ? void 0 : _a.userId, (_b = props.config) === null || _b === void 0 ? void 0 : _b.accessToken, (_c = props.config) === null || _c === void 0 ? void 0 : _c.attributes]);
|
|
8870
|
+
if ((_d = props.config) === null || _d === void 0 ? void 0 : _d.disabled) {
|
|
8823
8871
|
return React__default$1["default"].createElement(React__default$1["default"].Fragment, null);
|
|
8824
8872
|
}
|
|
8825
8873
|
var widgetProps = __assign(__assign({}, props), { messageMiddleware: messageMiddleware });
|