@subiz/widget-v4 4.1.122 → 4.1.123
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/assets/less/form.less +1 -1
- package/assets/less/message.less +7 -0
- package/assets/less/widget_header.less +5 -3
- package/compiled_src/chatbox/Event.js +15 -11
- package/compiled_src/chatbox/TextMessage.js +6 -2
- package/compiled_src/chatbox/Widget.js +4 -6
- package/compiled_src/store/api.js +5 -1
- package/compiled_src/store/store.js +2 -3
- package/dist/1964db39388.278.js +1 -0
- package/dist/1964db39388.app.js +1 -0
- package/dist/{19643345ab6.index.html → 1964db39388.index.html} +1 -1
- package/dist/{19643345ab6.library.html → 1964db39388.library.html} +1 -1
- package/dist/1964db39388.library.js +1 -0
- package/dist/{19643345ab6.preview.html → 1964db39388.preview.html} +1 -1
- package/dist/1964db39388.preview.js +1 -0
- package/dist/1964db39388.webview.js +1 -0
- package/dist/278.js +1 -1
- package/dist/HASH +1 -1
- package/dist/screenshoot.js +98 -83
- package/package.json +1 -1
- package/src/chatbox/Event.js +5 -3
- package/src/chatbox/TextMessage.js +6 -2
- package/src/chatbox/Widget.js +3 -4
- package/src/store/api.js +5 -1
- package/src/store/store.js +5 -4
- package/dist/19643345ab6.278.js +0 -1
- package/dist/19643345ab6.app.js +0 -1
- package/dist/19643345ab6.library.js +0 -1
- package/dist/19643345ab6.preview.js +0 -1
- package/dist/19643345ab6.webview.js +0 -1
- /package/dist/{19643345ab6.127.js → 1964db39388.127.js} +0 -0
- /package/dist/{19643345ab6.132.js → 1964db39388.132.js} +0 -0
- /package/dist/{19643345ab6.185.js → 1964db39388.185.js} +0 -0
- /package/dist/{19643345ab6.27.js → 1964db39388.27.js} +0 -0
- /package/dist/{19643345ab6.459.js → 1964db39388.459.js} +0 -0
- /package/dist/{19643345ab6.490.js → 1964db39388.490.js} +0 -0
- /package/dist/{19643345ab6.74.js → 1964db39388.74.js} +0 -0
- /package/dist/{19643345ab6.997.js → 1964db39388.997.js} +0 -0
package/dist/screenshoot.js
CHANGED
|
@@ -863,7 +863,7 @@ function Conn(apiUrl, credential, onDead, onEvents, callAPI, accid) {
|
|
|
863
863
|
// the polling loop starts after the first subscribe call finished successfully
|
|
864
864
|
var polling = function (backoff) {
|
|
865
865
|
if (dead) return
|
|
866
|
-
callAPI('get', apiUrl + 'poll?token=' + lastToken + '&account-id=' + accid, undefined, function (body, code) {
|
|
866
|
+
callAPI('get', apiUrl + 'poll?version=2&token=' + lastToken + '&account-id=' + accid, undefined, function (body, code) {
|
|
867
867
|
if (dead) return
|
|
868
868
|
if (retryable(code)) return setTimeout(polling, calcNextBackoff(backoff), backoff + 1)
|
|
869
869
|
if (code !== 200) {
|
|
@@ -899,7 +899,7 @@ function Conn(apiUrl, credential, onDead, onEvents, callAPI, accid) {
|
|
|
899
899
|
else if (credential.user_mask) query += '&user-mask=' + encodeURIComponent(credential.user_mask)
|
|
900
900
|
else if (access_token) query += '&access-token=' + access_token
|
|
901
901
|
|
|
902
|
-
let fullurl = apiUrl + 'subs' + query + '&account-id=' + encodeURIComponent(accid || credential.account_id)
|
|
902
|
+
let fullurl = apiUrl + 'subs' + query + '&version=2&account-id=' + encodeURIComponent(accid || credential.account_id)
|
|
903
903
|
callAPI('post', fullurl, JSON.stringify({events: events}), function (body, code) {
|
|
904
904
|
if (dead) {
|
|
905
905
|
out = repeat('dead', events.length)
|
|
@@ -3064,7 +3064,7 @@ function replaceCssVariablePlugin(css, setting) {
|
|
|
3064
3064
|
green: 238
|
|
3065
3065
|
};
|
|
3066
3066
|
let hue = rgbToHsl(parseColor.red, parseColor.green, parseColor.blue)[0];
|
|
3067
|
-
let [r, g, b] = hslToRgb(hue, 0.
|
|
3067
|
+
let [r, g, b] = hslToRgb(hue, 0.25, 0.95);
|
|
3068
3068
|
DEFVAL.primary_color_faded = `rgb(${r},${g},${b})`;
|
|
3069
3069
|
var ret = [];
|
|
3070
3070
|
for (var i = 0; i < tokens.length; i++) {
|
|
@@ -3115,7 +3115,7 @@ function replaceCssVariable(css, setting) {
|
|
|
3115
3115
|
green: 238
|
|
3116
3116
|
};
|
|
3117
3117
|
let hue = rgbToHsl(parseColor.red, parseColor.green, parseColor.blue)[0];
|
|
3118
|
-
let [r, g, b] = hslToRgb(hue, 0.
|
|
3118
|
+
let [r, g, b] = hslToRgb(hue, 0.25, 0.95);
|
|
3119
3119
|
DEFVAL.primary_color_faded = `rgb(${r},${g},${b})`;
|
|
3120
3120
|
var ret = [];
|
|
3121
3121
|
for (var i = 0; i < tokens.length; i++) {
|
|
@@ -4161,7 +4161,11 @@ function jsonifyTextPlain(param, done) {
|
|
|
4161
4161
|
let outuser;
|
|
4162
4162
|
for (let i = 0; true; i++) {
|
|
4163
4163
|
outuser = await ajax.setBaseUrl(this.ApiURL).withCredentials(true).addQuery('v', '6').addQuery('x-user-ref', this.ref).setParser('json').get(`/accounts/${this.accid}/users/${this.ref}`);
|
|
4164
|
-
if (
|
|
4164
|
+
if (util/* default */.A.get(outuser, 'body.error.code', '').indexOf('locked_account') != -1) break;
|
|
4165
|
+
if (util/* default */.A.get(outuser, 'body.error.code', '').indexOf('user_is_banned') != -1) {
|
|
4166
|
+
await util/* default */.A.sleep(120000);
|
|
4167
|
+
continue;
|
|
4168
|
+
}
|
|
4165
4169
|
if (!util/* default */.A.get(outuser, 'body.id')) {
|
|
4166
4170
|
let sleeptime = Math.min(2000 + i * 400, 60000);
|
|
4167
4171
|
await util/* default */.A.sleep(sleeptime);
|
|
@@ -5190,7 +5194,7 @@ class Store {
|
|
|
5190
5194
|
}, 1000);
|
|
5191
5195
|
}
|
|
5192
5196
|
async reconnectWs(accid, userid) {
|
|
5193
|
-
await this.realtime.subscribe([`conversation_state_updated.account.${accid}.user.${userid}`, `conversation_joined.account.${accid}.user.${userid}`, `conversation_typing.account.${accid}.user.${userid}`, `message_sent.account.${accid}.user.${userid}`, `
|
|
5197
|
+
await this.realtime.subscribe([`conversation_state_updated.account.${accid}.user.${userid}`, `conversation_joined.account.${accid}.user.${userid}`, `conversation_typing.account.${accid}.user.${userid}`, `message_sent.account.${accid}.user.${userid}`, `message_pong.account.${accid}.user.${userid}`, `conversation_rating_requested.account.${accid}.user.${userid}`, `conversation_rated.account.${accid}.user.${userid}`]);
|
|
5194
5198
|
await this.readyGate.entry();
|
|
5195
5199
|
this.disconnect('account');
|
|
5196
5200
|
return this.reconnect();
|
|
@@ -5327,9 +5331,10 @@ class Store {
|
|
|
5327
5331
|
if (!ev || !ev.type) return;
|
|
5328
5332
|
ev.created = util/* default */.A.getMs(ev.created);
|
|
5329
5333
|
if (ev.type === 'user_info_updated') {
|
|
5330
|
-
|
|
5331
|
-
let
|
|
5332
|
-
|
|
5334
|
+
return;
|
|
5335
|
+
let user = sb.cloneDeep(this.cache.match('user'));
|
|
5336
|
+
let attrs = sb.get(ev, 'data.user.attributes') || [];
|
|
5337
|
+
sb.map(attrs, attr => sb.setUserAttr(user, attr));
|
|
5333
5338
|
this._setUser(user);
|
|
5334
5339
|
return;
|
|
5335
5340
|
}
|
|
@@ -5351,8 +5356,6 @@ class Store {
|
|
|
5351
5356
|
}
|
|
5352
5357
|
}
|
|
5353
5358
|
if (!convo) return;
|
|
5354
|
-
let channel = util/* default */.A.get(ev, 'touchpoint.channel', '');
|
|
5355
|
-
if (channel && channel != 'subiz') return;
|
|
5356
5359
|
this.pubsub.publish('events', ev);
|
|
5357
5360
|
if (ev.type === 'conversation_joined') {
|
|
5358
5361
|
let members = util/* default */.A.get(ev, 'data.conversation.members', []);
|
|
@@ -6334,7 +6337,7 @@ function AgentsAvatar(props) {
|
|
|
6334
6337
|
}
|
|
6335
6338
|
let agentM = props.store.matchAgent('*');
|
|
6336
6339
|
var agents = util/* default */.A.map(props.agent_ids, id => agentM[id]);
|
|
6337
|
-
if (props.agent_ids
|
|
6340
|
+
if (props.agent_ids !== undefined && util/* default */.A.size(props.agent_ids) == 0) {
|
|
6338
6341
|
var agids = util/* default */.A.get(accountSetting, 'header.agent_ids', []);
|
|
6339
6342
|
agids = util/* default */.A.filter(agids, id => !!agentM[id]);
|
|
6340
6343
|
if (agids.length !== 0) {
|
|
@@ -6344,7 +6347,7 @@ function AgentsAvatar(props) {
|
|
|
6344
6347
|
}
|
|
6345
6348
|
}
|
|
6346
6349
|
agents = util/* default */.A.filter(agents, ag => !!ag);
|
|
6347
|
-
if (
|
|
6350
|
+
if (util/* default */.A.size(agents) === 0) {
|
|
6348
6351
|
return (0,preact_module.h)("div", {
|
|
6349
6352
|
class: `group-avatar group-avatar--${mode}`
|
|
6350
6353
|
}, (0,preact_module.h)("div", {
|
|
@@ -6486,12 +6489,6 @@ class Header extends common/* Com */.Mw {
|
|
|
6486
6489
|
class: cls,
|
|
6487
6490
|
style: style
|
|
6488
6491
|
}, $back, (0,preact_module.h)("div", {
|
|
6489
|
-
class: "mr-2"
|
|
6490
|
-
}), (0,preact_module.h)(AgentsAvatar, {
|
|
6491
|
-
plugin: this.props.plugin,
|
|
6492
|
-
store: this.props.store,
|
|
6493
|
-
mode: "secondary"
|
|
6494
|
-
}), (0,preact_module.h)("div", {
|
|
6495
6492
|
class: "widget-header--title-container"
|
|
6496
6493
|
}, (0,preact_module.h)("div", {
|
|
6497
6494
|
class: "widget-header--title"
|
|
@@ -6583,7 +6580,8 @@ Vui lòng hỏi chúng tôi bất cứ điều gì hoặc chia sẻ phản hồi
|
|
|
6583
6580
|
}, (0,preact_module.h)(AgentsAvatar, {
|
|
6584
6581
|
plugin: this.props.plugin,
|
|
6585
6582
|
store: this.props.store,
|
|
6586
|
-
mode: "primary"
|
|
6583
|
+
mode: "primary",
|
|
6584
|
+
agent_ids: []
|
|
6587
6585
|
})), (0,preact_module.h)("div", {
|
|
6588
6586
|
class: "widget-header--title-container"
|
|
6589
6587
|
}, (0,preact_module.h)("div", {
|
|
@@ -8071,8 +8069,10 @@ class TextMessage extends common/* Com */.Mw {
|
|
|
8071
8069
|
class: "message-agent message-text--agent",
|
|
8072
8070
|
title: t
|
|
8073
8071
|
}, tags, this.renderTime());
|
|
8072
|
+
let msgcls = 'message-user message-text--user';
|
|
8073
|
+
if (this.props.ev._error) msgcls += ' message-user--error';
|
|
8074
8074
|
return (0,preact_module.h)("div", {
|
|
8075
|
-
class:
|
|
8075
|
+
class: msgcls,
|
|
8076
8076
|
title: t
|
|
8077
8077
|
}, tags);
|
|
8078
8078
|
}
|
|
@@ -8090,8 +8090,10 @@ class TextMessage extends common/* Com */.Mw {
|
|
|
8090
8090
|
onLink: this.props.onLink
|
|
8091
8091
|
}), this.renderTime());
|
|
8092
8092
|
}
|
|
8093
|
+
let msgcls = 'message-user message-text--user';
|
|
8094
|
+
if (this.props.ev._error) msgcls += ' message-user--error';
|
|
8093
8095
|
return (0,preact_module.h)("div", {
|
|
8094
|
-
class:
|
|
8096
|
+
class: msgcls,
|
|
8095
8097
|
title: t
|
|
8096
8098
|
}, (0,preact_module.h)(chatbox_block/* default */.A, {
|
|
8097
8099
|
block: block,
|
|
@@ -8140,6 +8142,9 @@ class InfoMessage extends common/* Com */.Mw {
|
|
|
8140
8142
|
}
|
|
8141
8143
|
}
|
|
8142
8144
|
;// ./src/chatbox/Event.js
|
|
8145
|
+
function Event_defineProperty(e, r, t) { return (r = Event_toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
8146
|
+
function Event_toPropertyKey(t) { var i = Event_toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
8147
|
+
function Event_toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
8143
8148
|
|
|
8144
8149
|
|
|
8145
8150
|
|
|
@@ -8161,6 +8166,13 @@ const LoadOrderAttachments = () => __webpack_require__.e(/* import() */ 127).the
|
|
|
8161
8166
|
class Event extends common/* Com */.Mw {
|
|
8162
8167
|
constructor(props) {
|
|
8163
8168
|
super(props);
|
|
8169
|
+
Event_defineProperty(this, "resendMessage", () => {
|
|
8170
|
+
let cid = util/* default */.A.convoOfEv(this.props.event.ev);
|
|
8171
|
+
const message = util/* default */.A.get(this.props.event, 'ev.data.message');
|
|
8172
|
+
this.props.store.sendConvoEvent(cid, 'message_sent', {
|
|
8173
|
+
message
|
|
8174
|
+
});
|
|
8175
|
+
});
|
|
8164
8176
|
this.props.store.onConvoEvent(this, ev => this.onEvent(ev));
|
|
8165
8177
|
this.refForm = (0,preact_module/* createRef */._3)();
|
|
8166
8178
|
this.state = {
|
|
@@ -8451,18 +8463,19 @@ class Event extends common/* Com */.Mw {
|
|
|
8451
8463
|
class: "pt-3"
|
|
8452
8464
|
});
|
|
8453
8465
|
let $error = null;
|
|
8466
|
+
if (ev._error) $dot = null;
|
|
8454
8467
|
if (ev._error && ev.type === 'message_sent') {
|
|
8455
8468
|
let msg = this.props.t('error_send_message');
|
|
8456
8469
|
if (ev._error_message) msg = this.props.t(ev._error_message);
|
|
8457
8470
|
$error = (0,preact_module.h)("a", {
|
|
8458
8471
|
class: "message_error",
|
|
8459
8472
|
src: "javascript:;",
|
|
8460
|
-
onClick:
|
|
8473
|
+
onClick: this.resendMessage
|
|
8461
8474
|
}, (0,preact_module.h)("div", {
|
|
8462
|
-
class: "message_error__text"
|
|
8463
|
-
}, msg), (0,preact_module.h)("div", {
|
|
8464
8475
|
class: "message_error__icon"
|
|
8465
|
-
}))
|
|
8476
|
+
}), "\xA0", (0,preact_module.h)("div", {
|
|
8477
|
+
class: "message_error__text"
|
|
8478
|
+
}, msg));
|
|
8466
8479
|
}
|
|
8467
8480
|
return (0,preact_module.h)("div", {
|
|
8468
8481
|
class: "convo-event user-message"
|
|
@@ -8613,13 +8626,6 @@ class Event extends common/* Com */.Mw {
|
|
|
8613
8626
|
state
|
|
8614
8627
|
}));
|
|
8615
8628
|
}
|
|
8616
|
-
resendMessage() {
|
|
8617
|
-
let cid = util/* default */.A.convoOfEv(this.props.event.ev);
|
|
8618
|
-
const message = util/* default */.A.get(this.props.event, 'ev.data.message');
|
|
8619
|
-
this.props.store.sendConvoEvent(cid, 'message_sent', {
|
|
8620
|
-
message
|
|
8621
|
-
});
|
|
8622
|
-
}
|
|
8623
8629
|
getSenderName(ev) {
|
|
8624
8630
|
let bytype = util/* default */.A.get(ev, 'by.type');
|
|
8625
8631
|
let byid = util/* default */.A.get(ev, 'by.display_id', util/* default */.A.get(ev, 'by.id'));
|
|
@@ -8931,7 +8937,7 @@ function processEvents(convo, events) {
|
|
|
8931
8937
|
}
|
|
8932
8938
|
if (visibleEvent(curEvent.ev)) {
|
|
8933
8939
|
let elapsedSec = util/* default */.A.unixSec(curEvent.ev.created) - util/* default */.A.unixSec(lastEvent.ev.created);
|
|
8934
|
-
if (elapsedSec >
|
|
8940
|
+
if (elapsedSec > 300) curEvent.show_time = true;
|
|
8935
8941
|
}
|
|
8936
8942
|
}
|
|
8937
8943
|
if (lastAgentEvent) lastAgentEvent.show_time = true;
|
|
@@ -8956,7 +8962,10 @@ function processEvents(convo, events) {
|
|
|
8956
8962
|
}
|
|
8957
8963
|
function visibleEvent(ev) {
|
|
8958
8964
|
let type = util/* default */.A.get(ev, 'type');
|
|
8959
|
-
|
|
8965
|
+
if (type === 'message_sent') return true;
|
|
8966
|
+
if (type === 'conversation_state_updated') {
|
|
8967
|
+
return util/* default */.A.get(ev, 'data.conversation.state') == 'ended';
|
|
8968
|
+
}
|
|
8960
8969
|
}
|
|
8961
8970
|
function Events_isSummited(form) {
|
|
8962
8971
|
let fields = util/* default */.A.get(form, 'fields') || [];
|
|
@@ -9467,26 +9476,25 @@ class Widget extends common/* Com */.Mw {
|
|
|
9467
9476
|
class: cls
|
|
9468
9477
|
}, $header, $body);
|
|
9469
9478
|
}
|
|
9470
|
-
|
|
9471
|
-
|
|
9472
|
-
|
|
9473
|
-
|
|
9479
|
+
validateForm(formData) {
|
|
9480
|
+
let newformdata = {};
|
|
9481
|
+
util/* default */.A.map(formData, (field, key) => {
|
|
9482
|
+
field = Object.assign({}, field);
|
|
9483
|
+
field.is_empty_error = false;
|
|
9474
9484
|
if (field.is_required && (field.value === undefined || field.value === '' || util/* default */.A.size(field.value) === 0 && Array.isArray(field.value))) {
|
|
9485
|
+
field.is_empty_error = true;
|
|
9475
9486
|
field.error = this.props.t('error_empty');
|
|
9476
|
-
hasError = true;
|
|
9477
9487
|
} else field.error = '';
|
|
9478
9488
|
if (key.substr(5) === 'emails') {
|
|
9479
9489
|
if (field.is_required) {
|
|
9480
9490
|
if (!util/* default */.A.isEmail(field.value)) {
|
|
9481
9491
|
field.error = this.props.t('error_email_invalid');
|
|
9482
|
-
hasError = true;
|
|
9483
9492
|
}
|
|
9484
9493
|
} else {
|
|
9485
9494
|
let value = field.value || '';
|
|
9486
9495
|
if (typeof value !== 'string') value = value + '';
|
|
9487
9496
|
if (value.trim() && !util/* default */.A.isEmail(field.value)) {
|
|
9488
9497
|
field.error = this.props.t('error_email_invalid');
|
|
9489
|
-
hasError = true;
|
|
9490
9498
|
}
|
|
9491
9499
|
}
|
|
9492
9500
|
}
|
|
@@ -9494,19 +9502,30 @@ class Widget extends common/* Com */.Mw {
|
|
|
9494
9502
|
if (field.is_required) {
|
|
9495
9503
|
if (!util/* default */.A.isPhone(field.value)) {
|
|
9496
9504
|
field.error = this.props.t('error_phone_invalid');
|
|
9497
|
-
hasError = true;
|
|
9498
9505
|
}
|
|
9499
9506
|
} else {
|
|
9500
9507
|
let value = field.value || '';
|
|
9501
9508
|
if (typeof value !== 'string') value = value + '';
|
|
9502
9509
|
if (value.trim() && !util/* default */.A.isPhone(field.value)) {
|
|
9503
9510
|
field.error = this.props.t('error_phone_invalid');
|
|
9504
|
-
hasError = true;
|
|
9505
9511
|
}
|
|
9506
9512
|
}
|
|
9507
9513
|
}
|
|
9514
|
+
newformdata[key] = field;
|
|
9508
9515
|
});
|
|
9509
|
-
|
|
9516
|
+
return newformdata;
|
|
9517
|
+
}
|
|
9518
|
+
async submitPrechatForm(form, formName) {
|
|
9519
|
+
if (this.state.submiting) return;
|
|
9520
|
+
let newData = this.validateForm(this.state.formData);
|
|
9521
|
+
let hasError = util/* default */.A.find(newData, field => !!field.error);
|
|
9522
|
+
if (hasError) {
|
|
9523
|
+
this.setState({
|
|
9524
|
+
formData: newData
|
|
9525
|
+
});
|
|
9526
|
+
this.focusInput();
|
|
9527
|
+
return;
|
|
9528
|
+
}
|
|
9510
9529
|
let data = util/* default */.A.cloneDeep(this.state.formData);
|
|
9511
9530
|
let user = util/* default */.A.cloneDeep(this.props.store.matchUser());
|
|
9512
9531
|
let is_lead = false;
|
|
@@ -9630,6 +9649,7 @@ class Widget extends common/* Com */.Mw {
|
|
|
9630
9649
|
let field = util/* default */.A.find(formData, (_, fkkey) => fkkey === key);
|
|
9631
9650
|
if (!field) return;
|
|
9632
9651
|
field.value = val;
|
|
9652
|
+
field.error = undefined;
|
|
9633
9653
|
this.setState({
|
|
9634
9654
|
formData
|
|
9635
9655
|
});
|
|
@@ -9756,7 +9776,7 @@ class Widget extends common/* Com */.Mw {
|
|
|
9756
9776
|
if (field.type === 'text') {
|
|
9757
9777
|
if (key == 'question' || util/* default */.A.get(field, 'def.multiple_line')) {
|
|
9758
9778
|
$field = (0,preact_module.h)("textarea", {
|
|
9759
|
-
class:
|
|
9779
|
+
class: `form-control ${errclass}`,
|
|
9760
9780
|
ref: ref => {
|
|
9761
9781
|
this['form_' + Widget_encode(key)] = ref;
|
|
9762
9782
|
},
|
|
@@ -9764,8 +9784,7 @@ class Widget extends common/* Com */.Mw {
|
|
|
9764
9784
|
value: field.value || '',
|
|
9765
9785
|
onInput: e => this.onInputChange(key, e.target.value),
|
|
9766
9786
|
onChange: e => this.onInputChange(key, e.target.value),
|
|
9767
|
-
row: "4"
|
|
9768
|
-
class: "form-control"
|
|
9787
|
+
row: "4"
|
|
9769
9788
|
});
|
|
9770
9789
|
} else if (util/* default */.A.get(field, 'def.select') === 'checkbox') {
|
|
9771
9790
|
$field = this.renderCheckboxField(field);
|
|
@@ -9866,10 +9885,10 @@ class Widget extends common/* Com */.Mw {
|
|
|
9866
9885
|
class: "label",
|
|
9867
9886
|
for: 'form_' + Widget_encode(key)
|
|
9868
9887
|
}, label, field.is_required ? (0,preact_module.h)("span", {
|
|
9869
|
-
class: "
|
|
9870
|
-
}, "*") : ''), field.error ? (0,preact_module.h)("div", {
|
|
9888
|
+
class: "red"
|
|
9889
|
+
}, "*") : ''), $field, field.error ? (0,preact_module.h)("div", {
|
|
9871
9890
|
class: "form-control--valid-input--error"
|
|
9872
|
-
}, field.error) : ''
|
|
9891
|
+
}, field.error) : '');
|
|
9873
9892
|
});
|
|
9874
9893
|
return (0,preact_module.h)("div", {
|
|
9875
9894
|
class: "pt-2"
|
|
@@ -9879,6 +9898,10 @@ class Widget extends common/* Com */.Mw {
|
|
|
9879
9898
|
let title = this.props.t.i18n(util/* default */.A.get(form, `i18n_title`, {}));
|
|
9880
9899
|
if (!title) title = util/* default */.A.get(form, 'title', this.props.t('capture_lead_title'));
|
|
9881
9900
|
title = title.replace('↵', '');
|
|
9901
|
+
let btncls = 'btn--start-convo ';
|
|
9902
|
+
let hasError = util/* default */.A.find(this.state.formData, field => !!field.error);
|
|
9903
|
+
let newData = this.validateForm(this.state.formData);
|
|
9904
|
+
let hasEmptyError = util/* default */.A.find(newData, field => !!field.is_empty_error);
|
|
9882
9905
|
return (0,preact_module.h)("div", {
|
|
9883
9906
|
class: "widget-body"
|
|
9884
9907
|
}, (0,preact_module.h)(FormMounter, {
|
|
@@ -9886,22 +9909,15 @@ class Widget extends common/* Com */.Mw {
|
|
|
9886
9909
|
form: form,
|
|
9887
9910
|
onMount: this.formMounted
|
|
9888
9911
|
}), (0,preact_module.h)("div", {
|
|
9889
|
-
class: "widget-body--content flex-grow-1 pl-3 pr-3 d-flex flex-column"
|
|
9890
|
-
}, (0,preact_module.h)("div", {
|
|
9891
|
-
class: "flex-grow-1"
|
|
9912
|
+
class: "widget-body--content flex-grow-1 pl-3 pr-3 pb-2 d-flex flex-column"
|
|
9892
9913
|
}, (0,preact_module.h)("div", {
|
|
9893
|
-
class: "
|
|
9894
|
-
}, (0,preact_module.h)("div", null, title), this.renderFields(form, formName))
|
|
9895
|
-
|
|
9896
|
-
}), (0,preact_module.h)(
|
|
9897
|
-
|
|
9898
|
-
t: this.props.t
|
|
9899
|
-
})), (0,preact_module.h)("div", {
|
|
9900
|
-
class: "message-input message-input--preform"
|
|
9901
|
-
}, (0,preact_module.h)("button", {
|
|
9902
|
-
class: "btn--start-convo",
|
|
9914
|
+
class: "mt-2 d-flex flex-column"
|
|
9915
|
+
}, (0,preact_module.h)("div", null, title), this.renderFields(form, formName)), (0,preact_module.h)("div", {
|
|
9916
|
+
style: "min-height: 15px !important; flex: 1 !important; flex-shrink: 0 !important"
|
|
9917
|
+
}), (0,preact_module.h)("button", {
|
|
9918
|
+
class: btncls,
|
|
9903
9919
|
onClick: _ => this.submitPrechatForm(form, formName),
|
|
9904
|
-
disabled: this.state.creating
|
|
9920
|
+
disabled: !!hasEmptyError || !!hasError || this.state.creating
|
|
9905
9921
|
}, submitLabel)));
|
|
9906
9922
|
}
|
|
9907
9923
|
goToConvo(cid) {
|
|
@@ -9928,10 +9944,10 @@ class Widget extends common/* Com */.Mw {
|
|
|
9928
9944
|
}, (0,preact_module.h)(AgentsAvatar, {
|
|
9929
9945
|
plugin: this.props.plugin,
|
|
9930
9946
|
store: this.props.store,
|
|
9931
|
-
mode: "
|
|
9947
|
+
mode: "secondary",
|
|
9932
9948
|
class: "d-flex flex-row",
|
|
9933
9949
|
tooltipPos: "right",
|
|
9934
|
-
agent_ids: agentids
|
|
9950
|
+
agent_ids: [agentids[0]]
|
|
9935
9951
|
}), this.renderConvoSummary(convo));
|
|
9936
9952
|
});
|
|
9937
9953
|
let $body = (0,preact_module.h)("div", {
|
|
@@ -9957,7 +9973,9 @@ class Widget extends common/* Com */.Mw {
|
|
|
9957
9973
|
class: "convo-list--title"
|
|
9958
9974
|
}, this.props.t('conversations')), $body), (0,preact_module.h)("div", {
|
|
9959
9975
|
class: "convo-list--footer"
|
|
9960
|
-
}, (0,preact_module.h)(
|
|
9976
|
+
}, (0,preact_module.h)(PoweredBy, {
|
|
9977
|
+
store: this.props.store
|
|
9978
|
+
}), (0,preact_module.h)("button", {
|
|
9961
9979
|
class: "btn--start-convo",
|
|
9962
9980
|
onClick: _ => this.goToConvo('')
|
|
9963
9981
|
}, (0,preact_module.h)("span", null, this.props.t('start_conversation')), (0,preact_module.h)("img", {
|
|
@@ -9967,8 +9985,6 @@ class Widget extends common/* Com */.Mw {
|
|
|
9967
9985
|
height: "26"
|
|
9968
9986
|
})), (0,preact_module.h)("div", {
|
|
9969
9987
|
class: "mt-2"
|
|
9970
|
-
}), (0,preact_module.h)(PoweredBy, {
|
|
9971
|
-
store: this.props.store
|
|
9972
9988
|
})));
|
|
9973
9989
|
}
|
|
9974
9990
|
blur() {
|
|
@@ -9981,17 +9997,21 @@ class Widget extends common/* Com */.Mw {
|
|
|
9981
9997
|
focusInput(text) {
|
|
9982
9998
|
if (this.props.store.isPreview) return;
|
|
9983
9999
|
if (this.shouldShowForm()) {
|
|
9984
|
-
let
|
|
10000
|
+
let focusfieldkey = '';
|
|
9985
10001
|
util/* default */.A.map(this.state.formData, (field, key) => {
|
|
9986
|
-
if (field.type !== 'text') return;
|
|
9987
|
-
if (
|
|
9988
|
-
if (!field.value) firstemptykey = key;
|
|
10002
|
+
if (focusfieldkey || field.type !== 'text') return;
|
|
10003
|
+
if (!field.value || field.error) focusfieldkey = key;
|
|
9989
10004
|
});
|
|
10005
|
+
var $input = this['form_' + Widget_encode(focusfieldkey)];
|
|
10006
|
+
if ($input) $input.focus();
|
|
9990
10007
|
util/* default */.A.setTimeout(() => {
|
|
9991
|
-
|
|
9992
|
-
|
|
9993
|
-
|
|
9994
|
-
|
|
10008
|
+
util/* default */.A.map(this.state.formData, (field, key) => {
|
|
10009
|
+
if (focusfieldkey || field.type !== 'text') return;
|
|
10010
|
+
if (!field.value || field.error) focusfieldkey = key;
|
|
10011
|
+
});
|
|
10012
|
+
var $input = this['form_' + Widget_encode(focusfieldkey)];
|
|
10013
|
+
if ($input) $input.focus();
|
|
10014
|
+
}, 200);
|
|
9995
10015
|
return;
|
|
9996
10016
|
}
|
|
9997
10017
|
var $input = this.msgInput.current;
|
|
@@ -10823,11 +10843,6 @@ function lib_toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e
|
|
|
10823
10843
|
|
|
10824
10844
|
|
|
10825
10845
|
|
|
10826
|
-
var $link = document.createElement('link');
|
|
10827
|
-
$link.href = 'https://fonts.googleapis.com/css2?family=Inter:wght@400;500&display=swap';
|
|
10828
|
-
$link.rel = 'stylesheet';
|
|
10829
|
-
document.head.append($link);
|
|
10830
|
-
util/* default */.A.preloadWebfonts(['Inter'], [400, 500]);
|
|
10831
10846
|
class lib_Widget {
|
|
10832
10847
|
constructor(ApiURL, FileURL, RealtimeURL, inmem, fake) {
|
|
10833
10848
|
lib_defineProperty(this, "version", () => '4.5');
|
package/package.json
CHANGED
package/src/chatbox/Event.js
CHANGED
|
@@ -302,13 +302,15 @@ export default class Event extends Com {
|
|
|
302
302
|
if (this.props.event.mode === 'lead') $sender = <div class='pt-3'></div>
|
|
303
303
|
|
|
304
304
|
let $error = null
|
|
305
|
+
if (ev._error) $dot = null
|
|
305
306
|
if (ev._error && ev.type === 'message_sent') {
|
|
306
307
|
let msg = this.props.t('error_send_message')
|
|
307
308
|
if (ev._error_message) msg = this.props.t(ev._error_message)
|
|
308
309
|
$error = (
|
|
309
|
-
<a class='message_error' src='javascript:;' onClick={
|
|
310
|
-
<div class='message_error__text'>{msg}</div>
|
|
310
|
+
<a class='message_error' src='javascript:;' onClick={this.resendMessage}>
|
|
311
311
|
<div class='message_error__icon' />
|
|
312
|
+
|
|
313
|
+
<div class='message_error__text'>{msg}</div>
|
|
312
314
|
</a>
|
|
313
315
|
)
|
|
314
316
|
}
|
|
@@ -436,7 +438,7 @@ export default class Event extends Com {
|
|
|
436
438
|
return <div class='message-system'>{this.props.t('conversation_state_updated', {state})}</div>
|
|
437
439
|
}
|
|
438
440
|
|
|
439
|
-
resendMessage() {
|
|
441
|
+
resendMessage = () => {
|
|
440
442
|
let cid = sb.convoOfEv(this.props.event.ev)
|
|
441
443
|
const message = sb.get(this.props.event, 'ev.data.message')
|
|
442
444
|
this.props.store.sendConvoEvent(cid, 'message_sent', {message})
|
|
@@ -63,8 +63,10 @@ export default class TextMessage extends Com {
|
|
|
63
63
|
{this.renderTime()}
|
|
64
64
|
</div>
|
|
65
65
|
)
|
|
66
|
+
let msgcls = 'message-user message-text--user'
|
|
67
|
+
if (this.props.ev._error) msgcls += ' message-user--error'
|
|
66
68
|
return (
|
|
67
|
-
<div class=
|
|
69
|
+
<div class={msgcls} title={t}>
|
|
68
70
|
{tags}
|
|
69
71
|
</div>
|
|
70
72
|
)
|
|
@@ -83,8 +85,10 @@ export default class TextMessage extends Com {
|
|
|
83
85
|
</div>
|
|
84
86
|
)
|
|
85
87
|
}
|
|
88
|
+
let msgcls = 'message-user message-text--user'
|
|
89
|
+
if (this.props.ev._error) msgcls += ' message-user--error'
|
|
86
90
|
return (
|
|
87
|
-
<div class=
|
|
91
|
+
<div class={msgcls} title={t}>
|
|
88
92
|
<Block block={block} onLink={this.props.onLink} />
|
|
89
93
|
</div>
|
|
90
94
|
)
|
package/src/chatbox/Widget.js
CHANGED
|
@@ -609,7 +609,7 @@ export default class Widget extends Com {
|
|
|
609
609
|
<div key={'form_' + encode(key)}>
|
|
610
610
|
<label class='label' for={'form_' + encode(key)}>
|
|
611
611
|
{label}
|
|
612
|
-
{field.is_required ? <span class='
|
|
612
|
+
{field.is_required ? <span class='red'>*</span> : ''}
|
|
613
613
|
</label>
|
|
614
614
|
{$field}
|
|
615
615
|
{field.error ? <div class='form-control--valid-input--error'>{field.error}</div> : ''}
|
|
@@ -631,8 +631,8 @@ export default class Widget extends Com {
|
|
|
631
631
|
return (
|
|
632
632
|
<div class='widget-body'>
|
|
633
633
|
<FormMounter key={form._updated} form={form} onMount={this.formMounted} />
|
|
634
|
-
<div class='widget-body--content flex-grow-1 pl-3 pr-3 d-flex flex-column'>
|
|
635
|
-
<div class='mt-
|
|
634
|
+
<div class='widget-body--content flex-grow-1 pl-3 pr-3 pb-2 d-flex flex-column'>
|
|
635
|
+
<div class='mt-2 d-flex flex-column'>
|
|
636
636
|
<div>{title}</div>
|
|
637
637
|
{this.renderFields(form, formName)}
|
|
638
638
|
</div>
|
|
@@ -645,7 +645,6 @@ export default class Widget extends Com {
|
|
|
645
645
|
{submitLabel}
|
|
646
646
|
</button>
|
|
647
647
|
</div>
|
|
648
|
-
<div class='mt-2'></div>
|
|
649
648
|
</div>
|
|
650
649
|
)
|
|
651
650
|
}
|
package/src/store/api.js
CHANGED
|
@@ -63,7 +63,11 @@ export default class {
|
|
|
63
63
|
.addQuery('x-user-ref', this.ref)
|
|
64
64
|
.setParser('json')
|
|
65
65
|
.get(`/accounts/${this.accid}/users/${this.ref}`)
|
|
66
|
-
if (
|
|
66
|
+
if (sb.get(outuser, 'body.error.code', '').indexOf('locked_account') != -1) break
|
|
67
|
+
if (sb.get(outuser, 'body.error.code', '').indexOf('user_is_banned') != -1) {
|
|
68
|
+
await sb.sleep(120000) // sleep 2 min, incase of unblock
|
|
69
|
+
continue
|
|
70
|
+
}
|
|
67
71
|
|
|
68
72
|
if (!sb.get(outuser, 'body.id')) {
|
|
69
73
|
let sleeptime = Math.min(2000 + i * 400, 60000)
|
package/src/store/store.js
CHANGED
|
@@ -592,8 +592,8 @@ export default class Store {
|
|
|
592
592
|
`conversation_joined.account.${accid}.user.${userid}`,
|
|
593
593
|
`conversation_typing.account.${accid}.user.${userid}`,
|
|
594
594
|
`message_sent.account.${accid}.user.${userid}`,
|
|
595
|
-
`conversation_pending.account.${accid}.user.${userid}`,
|
|
596
|
-
`user_info_updated.account.${accid}.user.${userid}`,
|
|
595
|
+
// `conversation_pending.account.${accid}.user.${userid}`,
|
|
596
|
+
// `user_info_updated.account.${accid}.user.${userid}`,
|
|
597
597
|
`message_pong.account.${accid}.user.${userid}`,
|
|
598
598
|
`conversation_rating_requested.account.${accid}.user.${userid}`,
|
|
599
599
|
`conversation_rated.account.${accid}.user.${userid}`,
|
|
@@ -781,6 +781,7 @@ export default class Store {
|
|
|
781
781
|
if (!ev || !ev.type) return
|
|
782
782
|
ev.created = sb.getMs(ev.created)
|
|
783
783
|
if (ev.type === 'user_info_updated') {
|
|
784
|
+
return
|
|
784
785
|
let user = sb.cloneDeep(this.cache.match('user'))
|
|
785
786
|
let attrs = sb.get(ev, 'data.user.attributes') || []
|
|
786
787
|
sb.map(attrs, (attr) => sb.setUserAttr(user, attr))
|
|
@@ -808,8 +809,8 @@ export default class Store {
|
|
|
808
809
|
if (!convo) return
|
|
809
810
|
|
|
810
811
|
// ignore wrong channel
|
|
811
|
-
let channel = sb.get(ev, 'touchpoint.channel', '')
|
|
812
|
-
if (channel && channel != 'subiz') return
|
|
812
|
+
// let channel = sb.get(ev, 'touchpoint.channel', '')
|
|
813
|
+
// if (channel && channel != 'subiz') return
|
|
813
814
|
|
|
814
815
|
this.pubsub.publish('events', ev)
|
|
815
816
|
|