@subiz/widget-v4 4.1.161 → 4.1.162

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 (32) hide show
  1. package/compiled_src/chatbox/Event.js +6 -2
  2. package/compiled_src/chatbox/MessageInput.js +7 -0
  3. package/compiled_src/lib.js +0 -1
  4. package/dist/{1989dde475e.app.js → 198a2601817.app.js} +1 -1
  5. package/dist/{1989dde475e.chat.html → 198a2601817.chat.html} +1 -1
  6. package/dist/{1989dde475e.chat.js → 198a2601817.chat.js} +1 -1
  7. package/dist/{1989dde475e.form.html → 198a2601817.form.html} +1 -1
  8. package/dist/{1989dde475e.form.js → 198a2601817.form.js} +1 -1
  9. package/dist/{1989dde475e.index.html → 198a2601817.index.html} +1 -1
  10. package/dist/{1989dde475e.library.html → 198a2601817.library.html} +1 -1
  11. package/dist/{1989dde475e.library.js → 198a2601817.library.js} +1 -1
  12. package/dist/{1989dde475e.preview.html → 198a2601817.preview.html} +1 -1
  13. package/dist/198a2601817.preview.js +1 -0
  14. package/dist/{1989dde475e.webview.js → 198a2601817.webview.js} +1 -1
  15. package/dist/HASH +1 -1
  16. package/dist/screenshoot.js +31 -2
  17. package/package.json +1 -1
  18. package/src/chatbox/Event.js +6 -1
  19. package/src/chatbox/MessageInput.js +10 -0
  20. package/src/lib.js +1 -1
  21. package/src/store/store.js +0 -2
  22. package/dist/1989dde475e.preview.js +0 -1
  23. /package/dist/{1989dde475e.127.js → 198a2601817.127.js} +0 -0
  24. /package/dist/{1989dde475e.132.js → 198a2601817.132.js} +0 -0
  25. /package/dist/{1989dde475e.185.js → 198a2601817.185.js} +0 -0
  26. /package/dist/{1989dde475e.27.js → 198a2601817.27.js} +0 -0
  27. /package/dist/{1989dde475e.278.js → 198a2601817.278.js} +0 -0
  28. /package/dist/{1989dde475e.339.js → 198a2601817.339.js} +0 -0
  29. /package/dist/{1989dde475e.459.js → 198a2601817.459.js} +0 -0
  30. /package/dist/{1989dde475e.490.js → 198a2601817.490.js} +0 -0
  31. /package/dist/{1989dde475e.74.js → 198a2601817.74.js} +0 -0
  32. /package/dist/{1989dde475e.997.js → 198a2601817.997.js} +0 -0
package/dist/HASH CHANGED
@@ -1 +1 @@
1
- 1989dde475e
1
+ 198a2601817
@@ -7202,6 +7202,13 @@ class MessageInput extends common/* Com */.Mw {
7202
7202
  }
7203
7203
  focus() {
7204
7204
  if (this.props.disabled) return;
7205
+ const activeElement = document.activeElement;
7206
+ let focused = false;
7207
+ if (activeElement) {
7208
+ if (activeElement.tagName === 'INPUT' || activeElement.tagName === 'TEXTAREA') focused = true;
7209
+ if (activeElement.hasAttribute('contenteditable') && activeElement.getAttribute('contenteditable') === 'true') focused = true;
7210
+ }
7211
+ if (focused) return;
7205
7212
  this.refMessageInput.current && this.refMessageInput.current.focus();
7206
7213
  util/* default */.A.setTimeout(() => {
7207
7214
  this.refMessageInput.current && this.refMessageInput.current.focus();
@@ -8848,7 +8855,7 @@ class Event extends common/* Com */.Mw {
8848
8855
  let ev = this.props.event.ev;
8849
8856
  let attachments = util/* default */.A.get(ev, 'data.message.attachments');
8850
8857
  let hasForm = util/* default */.A.find(attachments, att => att.type === 'form');
8851
- if (ev.id === 'evshpgaeetsplfqprzmynrvrl') hasForm = true;
8858
+ if (isEmptyMessage(util/* default */.A.get(ev, 'data.message'))) return null;
8852
8859
  this.tryLoadOrder(ev);
8853
8860
  let t = new util/* default */.A.Date(ev.created).toLocaleString();
8854
8861
  if (util/* default */.A.get(ev, 'by.type') !== 'user') {
@@ -9117,6 +9124,10 @@ class Event extends common/* Com */.Mw {
9117
9124
  return acc.name;
9118
9125
  }
9119
9126
  }
9127
+ function isEmptyMessage(msg) {
9128
+ if (!msg) return true;
9129
+ if (!msg.text && !msg.block && !util/* default */.A.size(msg.attachments)) return true;
9130
+ }
9120
9131
  ;// ./src/chatbox/Events.js
9121
9132
 
9122
9133
 
@@ -11737,7 +11748,25 @@ class lib_Widget {
11737
11748
  return this.store.sendConversion(formid, values, impressiontoken);
11738
11749
  }
11739
11750
  startConvo(req) {
11740
- if (!req.is_light) return this.store.startConvo(req);else return this.store.startLightConvo(req.bot_id, req.welcome_message, req.locale, req.is_testing, req.bot_version);
11751
+ req = util/* default */.A.cloneDeep(req) || {};
11752
+ if (req.welcome_message) {
11753
+ return this.store.startLightConvo(req.bot_id, req.welcome_message, req.locale, req.is_testing, req.bot_version);
11754
+ }
11755
+ let members = req.members || [];
11756
+ if (req.bot_id) {
11757
+ let botid = req.bot_id;
11758
+ delete req.bot_id;
11759
+ if (!util/* default */.A.find(members, m => b.id == botid)) {
11760
+ members.push({
11761
+ type: 'bot',
11762
+ id: botid,
11763
+ bot_version: req.bot_version
11764
+ });
11765
+ }
11766
+ }
11767
+ req.members = members;
11768
+ req.initial_by = this.store.matchUser().id;
11769
+ return this.store.startConvo(req);
11741
11770
  }
11742
11771
  async showGreeting() {
11743
11772
  await this.domGate.entry();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@subiz/widget-v4",
3
- "version": "4.1.161",
3
+ "version": "4.1.162",
4
4
  "main": "./compiled_src/lib.js",
5
5
  "scripts": {
6
6
  "dev": "npx webpack serve --config webpack.dev.js",
@@ -234,7 +234,7 @@ export default class Event extends Com {
234
234
  let ev = this.props.event.ev
235
235
  let attachments = sb.get(ev, 'data.message.attachments')
236
236
  let hasForm = sb.find(attachments, (att) => att.type === 'form')
237
- if (ev.id === 'evshpgaeetsplfqprzmynrvrl') hasForm = true
237
+ if (isEmptyMessage(sb.get(ev, 'data.message'))) return null
238
238
  this.tryLoadOrder(ev)
239
239
  let t = new sb.Date(ev.created).toLocaleString()
240
240
  // message of agent
@@ -468,3 +468,8 @@ export default class Event extends Com {
468
468
  return acc.name
469
469
  }
470
470
  }
471
+
472
+ function isEmptyMessage(msg) {
473
+ if (!msg) return true
474
+ if (!msg.text && !msg.block && !sb.size(msg.attachments)) return true
475
+ }
@@ -242,6 +242,16 @@ export default class MessageInput extends Com {
242
242
 
243
243
  focus() {
244
244
  if (this.props.disabled) return
245
+ // check document has current input focused, so we dont interupt the compose procedure
246
+ const activeElement = document.activeElement
247
+ let focused = false
248
+ if (activeElement) {
249
+ if (activeElement.tagName === 'INPUT' || activeElement.tagName === 'TEXTAREA') focused = true
250
+ if (activeElement.hasAttribute('contenteditable') && activeElement.getAttribute('contenteditable') === 'true')
251
+ focused = true
252
+ }
253
+ if (focused) return
254
+
245
255
  this.refMessageInput.current && this.refMessageInput.current.focus()
246
256
  sb.setTimeout(() => {
247
257
  this.refMessageInput.current && this.refMessageInput.current.focus()
package/src/lib.js CHANGED
@@ -218,12 +218,12 @@ class Widget {
218
218
  return this.store.sendConversion(formid, values, impressiontoken)
219
219
  }
220
220
 
221
+ // req.bot_id != "" -> start conversation with bot id
221
222
  startConvo(req) {
222
223
  req = sb.cloneDeep(req) || {}
223
224
  if (req.welcome_message) {
224
225
  return this.store.startLightConvo(req.bot_id, req.welcome_message, req.locale, req.is_testing, req.bot_version)
225
226
  }
226
- console.log(req)
227
227
  let members = req.members || []
228
228
  if (req.bot_id) {
229
229
  let botid = req.bot_id
@@ -1067,8 +1067,6 @@ export default class Store {
1067
1067
  let {body: convo, error} = await this.api.start(req)
1068
1068
  this.convoGate.open()
1069
1069
 
1070
-
1071
-
1072
1070
  if (error) return {error}
1073
1071
  this._setConvo(convo)
1074
1072
  return {convo}