@subiz/widget-v4 4.1.117 → 4.1.120
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/base.less +1 -0
- package/assets/less/chatbox.less +2 -0
- package/assets/less/message.less +42 -22
- package/assets/less/message_input.less +2 -0
- package/assets/less/order.less +1 -1
- package/assets/less/widget.less +36 -18
- package/assets/less/widget_header.less +35 -36
- package/compiled_src/chatbox/AgentsAvatar.js +1 -1
- package/compiled_src/chatbox/Event.js +87 -13
- package/compiled_src/chatbox/Events.js +106 -19
- package/compiled_src/chatbox/Header.js +5 -4
- package/compiled_src/chatbox/InfoMessage.js +2 -13
- package/compiled_src/chatbox/MessageInput.js +19 -9
- package/compiled_src/chatbox/TextMessage.js +11 -2
- package/compiled_src/chatbox/Widget.js +28 -23
- package/compiled_src/chatbox/time.js +1 -0
- package/compiled_src/util/common.js +89 -0
- package/dist/185.js +19 -19
- package/dist/19641cfa41e.278.js +1 -0
- package/dist/19641cfa41e.app.js +1 -0
- package/dist/{195ec5442e3.index.html → 19641cfa41e.index.html} +1 -1
- package/dist/{195ec5442e3.library.html → 19641cfa41e.library.html} +1 -1
- package/dist/19641cfa41e.library.js +1 -0
- package/dist/{195ec5442e3.preview.html → 19641cfa41e.preview.html} +1 -1
- package/dist/19641cfa41e.preview.js +1 -0
- package/dist/19641cfa41e.webview.js +1 -0
- package/dist/278.js +1 -1
- package/dist/HASH +1 -1
- package/dist/screenshoot.js +562 -185
- package/package.json +2 -2
- package/src/chatbox/AgentsAvatar.js +1 -1
- package/src/chatbox/Event.js +88 -14
- package/src/chatbox/Events.js +93 -15
- package/src/chatbox/Header.js +3 -2
- package/src/chatbox/InfoMessage.js +0 -14
- package/src/chatbox/MessageInput.js +18 -7
- package/src/chatbox/TextMessage.js +13 -0
- package/src/chatbox/Widget.js +16 -18
- package/src/chatbox/time.js +12 -8
- package/src/util/common.js +121 -0
- package/up +33 -21
- package/compiled_src/chatbox/Typing.js +0 -77
- package/dist/195ec5442e3.278.js +0 -1
- package/dist/195ec5442e3.app.js +0 -1
- package/dist/195ec5442e3.library.js +0 -1
- package/dist/195ec5442e3.preview.js +0 -1
- package/dist/195ec5442e3.webview.js +0 -1
- package/src/chatbox/Typing.js +0 -72
- /package/dist/{195ec5442e3.127.js → 19641cfa41e.127.js} +0 -0
- /package/dist/{195ec5442e3.132.js → 19641cfa41e.132.js} +0 -0
- /package/dist/{195ec5442e3.185.js → 19641cfa41e.185.js} +0 -0
- /package/dist/{195ec5442e3.27.js → 19641cfa41e.27.js} +0 -0
- /package/dist/{195ec5442e3.459.js → 19641cfa41e.459.js} +0 -0
- /package/dist/{195ec5442e3.490.js → 19641cfa41e.490.js} +0 -0
- /package/dist/{195ec5442e3.74.js → 19641cfa41e.74.js} +0 -0
- /package/dist/{195ec5442e3.997.js → 19641cfa41e.997.js} +0 -0
|
@@ -37,9 +37,12 @@ class Event extends _common.Com {
|
|
|
37
37
|
render() {
|
|
38
38
|
var ev = _index.default.get(this.props.event, 'ev', {});
|
|
39
39
|
switch (ev.type) {
|
|
40
|
+
case 'conversation_typing':
|
|
41
|
+
return this.renderTyping();
|
|
40
42
|
case 'conversation_joined':
|
|
41
43
|
break;
|
|
42
44
|
case 'message_sent':
|
|
45
|
+
if (this.props.event.is_typing) return this.renderTyping();
|
|
43
46
|
return this.renderMessageSent();
|
|
44
47
|
case 'conversation_state_updated':
|
|
45
48
|
case 'conversation_rating_requested':
|
|
@@ -151,19 +154,88 @@ class Event extends _common.Com {
|
|
|
151
154
|
OrderAttachments = (await LoadOrderAttachments()).default;
|
|
152
155
|
});
|
|
153
156
|
}
|
|
157
|
+
renderTyping() {
|
|
158
|
+
if (!this.props.event.is_show) {
|
|
159
|
+
return (0, _preact.h)("div", {
|
|
160
|
+
key: 'container',
|
|
161
|
+
class: "convo-event agent-message",
|
|
162
|
+
style: "opacity: 0 !important"
|
|
163
|
+
}, (0, _preact.h)("div", {
|
|
164
|
+
class: "agent-convo-event-wrapper"
|
|
165
|
+
}, (0, _preact.h)("div", {
|
|
166
|
+
class: "agent-convo-event-inner"
|
|
167
|
+
}, (0, _preact.h)("div", {
|
|
168
|
+
class: "message-agent message-text--agent",
|
|
169
|
+
style: "opacity: 0.6 !important"
|
|
170
|
+
}, (0, _preact.h)("div", {
|
|
171
|
+
style: "height: 20px !important; width: 35px !important"
|
|
172
|
+
})))));
|
|
173
|
+
}
|
|
174
|
+
var html = `
|
|
175
|
+
<html>
|
|
176
|
+
<head>
|
|
177
|
+
<style>
|
|
178
|
+
.typing-container {
|
|
179
|
+
width: 100vw;
|
|
180
|
+
height: 100vh;
|
|
181
|
+
display: flex;
|
|
182
|
+
align-items: center;
|
|
183
|
+
gap: 4px;
|
|
184
|
+
justify-content: center;
|
|
185
|
+
}
|
|
186
|
+
.typing-dot {
|
|
187
|
+
display: inline-block;
|
|
188
|
+
vertical-align: middle;
|
|
189
|
+
width: 8px;
|
|
190
|
+
height: 8px;
|
|
191
|
+
background: black;
|
|
192
|
+
border-radius: 50%;
|
|
193
|
+
animation: typing 0.5s infinite alternate;
|
|
194
|
+
}
|
|
195
|
+
.typing-dot:nth-of-type(2) {
|
|
196
|
+
animation-delay: 0.2s;
|
|
197
|
+
}
|
|
198
|
+
.typing-dot:nth-of-type(3) {
|
|
199
|
+
animation-delay: 0.6s;
|
|
200
|
+
}
|
|
201
|
+
@keyframes typing {
|
|
202
|
+
0% {
|
|
203
|
+
opacity: 0.9;
|
|
204
|
+
}
|
|
205
|
+
100% {
|
|
206
|
+
opacity: 0.4;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
</style>
|
|
210
|
+
</head>
|
|
211
|
+
<body style="padding: 0; margin: 0">
|
|
212
|
+
<div class="typing-container">
|
|
213
|
+
<span class="typing-dot"></span>
|
|
214
|
+
<span class="typing-dot"></span>
|
|
215
|
+
<span class="typing-dot"></span>
|
|
216
|
+
</div>
|
|
217
|
+
</body>
|
|
218
|
+
</html>
|
|
219
|
+
`;
|
|
220
|
+
let src = 'data:text/html,' + encodeURIComponent(html);
|
|
221
|
+
return (0, _preact.h)("div", {
|
|
222
|
+
key: 'container',
|
|
223
|
+
class: "convo-event agent-message",
|
|
224
|
+
style: "opacity: 0.6 !important"
|
|
225
|
+
}, (0, _preact.h)("div", {
|
|
226
|
+
class: "agent-convo-event-wrapper"
|
|
227
|
+
}, (0, _preact.h)("div", {
|
|
228
|
+
class: "agent-convo-event-inner"
|
|
229
|
+
}, (0, _preact.h)("div", {
|
|
230
|
+
class: "message-agent message-text--agent"
|
|
231
|
+
}, (0, _preact.h)("iframe", {
|
|
232
|
+
src: src,
|
|
233
|
+
style: "width: 35px !important; height: 20px !important; display: block !important; overflow: hidden !important; padding: 0 !important "
|
|
234
|
+
})))));
|
|
235
|
+
}
|
|
154
236
|
renderMessageSent() {
|
|
155
237
|
let ev = this.props.event.ev;
|
|
156
238
|
this.tryLoadOrder(ev);
|
|
157
|
-
var $time = null;
|
|
158
|
-
if (this.props.event.show_time) {
|
|
159
|
-
$time = (0, _preact.h)("div", {
|
|
160
|
-
class: "convo-event-time"
|
|
161
|
-
}, (0, _preact.h)(_time.default, {
|
|
162
|
-
time: ev.created,
|
|
163
|
-
t: this.props.t
|
|
164
|
-
}));
|
|
165
|
-
}
|
|
166
|
-
if (this.props.store.isAIDevMode()) $time = null;
|
|
167
239
|
let t = new _index.default.Date(ev.created).toLocaleString();
|
|
168
240
|
if (_index.default.get(ev, 'by.type') !== 'user') {
|
|
169
241
|
let $sender = null;
|
|
@@ -172,11 +244,13 @@ class Event extends _common.Com {
|
|
|
172
244
|
if (this.props.isLast) innercls += ' last';
|
|
173
245
|
return (0, _preact.h)("div", {
|
|
174
246
|
class: "convo-event agent-message"
|
|
175
|
-
}, $
|
|
247
|
+
}, $sender, (0, _preact.h)("div", {
|
|
176
248
|
class: "agent-convo-event-wrapper"
|
|
177
249
|
}, (0, _preact.h)("div", {
|
|
178
250
|
class: innercls
|
|
179
251
|
}, (0, _preact.h)(_TextMessage.default, {
|
|
252
|
+
showTime: this.props.event.show_time,
|
|
253
|
+
isLast: this.props.isLast,
|
|
180
254
|
store: this.props.store,
|
|
181
255
|
ev: ev,
|
|
182
256
|
onLink: this.props.onLink
|
|
@@ -241,7 +315,7 @@ class Event extends _common.Com {
|
|
|
241
315
|
}
|
|
242
316
|
let $sender = null;
|
|
243
317
|
if (this.props.event.mode === 'lead') $sender = (0, _preact.h)("div", {
|
|
244
|
-
class: "pt-
|
|
318
|
+
class: "pt-2"
|
|
245
319
|
});
|
|
246
320
|
let $error = null;
|
|
247
321
|
if (ev._error && ev.type === 'message_sent') {
|
|
@@ -259,7 +333,7 @@ class Event extends _common.Com {
|
|
|
259
333
|
}
|
|
260
334
|
return (0, _preact.h)("div", {
|
|
261
335
|
class: "convo-event user-message"
|
|
262
|
-
}, $
|
|
336
|
+
}, $sender, (0, _preact.h)("div", {
|
|
263
337
|
class: "message-user__container"
|
|
264
338
|
}, $dot, (0, _preact.h)(_TextMessage.default, {
|
|
265
339
|
store: this.props.store,
|
|
@@ -26,9 +26,64 @@ class Events extends _common.Com {
|
|
|
26
26
|
}, 500);
|
|
27
27
|
this.checkAndSeen();
|
|
28
28
|
}
|
|
29
|
+
componentDidMount() {
|
|
30
|
+
this.setState({
|
|
31
|
+
isShowTyping: false,
|
|
32
|
+
typing_event: {}
|
|
33
|
+
});
|
|
34
|
+
this.props.store.onConvoEvent(this, ev => {
|
|
35
|
+
if (_index.default.convoOfEv(ev) !== this.props.cid) return;
|
|
36
|
+
if (_index.default.get(ev, 'by.type') === 'user') return;
|
|
37
|
+
let oldby = _index.default.get(this.state.typing_event, 'by.id');
|
|
38
|
+
if (oldby && _index.default.get(ev, 'by.id') !== oldby) return;
|
|
39
|
+
if (_index.default.get(ev, 'type') === 'message_sent') {
|
|
40
|
+
if (this.timer) _index.default.clearTimeout(this.timer);
|
|
41
|
+
this.timer = null;
|
|
42
|
+
this.setState({
|
|
43
|
+
isShowTyping: false
|
|
44
|
+
});
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (_index.default.get(ev, 'type') !== 'conversation_typing') return;
|
|
48
|
+
let ag = this.props.store.matchAgent(_index.default.get(ev, 'by.id')) || {};
|
|
49
|
+
if (ag.type == 'agent' && !_index.default.get(this.props.plugin, 'chatbox.show_agent_typing')) return;
|
|
50
|
+
this.setState({
|
|
51
|
+
typing_event: ev,
|
|
52
|
+
isShowTyping: true
|
|
53
|
+
});
|
|
54
|
+
if (this.timer) _index.default.clearTimeout(this.timer);
|
|
55
|
+
this.timer = _index.default.setTimeout(() => {
|
|
56
|
+
if (_index.default.convoOfEv(ev) !== this.props.cid) return;
|
|
57
|
+
this.timer = null;
|
|
58
|
+
this.setState({
|
|
59
|
+
isShowTyping: false
|
|
60
|
+
});
|
|
61
|
+
}, 5000);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
29
64
|
componentDidUpdate(prevProps) {
|
|
30
65
|
if (prevProps.cid !== this.props.cid) this.loadConvo();
|
|
31
66
|
}
|
|
67
|
+
ShowTyping() {
|
|
68
|
+
this.setState({
|
|
69
|
+
isShowTyping: true,
|
|
70
|
+
typing_event: {
|
|
71
|
+
id: 'evzz' + _index.default.Date.now(),
|
|
72
|
+
created: _index.default.Date.now(),
|
|
73
|
+
by: {
|
|
74
|
+
type: 'agent'
|
|
75
|
+
},
|
|
76
|
+
type: 'conversation_typing'
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
if (this.timer) _index.default.clearTimeout(this.timer);
|
|
80
|
+
this.timer = _index.default.setTimeout(() => {
|
|
81
|
+
this.timer = null;
|
|
82
|
+
this.setState({
|
|
83
|
+
isShowTyping: false
|
|
84
|
+
});
|
|
85
|
+
}, 5000);
|
|
86
|
+
}
|
|
32
87
|
render() {
|
|
33
88
|
if (this.state.error) return this.renderError();
|
|
34
89
|
let events = _index.default.map(this.props.store.listEvents(this.props.cid));
|
|
@@ -51,18 +106,34 @@ class Events extends _common.Com {
|
|
|
51
106
|
events = _index.default.map(events, ev => ({
|
|
52
107
|
ev: ev
|
|
53
108
|
}));
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
if (bytype !== 'user' && ev.type === 'message_sent') {
|
|
60
|
-
lastAgentMessageSentId = ev.id;
|
|
61
|
-
break;
|
|
109
|
+
let ev = this.state.typing_event || {
|
|
110
|
+
id: 'evzz' + _index.default.Date.now(),
|
|
111
|
+
created: _index.default.Date.now(),
|
|
112
|
+
by: {
|
|
113
|
+
type: 'agent'
|
|
62
114
|
}
|
|
63
|
-
}
|
|
115
|
+
};
|
|
116
|
+
let fakeev = {
|
|
117
|
+
is_typing: true,
|
|
118
|
+
is_show: this.state.isShowTyping,
|
|
119
|
+
id: ev.id,
|
|
120
|
+
ev: {
|
|
121
|
+
id: ev.id,
|
|
122
|
+
created: ev.created,
|
|
123
|
+
by: ev.by,
|
|
124
|
+
type: 'message_sent',
|
|
125
|
+
data: {
|
|
126
|
+
message: {
|
|
127
|
+
text: '...',
|
|
128
|
+
conversation_id: this.props.cid
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
events.push(fakeev);
|
|
134
|
+
processEvents(convo, events);
|
|
64
135
|
let $events = _index.default.map(events, ev => {
|
|
65
|
-
let isLast = ev.ev.id ===
|
|
136
|
+
let isLast = ev.ev.id === _index.default.get(convo, 'last_message_sent.id');
|
|
66
137
|
return (0, _preact.h)(_Event.default, {
|
|
67
138
|
isLast: isLast,
|
|
68
139
|
chatbox: this.props.chatbox,
|
|
@@ -78,7 +149,7 @@ class Events extends _common.Com {
|
|
|
78
149
|
});
|
|
79
150
|
let $loading = null;
|
|
80
151
|
let style = 'opacity: 1 !important';
|
|
81
|
-
if (this.
|
|
152
|
+
if (this.props.creating) {
|
|
82
153
|
$loading = (0, _preact.h)(_spinner.default, {
|
|
83
154
|
static: true,
|
|
84
155
|
mode: _index.default.get(this.props.chatbox, 'primary_color', 'dark'),
|
|
@@ -87,6 +158,17 @@ class Events extends _common.Com {
|
|
|
87
158
|
});
|
|
88
159
|
style = 'opacity: 0 !important';
|
|
89
160
|
}
|
|
161
|
+
if (this.state.loading) {
|
|
162
|
+
if (_index.default.Date.now() - this.state.loading > 500) {
|
|
163
|
+
$loading = (0, _preact.h)(_spinner.default, {
|
|
164
|
+
static: true,
|
|
165
|
+
mode: _index.default.get(this.props.chatbox, 'primary_color', 'dark'),
|
|
166
|
+
size: "120",
|
|
167
|
+
center: true
|
|
168
|
+
});
|
|
169
|
+
style = 'opacity: 0 !important';
|
|
170
|
+
}
|
|
171
|
+
}
|
|
90
172
|
return (0, _preact.h)(_preact.Fragment, null, $loading, (0, _preact.h)("div", {
|
|
91
173
|
style: style,
|
|
92
174
|
ref: ref => this.refBody = ref,
|
|
@@ -154,10 +236,16 @@ class Events extends _common.Com {
|
|
|
154
236
|
if (!this.props.cid) return;
|
|
155
237
|
this.lastContentOffsetY = 0;
|
|
156
238
|
this.setState({
|
|
157
|
-
loading:
|
|
239
|
+
loading: false
|
|
158
240
|
});
|
|
159
241
|
let events = this.props.store.listEvents(this.props.cid);
|
|
160
242
|
if (_index.default.size(events) === 0) {
|
|
243
|
+
this.setState({
|
|
244
|
+
loading: _index.default.Date.now()
|
|
245
|
+
});
|
|
246
|
+
_index.default.setTimeout(() => {
|
|
247
|
+
this.forceUpdate();
|
|
248
|
+
}, 800);
|
|
161
249
|
let cid = this.props.cid;
|
|
162
250
|
let {
|
|
163
251
|
error
|
|
@@ -173,17 +261,11 @@ class Events extends _common.Com {
|
|
|
173
261
|
return;
|
|
174
262
|
}
|
|
175
263
|
}
|
|
176
|
-
this.setState({
|
|
177
|
-
loading: true
|
|
178
|
-
});
|
|
179
264
|
this.props.store.fetchMoreEvents(this.props.cid);
|
|
180
265
|
this.setState({
|
|
181
266
|
error: false
|
|
182
267
|
});
|
|
183
268
|
this.scrollToBottom();
|
|
184
|
-
_index.default.setTimeout(() => this.setState({
|
|
185
|
-
loading: false
|
|
186
|
-
}), 50);
|
|
187
269
|
}
|
|
188
270
|
isBottom() {
|
|
189
271
|
let $container = this.refBody;
|
|
@@ -198,7 +280,7 @@ class Events extends _common.Com {
|
|
|
198
280
|
_index.default.setTimeout(() => {
|
|
199
281
|
const $div = this.refBody;
|
|
200
282
|
if ($div) $div.scrollTop = $div.scrollHeight;
|
|
201
|
-
},
|
|
283
|
+
}, 100);
|
|
202
284
|
if (this.props.isShow) {
|
|
203
285
|
if (this.props.store.browserVisibility === 'visible' && document.hasFocus()) {
|
|
204
286
|
this.props.store.seenConvo(this.props.cid);
|
|
@@ -210,14 +292,19 @@ exports.default = Events;
|
|
|
210
292
|
function processEvents(convo, events) {
|
|
211
293
|
events = events.filter(event => visibleEvent(event.ev));
|
|
212
294
|
if (events.length < 1) return;
|
|
295
|
+
var lastAgentEvent;
|
|
213
296
|
for (var i = 1; i < events.length; i++) {
|
|
214
297
|
let curEvent = events[i];
|
|
215
298
|
let lastEvent = events[i - 1];
|
|
299
|
+
if (_index.default.get(curEvent, 'ev.by.type') != 'user' && !curEvent.is_typing) {
|
|
300
|
+
lastAgentEvent = curEvent;
|
|
301
|
+
}
|
|
216
302
|
if (visibleEvent(curEvent.ev)) {
|
|
217
303
|
let elapsedSec = _index.default.unixSec(curEvent.ev.created) - _index.default.unixSec(lastEvent.ev.created);
|
|
218
304
|
if (elapsedSec > 120) curEvent.show_time = true;
|
|
219
305
|
}
|
|
220
306
|
}
|
|
307
|
+
if (lastAgentEvent) lastAgentEvent.show_time = true;
|
|
221
308
|
for (var i = 0; i < events.length; i++) {
|
|
222
309
|
let curEvent = events[i];
|
|
223
310
|
if (_index.default.get(curEvent, 'ev.type') === 'message_sent') {
|
|
@@ -49,11 +49,12 @@ class Header extends _common.Com {
|
|
|
49
49
|
return (0, _preact.h)("div", {
|
|
50
50
|
class: cls,
|
|
51
51
|
style: style
|
|
52
|
-
}, $back, (0, _preact.h)(
|
|
52
|
+
}, $back, (0, _preact.h)("div", {
|
|
53
|
+
class: "mr-2"
|
|
54
|
+
}), (0, _preact.h)(_AgentsAvatar.default, {
|
|
53
55
|
plugin: this.props.plugin,
|
|
54
56
|
store: this.props.store,
|
|
55
|
-
mode: "secondary"
|
|
56
|
-
agent_ids: agentIdsJoined
|
|
57
|
+
mode: "secondary"
|
|
57
58
|
}), (0, _preact.h)("div", {
|
|
58
59
|
class: "widget-header--title-container"
|
|
59
60
|
}, (0, _preact.h)("div", {
|
|
@@ -188,7 +189,7 @@ Vui lòng hỏi chúng tôi bất cứ điều gì hoặc chia sẻ phản hồi
|
|
|
188
189
|
let accSetting = this.props.plugin.chatbox || {};
|
|
189
190
|
if (accSetting.hide_close_button) return null;
|
|
190
191
|
return (0, _preact.h)("div", {
|
|
191
|
-
class: "widget-header--button
|
|
192
|
+
class: "widget-header--button-close",
|
|
192
193
|
"data-tooltip": this.props.t('close'),
|
|
193
194
|
"data-tooltip-position": "bottom",
|
|
194
195
|
onClick: e => this.onCloseClick(e)
|
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _index = _interopRequireDefault(require("../util/index.js"));
|
|
8
|
-
var _time = _interopRequireDefault(require("./time.js"));
|
|
9
8
|
var _common = require("../common.js");
|
|
10
9
|
var _preact = require("preact");
|
|
11
10
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -18,16 +17,6 @@ function getRateLang(rating) {
|
|
|
18
17
|
class InfoMessage extends _common.Com {
|
|
19
18
|
render() {
|
|
20
19
|
let ev = this.props.ev.ev;
|
|
21
|
-
var $time = null;
|
|
22
|
-
if (this.props.ev.show_time) {
|
|
23
|
-
$time = (0, _preact.h)("div", {
|
|
24
|
-
class: "convo-event-time"
|
|
25
|
-
}, (0, _preact.h)(_time.default, {
|
|
26
|
-
time: ev.created,
|
|
27
|
-
t: this.props.t
|
|
28
|
-
}));
|
|
29
|
-
}
|
|
30
|
-
if (this.props.store.isAIDevMode()) $time = null;
|
|
31
20
|
if (ev.type === 'conversation_rated') {
|
|
32
21
|
var rating = _index.default.get(ev, 'data.conversation.ratings.0', {
|
|
33
22
|
no_rating: true,
|
|
@@ -36,14 +25,14 @@ class InfoMessage extends _common.Com {
|
|
|
36
25
|
if (rating.no_rating) return null;
|
|
37
26
|
return (0, _preact.h)("div", {
|
|
38
27
|
class: "convo-event"
|
|
39
|
-
},
|
|
28
|
+
}, (0, _preact.h)("div", {
|
|
40
29
|
class: "info-message"
|
|
41
30
|
}, this.props.t('rated_as') + ' ' + this.props.t(getRateLang(rating.rating)).toLowerCase()));
|
|
42
31
|
}
|
|
43
32
|
if (ev.type === 'conversation_state_updated' && _index.default.get(ev, 'data.conversation.state') === 'ended') {
|
|
44
33
|
return (0, _preact.h)("div", {
|
|
45
34
|
class: "convo-event"
|
|
46
|
-
},
|
|
35
|
+
}, (0, _preact.h)("div", {
|
|
47
36
|
class: "info-message"
|
|
48
37
|
}, this.props.t('conversation_ended')));
|
|
49
38
|
}
|
|
@@ -7,6 +7,7 @@ exports.default = void 0;
|
|
|
7
7
|
var _index = _interopRequireDefault(require("../util/index.js"));
|
|
8
8
|
var _common = require("../common.js");
|
|
9
9
|
var _preact = require("preact");
|
|
10
|
+
var _spinner = _interopRequireDefault(require("./spinner.js"));
|
|
10
11
|
var _Emoji = _interopRequireDefault(require("./Emoji.js"));
|
|
11
12
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
13
|
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
@@ -43,7 +44,7 @@ class MessageInput extends _common.Com {
|
|
|
43
44
|
$input.blur();
|
|
44
45
|
}
|
|
45
46
|
render() {
|
|
46
|
-
var buttons = (0, _preact.h)("div", {
|
|
47
|
+
var $buttons = (0, _preact.h)("div", {
|
|
47
48
|
class: "d-flex flex-row align-self-end"
|
|
48
49
|
}, this.renderEmoji(), (0, _preact.h)("div", {
|
|
49
50
|
"data-tooltip-poasition": "top-left",
|
|
@@ -52,7 +53,7 @@ class MessageInput extends _common.Com {
|
|
|
52
53
|
}));
|
|
53
54
|
var msg = _index.default.trim(this.state.msgValue);
|
|
54
55
|
if (msg.length > 0) {
|
|
55
|
-
buttons = (0, _preact.h)("div", {
|
|
56
|
+
$buttons = (0, _preact.h)("div", {
|
|
56
57
|
class: "d-flex flex-row align-self-end"
|
|
57
58
|
}, this.renderEmoji(), (0, _preact.h)("div", {
|
|
58
59
|
"data-tooltip-position": "top-left",
|
|
@@ -60,9 +61,16 @@ class MessageInput extends _common.Com {
|
|
|
60
61
|
onClick: () => this.submitMessage()
|
|
61
62
|
}));
|
|
62
63
|
}
|
|
64
|
+
if (this.props.is_loading) {
|
|
65
|
+
$buttons = (0, _preact.h)("div", {
|
|
66
|
+
class: "d-flex flex-row align-self-end"
|
|
67
|
+
}, (0, _preact.h)(_spinner.default, {
|
|
68
|
+
size: "32"
|
|
69
|
+
}));
|
|
70
|
+
}
|
|
63
71
|
var containercls = '';
|
|
64
72
|
var disabled = this.hasUnfinishRequiredFormOrLock() || this.props.disabled;
|
|
65
|
-
if (disabled) containercls = 'message-input--disabled';
|
|
73
|
+
if (disabled || this.props.is_loading) containercls = 'message-input--disabled';
|
|
66
74
|
return (0, _preact.h)("div", {
|
|
67
75
|
class: `message-input ${containercls}`,
|
|
68
76
|
onClick: e => {
|
|
@@ -78,7 +86,7 @@ class MessageInput extends _common.Com {
|
|
|
78
86
|
disabled: disabled,
|
|
79
87
|
class: "message-input--input",
|
|
80
88
|
maxlength: "1024",
|
|
81
|
-
placeholder: this.props.t('message_input_help'),
|
|
89
|
+
placeholder: this.props.t('message_input_help').substr(0, 25),
|
|
82
90
|
ref: this.refMessageInput,
|
|
83
91
|
rows: "1",
|
|
84
92
|
value: this.state.msgValue,
|
|
@@ -86,7 +94,7 @@ class MessageInput extends _common.Com {
|
|
|
86
94
|
onPaste: e => this.pasteImage(e),
|
|
87
95
|
"data-emojiable": "true",
|
|
88
96
|
onKeydown: e => this.onKeydown(e)
|
|
89
|
-
}), buttons);
|
|
97
|
+
}), $buttons);
|
|
90
98
|
}
|
|
91
99
|
hasUnfinishRequiredFormOrLock() {
|
|
92
100
|
let convo = this.props.store.matchConvo(this.props.cid);
|
|
@@ -298,15 +306,17 @@ class MessageInput extends _common.Com {
|
|
|
298
306
|
msg = msg || _index.default.trim(this.state.msgValue) || '';
|
|
299
307
|
if (!msg) return;
|
|
300
308
|
if (this.props.disabled) return;
|
|
309
|
+
if (this.props.onSend) {
|
|
310
|
+
await this.props.onSend({
|
|
311
|
+
text: msg,
|
|
312
|
+
format: 'plaintext'
|
|
313
|
+
});
|
|
314
|
+
}
|
|
301
315
|
this.setState({
|
|
302
316
|
openEmoji: false,
|
|
303
317
|
msgValue: ''
|
|
304
318
|
});
|
|
305
319
|
this.resizeInput();
|
|
306
|
-
this.props.onSend && this.props.onSend({
|
|
307
|
-
text: msg,
|
|
308
|
-
format: 'plaintext'
|
|
309
|
-
});
|
|
310
320
|
}
|
|
311
321
|
sendTyping() {
|
|
312
322
|
if (!this.props.cid) return;
|
|
@@ -9,8 +9,17 @@ var _block = _interopRequireDefault(require("./block.js"));
|
|
|
9
9
|
var _common = require("../common.js");
|
|
10
10
|
var _preact = require("preact");
|
|
11
11
|
var _Emoji = _interopRequireDefault(require("./Emoji.js"));
|
|
12
|
+
var _time = _interopRequireDefault(require("./time.js"));
|
|
12
13
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
14
|
class TextMessage extends _common.Com {
|
|
15
|
+
renderTime() {
|
|
16
|
+
if (!this.props.showTime && !this.props.isLast && !this.props.isFirst) return null;
|
|
17
|
+
return (0, _preact.h)("div", null, (0, _preact.h)(_time.default, {
|
|
18
|
+
class: "inline-time",
|
|
19
|
+
time: _index.default.get(this.props.ev, 'created', _index.default.Date.now()),
|
|
20
|
+
t: this.props.t
|
|
21
|
+
}));
|
|
22
|
+
}
|
|
14
23
|
render() {
|
|
15
24
|
var format = _index.default.get(this.props.ev, 'data.message.format', 'plaintext');
|
|
16
25
|
let block = _index.default.get(this.props.ev, 'data.message.block');
|
|
@@ -52,7 +61,7 @@ class TextMessage extends _common.Com {
|
|
|
52
61
|
if (byType === 'agent') return (0, _preact.h)("div", {
|
|
53
62
|
class: "message-agent message-text--agent",
|
|
54
63
|
title: t
|
|
55
|
-
}, tags);
|
|
64
|
+
}, tags, this.renderTime());
|
|
56
65
|
return (0, _preact.h)("div", {
|
|
57
66
|
class: "message-user message-text--user",
|
|
58
67
|
title: t
|
|
@@ -70,7 +79,7 @@ class TextMessage extends _common.Com {
|
|
|
70
79
|
}, (0, _preact.h)(_block.default, {
|
|
71
80
|
block: block,
|
|
72
81
|
onLink: this.props.onLink
|
|
73
|
-
}));
|
|
82
|
+
}), this.renderTime());
|
|
74
83
|
}
|
|
75
84
|
return (0, _preact.h)("div", {
|
|
76
85
|
class: "message-user message-text--user",
|
|
@@ -11,10 +11,8 @@ var _AgentsAvatar = _interopRequireDefault(require("./AgentsAvatar.js"));
|
|
|
11
11
|
var _Header = _interopRequireDefault(require("./Header.js"));
|
|
12
12
|
var _MessageInput = _interopRequireDefault(require("./MessageInput.js"));
|
|
13
13
|
var _Events = _interopRequireDefault(require("./Events.js"));
|
|
14
|
-
var _Typing = _interopRequireDefault(require("./Typing.js"));
|
|
15
14
|
var _Rating = _interopRequireDefault(require("./Rating.js"));
|
|
16
15
|
var _ListField = _interopRequireDefault(require("./ListField.js"));
|
|
17
|
-
var _spinner = _interopRequireDefault(require("./spinner.js"));
|
|
18
16
|
var _time = _interopRequireDefault(require("./time.js"));
|
|
19
17
|
var _common = require("../common.js");
|
|
20
18
|
var _preact = require("preact");
|
|
@@ -73,26 +71,33 @@ class Widget extends _common.Com {
|
|
|
73
71
|
initial_by: this.props.store.matchUser().id
|
|
74
72
|
});
|
|
75
73
|
if (_creating != this._creating) return;
|
|
76
|
-
if (error) {
|
|
74
|
+
if (error) {
|
|
75
|
+
this.setState({
|
|
76
|
+
creating: false
|
|
77
|
+
});
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
77
80
|
await this.props.store.sendConvoEvent(convo.id, 'message_sent', {
|
|
78
81
|
message
|
|
79
82
|
});
|
|
80
83
|
if (_creating != this._creating) return;
|
|
81
|
-
this.setState({
|
|
82
|
-
creating: false
|
|
83
|
-
});
|
|
84
84
|
this.props.onGo({
|
|
85
85
|
view: 'chat',
|
|
86
86
|
cid: convo.id
|
|
87
87
|
});
|
|
88
|
+
this.setState({
|
|
89
|
+
creating: false
|
|
90
|
+
});
|
|
88
91
|
return;
|
|
89
92
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
93
|
+
_index.default.setTimeout(async () => {
|
|
94
|
+
await this.props.store.sendConvoEvent(this.props.cid, 'message_sent', {
|
|
95
|
+
message
|
|
96
|
+
});
|
|
97
|
+
this.setState({
|
|
98
|
+
creating: false
|
|
99
|
+
});
|
|
100
|
+
}, 1);
|
|
96
101
|
});
|
|
97
102
|
_defineProperty(this, "onLink", (e, url) => {
|
|
98
103
|
if (!url) return e.preventDefault();
|
|
@@ -151,14 +156,14 @@ class Widget extends _common.Com {
|
|
|
151
156
|
quickReplyMessage: {}
|
|
152
157
|
});
|
|
153
158
|
_index.default.setTimeout(() => {
|
|
154
|
-
this
|
|
159
|
+
this.$events && this.$events.focus();
|
|
155
160
|
if (!this.props.store.isMobile()) this.focusInput();
|
|
156
161
|
}, 100);
|
|
157
162
|
this.updateFormDataFields();
|
|
158
163
|
}
|
|
159
164
|
}
|
|
160
165
|
ShowTyping() {
|
|
161
|
-
this
|
|
166
|
+
this.$events && this.$events.ShowTyping();
|
|
162
167
|
}
|
|
163
168
|
shouldShowForm() {
|
|
164
169
|
let form;
|
|
@@ -647,7 +652,9 @@ class Widget extends _common.Com {
|
|
|
647
652
|
class: "flex-grow-1"
|
|
648
653
|
}, (0, _preact.h)("div", {
|
|
649
654
|
class: "form mt-3 pl-3 pr-3 pt-3 pb-3 d-flex flex-column"
|
|
650
|
-
}, (0, _preact.h)("div", null, title), this.renderFields(form, formName))), (0, _preact.h)(
|
|
655
|
+
}, (0, _preact.h)("div", null, title), this.renderFields(form, formName))), (0, _preact.h)("div", {
|
|
656
|
+
class: "mt-2"
|
|
657
|
+
}), (0, _preact.h)(_PoweredBy.default, {
|
|
651
658
|
store: this.props.store,
|
|
652
659
|
t: this.props.t
|
|
653
660
|
})), (0, _preact.h)("div", {
|
|
@@ -719,7 +726,9 @@ class Widget extends _common.Com {
|
|
|
719
726
|
alt: "send button",
|
|
720
727
|
width: "26",
|
|
721
728
|
height: "26"
|
|
722
|
-
})), (0, _preact.h)(
|
|
729
|
+
})), (0, _preact.h)("div", {
|
|
730
|
+
class: "mt-2"
|
|
731
|
+
}), (0, _preact.h)(_PoweredBy.default, {
|
|
723
732
|
store: this.props.store
|
|
724
733
|
})));
|
|
725
734
|
}
|
|
@@ -783,6 +792,7 @@ class Widget extends _common.Com {
|
|
|
783
792
|
ref: this.msgInput,
|
|
784
793
|
cid: this.props.cid,
|
|
785
794
|
onChange: this.onChangeMessageInput,
|
|
795
|
+
is_loading: this.state.creating,
|
|
786
796
|
onSend: this.sendMessage,
|
|
787
797
|
t: this.props.t
|
|
788
798
|
});
|
|
@@ -806,18 +816,13 @@ class Widget extends _common.Com {
|
|
|
806
816
|
store: this.props.store,
|
|
807
817
|
chatbox: this.props.plugin.chatbox || {},
|
|
808
818
|
onFormSubmit: e => this.onEventFormSubmit(e),
|
|
809
|
-
ref: ref => this
|
|
819
|
+
ref: ref => this.$events = ref,
|
|
810
820
|
cid: this.props.cid,
|
|
811
821
|
creating: this.creating,
|
|
812
822
|
onSend: e => this.sendMessage(e),
|
|
813
823
|
onPostback: e => this.createPostback(e),
|
|
814
|
-
t: this.props.t
|
|
815
|
-
}), (0, _preact.h)(_Typing.default, {
|
|
816
|
-
store: this.props.store,
|
|
817
|
-
cid: this.props.cid,
|
|
818
824
|
t: this.props.t,
|
|
819
|
-
plugin: this.props.plugin
|
|
820
|
-
ref: this.refTyping
|
|
825
|
+
plugin: this.props.plugin
|
|
821
826
|
})), (0, _preact.h)(_Rating.default, {
|
|
822
827
|
forceView: this.props.view,
|
|
823
828
|
plugin: this.props.plugin,
|