@subiz/widget-v4 4.0.85 → 4.0.88
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/.prettierrc.js +1 -1
- package/compiled_src/chatbox/AgentsAvatar.js +20 -3
- package/compiled_src/chatbox/ChatButton.js +11 -8
- package/compiled_src/chatbox/Event.js +12 -0
- package/compiled_src/chatbox/Events.js +1 -0
- package/compiled_src/chatbox/MessageInput.js +6 -0
- package/compiled_src/chatbox/Widget.js +41 -37
- package/compiled_src/chatbox/main.js +10 -0
- package/compiled_src/popup/popup.js +14 -2
- package/compiled_src/store/store.js +24 -40
- package/compiled_src/util/common.js +10 -10
- package/dist/132.js +105 -48
- package/dist/182ee177a49.132.js +1 -0
- package/dist/{181a9b734bb.178.js → 182ee177a49.178.js} +0 -0
- package/dist/{181a9b734bb.213.js → 182ee177a49.213.js} +1 -1
- package/dist/{181a9b734bb.335.js → 182ee177a49.335.js} +0 -0
- package/dist/{181a9b734bb.362.js → 182ee177a49.362.js} +1 -1
- package/dist/182ee177a49.441.js +1 -0
- package/dist/{181a9b734bb.605.js → 182ee177a49.605.js} +0 -0
- package/dist/{181a9b734bb.678.js → 182ee177a49.678.js} +0 -0
- package/dist/{181a9b734bb.782.js → 182ee177a49.782.js} +1 -1
- package/dist/182ee177a49.app.js +1 -0
- package/dist/{181a9b734bb.index.html → 182ee177a49.index.html} +2 -2
- package/dist/{181a9b734bb.library.html → 182ee177a49.library.html} +2 -2
- package/dist/182ee177a49.library.js +1 -0
- package/dist/{181a9b734bb.preview.html → 182ee177a49.preview.html} +1 -1
- package/dist/182ee177a49.preview.js +1 -0
- package/dist/182ee177a49.screenshoot.js +1 -0
- package/dist/213.js +18 -1
- package/dist/362.js +1 -1
- package/dist/441.js +14 -1
- package/dist/782.js +1 -1
- package/dist/HASH +1 -1
- package/dist/screenshoot.html +1 -1
- package/dist/screenshoot.js +36 -56
- package/index.html +1 -1
- package/package.json +11 -11
- package/src/chatbox/AgentsAvatar.js +32 -10
- package/src/chatbox/ChatButton.js +11 -4
- package/src/chatbox/Event.js +23 -4
- package/src/chatbox/Events.js +3 -1
- package/src/chatbox/MessageInput.js +14 -5
- package/src/chatbox/Widget.js +10 -9
- package/src/chatbox/main.js +8 -1
- package/src/popup/popup.js +14 -1
- package/src/store/store.js +24 -36
- package/src/util/common.js +16 -19
- package/dist/181a9b734bb.132.js +0 -1
- package/dist/181a9b734bb.441.js +0 -1
- package/dist/181a9b734bb.app.js +0 -1
- package/dist/181a9b734bb.library.js +0 -1
- package/dist/181a9b734bb.preview.js +0 -1
- package/dist/181a9b734bb.screenshoot.js +0 -1
package/dist/132.js
CHANGED
|
@@ -225,6 +225,13 @@ class ChatButton extends common/* Com */.up {
|
|
|
225
225
|
position = util/* default.get */.Z.get(accountSetting, 'mobile_button.position') || position;
|
|
226
226
|
}
|
|
227
227
|
|
|
228
|
+
if (accountSetting && accountSetting.hide_agent_profile) {
|
|
229
|
+
agent = Object.assign({}, account, {
|
|
230
|
+
avatar_url: account.logo_url || __webpack_require__(9895),
|
|
231
|
+
fullname: account.name || this.props.t('agent')
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
|
|
228
235
|
let cls = 'widget-preview widget-preview--' + position;
|
|
229
236
|
if (!this.state.displayPreview) cls += ' widget-preview--hidden';
|
|
230
237
|
var tags = this.renderMessagePreview(this.state.previewEvent, this.props.t('sent_you_a_message'));
|
|
@@ -258,21 +265,17 @@ class ChatButton extends common/* Com */.up {
|
|
|
258
265
|
}
|
|
259
266
|
|
|
260
267
|
onProfileReady() {
|
|
261
|
-
if (this.
|
|
268
|
+
if (this._buttonLoaded) this.setState({
|
|
262
269
|
opacity: 1
|
|
263
270
|
});
|
|
264
|
-
this.
|
|
265
|
-
profileLoaded: true
|
|
266
|
-
});
|
|
271
|
+
this._profileLoaded = true;
|
|
267
272
|
}
|
|
268
273
|
|
|
269
274
|
onButtonReady() {
|
|
270
|
-
if (this.
|
|
275
|
+
if (this._profileLoaded) this.setState({
|
|
271
276
|
opacity: 1
|
|
272
277
|
});
|
|
273
|
-
this.
|
|
274
|
-
buttonLoaded: true
|
|
275
|
-
});
|
|
278
|
+
this._buttonLoaded = true;
|
|
276
279
|
}
|
|
277
280
|
|
|
278
281
|
renderButton() {
|
|
@@ -462,6 +465,26 @@ class AgentsAvatar extends common/* Com */.up {
|
|
|
462
465
|
|
|
463
466
|
render() {
|
|
464
467
|
let accountSetting = this.props.plugin.chatbox;
|
|
468
|
+
let acc = this.props.store.matchAccount();
|
|
469
|
+
var tooltippos = this.props.tooltipPos || 'bottom';
|
|
470
|
+
var mode = this.props.mode || 'primary';
|
|
471
|
+
|
|
472
|
+
if (accountSetting && accountSetting.hide_agent_profile) {
|
|
473
|
+
return (0,preact_module.h)("div", {
|
|
474
|
+
class: `group-avatar group-avatar--${mode}`
|
|
475
|
+
}, (0,preact_module.h)("div", {
|
|
476
|
+
class: "d-inline-block pos-relative",
|
|
477
|
+
"data-tooltip": acc.name,
|
|
478
|
+
"data-tooltip-position": tooltippos
|
|
479
|
+
}, (0,preact_module.h)("img", {
|
|
480
|
+
width: 35,
|
|
481
|
+
height: 35,
|
|
482
|
+
alt: "agent avatar left",
|
|
483
|
+
class: "avatar group-avatar--agent-left",
|
|
484
|
+
src: this.props.store.replaceFileUrl(acc.logo_url) || __webpack_require__(9895)
|
|
485
|
+
})));
|
|
486
|
+
}
|
|
487
|
+
|
|
465
488
|
let agentM = this.props.store.matchAgent('*');
|
|
466
489
|
var agents = util/* default.map */.Z.map(this.props.agent_ids, id => agentM[id]);
|
|
467
490
|
|
|
@@ -477,9 +500,6 @@ class AgentsAvatar extends common/* Com */.up {
|
|
|
477
500
|
}
|
|
478
501
|
|
|
479
502
|
agents = util/* default.filter */.Z.filter(agents, ag => !!ag);
|
|
480
|
-
let acc = this.props.store.matchAccount();
|
|
481
|
-
var tooltippos = this.props.tooltipPos || 'bottom';
|
|
482
|
-
var mode = this.props.mode || 'primary';
|
|
483
503
|
|
|
484
504
|
if (agents.length === 0) {
|
|
485
505
|
return (0,preact_module.h)("div", {
|
|
@@ -840,6 +860,12 @@ class MessageInput extends common/* Com */.up {
|
|
|
840
860
|
}, 5);
|
|
841
861
|
}
|
|
842
862
|
|
|
863
|
+
blur() {
|
|
864
|
+
const $input = this.refMessageInput.current;
|
|
865
|
+
if (!$input) return;
|
|
866
|
+
$input.blur();
|
|
867
|
+
}
|
|
868
|
+
|
|
843
869
|
render() {
|
|
844
870
|
var buttons = (0,preact_module.h)("div", {
|
|
845
871
|
class: "d-flex flex-row align-self-end"
|
|
@@ -2730,6 +2756,18 @@ class Event extends common/* Com */.up {
|
|
|
2730
2756
|
|
|
2731
2757
|
var uri = acc.logo_url || __webpack_require__(9895);
|
|
2732
2758
|
|
|
2759
|
+
if (true) {
|
|
2760
|
+
return (0,preact_module.h)("div", {
|
|
2761
|
+
class: "message-sender"
|
|
2762
|
+
}, (0,preact_module.h)("img", {
|
|
2763
|
+
alt: "sender",
|
|
2764
|
+
class: "message-sender-avatar",
|
|
2765
|
+
src: this.props.store.replaceFileUrl(uri)
|
|
2766
|
+
}), (0,preact_module.h)("p", {
|
|
2767
|
+
class: "message-sender-name"
|
|
2768
|
+
}, acc.name));
|
|
2769
|
+
}
|
|
2770
|
+
|
|
2733
2771
|
let agentM = this.props.store.matchAgent('*');
|
|
2734
2772
|
|
|
2735
2773
|
if (byid !== 'system' || bytype !== 'dummy') {
|
|
@@ -3026,6 +3064,7 @@ class Events extends common/* Com */.up {
|
|
|
3026
3064
|
}));
|
|
3027
3065
|
processEvents(convo, events);
|
|
3028
3066
|
let $events = util/* default.map */.Z.map(events, ev => (0,preact_module.h)(Event, {
|
|
3067
|
+
chatbox: this.props.chatbox,
|
|
3029
3068
|
onLink: this.props.onLink,
|
|
3030
3069
|
store: this.props.store,
|
|
3031
3070
|
onFormSubmit: this.props.onFormSubmit,
|
|
@@ -5626,6 +5665,40 @@ class Widget extends common/* Com */.up {
|
|
|
5626
5665
|
constructor(props) {
|
|
5627
5666
|
super(props);
|
|
5628
5667
|
|
|
5668
|
+
Widget_defineProperty(this, "msgInput", (0,preact_module/* createRef */.Vf)());
|
|
5669
|
+
|
|
5670
|
+
Widget_defineProperty(this, "sendMessage", async message => {
|
|
5671
|
+
let text = message.text;
|
|
5672
|
+
|
|
5673
|
+
if (!this.props.cid) {
|
|
5674
|
+
this.creating = true;
|
|
5675
|
+
const {
|
|
5676
|
+
convo,
|
|
5677
|
+
error
|
|
5678
|
+
} = await this.props.store.startConvo({
|
|
5679
|
+
locale: this.props.t.locale(),
|
|
5680
|
+
message: text,
|
|
5681
|
+
initial_by: this.props.store.matchUser().id
|
|
5682
|
+
});
|
|
5683
|
+
|
|
5684
|
+
if (error) {}
|
|
5685
|
+
|
|
5686
|
+
this.creating = false;
|
|
5687
|
+
this.props.store.sendConvoEvent(convo.id, 'message_sent', {
|
|
5688
|
+
message
|
|
5689
|
+
});
|
|
5690
|
+
this.props.onGo({
|
|
5691
|
+
view: 'chat',
|
|
5692
|
+
cid: convo.id
|
|
5693
|
+
});
|
|
5694
|
+
return;
|
|
5695
|
+
}
|
|
5696
|
+
|
|
5697
|
+
this.props.store.sendConvoEvent(this.props.cid, 'message_sent', {
|
|
5698
|
+
message
|
|
5699
|
+
});
|
|
5700
|
+
});
|
|
5701
|
+
|
|
5629
5702
|
Widget_defineProperty(this, "onLink", (e, url) => {
|
|
5630
5703
|
if (!url) return e.preventDefault();
|
|
5631
5704
|
let noschemeurl = url.replace(/(^\w+:|^)\/\//, '');
|
|
@@ -5758,17 +5831,23 @@ class Widget extends common/* Com */.up {
|
|
|
5758
5831
|
if (hasError) return this.forceUpdate();
|
|
5759
5832
|
let data = util/* default.cloneDeep */.Z.cloneDeep(this.state.formData);
|
|
5760
5833
|
let user = util/* default.cloneDeep */.Z.cloneDeep(this.props.store.matchUser());
|
|
5834
|
+
let is_lead = false;
|
|
5761
5835
|
util/* default.map */.Z.map(data, (field, key) => {
|
|
5762
5836
|
if (!key.startsWith('attr:')) return;
|
|
5763
5837
|
var attr = {
|
|
5764
5838
|
key: key.substr(5)
|
|
5765
5839
|
};
|
|
5840
|
+
is_lead = is_lead || key == 'emails' || key == 'phones';
|
|
5766
5841
|
if (field.type === 'number') attr.number = parseInt(field.value);
|
|
5767
5842
|
if (field.type === 'datetime') attr.datetime = new util/* default.Date */.Z.Date(field.value).toISOString();
|
|
5768
5843
|
if (field.type === 'list') attr.list = field.value;
|
|
5769
5844
|
if (field.type === 'text' || field.type === 'boolean') attr[field.type] = field.value;
|
|
5770
5845
|
util/* default.setUserAttr */.Z.setUserAttr(user, attr);
|
|
5771
5846
|
});
|
|
5847
|
+
if (is_lead) util/* default.setUserAttr */.Z.setUserAttr(user, {
|
|
5848
|
+
key: 'lead_source',
|
|
5849
|
+
text: 'widget'
|
|
5850
|
+
});
|
|
5772
5851
|
let firstmsg = util/* default.get */.Z.get(data, 'question.value');
|
|
5773
5852
|
let groupid = util/* default.get */.Z.get(data, 'group.value', '');
|
|
5774
5853
|
|
|
@@ -6112,7 +6191,7 @@ class Widget extends common/* Com */.up {
|
|
|
6112
6191
|
|
|
6113
6192
|
blur() {
|
|
6114
6193
|
if (this.props.store.isPreview) return;
|
|
6115
|
-
var $input = this.msgInput;
|
|
6194
|
+
var $input = this.msgInput.current;
|
|
6116
6195
|
if (!$input) return;
|
|
6117
6196
|
setTimeout(() => $input && $input.blur());
|
|
6118
6197
|
setTimeout(() => $input && $input.blur(), 300);
|
|
@@ -6136,7 +6215,7 @@ class Widget extends common/* Com */.up {
|
|
|
6136
6215
|
return;
|
|
6137
6216
|
}
|
|
6138
6217
|
|
|
6139
|
-
var $input = this.msgInput;
|
|
6218
|
+
var $input = this.msgInput.current;
|
|
6140
6219
|
if (!$input) return;
|
|
6141
6220
|
setTimeout(() => $input.focus());
|
|
6142
6221
|
setTimeout(() => $input.focus(), 300);
|
|
@@ -6152,38 +6231,6 @@ class Widget extends common/* Com */.up {
|
|
|
6152
6231
|
this.focusInput();
|
|
6153
6232
|
}
|
|
6154
6233
|
|
|
6155
|
-
async sendMessage(message) {
|
|
6156
|
-
let text = message.text;
|
|
6157
|
-
|
|
6158
|
-
if (!this.props.cid) {
|
|
6159
|
-
this.creating = true;
|
|
6160
|
-
const {
|
|
6161
|
-
convo,
|
|
6162
|
-
error
|
|
6163
|
-
} = await this.props.store.startConvo({
|
|
6164
|
-
locale: this.props.t.locale(),
|
|
6165
|
-
message: text,
|
|
6166
|
-
initial_by: this.props.store.matchUser().id
|
|
6167
|
-
});
|
|
6168
|
-
|
|
6169
|
-
if (error) {}
|
|
6170
|
-
|
|
6171
|
-
this.creating = false;
|
|
6172
|
-
this.props.store.sendConvoEvent(convo.id, 'message_sent', {
|
|
6173
|
-
message
|
|
6174
|
-
});
|
|
6175
|
-
this.props.onGo({
|
|
6176
|
-
view: 'chat',
|
|
6177
|
-
cid: convo.id
|
|
6178
|
-
});
|
|
6179
|
-
return;
|
|
6180
|
-
}
|
|
6181
|
-
|
|
6182
|
-
this.props.store.sendConvoEvent(this.props.cid, 'message_sent', {
|
|
6183
|
-
message
|
|
6184
|
-
});
|
|
6185
|
-
}
|
|
6186
|
-
|
|
6187
6234
|
createPostback(postback) {
|
|
6188
6235
|
this.props.store.createPostback(this.props.cid, postback);
|
|
6189
6236
|
}
|
|
@@ -6191,9 +6238,9 @@ class Widget extends common/* Com */.up {
|
|
|
6191
6238
|
renderChat() {
|
|
6192
6239
|
let $input = (0,preact_module.h)(MessageInput, {
|
|
6193
6240
|
store: this.props.store,
|
|
6194
|
-
ref:
|
|
6241
|
+
ref: this.msgInput,
|
|
6195
6242
|
cid: this.props.cid,
|
|
6196
|
-
onSend:
|
|
6243
|
+
onSend: this.sendMessage,
|
|
6197
6244
|
t: this.props.t
|
|
6198
6245
|
});
|
|
6199
6246
|
let convo = this.props.store.matchConvo(this.props.cid) || {};
|
|
@@ -6216,6 +6263,7 @@ class Widget extends common/* Com */.up {
|
|
|
6216
6263
|
isShow: this.props.isShow,
|
|
6217
6264
|
onLink: this.onLink,
|
|
6218
6265
|
store: this.props.store,
|
|
6266
|
+
chatbox: this.props.plugin.chatbox || {},
|
|
6219
6267
|
onFormSubmit: e => this.onEventFormSubmit(e),
|
|
6220
6268
|
ref: ref => this.events = ref,
|
|
6221
6269
|
cid: this.props.cid,
|
|
@@ -6284,6 +6332,7 @@ class Widget extends common/* Com */.up {
|
|
|
6284
6332
|
}
|
|
6285
6333
|
|
|
6286
6334
|
renderConvoSummary(convo) {
|
|
6335
|
+
let accountSetting = this.props.plugin.chatbox || {};
|
|
6287
6336
|
let agentM = this.props.store.matchAgent('*');
|
|
6288
6337
|
let ags = util/* default.filter */.Z.filter(convo.members, m => {
|
|
6289
6338
|
return (m.type === 'agent' || m.type === 'bot') && m.membership === 'active';
|
|
@@ -6295,7 +6344,7 @@ class Widget extends common/* Com */.up {
|
|
|
6295
6344
|
fullname: 'Offline Agent'
|
|
6296
6345
|
});
|
|
6297
6346
|
var name = util/* default.each */.Z.each(agents, ag => ag.fullname).join(', ');
|
|
6298
|
-
if (!name) name = this.props.store.matchAccount().name;
|
|
6347
|
+
if (accountSetting.hide_agent_profile || !name) name = this.props.store.matchAccount().name;
|
|
6299
6348
|
if (!name) name = this.props.t('agent');
|
|
6300
6349
|
var $you = null;
|
|
6301
6350
|
|
|
@@ -6637,6 +6686,14 @@ class Main extends common/* Com */.up {
|
|
|
6637
6686
|
}
|
|
6638
6687
|
|
|
6639
6688
|
p = p || {};
|
|
6689
|
+
|
|
6690
|
+
if (!p.view && !p.cid) {
|
|
6691
|
+
let convoM = this.props.store.matchConvo('*');
|
|
6692
|
+
let redconvo = util/* default.find */.Z.find(convoM, convo => !util/* default.isConvoSeen */.Z.isConvoSeen(convo, this.props.store.matchUser().id));
|
|
6693
|
+
p.cid = util/* default.get */.Z.get(redconvo, 'id', util/* default.get */.Z.get(convoM, '0.id'));
|
|
6694
|
+
p.view = 'chat';
|
|
6695
|
+
}
|
|
6696
|
+
|
|
6640
6697
|
if (this.props.store.isMobile()) modifyViewport();
|
|
6641
6698
|
this.setState({
|
|
6642
6699
|
widgetConvoId: p.cid,
|