@subiz/widget-v4 4.0.82 → 4.0.86

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 (73) hide show
  1. package/compiled_src/chatbox/ChatButton.js +4 -8
  2. package/compiled_src/chatbox/TextMessage.js +1 -2
  3. package/compiled_src/chatbox/Typing.js +1 -1
  4. package/compiled_src/chatbox/Widget.js +9 -1
  5. package/compiled_src/popup/popup.js +7 -0
  6. package/compiled_src/store/store.js +4 -6
  7. package/dist/132.js +162 -44
  8. package/dist/178.js +174 -341
  9. package/dist/18224b3b0f8.132.js +1 -0
  10. package/dist/18224b3b0f8.178.js +1 -0
  11. package/dist/{17f00e48d38.213.js → 18224b3b0f8.213.js} +1 -1
  12. package/dist/{17f00e48d38.335.js → 18224b3b0f8.335.js} +1 -1
  13. package/dist/18224b3b0f8.362.js +1 -0
  14. package/dist/18224b3b0f8.441.js +1 -0
  15. package/dist/{17f00e48d38.605.js → 18224b3b0f8.605.js} +0 -0
  16. package/dist/18224b3b0f8.678.js +1 -0
  17. package/dist/18224b3b0f8.782.js +1 -0
  18. package/dist/18224b3b0f8.app.js +1 -0
  19. package/dist/{17f00e48d38.index.html → 18224b3b0f8.index.html} +7 -3
  20. package/dist/{17f00e48d38.library.html → 18224b3b0f8.library.html} +7 -3
  21. package/dist/18224b3b0f8.library.js +1 -0
  22. package/dist/{17f00e48d38.preview.html → 18224b3b0f8.preview.html} +1 -1
  23. package/dist/18224b3b0f8.preview.js +1 -0
  24. package/dist/18224b3b0f8.screenshoot.js +1 -0
  25. package/dist/213.js +16 -0
  26. package/dist/335.js +2 -2
  27. package/dist/362.js +21 -71
  28. package/dist/441.js +150 -56
  29. package/dist/678.js +20 -70
  30. package/dist/782.js +21 -118
  31. package/dist/HASH +1 -1
  32. package/dist/screenshoot.html +1 -1
  33. package/dist/screenshoot.js +185 -133
  34. package/package.json +14 -14
  35. package/src/chatbox/ChatButton.js +4 -4
  36. package/src/chatbox/TextMessage.js +4 -2
  37. package/src/chatbox/Typing.js +10 -11
  38. package/src/chatbox/Widget.js +7 -2
  39. package/src/popup/popup.js +23 -11
  40. package/src/store/store.js +3 -4
  41. package/dist/0b82fa7e5c3b07b40a44.png +0 -1
  42. package/dist/0f4af006e38ee8b93633.png +0 -1
  43. package/dist/17f00e48d38.132.js +0 -1
  44. package/dist/17f00e48d38.178.js +0 -1
  45. package/dist/17f00e48d38.362.js +0 -1
  46. package/dist/17f00e48d38.441.js +0 -1
  47. package/dist/17f00e48d38.678.js +0 -1
  48. package/dist/17f00e48d38.782.js +0 -1
  49. package/dist/17f00e48d38.app.js +0 -1
  50. package/dist/17f00e48d38.library.js +0 -1
  51. package/dist/17f00e48d38.preview.js +0 -1
  52. package/dist/17f00e48d38.screenshoot.js +0 -1
  53. package/dist/1ea1c6cd21d25176810c.png +0 -1
  54. package/dist/292d42404e1b03398f61.png +0 -1
  55. package/dist/312d376370831b7bea83.png +0 -1
  56. package/dist/313d1bfc1cf776d1aefe.png +0 -1
  57. package/dist/4aa58bb7a66bb44975aa.png +0 -1
  58. package/dist/56ce063bc6c81adb7322.png +0 -1
  59. package/dist/6a411166ef5cc79e0714.png +0 -1
  60. package/dist/6faf403782fefacc1649.png +0 -1
  61. package/dist/79dca33c68fab79c067f.png +0 -1
  62. package/dist/82da1578fa84f9debaeb.png +0 -1
  63. package/dist/8b8e0f0824743974b282.png +0 -1
  64. package/dist/8d551390d81e39130a3c.png +0 -1
  65. package/dist/9fc61b9479877ebdb6c7.png +0 -1
  66. package/dist/a165d31dcb3dc90f1057.png +0 -1
  67. package/dist/a98d4a5698812c4426b3.png +0 -1
  68. package/dist/c41606bf9d1b604e46d5.png +0 -1
  69. package/dist/ce1f7450ce6c1aacd330.png +0 -1
  70. package/dist/cf8c01e88f4770a6e3e5.png +0 -1
  71. package/dist/dfbcfeab1d5622a737e2.png +0 -1
  72. package/dist/e4893ed8c2f7b8329919.png +0 -1
  73. package/dist/ec2ab4eb4ef73d186186.png +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@subiz/widget-v4",
3
- "version": "4.0.82",
3
+ "version": "4.0.86",
4
4
  "main": "./compiled_src/lib.js",
5
5
  "scripts": {
6
6
  "dev": "npx webpack serve --config webpack.dev.js",
@@ -14,28 +14,28 @@
14
14
  "@subiz/storage": "0.0.8",
15
15
  "@subiz/wsclient": "^3.1.7",
16
16
  "cookie_js": "1.4.2",
17
- "core-js": "^3.22.8",
17
+ "core-js": "^3.23.5",
18
18
  "css-loader": "5.2.7",
19
19
  "file-loader": "^6.2.0",
20
- "less": "^4.1.2",
20
+ "less": "^4.1.3",
21
21
  "less-loader": "^11.0.0",
22
- "marked": "^4.0.16",
23
- "preact": "^10.7.3"
22
+ "marked": "^4.0.18",
23
+ "preact": "^10.10.0"
24
24
  },
25
25
  "devDependencies": {
26
- "@babel/cli": "^7.17.10",
27
- "@babel/core": "^7.18.2",
28
- "@babel/plugin-proposal-class-properties": "^7.17.12",
29
- "@babel/plugin-transform-react-jsx": "^7.17.12",
30
- "@babel/preset-env": "^7.18.2",
26
+ "@babel/cli": "^7.18.9",
27
+ "@babel/core": "^7.18.9",
28
+ "@babel/plugin-proposal-class-properties": "^7.18.6",
29
+ "@babel/plugin-transform-react-jsx": "^7.18.6",
30
+ "@babel/preset-env": "^7.18.9",
31
31
  "babel-loader": "^8.2.5",
32
32
  "babel-plugin-syntax-jsx": "^6.18.0",
33
33
  "html-webpack-plugin": "^5.5.0",
34
- "prettier": "^2.6.2",
35
- "puppeteer": "^14.2.1",
34
+ "prettier": "^2.7.1",
35
+ "puppeteer": "^15.4.0",
36
36
  "webpack": "^5.73.0",
37
37
  "webpack-bundle-analyzer": "^4.5.0",
38
- "webpack-cli": "^4.9.2",
39
- "webpack-dev-server": "^4.9.1"
38
+ "webpack-cli": "^4.10.0",
39
+ "webpack-dev-server": "^4.9.3"
40
40
  }
41
41
  }
@@ -206,13 +206,13 @@ export default class ChatButton extends Com {
206
206
  }
207
207
 
208
208
  onProfileReady() {
209
- if (this.state.buttonLoaded) this.setState({opacity: 1})
210
- this.setState({profileLoaded: true})
209
+ if (this._buttonLoaded) this.setState({opacity: 1})
210
+ this._profileLoaded = true
211
211
  }
212
212
 
213
213
  onButtonReady() {
214
- if (this.state.profileLoaded) this.setState({opacity: 1})
215
- this.setState({buttonLoaded: true})
214
+ if (this._profileLoaded) this.setState({opacity: 1})
215
+ this._buttonLoaded = true
216
216
  }
217
217
 
218
218
  renderButton() {
@@ -71,11 +71,13 @@ export default class TextMessage extends Com {
71
71
  let isMarkdown = sb.find(
72
72
  deltas,
73
73
  (delta) =>
74
- sb.get(delta, 'attributes.bold') || sb.get(delta, 'attributes.italic') || sb.get(delta, 'attributes.underline'),
74
+ sb.get(delta, 'attributes.bold') ||
75
+ sb.get(delta, 'attributes.italic') ||
76
+ sb.get(delta, 'attributes.underline') ||
77
+ sb.get(delta, 'insert.emoji'),
75
78
  )
76
79
  if (isMarkdown) {
77
80
  var text = deltaToMarkdown(deltas)
78
- console.log('text', text)
79
81
  return this.renderMarkdown(text)
80
82
  }
81
83
  return this.renderPlainText()
@@ -1,24 +1,23 @@
1
1
  import sb from '../util/index.js'
2
- import { Com } from '../common.js'
3
- import { h } from 'preact'
2
+ import {Com} from '../common.js'
3
+ import {h} from 'preact'
4
4
 
5
5
  export default class Typing extends Com {
6
- constructor (props) {
6
+ constructor(props) {
7
7
  super(props)
8
8
  }
9
9
 
10
- componentDidMount () {
10
+ componentDidMount() {
11
11
  this.setState({
12
12
  isShow: false,
13
13
  ev: {},
14
14
  })
15
15
 
16
- this.props.store.onConvoEvent(this, ev => {
16
+ this.props.store.onConvoEvent(this, (ev) => {
17
17
  if (sb.convoOfEv(ev) !== this.props.cid) return
18
18
  let user = this.props.store.matchUser()
19
19
  if (sb.get(ev, 'by.id') === user.id) return
20
20
 
21
-
22
21
  let oldby = sb.get(this.state.ev, 'by.id')
23
22
  if (oldby && sb.get(ev, 'by.id') !== oldby) return
24
23
 
@@ -26,27 +25,27 @@ export default class Typing extends Com {
26
25
  // stop the typing
27
26
  if (this.timer) clearTimeout(this.timer)
28
27
  this.timer = null
29
- this.setState({ isShow: false })
28
+ this.setState({isShow: false})
30
29
  return
31
30
  }
32
31
 
33
32
  // dont show typing of agent, some agent dont like this
34
- let ag = this.props.store.matchAgent(ev.by.id)
33
+ let ag = this.props.store.matchAgent(ev.by.id) || {}
35
34
  if (ag.type == 'agent') return
36
35
 
37
36
  if (sb.get(ev, 'type') !== 'conversation_typing') return
38
- this.setState({ ev: ev, isShow: true })
37
+ this.setState({ev: ev, isShow: true})
39
38
  if (this.timer) clearTimeout(this.timer)
40
39
  this.timer = setTimeout(() => {
41
40
  if (sb.convoOfEv(ev) !== this.props.cid) return
42
41
 
43
42
  this.timer = null
44
- this.setState({ isShow: false })
43
+ this.setState({isShow: false})
45
44
  }, 5000)
46
45
  })
47
46
  }
48
47
 
49
- render () {
48
+ render() {
50
49
  let account = this.props.store.matchAccount()
51
50
  var cls = this.state.isShow ? '' : 'typing--hidden'
52
51
  let byid = sb.get(this.state.ev, 'by.display_id', sb.get(this.state.ev, 'by.id'))
@@ -148,9 +148,11 @@ export default class Widget extends Com {
148
148
  let data = sb.cloneDeep(this.state.formData)
149
149
  // update user info based on form data
150
150
  let user = sb.cloneDeep(this.props.store.matchUser())
151
+ let is_lead = false
151
152
  sb.map(data, (field, key) => {
152
153
  if (!key.startsWith('attr:')) return
153
154
  var attr = {key: key.substr(5)}
155
+ is_lead = is_lead || key == 'emails' || key == 'phones'
154
156
  if (field.type === 'number') attr.number = parseInt(field.value)
155
157
  if (field.type === 'datetime') attr.datetime = new sb.Date(field.value).toISOString()
156
158
  if (field.type === 'list') attr.list = field.value
@@ -158,6 +160,8 @@ export default class Widget extends Com {
158
160
  sb.setUserAttr(user, attr)
159
161
  })
160
162
 
163
+ if (is_lead) sb.setUserAttr(user, {key: 'lead_source', text: 'widget'})
164
+
161
165
  let firstmsg = sb.get(data, 'question.value')
162
166
  let groupid = sb.get(data, 'group.value', '')
163
167
 
@@ -184,8 +188,8 @@ export default class Widget extends Com {
184
188
  let req = {group_id: groupid, message: firstmsg, locale: this.props.t.locale(), initial_by: user.id}
185
189
 
186
190
  this.setState({creatingError: null})
191
+ await this.props.store.setUser(user)
187
192
  const {error, convo} = await this.props.store.startConvo(req)
188
- this.props.store.setUser(user)
189
193
  if (error) {
190
194
  this.setState({creating: false, creatingError: error})
191
195
  return
@@ -269,7 +273,8 @@ export default class Widget extends Com {
269
273
  value={field.value || ''}
270
274
  onInput={(e) => this.onInputChange(key, e.target.value)}
271
275
  row='4'
272
- class='form-control'></textarea>
276
+ class='form-control'
277
+ ></textarea>
273
278
  )
274
279
  } else {
275
280
  $field = (
@@ -156,7 +156,8 @@ export default class Popup extends Com {
156
156
  height='24'
157
157
  viewBox='0 0 24 24'
158
158
  stroke-linecap='round'
159
- stroke-linejoin='round'>
159
+ stroke-linejoin='round'
160
+ >
160
161
  <line x1='17' y1='7' x2='7' y2='17' style='stroke-width: 3 !important;'></line>
161
162
  <line x1='7' y1='7' x2='17' y2='17' style='stroke-width: 3 !important;'></line>
162
163
  </svg>
@@ -213,6 +214,7 @@ export default class Popup extends Com {
213
214
  var summitFields = []
214
215
 
215
216
  let user = sb.cloneDeep(this.props.store.matchUser())
217
+ let is_lead = false
216
218
  for (var pair of formData.entries()) {
217
219
  let page = sb.get(this.props.plugin.popup, `pages.${this.getPageIndex()}`)
218
220
  let form = sb.find(page.components, (com) => com.type === 'form')
@@ -226,10 +228,12 @@ export default class Popup extends Com {
226
228
  let key = pair[0]
227
229
  if (key === 'email') key = 'emails'
228
230
  if (key === 'phone') key = 'phones'
229
-
231
+ is_lead = is_lead || key == 'emails' || key == 'phones'
230
232
  sb.setUserAttr(user, {key: key, text: pair[1]})
231
233
  }
234
+ if (is_lead) sb.setUserAttr(user, {key: 'lead_source', text: 'plugin.' + this.props.plugin.id})
232
235
  this.props.store.sendConversion(this.props.plugin.id, summitFields, this.impressionToken)
236
+
233
237
  this.props.store.setUser(user)
234
238
  }
235
239
 
@@ -277,7 +281,8 @@ export default class Popup extends Com {
277
281
  <div
278
282
  class={'btn btn__primary '}
279
283
  style={this.js2css(primarystyle)}
280
- onClick={(e) => this.onButtonClick(e, 'primary')}>
284
+ onClick={(e) => this.onButtonClick(e, 'primary')}
285
+ >
281
286
  {this.props.t.i18n(com.buttons.i18n_primary_text) || com.buttons.primary_text}
282
287
  </div>
283
288
  )
@@ -290,7 +295,8 @@ export default class Popup extends Com {
290
295
  <div
291
296
  class={'btn btn__secondary'}
292
297
  style={this.js2css(style)}
293
- onClick={(e) => this.onButtonClick(e, 'secondary')}>
298
+ onClick={(e) => this.onButtonClick(e, 'secondary')}
299
+ >
294
300
  {this.props.t.i18n(com.buttons.i18n_secondary_text) || com.buttons.secondary_text}
295
301
  </div>
296
302
  )
@@ -303,7 +309,8 @@ export default class Popup extends Com {
303
309
  display: 'flex',
304
310
  flex_direction: buttonsstyle.flex_direction,
305
311
  align_items: buttonsstyle.align_items,
306
- })}>
312
+ })}
313
+ >
307
314
  {$primary}
308
315
  <div style={this.js2css({width: '10px', height: '1px'})} />
309
316
  {$secondary}
@@ -503,7 +510,8 @@ export default class Popup extends Com {
503
510
  color: popup.text_color,
504
511
  font_family: popup.font_family,
505
512
  font_size: popup.font_size || '14px',
506
- })}>
513
+ })}
514
+ >
507
515
  {this.props.t.i18n(field.i18n_label) || field.label}
508
516
  </div>
509
517
  )
@@ -517,7 +525,8 @@ export default class Popup extends Com {
517
525
  $error = (
518
526
  <div
519
527
  class='text__danger '
520
- style={this.js2css({margin_top: '5px', font_family: popup.font_family, font_size: popup.font_size})}>
528
+ style={this.js2css({margin_top: '5px', font_family: popup.font_family, font_size: popup.font_size})}
529
+ >
521
530
  {this.props.t('invalid_field')}
522
531
  </div>
523
532
  )
@@ -527,7 +536,8 @@ export default class Popup extends Com {
527
536
  $error = (
528
537
  <div
529
538
  class='text__danger '
530
- style={this.js2css({margin_top: '5px', font_family: popup.font_family, font_size: popup.font_size})}>
539
+ style={this.js2css({margin_top: '5px', font_family: popup.font_family, font_size: popup.font_size})}
540
+ >
531
541
  {this.props.t('required')}
532
542
  </div>
533
543
  )
@@ -547,7 +557,8 @@ export default class Popup extends Com {
547
557
  style={this.js2css(com.style)}
548
558
  class='form popup_component'
549
559
  ref={this._formRef}
550
- onClick={(e) => e.stopPropagation()}>
560
+ onClick={(e) => e.stopPropagation()}
561
+ >
551
562
  {$fields}
552
563
  </form>
553
564
  )
@@ -600,7 +611,8 @@ export default class Popup extends Com {
600
611
  <span
601
612
  style={this.js2css(
602
613
  Object.assign({white_space: 'nowrap', overflow: 'hidden', text_overflow: 'ellipsis'}, textstyle),
603
- )}>
614
+ )}
615
+ >
604
616
  {this.props.t('follow_us_on_facebook')}
605
617
  </span>
606
618
  </div>
@@ -919,7 +931,7 @@ export default class Popup extends Com {
919
931
  if (com.type === 'image') return this.renderImageComponent(com, i)
920
932
  })
921
933
 
922
- // fix bug image only popup has white block
934
+ // fix bug image only popup has white block
923
935
  let formComponents = sb.filter(page.components, (com) => com.type !== 'image')
924
936
  if (!formComponents.length) {
925
937
  formcss.background = 'transparent'
@@ -1161,16 +1161,15 @@ function sendToFBPixel(category, action, label) {
1161
1161
  }
1162
1162
 
1163
1163
  function sendToGA(category, action, label) {
1164
- console.log('SENT.', category, action, label)
1164
+ // console.log('SENT.', category, action, label)
1165
+ if (window.gtag) window.gtag('event', category, {Action: action, Label: label})
1165
1166
  if (window.ga && window.ga.getAll) {
1167
+ // only send gtag when ga is not available
1166
1168
  const allTrackers = window.ga.getAll() || []
1167
1169
  allTrackers.forEach(function (tracker) {
1168
1170
  const name = tracker.get('name')
1169
1171
  window.ga(name + '.send', 'event', category, action, label)
1170
1172
  })
1171
- } else {
1172
- // only send gtag when ga is not available
1173
- if (window.gtag) window.gtag('event', category, {Action: action, Label: label})
1174
1173
  }
1175
1174
  }
1176
1175
 
@@ -1 +0,0 @@
1
- module.exports = __webpack_public_path__ + "assets/img/emoji/messenger/sub_58.824_78.431.f910f2a.png";
@@ -1 +0,0 @@
1
- module.exports = __webpack_public_path__ + "assets/img/emoji/messenger/sub_60.784_29.412.e36d284.png";