@subiz/widget-v4 4.0.64 → 4.0.68

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 (77) hide show
  1. package/assets/less/chatbox.less +6 -1
  2. package/compiled_src/chatbox/ChatButton.js +3 -1
  3. package/compiled_src/chatbox/Event.js +1 -0
  4. package/compiled_src/chatbox/ProductAttachments.js +40 -4
  5. package/compiled_src/chatbox/Typing.js +3 -1
  6. package/compiled_src/chatbox/main.js +2 -0
  7. package/compiled_src/lib.js +18 -4
  8. package/compiled_src/store/store.js +26 -3
  9. package/compiled_src/util/common.js +1 -1
  10. package/dist/132.js +48 -6
  11. package/dist/178.js +174 -341
  12. package/dist/1801c652a77.132.js +1 -0
  13. package/dist/1801c652a77.178.js +1 -0
  14. package/dist/{17ee31b89ac.213.js → 1801c652a77.213.js} +0 -0
  15. package/dist/{17ee31b89ac.335.js → 1801c652a77.335.js} +1 -1
  16. package/dist/1801c652a77.362.js +1 -0
  17. package/dist/{17ee31b89ac.441.js → 1801c652a77.441.js} +0 -0
  18. package/dist/{17ee31b89ac.605.js → 1801c652a77.605.js} +0 -0
  19. package/dist/1801c652a77.678.js +1 -0
  20. package/dist/1801c652a77.782.js +1 -0
  21. package/dist/1801c652a77.app.js +1 -0
  22. package/dist/{17ee31b89ac.index.html → 1801c652a77.index.html} +1 -1
  23. package/dist/{17ee31b89ac.library.html → 1801c652a77.library.html} +1 -1
  24. package/dist/1801c652a77.library.js +1 -0
  25. package/dist/{17ee31b89ac.preview.html → 1801c652a77.preview.html} +1 -1
  26. package/dist/1801c652a77.preview.js +1 -0
  27. package/dist/1801c652a77.screenshoot.js +1 -0
  28. package/dist/335.js +2 -2
  29. package/dist/362.js +20 -70
  30. package/dist/678.js +20 -70
  31. package/dist/782.js +21 -118
  32. package/dist/HASH +1 -1
  33. package/dist/screenshoot.html +1 -1
  34. package/dist/screenshoot.js +101 -64
  35. package/package.json +10 -10
  36. package/src/chatbox/Buttons.js +8 -8
  37. package/src/chatbox/ChatButton.js +2 -2
  38. package/src/chatbox/Event.js +1 -1
  39. package/src/chatbox/ProductAttachments.js +41 -5
  40. package/src/chatbox/Typing.js +5 -1
  41. package/src/chatbox/main.js +4 -1
  42. package/src/lib.js +13 -4
  43. package/src/store/store.js +25 -11
  44. package/src/util/common.js +1 -1
  45. package/up +1 -1
  46. package/dist/0b82fa7e5c3b07b40a44.png +0 -1
  47. package/dist/0f4af006e38ee8b93633.png +0 -1
  48. package/dist/17ee31b89ac.132.js +0 -1
  49. package/dist/17ee31b89ac.178.js +0 -1
  50. package/dist/17ee31b89ac.362.js +0 -1
  51. package/dist/17ee31b89ac.678.js +0 -1
  52. package/dist/17ee31b89ac.782.js +0 -1
  53. package/dist/17ee31b89ac.app.js +0 -1
  54. package/dist/17ee31b89ac.library.js +0 -1
  55. package/dist/17ee31b89ac.preview.js +0 -1
  56. package/dist/17ee31b89ac.screenshoot.js +0 -1
  57. package/dist/1ea1c6cd21d25176810c.png +0 -1
  58. package/dist/292d42404e1b03398f61.png +0 -1
  59. package/dist/312d376370831b7bea83.png +0 -1
  60. package/dist/313d1bfc1cf776d1aefe.png +0 -1
  61. package/dist/4aa58bb7a66bb44975aa.png +0 -1
  62. package/dist/56ce063bc6c81adb7322.png +0 -1
  63. package/dist/6a411166ef5cc79e0714.png +0 -1
  64. package/dist/6faf403782fefacc1649.png +0 -1
  65. package/dist/79dca33c68fab79c067f.png +0 -1
  66. package/dist/82da1578fa84f9debaeb.png +0 -1
  67. package/dist/8b8e0f0824743974b282.png +0 -1
  68. package/dist/8d551390d81e39130a3c.png +0 -1
  69. package/dist/9fc61b9479877ebdb6c7.png +0 -1
  70. package/dist/a165d31dcb3dc90f1057.png +0 -1
  71. package/dist/a98d4a5698812c4426b3.png +0 -1
  72. package/dist/c41606bf9d1b604e46d5.png +0 -1
  73. package/dist/ce1f7450ce6c1aacd330.png +0 -1
  74. package/dist/cf8c01e88f4770a6e3e5.png +0 -1
  75. package/dist/dfbcfeab1d5622a737e2.png +0 -1
  76. package/dist/e4893ed8c2f7b8329919.png +0 -1
  77. package/dist/ec2ab4eb4ef73d186186.png +0 -1
@@ -47,12 +47,17 @@
47
47
  @z-index-4: '@z_index_4';
48
48
  @z-index-5: '@z_index_5';
49
49
 
50
-
51
50
  // stop client css rule on all elements inside #subiz
52
51
  #sbz92 * {
53
52
  all: unset !important;
54
53
  }
55
54
 
55
+ .sbz_no_scroll {
56
+ overflow: hidden !important;
57
+ overflow-x: hidden !important;
58
+ overflow-y: hidden !important;
59
+ }
60
+
56
61
  #sbz92 {
57
62
  #makeImportant() !important;
58
63
  }
@@ -146,7 +146,9 @@ class ChatButton extends _common.Com {
146
146
 
147
147
  let greeting = _index.default.get(accountSetting, 'greeting', {});
148
148
 
149
- if (!greeting.message || !greeting.enabled) {
149
+ let text = this.props.t.i18n(_index.default.get(greeting, 'greeting', {})) || greeting.message;
150
+
151
+ if (!text || !greeting.enabled) {
150
152
  this.setState({
151
153
  previewEvent: {}
152
154
  });
@@ -200,6 +200,7 @@ class Event extends _common.Com {
200
200
  onSelect: e => this.choosePostbackBtn(e)
201
201
  }), (0, _preact.h)(_ProductAttachments.default, {
202
202
  t: this.props.t,
203
+ onPostback: e => this.choosePostbackBtn(e),
203
204
  store: this.props.store,
204
205
  ev: ev
205
206
  }), (0, _preact.h)(_OrderAttachments.default, {
@@ -29,17 +29,53 @@ class ProductAttachments extends _common.Com {
29
29
 
30
30
  let $products = _index.default.map(products, (att, index) => {
31
31
  let product = att.product;
32
- let $detailbtn = null;
32
+ let $detailbtns = [];
33
33
  let url = product.url || product.mobile_url;
34
34
  if (this.props.store.isMobile()) url = product.mobile_url || product.url;
35
- if (url) $detailbtn = (0, _preact.h)("a", {
35
+ if (url && _index.default.size(product.buttons) == 0) $detailbtns.push((0, _preact.h)("a", {
36
36
  class: "product_attachment__btn",
37
37
  href: url,
38
38
  target: "_blank"
39
39
  }, this.props.t('detail'), (0, _preact.h)("img", {
40
40
  src: require('../../assets/img/external-link.svg'),
41
41
  class: "product_attachment__btn_external_link"
42
- }));
42
+ })));
43
+ console.log("P", product);
44
+
45
+ if (_index.default.size(product.buttons) > 0) {
46
+ $detailbtns = $detailbtns.concat(_index.default.map(product.buttons, (button, index) => {
47
+ if (button.type === 'call_button') {
48
+ return (0, _preact.h)("a", {
49
+ class: "product_attachment__btn",
50
+ href: 'tel:' + button.phone_number,
51
+ key: index,
52
+ title: button.title
53
+ }, button.title);
54
+ }
55
+
56
+ if (button.type === 'url_button') {
57
+ return (0, _preact.h)("a", {
58
+ class: "product_attachment__btn",
59
+ href: button.url,
60
+ target: "_blank",
61
+ key: index,
62
+ title: button.title
63
+ }, button.title || this.props.t('detail'), ' ', (0, _preact.h)("img", {
64
+ src: require('../../assets/img/external-link.svg'),
65
+ class: "product_attachment__btn_external_link"
66
+ }));
67
+ }
68
+
69
+ if (button.type === 'postback_button') {
70
+ return (0, _preact.h)("a", {
71
+ class: "product_attachment__btn",
72
+ href: "javascript:;",
73
+ onClick: _ => this.props.onPostback(button)
74
+ }, button.title);
75
+ }
76
+ }));
77
+ }
78
+
43
79
  let $title = (0, _preact.h)("a", {
44
80
  href: url,
45
81
  class: "product_attachment__title",
@@ -68,7 +104,7 @@ class ProductAttachments extends _common.Com {
68
104
  src: this.props.store.replaceFileUrl(product.image)
69
105
  }))), $title, $subtitle, $price, (0, _preact.h)("div", {
70
106
  class: "product_attachment__btns"
71
- }, $detailbtn));
107
+ }, $detailbtns));
72
108
  });
73
109
 
74
110
  return $products;
@@ -41,6 +41,8 @@ class Typing extends _common.Com {
41
41
  return;
42
42
  }
43
43
 
44
+ let ag = this.props.store.matchAgent(ev.by.id);
45
+ if (ag.type == 'agent') return;
44
46
  if (_index.default.get(ev, 'type') !== 'conversation_typing') return;
45
47
  this.setState({
46
48
  ev: ev,
@@ -53,7 +55,7 @@ class Typing extends _common.Com {
53
55
  this.setState({
54
56
  isShow: false
55
57
  });
56
- }, 10000);
58
+ }, 5000);
57
59
  });
58
60
  }
59
61
 
@@ -184,11 +184,13 @@ class Main extends _common.Com {
184
184
  exports.default = Main;
185
185
 
186
186
  function restoreViewport() {
187
+ if (document.body && document.body.classList) document.body.classList.remove('sbz_no_scroll');
187
188
  let metatag = document.getElementById('subiz-meta-viewport');
188
189
  if (metatag) metatag.remove();
189
190
  }
190
191
 
191
192
  function modifyViewport() {
193
+ if (document.body && document.body.classList) document.body.classList.add('sbz_no_scroll');
192
194
  let metatag = document.createElement('meta');
193
195
  metatag.httpEquiv = 'X-UA-Compatible';
194
196
  metatag.name = 'viewport';
@@ -24,7 +24,7 @@ _index.default.preloadWebfonts(['Roboto'], [400, 500]);
24
24
 
25
25
  class Widget {
26
26
  constructor(ApiURL, FileURL, RealtimeURL, inmem, fake, agenttoken) {
27
- _defineProperty(this, "version", () => '4.4');
27
+ _defineProperty(this, "version", () => '4.5');
28
28
 
29
29
  _defineProperty(this, "setSetting", setting => this.store.setSetting({
30
30
  account_setting: setting
@@ -108,7 +108,21 @@ class Widget {
108
108
  }
109
109
 
110
110
  async sendMessage(convoid, message) {
111
- this.store.sendConvoEvent(convoid, 'message_sent', {
111
+ if (!convoid) {
112
+ const {
113
+ convo,
114
+ error
115
+ } = await this.store.startConvo({
116
+ message: message.text,
117
+ initial_by: this.store.matchUser().id
118
+ });
119
+ if (error) return {
120
+ error
121
+ };
122
+ convoid = convo.id;
123
+ }
124
+
125
+ return this.store.sendConvoEvent(convoid, 'message_sent', {
112
126
  message
113
127
  });
114
128
  }
@@ -127,11 +141,11 @@ class Widget {
127
141
  this.pluginMgr.hideCurrentGreeting();
128
142
  }
129
143
 
130
- async showWidget(view, convo) {
144
+ async showWidget(view, cid) {
131
145
  await this.domGate.entry();
132
146
  this.pluginMgr.showCurrentChatbox({
133
147
  view,
134
- cid: convo
148
+ cid: cid
135
149
  });
136
150
  }
137
151
 
@@ -190,7 +190,10 @@ class Store {
190
190
  _defineProperty(this, "setIsOpen", isopen => {
191
191
  let lastisopen = this.kv.match('isopen');
192
192
  this.kv.put('isopen', isopen);
193
- if (!lastisopen && isopen) sendEventToThirdParty('SUBIZ Chat', 'Opened', 'Subiz Windows');
193
+
194
+ if (!lastisopen && isopen) {
195
+ sendEventToThirdParty('SUBIZ Chat', 'Opened', 'Subiz Windows');
196
+ }
194
197
  });
195
198
 
196
199
  _defineProperty(this, "closePreview", () => this.kv.put('close_preview_at', new _index.default.Date().getTime()));
@@ -904,6 +907,20 @@ class Store {
904
907
 
905
908
  this.onWs(ret);
906
909
  sendEventToThirdParty('SUBIZ Chat', 'Sent', 'User');
910
+ let lastMsgSent = this.kv.match('last_msg_sent');
911
+
912
+ if (!lastMsgSent) {
913
+ let dataLayer = window.dataLayer || [];
914
+ dataLayer.push({
915
+ event: 'SUBIZ Chat',
916
+ event_action: 'Sent',
917
+ event_label: 'User',
918
+ first_interaction: 1
919
+ });
920
+ }
921
+
922
+ this.kv.put('last_msg_sent', _index.default.Date.now());
923
+ return ret;
907
924
  }
908
925
 
909
926
  _setConvo(convo) {
@@ -1044,7 +1061,7 @@ class Store {
1044
1061
  async loopTime() {
1045
1062
  let startms = _index.default.Date.now();
1046
1063
 
1047
- if (!_index.default.get(this.kv.match('user'), 'id')) return setTimeout(() => this.loopTime(), 30000);
1064
+ if (!_index.default.get(this.kv.match('user'), 'id')) return setTimeout(() => this.loopTime(), 120000);
1048
1065
  let {
1049
1066
  body: t,
1050
1067
  error
@@ -1056,7 +1073,7 @@ class Store {
1056
1073
  var localMs = _index.default.Date.now();
1057
1074
 
1058
1075
  this.timeDiff = Math.floor(serverMs - localMs);
1059
- setTimeout(() => this.loopTime(), 60000);
1076
+ setTimeout(() => this.loopTime(), 120000);
1060
1077
  }
1061
1078
 
1062
1079
  replaceFileUrl(src) {
@@ -1214,6 +1231,12 @@ function sendEventToThirdParty(category, action, label) {
1214
1231
  }));
1215
1232
  sendToGA(category, action, label);
1216
1233
  sendToFBPixel(category, action, label);
1234
+ let dataLayer = window.dataLayer || [];
1235
+ dataLayer.push({
1236
+ event: category,
1237
+ event_action: action,
1238
+ event_label: label
1239
+ });
1217
1240
  }
1218
1241
 
1219
1242
  let mobileCheck = function (a) {
@@ -422,7 +422,7 @@ function isURL(url) {
422
422
  }
423
423
 
424
424
  function isNumber(num) {
425
- var reg = /^\d+$/;
425
+ var re = /^\d+$/;
426
426
  return re.test(String(num));
427
427
  }
428
428
 
package/dist/132.js CHANGED
@@ -161,8 +161,9 @@ class ChatButton extends common/* Com */.up {
161
161
  let accountSetting = this.props.plugin.chatbox;
162
162
  if (new util/* default.Date */.Z.Date().getTime() - this.props.store.matchClosePreviewAt() < Ms30Mins) return;
163
163
  let greeting = util/* default.get */.Z.get(accountSetting, 'greeting', {});
164
+ let text = this.props.t.i18n(util/* default.get */.Z.get(greeting, 'greeting', {})) || greeting.message;
164
165
 
165
- if (!greeting.message || !greeting.enabled) {
166
+ if (!text || !greeting.enabled) {
166
167
  this.setState({
167
168
  previewEvent: {}
168
169
  });
@@ -2031,17 +2032,53 @@ class ProductAttachments extends common/* Com */.up {
2031
2032
  let acc = this.props.store.matchAccount();
2032
2033
  let $products = util/* default.map */.Z.map(products, (att, index) => {
2033
2034
  let product = att.product;
2034
- let $detailbtn = null;
2035
+ let $detailbtns = [];
2035
2036
  let url = product.url || product.mobile_url;
2036
2037
  if (this.props.store.isMobile()) url = product.mobile_url || product.url;
2037
- if (url) $detailbtn = (0,preact_module.h)("a", {
2038
+ if (url && util/* default.size */.Z.size(product.buttons) == 0) $detailbtns.push((0,preact_module.h)("a", {
2038
2039
  class: "product_attachment__btn",
2039
2040
  href: url,
2040
2041
  target: "_blank"
2041
2042
  }, this.props.t('detail'), (0,preact_module.h)("img", {
2042
2043
  src: __webpack_require__(8453),
2043
2044
  class: "product_attachment__btn_external_link"
2044
- }));
2045
+ })));
2046
+ console.log("P", product);
2047
+
2048
+ if (util/* default.size */.Z.size(product.buttons) > 0) {
2049
+ $detailbtns = $detailbtns.concat(util/* default.map */.Z.map(product.buttons, (button, index) => {
2050
+ if (button.type === 'call_button') {
2051
+ return (0,preact_module.h)("a", {
2052
+ class: "product_attachment__btn",
2053
+ href: 'tel:' + button.phone_number,
2054
+ key: index,
2055
+ title: button.title
2056
+ }, button.title);
2057
+ }
2058
+
2059
+ if (button.type === 'url_button') {
2060
+ return (0,preact_module.h)("a", {
2061
+ class: "product_attachment__btn",
2062
+ href: button.url,
2063
+ target: "_blank",
2064
+ key: index,
2065
+ title: button.title
2066
+ }, button.title || this.props.t('detail'), ' ', (0,preact_module.h)("img", {
2067
+ src: __webpack_require__(8453),
2068
+ class: "product_attachment__btn_external_link"
2069
+ }));
2070
+ }
2071
+
2072
+ if (button.type === 'postback_button') {
2073
+ return (0,preact_module.h)("a", {
2074
+ class: "product_attachment__btn",
2075
+ href: "javascript:;",
2076
+ onClick: _ => this.props.onPostback(button)
2077
+ }, button.title);
2078
+ }
2079
+ }));
2080
+ }
2081
+
2045
2082
  let $title = (0,preact_module.h)("a", {
2046
2083
  href: url,
2047
2084
  class: "product_attachment__title",
@@ -2070,7 +2107,7 @@ class ProductAttachments extends common/* Com */.up {
2070
2107
  src: this.props.store.replaceFileUrl(product.image)
2071
2108
  }))), $title, $subtitle, $price, (0,preact_module.h)("div", {
2072
2109
  class: "product_attachment__btns"
2073
- }, $detailbtn));
2110
+ }, $detailbtns));
2074
2111
  });
2075
2112
  return $products;
2076
2113
  }
@@ -2696,6 +2733,7 @@ class Event extends common/* Com */.up {
2696
2733
  onSelect: e => this.choosePostbackBtn(e)
2697
2734
  }), (0,preact_module.h)(ProductAttachments, {
2698
2735
  t: this.props.t,
2736
+ onPostback: e => this.choosePostbackBtn(e),
2699
2737
  store: this.props.store,
2700
2738
  ev: ev
2701
2739
  }), (0,preact_module.h)(OrderAttachments_ProductAttachments, {
@@ -3149,6 +3187,8 @@ class Typing extends common/* Com */.up {
3149
3187
  return;
3150
3188
  }
3151
3189
 
3190
+ let ag = this.props.store.matchAgent(ev.by.id);
3191
+ if (ag.type == 'agent') return;
3152
3192
  if (util/* default.get */.Z.get(ev, 'type') !== 'conversation_typing') return;
3153
3193
  this.setState({
3154
3194
  ev: ev,
@@ -3161,7 +3201,7 @@ class Typing extends common/* Com */.up {
3161
3201
  this.setState({
3162
3202
  isShow: false
3163
3203
  });
3164
- }, 10000);
3204
+ }, 5000);
3165
3205
  });
3166
3206
  }
3167
3207
 
@@ -6563,11 +6603,13 @@ class Main extends common/* Com */.up {
6563
6603
  }
6564
6604
 
6565
6605
  function restoreViewport() {
6606
+ if (document.body && document.body.classList) document.body.classList.remove('sbz_no_scroll');
6566
6607
  let metatag = document.getElementById('subiz-meta-viewport');
6567
6608
  if (metatag) metatag.remove();
6568
6609
  }
6569
6610
 
6570
6611
  function modifyViewport() {
6612
+ if (document.body && document.body.classList) document.body.classList.add('sbz_no_scroll');
6571
6613
  let metatag = document.createElement('meta');
6572
6614
  metatag.httpEquiv = 'X-UA-Compatible';
6573
6615
  metatag.name = 'viewport';