@subiz/widget-v4 4.1.161 → 4.1.163

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.
Files changed (37) hide show
  1. package/compiled_src/chatbox/Event.js +1 -1
  2. package/compiled_src/chatbox/MessageInput.js +7 -0
  3. package/compiled_src/chatbox/TextMessage.js +2 -7
  4. package/compiled_src/lib.js +0 -1
  5. package/compiled_src/util/common.js +11 -0
  6. package/dist/{1989dde475e.app.js → 198a2dde018.app.js} +1 -1
  7. package/dist/{1989dde475e.chat.html → 198a2dde018.chat.html} +1 -1
  8. package/dist/{1989dde475e.chat.js → 198a2dde018.chat.js} +1 -1
  9. package/dist/{1989dde475e.form.html → 198a2dde018.form.html} +1 -1
  10. package/dist/{1989dde475e.form.js → 198a2dde018.form.js} +1 -1
  11. package/dist/{1989dde475e.index.html → 198a2dde018.index.html} +1 -1
  12. package/dist/{1989dde475e.library.html → 198a2dde018.library.html} +1 -1
  13. package/dist/{1989dde475e.library.js → 198a2dde018.library.js} +1 -1
  14. package/dist/{1989dde475e.preview.html → 198a2dde018.preview.html} +1 -1
  15. package/dist/198a2dde018.preview.js +1 -0
  16. package/dist/{1989dde475e.webview.js → 198a2dde018.webview.js} +1 -1
  17. package/dist/HASH +1 -1
  18. package/dist/screenshoot.js +31 -2
  19. package/package.json +1 -1
  20. package/src/chatbox/Event.js +2 -1
  21. package/src/chatbox/MessageInput.js +10 -0
  22. package/src/chatbox/TextMessage.js +1 -13
  23. package/src/lib.js +1 -1
  24. package/src/store/store.js +0 -2
  25. package/src/util/common.js +21 -4
  26. package/tracking.js +44 -0
  27. package/dist/1989dde475e.preview.js +0 -1
  28. /package/dist/{1989dde475e.127.js → 198a2dde018.127.js} +0 -0
  29. /package/dist/{1989dde475e.132.js → 198a2dde018.132.js} +0 -0
  30. /package/dist/{1989dde475e.185.js → 198a2dde018.185.js} +0 -0
  31. /package/dist/{1989dde475e.27.js → 198a2dde018.27.js} +0 -0
  32. /package/dist/{1989dde475e.278.js → 198a2dde018.278.js} +0 -0
  33. /package/dist/{1989dde475e.339.js → 198a2dde018.339.js} +0 -0
  34. /package/dist/{1989dde475e.459.js → 198a2dde018.459.js} +0 -0
  35. /package/dist/{1989dde475e.490.js → 198a2dde018.490.js} +0 -0
  36. /package/dist/{1989dde475e.74.js → 198a2dde018.74.js} +0 -0
  37. /package/dist/{1989dde475e.997.js → 198a2dde018.997.js} +0 -0
@@ -246,7 +246,7 @@ class Event extends _common.Com {
246
246
  let ev = this.props.event.ev;
247
247
  let attachments = _index.default.get(ev, 'data.message.attachments');
248
248
  let hasForm = _index.default.find(attachments, att => att.type === 'form');
249
- if (ev.id === 'evshpgaeetsplfqprzmynrvrl') hasForm = true;
249
+ if (_index.default.isEmptyMessage(_index.default.get(ev, 'data.message'))) return null;
250
250
  this.tryLoadOrder(ev);
251
251
  let t = new _index.default.Date(ev.created).toLocaleString();
252
252
  if (_index.default.get(ev, 'by.type') !== 'user') {
@@ -230,6 +230,13 @@ class MessageInput extends _common.Com {
230
230
  }
231
231
  focus() {
232
232
  if (this.props.disabled) return;
233
+ const activeElement = document.activeElement;
234
+ let focused = false;
235
+ if (activeElement) {
236
+ if (activeElement.tagName === 'INPUT' || activeElement.tagName === 'TEXTAREA') focused = true;
237
+ if (activeElement.hasAttribute('contenteditable') && activeElement.getAttribute('contenteditable') === 'true') focused = true;
238
+ }
239
+ if (focused) return;
233
240
  this.refMessageInput.current && this.refMessageInput.current.focus();
234
241
  _index.default.setTimeout(() => {
235
242
  this.refMessageInput.current && this.refMessageInput.current.focus();
@@ -71,7 +71,7 @@ class TextMessage extends _common.Com {
71
71
  }, tags);
72
72
  }
73
73
  renderBlock(block) {
74
- if (isEmptyBlock(block)) return null;
74
+ if (_index.default.isEmptyBlock(block)) return null;
75
75
  let t = new _index.default.Date(_index.default.get(this.props.ev, 'created')).toLocaleString();
76
76
  let byType = _index.default.get(this.props.ev, 'by.type');
77
77
  if (byType !== 'user') byType = 'agent';
@@ -97,9 +97,4 @@ class TextMessage extends _common.Com {
97
97
  }));
98
98
  }
99
99
  }
100
- exports.default = TextMessage;
101
- function isEmptyBlock(block) {
102
- if (!block || !block.type) return true;
103
- let hasContent = _index.default.size(_index.default.filter(_index.default.map(block.content, block => isEmptyBlock(block)), isEmpty => !isEmpty)) > 0;
104
- return !_index.default.trim(block.text) && !hasContent;
105
- }
100
+ exports.default = TextMessage;
@@ -221,7 +221,6 @@ class Widget {
221
221
  if (req.welcome_message) {
222
222
  return this.store.startLightConvo(req.bot_id, req.welcome_message, req.locale, req.is_testing, req.bot_version);
223
223
  }
224
- console.log(req);
225
224
  let members = req.members || [];
226
225
  if (req.bot_id) {
227
226
  let botid = req.bot_id;
@@ -34,6 +34,8 @@ exports.includes = includes;
34
34
  exports.isBlockEmpty = isBlockEmpty;
35
35
  exports.isConvoSeen = isConvoSeen;
36
36
  exports.isEmail = isEmail;
37
+ exports.isEmptyBlock = isEmptyBlock;
38
+ exports.isEmptyMessage = isEmptyMessage;
37
39
  exports.isNumber = isNumber;
38
40
  exports.isPhone = isPhone;
39
41
  exports.isURL = isURL;
@@ -1291,4 +1293,13 @@ emojis = map(emojis, e => ':' + e + ':');
1291
1293
  function absLink(url) {
1292
1294
  if (!url.startsWith('http://') && !url.startsWith('https://') && !url.startsWith('//')) return 'http://' + url;
1293
1295
  return url;
1296
+ }
1297
+ function isEmptyBlock(block) {
1298
+ if (!block || !block.type) return true;
1299
+ let hasContent = size(filter(map(block.content, block => isEmptyBlock(block)), isEmpty => !isEmpty)) > 0;
1300
+ return !trim(block.text) && !hasContent;
1301
+ }
1302
+ function isEmptyMessage(msg) {
1303
+ if (!msg) return true;
1304
+ if (!msg.text && isEmptyBlock(msg.block) && !size(msg.attachments)) return true;
1294
1305
  }