@subiz/widget-v4 4.1.210 → 4.1.212
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/README.md +21 -2
- package/assets/img/dot_chat.svg +3 -0
- package/assets/less/chatbox.less +9 -0
- package/assets/less/form.less +10 -0
- package/assets/less/message.less +114 -13
- package/assets/less/widget.less +15 -18
- package/compiled_src/call/css.js +1 -1
- package/compiled_src/chatbox/Buttons.js +7 -4
- package/compiled_src/chatbox/ChatButton.js +127 -29
- package/compiled_src/chatbox/Event.js +37 -5
- package/compiled_src/chatbox/Events.js +348 -129
- package/compiled_src/chatbox/FormAttachment.js +1 -1
- package/compiled_src/chatbox/Header.js +7 -2
- package/compiled_src/chatbox/InfoMessage.js +1 -1
- package/compiled_src/chatbox/MessageInput.js +24 -9
- package/compiled_src/chatbox/OrderAttachments.js +13 -13
- package/compiled_src/chatbox/QuoteMessage.js +3 -2
- package/compiled_src/chatbox/TextMessage.js +22 -18
- package/compiled_src/chatbox/Widget.js +200 -129
- package/compiled_src/chatbox/block.js +39 -29
- package/compiled_src/chatbox/conversation-history.js +44 -0
- package/compiled_src/chatbox/event-layout.js +59 -0
- package/compiled_src/chatbox/greeting.js +32 -0
- package/compiled_src/chatbox/main.js +3 -0
- package/compiled_src/common.js +13 -9
- package/compiled_src/form/css.js +1 -1
- package/compiled_src/lib.js +22 -32
- package/compiled_src/notif/css.js +1 -1
- package/compiled_src/plugin.js +11 -18
- package/compiled_src/popup/css.js +1 -1
- package/compiled_src/popup/popup.js +1 -1
- package/compiled_src/store/api.js +0 -2
- package/compiled_src/store/api_fake.js +1 -1
- package/compiled_src/store/attachments.js +28 -0
- package/compiled_src/store/chain.js +24 -10
- package/compiled_src/store/kv.js +9 -13
- package/compiled_src/store/lsdb.js +1 -1
- package/compiled_src/store/store.js +356 -117
- package/compiled_src/util/common.js +48 -41
- package/compiled_src/util/event.js +15 -0
- package/compiled_src/util/pubsub.js +28 -13
- package/compiled_src/util/url.js +18 -0
- package/dist/127.js +13 -13
- package/dist/132.js +1 -1
- package/dist/1a0f6f3ff1a.127.js +1 -0
- package/dist/{1a0d80f6e72.132.js → 1a0f6f3ff1a.132.js} +1 -1
- package/dist/{1a0d80f6e72.27.js → 1a0f6f3ff1a.27.js} +1 -1
- package/dist/1a0f6f3ff1a.278.js +1 -0
- package/dist/{1a0d80f6e72.339.js → 1a0f6f3ff1a.339.js} +1 -1
- package/dist/1a0f6f3ff1a.459.js +1 -0
- package/dist/1a0f6f3ff1a.app.js +1 -0
- package/dist/{1a0d80f6e72.chat.html → 1a0f6f3ff1a.chat.html} +1 -1
- package/dist/1a0f6f3ff1a.chat.js +1 -0
- package/dist/{1a0d80f6e72.form.html → 1a0f6f3ff1a.form.html} +1 -1
- package/dist/1a0f6f3ff1a.form.js +1 -0
- package/dist/{1a0d80f6e72.index.html → 1a0f6f3ff1a.index.html} +1 -1
- package/dist/{1a0d80f6e72.library.html → 1a0f6f3ff1a.library.html} +1 -1
- package/dist/1a0f6f3ff1a.library.js +1 -0
- package/dist/{1a0d80f6e72.preview.html → 1a0f6f3ff1a.preview.html} +1 -1
- package/dist/1a0f6f3ff1a.preview.js +1 -0
- package/dist/1a0f6f3ff1a.webview.js +1 -0
- package/dist/27.js +2 -2
- package/dist/459.js +2 -2
- package/dist/HASH +1 -1
- package/dist/assets/img/dot_chat.335fd8a.svg +3 -0
- package/dist/screenshoot.js +1523 -619
- package/package.json +12 -5
- package/src/chatbox/Buttons.js +5 -4
- package/src/chatbox/ChatButton.js +133 -39
- package/src/chatbox/Event.js +38 -5
- package/src/chatbox/Events.js +306 -134
- package/src/chatbox/FormAttachment.js +1 -1
- package/src/chatbox/Header.js +5 -4
- package/src/chatbox/InfoMessage.js +1 -1
- package/src/chatbox/MessageInput.js +15 -10
- package/src/chatbox/OrderAttachments.js +13 -13
- package/src/chatbox/QuoteMessage.js +3 -2
- package/src/chatbox/TextMessage.js +21 -20
- package/src/chatbox/Widget.js +150 -150
- package/src/chatbox/block.js +29 -27
- package/src/chatbox/conversation-history.js +37 -0
- package/src/chatbox/event-layout.js +72 -0
- package/src/chatbox/greeting.js +13 -0
- package/src/chatbox/main.js +3 -0
- package/src/common.js +15 -9
- package/src/lib.js +22 -35
- package/src/plugin.js +11 -13
- package/src/popup/popup.js +1 -1
- package/src/store/api.js +0 -2
- package/src/store/api_fake.js +1 -1
- package/src/store/attachments.js +21 -0
- package/src/store/chain.js +25 -12
- package/src/store/kv.js +10 -19
- package/src/store/lsdb.js +1 -1
- package/src/store/store.js +313 -130
- package/src/util/common.js +48 -43
- package/src/util/event.js +7 -0
- package/src/util/pubsub.js +27 -8
- package/src/util/url.js +14 -0
- package/test.cjs +59 -0
- package/assets/less/contact.less +0 -126
- package/compiled_src/util/common.test.js +0 -414
- package/compiled_src/util/event.test.js +0 -38
- package/compiled_src/util/extractor.test.js +0 -299
- package/compiled_src/util/extractor.test2.js +0 -61
- package/compiled_src/util/gate.test.js +0 -18
- package/compiled_src/util/pubsub.test.js +0 -35
- package/dist/1a0d80f6e72.127.js +0 -1
- package/dist/1a0d80f6e72.278.js +0 -1
- package/dist/1a0d80f6e72.459.js +0 -1
- package/dist/1a0d80f6e72.74.js +0 -1
- package/dist/1a0d80f6e72.997.js +0 -1
- package/dist/1a0d80f6e72.app.js +0 -1
- package/dist/1a0d80f6e72.chat.js +0 -1
- package/dist/1a0d80f6e72.form.js +0 -1
- package/dist/1a0d80f6e72.library.js +0 -1
- package/dist/1a0d80f6e72.preview.js +0 -1
- package/dist/1a0d80f6e72.webview.js +0 -1
- package/dist/74.js +0 -376
- package/dist/997.js +0 -37
- package/src/contact/contact.js +0 -400
- package/src/contact/css.js +0 -1
- package/src/util/common.test.js +0 -301
- package/src/util/event.test.js +0 -31
- package/src/util/extractor.test.js +0 -240
- package/src/util/extractor.test2.js +0 -56
- package/src/util/gate.test.js +0 -20
- package/src/util/pubsub.test.js +0 -37
- /package/dist/{1a0d80f6e72.185.js → 1a0f6f3ff1a.185.js} +0 -0
- /package/dist/{1a0d80f6e72.490.js → 1a0f6f3ff1a.490.js} +0 -0
|
@@ -56,10 +56,26 @@ class Event extends _common.Com {
|
|
|
56
56
|
this.state = {
|
|
57
57
|
pongs: _index.default.get(this.props.event, 'ev.data.message.pongs') || []
|
|
58
58
|
};
|
|
59
|
+
const _ev = this.props.event.ev;
|
|
60
|
+
const age = (this.props.store.now ? this.props.store.now() : _index.default.Date.now()) - _ev.created;
|
|
61
|
+
this.animateSend = !props.isHistory && _ev.type === 'message_sent' && _index.default.get(_ev, 'by.type') === 'user' && _ev.id === _index.default.get(_ev, 'source_event_id') && age >= 0 && age < 2000;
|
|
59
62
|
this.textMessageRef = (0, _preact.createRef)();
|
|
60
63
|
this.fileAttachmentRef = (0, _preact.createRef)();
|
|
61
64
|
this.imageAttachmentRef = (0, _preact.createRef)();
|
|
62
65
|
}
|
|
66
|
+
componentDidMount() {
|
|
67
|
+
if (!this.animateSend) return;
|
|
68
|
+
this.sendAnimationFrame = window.requestAnimationFrame(() => {
|
|
69
|
+
this.sendAnimationFrame = window.requestAnimationFrame(() => {
|
|
70
|
+
if (this._isMounted) this.setState({
|
|
71
|
+
sendEntered: true
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
componentWillUnmount() {
|
|
77
|
+
if (this.sendAnimationFrame) window.cancelAnimationFrame(this.sendAnimationFrame);
|
|
78
|
+
}
|
|
63
79
|
render() {
|
|
64
80
|
var ev = _index.default.get(this.props.event, 'ev', {});
|
|
65
81
|
switch (ev.type) {
|
|
@@ -104,6 +120,7 @@ class Event extends _common.Com {
|
|
|
104
120
|
return !!_index.default.find(pongs, pong => pong.type === 'dislike');
|
|
105
121
|
}
|
|
106
122
|
chooseQuickReply(reply) {
|
|
123
|
+
if (this.props.isHistory) return;
|
|
107
124
|
let ev = _index.default.get(this.props.event, 'ev', {});
|
|
108
125
|
let message = {
|
|
109
126
|
text: reply.title,
|
|
@@ -121,6 +138,7 @@ class Event extends _common.Com {
|
|
|
121
138
|
this.props.onSend(message);
|
|
122
139
|
}
|
|
123
140
|
choosePostbackBtn(button) {
|
|
141
|
+
if (this.props.isHistory) return;
|
|
124
142
|
let ev = _index.default.get(this.props.event, 'ev', {});
|
|
125
143
|
let message = {
|
|
126
144
|
text: button.title,
|
|
@@ -261,6 +279,17 @@ class Event extends _common.Com {
|
|
|
261
279
|
}
|
|
262
280
|
renderMessageSent() {
|
|
263
281
|
let ev = this.props.event.ev;
|
|
282
|
+
if (_index.default.get(ev, 'data.message.deleted')) {
|
|
283
|
+
let byType = _index.default.get(ev, 'by.type') === 'user' ? 'user' : 'agent';
|
|
284
|
+
return (0, _preact.h)("div", {
|
|
285
|
+
class: 'convo-event ' + byType + '-message',
|
|
286
|
+
"data-ev-id": ev.id
|
|
287
|
+
}, (0, _preact.h)(_TextMessage.default, {
|
|
288
|
+
ev: ev,
|
|
289
|
+
t: this.props.t,
|
|
290
|
+
store: this.props.store
|
|
291
|
+
}));
|
|
292
|
+
}
|
|
264
293
|
let attachments = _index.default.get(ev, 'data.message.attachments');
|
|
265
294
|
let hasForm = _index.default.find(attachments, att => att.type === 'form');
|
|
266
295
|
if (_index.default.isEmptyMessage(_index.default.get(ev, 'data.message'))) return null;
|
|
@@ -331,13 +360,13 @@ class Event extends _common.Com {
|
|
|
331
360
|
t: this.props.t,
|
|
332
361
|
store: this.props.store,
|
|
333
362
|
ev: ev
|
|
334
|
-
}), (0, _preact.h)(_QuickReplies.default, {
|
|
363
|
+
}), !this.props.isHistory && (0, _preact.h)(_QuickReplies.default, {
|
|
335
364
|
store: this.props.store,
|
|
336
365
|
ev: ev,
|
|
337
366
|
onSelect: e => this.chooseQuickReply(e)
|
|
338
367
|
}), this.renderReactions(), this.renderAIDevNote())));
|
|
339
368
|
}
|
|
340
|
-
if (_index.default.get(ev, '
|
|
369
|
+
if (_index.default.get(ev, 'source_event_id') === ev.id && this.props.store.now() - ev.created < 900) {
|
|
341
370
|
_index.default.setTimeout(() => this.setState({
|
|
342
371
|
refresh: this.state.refresh
|
|
343
372
|
}), 1000);
|
|
@@ -345,7 +374,7 @@ class Event extends _common.Com {
|
|
|
345
374
|
let $dot = (0, _preact.h)("div", {
|
|
346
375
|
class: "sending_dot"
|
|
347
376
|
});
|
|
348
|
-
if (this.props.store.now() - ev.created < 900 || _index.default.get(ev, '
|
|
377
|
+
if (this.props.store.now() - ev.created < 900 || _index.default.get(ev, 'source_event_id') !== ev.id) {
|
|
349
378
|
$dot = (0, _preact.h)("div", {
|
|
350
379
|
class: "sending_dot sending_dot__hide"
|
|
351
380
|
});
|
|
@@ -373,10 +402,11 @@ class Event extends _common.Com {
|
|
|
373
402
|
class: "convo-event user-message",
|
|
374
403
|
"data-ev-id": ev.id
|
|
375
404
|
}, $sender, (0, _preact.h)("div", {
|
|
376
|
-
class:
|
|
405
|
+
class: 'message-user__container' + (this.animateSend && !this.props.isHistory ? ' message-user__container--send' + (this.state.sendEntered ? '' : ' message-user__container--enter') : '')
|
|
377
406
|
}, $dot, (0, _preact.h)(_TextMessage.default, {
|
|
378
407
|
ref: this.textMessageRef,
|
|
379
408
|
store: this.props.store,
|
|
409
|
+
t: this.props.t,
|
|
380
410
|
ev: ev,
|
|
381
411
|
refresh: this.state.refresh,
|
|
382
412
|
onLink: this.props.onLink
|
|
@@ -412,6 +442,7 @@ class Event extends _common.Com {
|
|
|
412
442
|
})), $error);
|
|
413
443
|
}
|
|
414
444
|
async onSendReaction(action) {
|
|
445
|
+
if (this.props.isHistory) return;
|
|
415
446
|
if (this._reacting) return;
|
|
416
447
|
let ev = this.props.event.ev;
|
|
417
448
|
let cid = _index.default.get(ev, 'data.message.conversation_id');
|
|
@@ -463,6 +494,7 @@ class Event extends _common.Com {
|
|
|
463
494
|
this._reacting = false;
|
|
464
495
|
}
|
|
465
496
|
renderReactions() {
|
|
497
|
+
if (this.props.isHistory) return null;
|
|
466
498
|
if (this.props.store.isAIDevMode()) return null;
|
|
467
499
|
let cid = _index.default.get(this.props.event.ev, 'data.message.conversation_id', '');
|
|
468
500
|
if (cid.startsWith('cslight')) return null;
|
|
@@ -550,7 +582,7 @@ class Event extends _common.Com {
|
|
|
550
582
|
let byid = _index.default.get(ev, 'by.display_id', _index.default.get(ev, 'by.id')) || '';
|
|
551
583
|
if (bytype === 'user') return _index.default.getUserDisplayName(this.props.store.matchUser());
|
|
552
584
|
let acc = this.props.store.matchAccount();
|
|
553
|
-
if (bytype === 'agent') return _index.default.getAgentDisplayName(acc, this.props.store.matchAgent(byid));
|
|
585
|
+
if (bytype === 'agent' || _index.default.get(ev, 'by.display_type') === 'agent') return _index.default.getAgentDisplayName(acc, this.props.store.matchAgent(byid));
|
|
554
586
|
if (byid.startsWith('at')) return _index.default.getAgentDisplayName(acc, this.props.store.matchAgent(byid));
|
|
555
587
|
if (bytype === 'bot') {
|
|
556
588
|
let bot = this.props.store.matchBot()[byid];
|