@subiz/widget-v4 4.0.83 → 4.0.87

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 (85) hide show
  1. package/.prettierrc.js +1 -1
  2. package/compiled_src/chatbox/AgentsAvatar.js +20 -3
  3. package/compiled_src/chatbox/ChatButton.js +11 -8
  4. package/compiled_src/chatbox/Event.js +12 -0
  5. package/compiled_src/chatbox/Events.js +1 -0
  6. package/compiled_src/chatbox/MessageInput.js +6 -0
  7. package/compiled_src/chatbox/Typing.js +1 -1
  8. package/compiled_src/chatbox/Widget.js +50 -38
  9. package/compiled_src/chatbox/main.js +10 -0
  10. package/compiled_src/popup/popup.js +21 -2
  11. package/compiled_src/store/store.js +24 -40
  12. package/compiled_src/util/common.js +10 -10
  13. package/dist/132.js +162 -44
  14. package/dist/178.js +174 -341
  15. package/dist/182ed9b853b.132.js +1 -0
  16. package/dist/182ed9b853b.178.js +1 -0
  17. package/dist/{17f00e48d38.213.js → 182ed9b853b.213.js} +1 -1
  18. package/dist/{17f00e48d38.335.js → 182ed9b853b.335.js} +1 -1
  19. package/dist/182ed9b853b.362.js +1 -0
  20. package/dist/182ed9b853b.441.js +1 -0
  21. package/dist/{17f00e48d38.605.js → 182ed9b853b.605.js} +0 -0
  22. package/dist/182ed9b853b.678.js +1 -0
  23. package/dist/182ed9b853b.782.js +1 -0
  24. package/dist/182ed9b853b.app.js +1 -0
  25. package/dist/{17f00e48d38.index.html → 182ed9b853b.index.html} +7 -3
  26. package/dist/{17f00e48d38.library.html → 182ed9b853b.library.html} +7 -3
  27. package/dist/182ed9b853b.library.js +1 -0
  28. package/dist/{17f00e48d38.preview.html → 182ed9b853b.preview.html} +1 -1
  29. package/dist/182ed9b853b.preview.js +1 -0
  30. package/dist/182ed9b853b.screenshoot.js +1 -0
  31. package/dist/213.js +28 -1
  32. package/dist/335.js +2 -2
  33. package/dist/362.js +21 -71
  34. package/dist/441.js +152 -57
  35. package/dist/678.js +20 -70
  36. package/dist/782.js +21 -118
  37. package/dist/HASH +1 -1
  38. package/dist/screenshoot.html +1 -1
  39. package/dist/screenshoot.js +208 -174
  40. package/index.html +1 -1
  41. package/package.json +16 -16
  42. package/src/chatbox/AgentsAvatar.js +32 -10
  43. package/src/chatbox/ChatButton.js +11 -4
  44. package/src/chatbox/Event.js +23 -4
  45. package/src/chatbox/Events.js +3 -1
  46. package/src/chatbox/MessageInput.js +14 -5
  47. package/src/chatbox/Typing.js +10 -11
  48. package/src/chatbox/Widget.js +17 -11
  49. package/src/chatbox/main.js +8 -1
  50. package/src/popup/popup.js +37 -12
  51. package/src/store/store.js +24 -36
  52. package/src/util/common.js +16 -19
  53. package/dist/0b82fa7e5c3b07b40a44.png +0 -1
  54. package/dist/0f4af006e38ee8b93633.png +0 -1
  55. package/dist/17f00e48d38.132.js +0 -1
  56. package/dist/17f00e48d38.178.js +0 -1
  57. package/dist/17f00e48d38.362.js +0 -1
  58. package/dist/17f00e48d38.441.js +0 -1
  59. package/dist/17f00e48d38.678.js +0 -1
  60. package/dist/17f00e48d38.782.js +0 -1
  61. package/dist/17f00e48d38.app.js +0 -1
  62. package/dist/17f00e48d38.library.js +0 -1
  63. package/dist/17f00e48d38.preview.js +0 -1
  64. package/dist/17f00e48d38.screenshoot.js +0 -1
  65. package/dist/1ea1c6cd21d25176810c.png +0 -1
  66. package/dist/292d42404e1b03398f61.png +0 -1
  67. package/dist/312d376370831b7bea83.png +0 -1
  68. package/dist/313d1bfc1cf776d1aefe.png +0 -1
  69. package/dist/4aa58bb7a66bb44975aa.png +0 -1
  70. package/dist/56ce063bc6c81adb7322.png +0 -1
  71. package/dist/6a411166ef5cc79e0714.png +0 -1
  72. package/dist/6faf403782fefacc1649.png +0 -1
  73. package/dist/79dca33c68fab79c067f.png +0 -1
  74. package/dist/82da1578fa84f9debaeb.png +0 -1
  75. package/dist/8b8e0f0824743974b282.png +0 -1
  76. package/dist/8d551390d81e39130a3c.png +0 -1
  77. package/dist/9fc61b9479877ebdb6c7.png +0 -1
  78. package/dist/a165d31dcb3dc90f1057.png +0 -1
  79. package/dist/a98d4a5698812c4426b3.png +0 -1
  80. package/dist/c41606bf9d1b604e46d5.png +0 -1
  81. package/dist/ce1f7450ce6c1aacd330.png +0 -1
  82. package/dist/cf8c01e88f4770a6e3e5.png +0 -1
  83. package/dist/dfbcfeab1d5622a737e2.png +0 -1
  84. package/dist/e4893ed8c2f7b8329919.png +0 -1
  85. package/dist/ec2ab4eb4ef73d186186.png +0 -1
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
  });
@@ -257,21 +258,17 @@ class ChatButton extends common/* Com */.up {
257
258
  }
258
259
 
259
260
  onProfileReady() {
260
- if (this.state.buttonLoaded) this.setState({
261
+ if (this._buttonLoaded) this.setState({
261
262
  opacity: 1
262
263
  });
263
- this.setState({
264
- profileLoaded: true
265
- });
264
+ this._profileLoaded = true;
266
265
  }
267
266
 
268
267
  onButtonReady() {
269
- if (this.state.profileLoaded) this.setState({
268
+ if (this._profileLoaded) this.setState({
270
269
  opacity: 1
271
270
  });
272
- this.setState({
273
- buttonLoaded: true
274
- });
271
+ this._buttonLoaded = true;
275
272
  }
276
273
 
277
274
  renderButton() {
@@ -1295,7 +1292,7 @@ class Buttons extends common/* Com */.up {
1295
1292
  href: 'tel:' + button.phone_number,
1296
1293
  key: index,
1297
1294
  title: button.title
1298
- }, button.title);
1295
+ }, this.props.t.i18n(button.i18n_title) || button.title);
1299
1296
  }
1300
1297
 
1301
1298
  if (button.type === 'url_button') {
@@ -1305,7 +1302,7 @@ class Buttons extends common/* Com */.up {
1305
1302
  target: "_blank",
1306
1303
  key: index,
1307
1304
  title: button.title
1308
- }, button.title || button.url);
1305
+ }, this.props.t.i18n(button.i18n_title) || button.title || button.url);
1309
1306
  }
1310
1307
 
1311
1308
  if (button.type === 'postback_button') {
@@ -1313,7 +1310,7 @@ class Buttons extends common/* Com */.up {
1313
1310
  class: "url-button-attachment",
1314
1311
  href: "javascript:;",
1315
1312
  onClick: _ => this.props.onSelect(button)
1316
- }, button.title);
1313
+ }, this.props.t.i18n(button.i18n_title) || button.title);
1317
1314
  }
1318
1315
 
1319
1316
  if (button.type === 'widget_ask_desktop_notify_button') return null;
@@ -1347,7 +1344,8 @@ class ButtonAttachments extends common/* Com */.up {
1347
1344
  });
1348
1345
  return (0,preact_module.h)(Buttons, {
1349
1346
  store: this.props.store,
1350
- buttons: buttons
1347
+ buttons: buttons,
1348
+ t: this.props.t
1351
1349
  });
1352
1350
  }
1353
1351
 
@@ -1956,7 +1954,10 @@ class GenericTemplateAttachments extends common/* Com */.up {
1956
1954
  this.setState({
1957
1955
  focusing: eleindex
1958
1956
  });
1959
- this.galleryRef.current.scrollLeft = 190 * eleindex - 20;
1957
+ this.galleryRef.current.scrollTo({
1958
+ left: 220 * eleindex,
1959
+ behavior: 'smooth'
1960
+ });
1960
1961
  }
1961
1962
 
1962
1963
  render() {
@@ -1967,21 +1968,26 @@ class GenericTemplateAttachments extends common/* Com */.up {
1967
1968
  if (generics.length === 0) return null;
1968
1969
  var $generics = util/* default.map */.Z.map(generics, (gen, index) => {
1969
1970
  var $eles = util/* default.map */.Z.map(gen.elements, ele => {
1970
- let $title = ele.title ? (0,preact_module.h)("div", {
1971
+ let title = this.props.t.i18n(ele.i18n_title) || ele.title;
1972
+ let subtitle = this.props.t.i18n(ele.i18n_subtitle) || ele.subtitle;
1973
+ let $title = title ? (0,preact_module.h)("div", {
1971
1974
  class: "generic-attachment--element-title"
1972
- }, ele.title) : null;
1973
- let $subtitle = ele.subtitle ? (0,preact_module.h)("div", {
1975
+ }, title) : null;
1976
+ let $subtitle = subtitle ? (0,preact_module.h)("div", {
1974
1977
  class: "generic-attachment--element-subtitle"
1975
- }, ele.subtitle) : null;
1978
+ }, subtitle) : null;
1976
1979
  return (0,preact_module.h)("div", {
1977
1980
  class: "generic-attachment--element swiper-slide"
1978
1981
  }, (0,preact_module.h)("div", null, (0,preact_module.h)("img", {
1979
1982
  alt: "generic attachment element",
1980
1983
  class: "generic-attachment--element-img",
1981
1984
  src: this.props.store.replaceFileUrl(ele.image_url)
1982
- })), $title, $subtitle, (0,preact_module.h)(Buttons, {
1985
+ })), (0,preact_module.h)("div", {
1986
+ class: "generic-attachment--element-content"
1987
+ }, $title, $subtitle), (0,preact_module.h)(Buttons, {
1983
1988
  buttons: ele.buttons,
1984
- onSelect: button => this.props.onSelect(button)
1989
+ onSelect: button => this.props.onSelect(button),
1990
+ t: this.props.t
1985
1991
  }));
1986
1992
  });
1987
1993
  let elements = util/* default.get */.Z.get(attachments, '0.elements', []);
@@ -2031,17 +2037,53 @@ class ProductAttachments extends common/* Com */.up {
2031
2037
  let acc = this.props.store.matchAccount();
2032
2038
  let $products = util/* default.map */.Z.map(products, (att, index) => {
2033
2039
  let product = att.product;
2034
- let $detailbtn = null;
2040
+ let $detailbtns = [];
2035
2041
  let url = product.url || product.mobile_url;
2036
2042
  if (this.props.store.isMobile()) url = product.mobile_url || product.url;
2037
- if (url) $detailbtn = (0,preact_module.h)("a", {
2043
+ if (url && util/* default.size */.Z.size(product.buttons) == 0) $detailbtns.push((0,preact_module.h)("a", {
2038
2044
  class: "product_attachment__btn",
2039
2045
  href: url,
2040
2046
  target: "_blank"
2041
2047
  }, this.props.t('detail'), (0,preact_module.h)("img", {
2042
2048
  src: __webpack_require__(8453),
2043
2049
  class: "product_attachment__btn_external_link"
2044
- }));
2050
+ })));
2051
+ console.log('P', product);
2052
+
2053
+ if (util/* default.size */.Z.size(product.buttons) > 0) {
2054
+ $detailbtns = $detailbtns.concat(util/* default.map */.Z.map(product.buttons, (button, index) => {
2055
+ if (button.type === 'call_button') {
2056
+ return (0,preact_module.h)("a", {
2057
+ class: "product_attachment__btn",
2058
+ href: 'tel:' + button.phone_number,
2059
+ key: index,
2060
+ title: button.title
2061
+ }, this.props.t.i18n(button.i18n_title) || button.title);
2062
+ }
2063
+
2064
+ if (button.type === 'url_button') {
2065
+ return (0,preact_module.h)("a", {
2066
+ class: "product_attachment__btn",
2067
+ href: button.url,
2068
+ target: "_blank",
2069
+ key: index,
2070
+ title: button.title
2071
+ }, this.props.t.i18n(button.i18n_title) || button.title || this.props.t('detail'), ' ', (0,preact_module.h)("img", {
2072
+ src: __webpack_require__(8453),
2073
+ class: "product_attachment__btn_external_link"
2074
+ }));
2075
+ }
2076
+
2077
+ if (button.type === 'postback_button') {
2078
+ return (0,preact_module.h)("a", {
2079
+ class: "product_attachment__btn",
2080
+ href: "javascript:;",
2081
+ onClick: _ => this.props.onPostback(button)
2082
+ }, this.props.t.i18n(button.i18n_title) || button.title);
2083
+ }
2084
+ }));
2085
+ }
2086
+
2045
2087
  let $title = (0,preact_module.h)("a", {
2046
2088
  href: url,
2047
2089
  class: "product_attachment__title",
@@ -2070,7 +2112,7 @@ class ProductAttachments extends common/* Com */.up {
2070
2112
  src: this.props.store.replaceFileUrl(product.image)
2071
2113
  }))), $title, $subtitle, $price, (0,preact_module.h)("div", {
2072
2114
  class: "product_attachment__btns"
2073
- }, $detailbtn));
2115
+ }, $detailbtns));
2074
2116
  });
2075
2117
  return $products;
2076
2118
  }
@@ -2226,8 +2268,7 @@ img { max-width: 100%; display: block; margin: 10px auto; }
2226
2268
  * { white-space: normal }
2227
2269
  ul > li { margin-bottom: 5px }
2228
2270
  ul:last-child { margin-bottom: 0 }
2229
- p:first-child { margin-top: 0;}
2230
- p:last-child { margin-bottom: 0;}
2271
+ p { margin-bottom: 0; margin-top: 0;}
2231
2272
  </style>
2232
2273
  <div>${html}</div>`;
2233
2274
  let links = this.shadowRoot.querySelectorAll('a');
@@ -2271,6 +2312,11 @@ class TextMessage extends common/* Com */.up {
2271
2312
  render() {
2272
2313
  var format = util/* default.get */.Z.get(this.props.ev, 'data.message.format', 'plaintext');
2273
2314
  if (format === 'markdown') return this.renderMarkdown();
2315
+ if (format === 'delta') return this.renderDelta();
2316
+ return this.renderPlainText();
2317
+ }
2318
+
2319
+ renderPlainText() {
2274
2320
  var text = util/* default.get */.Z.get(this.props.ev, 'data.message.text');
2275
2321
  text = util/* default.trim */.Z.trim(text);
2276
2322
  if (util/* default.size */.Z.size(text) === 0) return null;
@@ -2316,8 +2362,22 @@ class TextMessage extends common/* Com */.up {
2316
2362
  }, tags);
2317
2363
  }
2318
2364
 
2319
- renderMarkdown() {
2320
- var text = util/* default.get */.Z.get(this.props.ev, 'data.message.text');
2365
+ renderDelta() {
2366
+ let deltas = util/* default.get */.Z.get(this.props.ev, 'data.message.quill_delta');
2367
+ deltas = util/* default.parseJSON */.Z.parseJSON(deltas) || {};
2368
+ deltas = deltas.ops || [];
2369
+ let isMarkdown = util/* default.find */.Z.find(deltas, delta => util/* default.get */.Z.get(delta, 'attributes.bold') || util/* default.get */.Z.get(delta, 'attributes.italic') || util/* default.get */.Z.get(delta, 'attributes.underline') || util/* default.get */.Z.get(delta, 'insert.emoji'));
2370
+
2371
+ if (isMarkdown) {
2372
+ var text = deltaToMarkdown(deltas);
2373
+ return this.renderMarkdown(text);
2374
+ }
2375
+
2376
+ return this.renderPlainText();
2377
+ }
2378
+
2379
+ renderMarkdown(text) {
2380
+ if (!text) text = util/* default.get */.Z.get(this.props.ev, 'data.message.text');
2321
2381
  if (util/* default.size */.Z.size(text) === 0) return null;
2322
2382
  let byType = util/* default.get */.Z.get(this.props.ev, 'by.type');
2323
2383
  text = util/* default.trim */.Z.trim(text);
@@ -2341,6 +2401,48 @@ class TextMessage extends common/* Com */.up {
2341
2401
  }
2342
2402
 
2343
2403
  }
2404
+
2405
+ function deltaToMarkdown(deltas) {
2406
+ let output = '';
2407
+ util/* default.each */.Z.each(deltas, (delta, idx) => {
2408
+ let text = '';
2409
+ let insert = delta.insert;
2410
+ let attributes = delta.attributes;
2411
+ if (insert.emoji) text = emojiCodes[insert.emoji] || '';
2412
+
2413
+ if (attributes) {
2414
+ if (attributes.italic && attributes.bold) text = `*__${insert}__*`;else if (attributes.italic) text = `*${insert}*`;else if (attributes.bold) text = `**${insert}**`;else text = insert;
2415
+ }
2416
+
2417
+ if (insert.dynamicField) text = `${util/* default.get */.Z.get(insert, 'dynamicField.text', '')}`;
2418
+
2419
+ if (!insert.emoji && !attributes && !insert.dynamicField) {
2420
+ text = insert || '';
2421
+ text = text.replace(/\n/g, '<br/>');
2422
+ }
2423
+
2424
+ output += text;
2425
+ });
2426
+ return output;
2427
+ }
2428
+
2429
+ const emojiCodes = {
2430
+ like: '👍',
2431
+ unlike: '👎',
2432
+ angry: '😠',
2433
+ confused: '😕',
2434
+ crying: '😢',
2435
+ grinning: '😀',
2436
+ 'heart-eyes': '😍',
2437
+ neutral: '😐',
2438
+ sleepy: '😪',
2439
+ sad: '😞',
2440
+ smiling: '😄',
2441
+ 'tongue-out': '😛',
2442
+ tired: '😩',
2443
+ surprised: '😮',
2444
+ wink: '😉'
2445
+ };
2344
2446
  ;// CONCATENATED MODULE: ./src/chatbox/time.js
2345
2447
 
2346
2448
  var g_pub = new util/* default.Pubsub */.Z.Pubsub();
@@ -2679,7 +2781,8 @@ class Event extends common/* Com */.up {
2679
2781
  ev: ev
2680
2782
  }), (0,preact_module.h)(ButtonAttachments, {
2681
2783
  store: this.props.store,
2682
- ev: ev
2784
+ ev: ev,
2785
+ t: this.props.t
2683
2786
  }), (0,preact_module.h)(FormAttachments, {
2684
2787
  store: this.props.store,
2685
2788
  onSubmit: this.props.onFormSubmit,
@@ -2693,9 +2796,11 @@ class Event extends common/* Com */.up {
2693
2796
  }), (0,preact_module.h)(GenericTemplateAttachments, {
2694
2797
  store: this.props.store,
2695
2798
  ev: ev,
2696
- onSelect: e => this.choosePostbackBtn(e)
2799
+ onSelect: e => this.choosePostbackBtn(e),
2800
+ t: this.props.t
2697
2801
  }), (0,preact_module.h)(ProductAttachments, {
2698
2802
  t: this.props.t,
2803
+ onPostback: e => this.choosePostbackBtn(e),
2699
2804
  store: this.props.store,
2700
2805
  ev: ev
2701
2806
  }), (0,preact_module.h)(OrderAttachments_ProductAttachments, {
@@ -2767,7 +2872,8 @@ class Event extends common/* Com */.up {
2767
2872
  ev: ev
2768
2873
  }), (0,preact_module.h)(ButtonAttachments, {
2769
2874
  store: this.props.store,
2770
- ev: ev
2875
+ ev: ev,
2876
+ t: this.props.t
2771
2877
  }), (0,preact_module.h)(FormAttachments, {
2772
2878
  store: this.props.store,
2773
2879
  onSubmit: this.props.onFormSubmit,
@@ -3149,6 +3255,8 @@ class Typing extends common/* Com */.up {
3149
3255
  return;
3150
3256
  }
3151
3257
 
3258
+ let ag = this.props.store.matchAgent(ev.by.id) || {};
3259
+ if (ag.type == 'agent') return;
3152
3260
  if (util/* default.get */.Z.get(ev, 'type') !== 'conversation_typing') return;
3153
3261
  this.setState({
3154
3262
  ev: ev,
@@ -3161,7 +3269,7 @@ class Typing extends common/* Com */.up {
3161
3269
  this.setState({
3162
3270
  isShow: false
3163
3271
  });
3164
- }, 10000);
3272
+ }, 5000);
3165
3273
  });
3166
3274
  }
3167
3275
 
@@ -4061,6 +4169,7 @@ class order_Order extends common/* Com */.up {
4061
4169
  loading: true,
4062
4170
  order: {},
4063
4171
  err: {},
4172
+ shipping_address: 'new',
4064
4173
  selectedProvince: null,
4065
4174
  selectedDistrict: null,
4066
4175
  selectedWard: null,
@@ -4353,16 +4462,17 @@ class order_Order extends common/* Com */.up {
4353
4462
 
4354
4463
  order_defineProperty(this, "onCancel", () => {
4355
4464
  if (this.props.onResponse) this.props.onResponse('rejected');
4356
- this.close();
4357
- });
4358
4465
 
4359
- order_defineProperty(this, "close", () => {
4360
4466
  if (this.props.cid && !this.state.order.user_confirmation) {
4361
4467
  let order = util/* default.cloneDeep */.Z.cloneDeep(this.state.order);
4362
4468
  order.user_confirmation = 'rejected';
4363
4469
  this.props.store.updateOrder(order);
4364
4470
  }
4365
4471
 
4472
+ this.close();
4473
+ });
4474
+
4475
+ order_defineProperty(this, "close", () => {
4366
4476
  if (this.props.onClose) this.props.onClose();
4367
4477
  });
4368
4478
 
@@ -4432,7 +4542,7 @@ class order_Order extends common/* Com */.up {
4432
4542
  return null;
4433
4543
  let editmode = false;
4434
4544
 
4435
- if (!order.status || order.status == 'new') {
4545
+ if (!order.status || order.status == 'open') {
4436
4546
  editmode = !order.user_confirmation;
4437
4547
  }
4438
4548
 
@@ -4523,7 +4633,7 @@ class order_Order extends common/* Com */.up {
4523
4633
  renderDesktopShipping(order) {
4524
4634
  let editmode = false;
4525
4635
 
4526
- if (!order.status || order.status == 'new') {
4636
+ if (!order.status || order.status == 'open') {
4527
4637
  editmode = !order.user_confirmation;
4528
4638
  }
4529
4639
 
@@ -4824,7 +4934,7 @@ class order_Order extends common/* Com */.up {
4824
4934
  }, (0,preact_module.h)("div", null, "Ph\xED v\u1EADn chuy\u1EC3n"), (0,preact_module.h)("div", null, util/* default.get */.Z.get(order, 'shipping.fee', 0), " d"));
4825
4935
  let editmode = false;
4826
4936
 
4827
- if (!order.status || order.status == 'new') {
4937
+ if (!order.status || order.status == 'open') {
4828
4938
  editmode = !order.user_confirmation;
4829
4939
  }
4830
4940
 
@@ -4860,7 +4970,7 @@ class order_Order extends common/* Com */.up {
4860
4970
  }
4861
4971
 
4862
4972
  renderStatusBadge(order) {
4863
- let status = order.status || 'new';
4973
+ let status = order.status || 'open';
4864
4974
  return (0,preact_module.h)("div", {
4865
4975
  style: "float: right !important;",
4866
4976
  class: 'order_status order_status__' + status
@@ -4868,7 +4978,7 @@ class order_Order extends common/* Com */.up {
4868
4978
  }
4869
4979
 
4870
4980
  renderShippingInfo(order) {
4871
- if (order.status != 'new' || order.user_confirmation) {}
4981
+ if (order.status != 'open' || order.user_confirmation) {}
4872
4982
 
4873
4983
  let shipping_provider = util/* default.get */.Z.get(order, 'shipping.shipping_provider');
4874
4984
  if (!shipping_provider) return null;
@@ -4968,7 +5078,7 @@ class order_Order extends common/* Com */.up {
4968
5078
  let $products = null;
4969
5079
  let editmode = false;
4970
5080
 
4971
- if (!order.status || order.status == 'new') {
5081
+ if (!order.status || order.status == 'open') {
4972
5082
  editmode = !order.user_confirmation;
4973
5083
  }
4974
5084
 
@@ -5072,7 +5182,7 @@ class order_Order extends common/* Com */.up {
5072
5182
  onClick: this.onCancel
5073
5183
  }, this.props.t('cancel_order'));
5074
5184
 
5075
- if (order.user_confirmation || order.status != 'new') {
5185
+ if (order.user_confirmation || order.status != 'open') {
5076
5186
  $status = null;
5077
5187
  if (this.props.cid) $close = (0,preact_module.h)("div", {
5078
5188
  class: "order_btn order__btn__light mt-3",
@@ -5104,7 +5214,7 @@ class order_Order extends common/* Com */.up {
5104
5214
  let $actions = null;
5105
5215
  let editmode = false;
5106
5216
 
5107
- if (!order.status || order.status == 'new') {
5217
+ if (!order.status || order.status == 'open') {
5108
5218
  editmode = !order.user_confirmation;
5109
5219
  }
5110
5220
 
@@ -5644,17 +5754,23 @@ class Widget extends common/* Com */.up {
5644
5754
  if (hasError) return this.forceUpdate();
5645
5755
  let data = util/* default.cloneDeep */.Z.cloneDeep(this.state.formData);
5646
5756
  let user = util/* default.cloneDeep */.Z.cloneDeep(this.props.store.matchUser());
5757
+ let is_lead = false;
5647
5758
  util/* default.map */.Z.map(data, (field, key) => {
5648
5759
  if (!key.startsWith('attr:')) return;
5649
5760
  var attr = {
5650
5761
  key: key.substr(5)
5651
5762
  };
5763
+ is_lead = is_lead || key == 'emails' || key == 'phones';
5652
5764
  if (field.type === 'number') attr.number = parseInt(field.value);
5653
5765
  if (field.type === 'datetime') attr.datetime = new util/* default.Date */.Z.Date(field.value).toISOString();
5654
5766
  if (field.type === 'list') attr.list = field.value;
5655
5767
  if (field.type === 'text' || field.type === 'boolean') attr[field.type] = field.value;
5656
5768
  util/* default.setUserAttr */.Z.setUserAttr(user, attr);
5657
5769
  });
5770
+ if (is_lead) util/* default.setUserAttr */.Z.setUserAttr(user, {
5771
+ key: 'lead_source',
5772
+ text: 'widget'
5773
+ });
5658
5774
  let firstmsg = util/* default.get */.Z.get(data, 'question.value');
5659
5775
  let groupid = util/* default.get */.Z.get(data, 'group.value', '');
5660
5776
 
@@ -5693,11 +5809,11 @@ class Widget extends common/* Com */.up {
5693
5809
  this.setState({
5694
5810
  creatingError: null
5695
5811
  });
5812
+ await this.props.store.setUser(user);
5696
5813
  const {
5697
5814
  error,
5698
5815
  convo
5699
5816
  } = await this.props.store.startConvo(req);
5700
- this.props.store.setUser(user);
5701
5817
 
5702
5818
  if (error) {
5703
5819
  this.setState({
@@ -6563,11 +6679,13 @@ class Main extends common/* Com */.up {
6563
6679
  }
6564
6680
 
6565
6681
  function restoreViewport() {
6682
+ if (document.body && document.body.classList) document.body.classList.remove('sbz_no_scroll');
6566
6683
  let metatag = document.getElementById('subiz-meta-viewport');
6567
6684
  if (metatag) metatag.remove();
6568
6685
  }
6569
6686
 
6570
6687
  function modifyViewport() {
6688
+ if (document.body && document.body.classList) document.body.classList.add('sbz_no_scroll');
6571
6689
  let metatag = document.createElement('meta');
6572
6690
  metatag.httpEquiv = 'X-UA-Compatible';
6573
6691
  metatag.name = 'viewport';