@subiz/widget-v4 4.0.89 → 4.0.91

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 (67) hide show
  1. package/compiled_src/chatbox/Event.js +3 -4
  2. package/compiled_src/chatbox/TextMessage.js +110 -9
  3. package/compiled_src/chatbox/Widget.js +11 -10
  4. package/dist/0b82fa7e5c3b07b40a44.png +1 -0
  5. package/dist/0f4af006e38ee8b93633.png +1 -0
  6. package/dist/132.js +84 -302
  7. package/dist/178.js +341 -174
  8. package/dist/17f00e48d38.132.js +1 -0
  9. package/dist/17f00e48d38.178.js +1 -0
  10. package/dist/{1833a09e682.213.js → 17f00e48d38.213.js} +1 -1
  11. package/dist/{1833a09e682.335.js → 17f00e48d38.335.js} +1 -1
  12. package/dist/17f00e48d38.362.js +1 -0
  13. package/dist/17f00e48d38.441.js +1 -0
  14. package/dist/{1833a09e682.605.js → 17f00e48d38.605.js} +0 -0
  15. package/dist/17f00e48d38.678.js +1 -0
  16. package/dist/17f00e48d38.782.js +1 -0
  17. package/dist/17f00e48d38.app.js +1 -0
  18. package/dist/{1833a09e682.index.html → 17f00e48d38.index.html} +3 -7
  19. package/dist/{1833a09e682.library.html → 17f00e48d38.library.html} +3 -7
  20. package/dist/17f00e48d38.library.js +1 -0
  21. package/dist/{1833a09e682.preview.html → 17f00e48d38.preview.html} +1 -1
  22. package/dist/17f00e48d38.preview.js +1 -0
  23. package/dist/17f00e48d38.screenshoot.js +1 -0
  24. package/dist/1ea1c6cd21d25176810c.png +1 -0
  25. package/dist/213.js +1 -28
  26. package/dist/292d42404e1b03398f61.png +1 -0
  27. package/dist/312d376370831b7bea83.png +1 -0
  28. package/dist/313d1bfc1cf776d1aefe.png +1 -0
  29. package/dist/335.js +2 -2
  30. package/dist/362.js +71 -21
  31. package/dist/441.js +100 -202
  32. package/dist/4aa58bb7a66bb44975aa.png +1 -0
  33. package/dist/56ce063bc6c81adb7322.png +1 -0
  34. package/dist/678.js +70 -20
  35. package/dist/6a411166ef5cc79e0714.png +1 -0
  36. package/dist/6faf403782fefacc1649.png +1 -0
  37. package/dist/782.js +118 -21
  38. package/dist/79dca33c68fab79c067f.png +1 -0
  39. package/dist/82da1578fa84f9debaeb.png +1 -0
  40. package/dist/8b8e0f0824743974b282.png +1 -0
  41. package/dist/8d551390d81e39130a3c.png +1 -0
  42. package/dist/9fc61b9479877ebdb6c7.png +1 -0
  43. package/dist/HASH +1 -1
  44. package/dist/a165d31dcb3dc90f1057.png +1 -0
  45. package/dist/a98d4a5698812c4426b3.png +1 -0
  46. package/dist/c41606bf9d1b604e46d5.png +1 -0
  47. package/dist/ce1f7450ce6c1aacd330.png +1 -0
  48. package/dist/cf8c01e88f4770a6e3e5.png +1 -0
  49. package/dist/dfbcfeab1d5622a737e2.png +1 -0
  50. package/dist/e4893ed8c2f7b8329919.png +1 -0
  51. package/dist/ec2ab4eb4ef73d186186.png +1 -0
  52. package/dist/screenshoot.html +1 -1
  53. package/dist/screenshoot.js +174 -208
  54. package/package.json +5 -5
  55. package/src/chatbox/Event.js +3 -4
  56. package/src/chatbox/TextMessage.js +88 -15
  57. package/src/chatbox/Widget.js +10 -9
  58. package/dist/1833a09e682.132.js +0 -1
  59. package/dist/1833a09e682.178.js +0 -1
  60. package/dist/1833a09e682.362.js +0 -1
  61. package/dist/1833a09e682.441.js +0 -1
  62. package/dist/1833a09e682.678.js +0 -1
  63. package/dist/1833a09e682.782.js +0 -1
  64. package/dist/1833a09e682.app.js +0 -1
  65. package/dist/1833a09e682.library.js +0 -1
  66. package/dist/1833a09e682.preview.js +0 -1
  67. package/dist/1833a09e682.screenshoot.js +0 -1
package/dist/132.js CHANGED
@@ -161,9 +161,8 @@ 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;
165
164
 
166
- if (!text || !greeting.enabled) {
165
+ if (!greeting.message || !greeting.enabled) {
167
166
  this.setState({
168
167
  previewEvent: {}
169
168
  });
@@ -225,13 +224,6 @@ class ChatButton extends common/* Com */.up {
225
224
  position = util/* default.get */.Z.get(accountSetting, 'mobile_button.position') || position;
226
225
  }
227
226
 
228
- if (accountSetting && accountSetting.hide_agent_profile) {
229
- agent = Object.assign({}, account, {
230
- avatar_url: account.logo_url || __webpack_require__(9895),
231
- fullname: account.name || this.props.t('agent')
232
- });
233
- }
234
-
235
227
  let cls = 'widget-preview widget-preview--' + position;
236
228
  if (!this.state.displayPreview) cls += ' widget-preview--hidden';
237
229
  var tags = this.renderMessagePreview(this.state.previewEvent, this.props.t('sent_you_a_message'));
@@ -265,17 +257,21 @@ class ChatButton extends common/* Com */.up {
265
257
  }
266
258
 
267
259
  onProfileReady() {
268
- if (this._buttonLoaded) this.setState({
260
+ if (this.state.buttonLoaded) this.setState({
269
261
  opacity: 1
270
262
  });
271
- this._profileLoaded = true;
263
+ this.setState({
264
+ profileLoaded: true
265
+ });
272
266
  }
273
267
 
274
268
  onButtonReady() {
275
- if (this._profileLoaded) this.setState({
269
+ if (this.state.profileLoaded) this.setState({
276
270
  opacity: 1
277
271
  });
278
- this._buttonLoaded = true;
272
+ this.setState({
273
+ buttonLoaded: true
274
+ });
279
275
  }
280
276
 
281
277
  renderButton() {
@@ -465,26 +461,6 @@ class AgentsAvatar extends common/* Com */.up {
465
461
 
466
462
  render() {
467
463
  let accountSetting = this.props.plugin.chatbox;
468
- let acc = this.props.store.matchAccount();
469
- var tooltippos = this.props.tooltipPos || 'bottom';
470
- var mode = this.props.mode || 'primary';
471
-
472
- if (accountSetting && accountSetting.hide_agent_profile) {
473
- return (0,preact_module.h)("div", {
474
- class: `group-avatar group-avatar--${mode}`
475
- }, (0,preact_module.h)("div", {
476
- class: "d-inline-block pos-relative",
477
- "data-tooltip": acc.name,
478
- "data-tooltip-position": tooltippos
479
- }, (0,preact_module.h)("img", {
480
- width: 35,
481
- height: 35,
482
- alt: "agent avatar left",
483
- class: "avatar group-avatar--agent-left",
484
- src: this.props.store.replaceFileUrl(acc.logo_url) || __webpack_require__(9895)
485
- })));
486
- }
487
-
488
464
  let agentM = this.props.store.matchAgent('*');
489
465
  var agents = util/* default.map */.Z.map(this.props.agent_ids, id => agentM[id]);
490
466
 
@@ -500,6 +476,9 @@ class AgentsAvatar extends common/* Com */.up {
500
476
  }
501
477
 
502
478
  agents = util/* default.filter */.Z.filter(agents, ag => !!ag);
479
+ let acc = this.props.store.matchAccount();
480
+ var tooltippos = this.props.tooltipPos || 'bottom';
481
+ var mode = this.props.mode || 'primary';
503
482
 
504
483
  if (agents.length === 0) {
505
484
  return (0,preact_module.h)("div", {
@@ -860,12 +839,6 @@ class MessageInput extends common/* Com */.up {
860
839
  }, 5);
861
840
  }
862
841
 
863
- blur() {
864
- const $input = this.refMessageInput.current;
865
- if (!$input) return;
866
- $input.blur();
867
- }
868
-
869
842
  render() {
870
843
  var buttons = (0,preact_module.h)("div", {
871
844
  class: "d-flex flex-row align-self-end"
@@ -1322,7 +1295,7 @@ class Buttons extends common/* Com */.up {
1322
1295
  href: 'tel:' + button.phone_number,
1323
1296
  key: index,
1324
1297
  title: button.title
1325
- }, this.props.t.i18n(button.i18n_title) || button.title);
1298
+ }, button.title);
1326
1299
  }
1327
1300
 
1328
1301
  if (button.type === 'url_button') {
@@ -1332,7 +1305,7 @@ class Buttons extends common/* Com */.up {
1332
1305
  target: "_blank",
1333
1306
  key: index,
1334
1307
  title: button.title
1335
- }, this.props.t.i18n(button.i18n_title) || button.title || button.url);
1308
+ }, button.title || button.url);
1336
1309
  }
1337
1310
 
1338
1311
  if (button.type === 'postback_button') {
@@ -1340,7 +1313,7 @@ class Buttons extends common/* Com */.up {
1340
1313
  class: "url-button-attachment",
1341
1314
  href: "javascript:;",
1342
1315
  onClick: _ => this.props.onSelect(button)
1343
- }, this.props.t.i18n(button.i18n_title) || button.title);
1316
+ }, button.title);
1344
1317
  }
1345
1318
 
1346
1319
  if (button.type === 'widget_ask_desktop_notify_button') return null;
@@ -1374,8 +1347,7 @@ class ButtonAttachments extends common/* Com */.up {
1374
1347
  });
1375
1348
  return (0,preact_module.h)(Buttons, {
1376
1349
  store: this.props.store,
1377
- buttons: buttons,
1378
- t: this.props.t
1350
+ buttons: buttons
1379
1351
  });
1380
1352
  }
1381
1353
 
@@ -1984,10 +1956,7 @@ class GenericTemplateAttachments extends common/* Com */.up {
1984
1956
  this.setState({
1985
1957
  focusing: eleindex
1986
1958
  });
1987
- this.galleryRef.current.scrollTo({
1988
- left: 220 * eleindex,
1989
- behavior: 'smooth'
1990
- });
1959
+ this.galleryRef.current.scrollLeft = 190 * eleindex - 20;
1991
1960
  }
1992
1961
 
1993
1962
  render() {
@@ -1998,26 +1967,21 @@ class GenericTemplateAttachments extends common/* Com */.up {
1998
1967
  if (generics.length === 0) return null;
1999
1968
  var $generics = util/* default.map */.Z.map(generics, (gen, index) => {
2000
1969
  var $eles = util/* default.map */.Z.map(gen.elements, ele => {
2001
- let title = this.props.t.i18n(ele.i18n_title) || ele.title;
2002
- let subtitle = this.props.t.i18n(ele.i18n_subtitle) || ele.subtitle;
2003
- let $title = title ? (0,preact_module.h)("div", {
1970
+ let $title = ele.title ? (0,preact_module.h)("div", {
2004
1971
  class: "generic-attachment--element-title"
2005
- }, title) : null;
2006
- let $subtitle = subtitle ? (0,preact_module.h)("div", {
1972
+ }, ele.title) : null;
1973
+ let $subtitle = ele.subtitle ? (0,preact_module.h)("div", {
2007
1974
  class: "generic-attachment--element-subtitle"
2008
- }, subtitle) : null;
1975
+ }, ele.subtitle) : null;
2009
1976
  return (0,preact_module.h)("div", {
2010
1977
  class: "generic-attachment--element swiper-slide"
2011
1978
  }, (0,preact_module.h)("div", null, (0,preact_module.h)("img", {
2012
1979
  alt: "generic attachment element",
2013
1980
  class: "generic-attachment--element-img",
2014
1981
  src: this.props.store.replaceFileUrl(ele.image_url)
2015
- })), (0,preact_module.h)("div", {
2016
- class: "generic-attachment--element-content"
2017
- }, $title, $subtitle), (0,preact_module.h)(Buttons, {
1982
+ })), $title, $subtitle, (0,preact_module.h)(Buttons, {
2018
1983
  buttons: ele.buttons,
2019
- onSelect: button => this.props.onSelect(button),
2020
- t: this.props.t
1984
+ onSelect: button => this.props.onSelect(button)
2021
1985
  }));
2022
1986
  });
2023
1987
  let elements = util/* default.get */.Z.get(attachments, '0.elements', []);
@@ -2067,53 +2031,17 @@ class ProductAttachments extends common/* Com */.up {
2067
2031
  let acc = this.props.store.matchAccount();
2068
2032
  let $products = util/* default.map */.Z.map(products, (att, index) => {
2069
2033
  let product = att.product;
2070
- let $detailbtns = [];
2034
+ let $detailbtn = null;
2071
2035
  let url = product.url || product.mobile_url;
2072
2036
  if (this.props.store.isMobile()) url = product.mobile_url || product.url;
2073
- if (url && util/* default.size */.Z.size(product.buttons) == 0) $detailbtns.push((0,preact_module.h)("a", {
2037
+ if (url) $detailbtn = (0,preact_module.h)("a", {
2074
2038
  class: "product_attachment__btn",
2075
2039
  href: url,
2076
2040
  target: "_blank"
2077
2041
  }, this.props.t('detail'), (0,preact_module.h)("img", {
2078
2042
  src: __webpack_require__(8453),
2079
2043
  class: "product_attachment__btn_external_link"
2080
- })));
2081
- console.log('P', product);
2082
-
2083
- if (util/* default.size */.Z.size(product.buttons) > 0) {
2084
- $detailbtns = $detailbtns.concat(util/* default.map */.Z.map(product.buttons, (button, index) => {
2085
- if (button.type === 'call_button') {
2086
- return (0,preact_module.h)("a", {
2087
- class: "product_attachment__btn",
2088
- href: 'tel:' + button.phone_number,
2089
- key: index,
2090
- title: button.title
2091
- }, this.props.t.i18n(button.i18n_title) || button.title);
2092
- }
2093
-
2094
- if (button.type === 'url_button') {
2095
- return (0,preact_module.h)("a", {
2096
- class: "product_attachment__btn",
2097
- href: button.url,
2098
- target: "_blank",
2099
- key: index,
2100
- title: button.title
2101
- }, this.props.t.i18n(button.i18n_title) || button.title || this.props.t('detail'), ' ', (0,preact_module.h)("img", {
2102
- src: __webpack_require__(8453),
2103
- class: "product_attachment__btn_external_link"
2104
- }));
2105
- }
2106
-
2107
- if (button.type === 'postback_button') {
2108
- return (0,preact_module.h)("a", {
2109
- class: "product_attachment__btn",
2110
- href: "javascript:;",
2111
- onClick: _ => this.props.onPostback(button)
2112
- }, this.props.t.i18n(button.i18n_title) || button.title);
2113
- }
2114
- }));
2115
- }
2116
-
2044
+ }));
2117
2045
  let $title = (0,preact_module.h)("a", {
2118
2046
  href: url,
2119
2047
  class: "product_attachment__title",
@@ -2142,7 +2070,7 @@ class ProductAttachments extends common/* Com */.up {
2142
2070
  src: this.props.store.replaceFileUrl(product.image)
2143
2071
  }))), $title, $subtitle, $price, (0,preact_module.h)("div", {
2144
2072
  class: "product_attachment__btns"
2145
- }, $detailbtns));
2073
+ }, $detailbtn));
2146
2074
  });
2147
2075
  return $products;
2148
2076
  }
@@ -2298,7 +2226,8 @@ img { max-width: 100%; display: block; margin: 10px auto; }
2298
2226
  * { white-space: normal }
2299
2227
  ul > li { margin-bottom: 5px }
2300
2228
  ul:last-child { margin-bottom: 0 }
2301
- p { margin-bottom: 0; margin-top: 0;}
2229
+ p:first-child { margin-top: 0;}
2230
+ p:last-child { margin-bottom: 0;}
2302
2231
  </style>
2303
2232
  <div>${html}</div>`;
2304
2233
  let links = this.shadowRoot.querySelectorAll('a');
@@ -2342,11 +2271,6 @@ class TextMessage extends common/* Com */.up {
2342
2271
  render() {
2343
2272
  var format = util/* default.get */.Z.get(this.props.ev, 'data.message.format', 'plaintext');
2344
2273
  if (format === 'markdown') return this.renderMarkdown();
2345
- if (format === 'delta') return this.renderDelta();
2346
- return this.renderPlainText();
2347
- }
2348
-
2349
- renderPlainText() {
2350
2274
  var text = util/* default.get */.Z.get(this.props.ev, 'data.message.text');
2351
2275
  text = util/* default.trim */.Z.trim(text);
2352
2276
  if (util/* default.size */.Z.size(text) === 0) return null;
@@ -2392,22 +2316,8 @@ class TextMessage extends common/* Com */.up {
2392
2316
  }, tags);
2393
2317
  }
2394
2318
 
2395
- renderDelta() {
2396
- let deltas = util/* default.get */.Z.get(this.props.ev, 'data.message.quill_delta');
2397
- deltas = util/* default.parseJSON */.Z.parseJSON(deltas) || {};
2398
- deltas = deltas.ops || [];
2399
- 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'));
2400
-
2401
- if (isMarkdown) {
2402
- var text = deltaToMarkdown(deltas);
2403
- return this.renderMarkdown(text);
2404
- }
2405
-
2406
- return this.renderPlainText();
2407
- }
2408
-
2409
- renderMarkdown(text) {
2410
- if (!text) text = util/* default.get */.Z.get(this.props.ev, 'data.message.text');
2319
+ renderMarkdown() {
2320
+ var text = util/* default.get */.Z.get(this.props.ev, 'data.message.text');
2411
2321
  if (util/* default.size */.Z.size(text) === 0) return null;
2412
2322
  let byType = util/* default.get */.Z.get(this.props.ev, 'by.type');
2413
2323
  text = util/* default.trim */.Z.trim(text);
@@ -2431,48 +2341,6 @@ class TextMessage extends common/* Com */.up {
2431
2341
  }
2432
2342
 
2433
2343
  }
2434
-
2435
- function deltaToMarkdown(deltas) {
2436
- let output = '';
2437
- util/* default.each */.Z.each(deltas, (delta, idx) => {
2438
- let text = '';
2439
- let insert = delta.insert;
2440
- let attributes = delta.attributes;
2441
- if (insert.emoji) text = emojiCodes[insert.emoji] || '';
2442
-
2443
- if (attributes) {
2444
- if (attributes.italic && attributes.bold) text = `*__${insert}__*`;else if (attributes.italic) text = `*${insert}*`;else if (attributes.bold) text = `**${insert}**`;else text = insert;
2445
- }
2446
-
2447
- if (insert.dynamicField) text = `${util/* default.get */.Z.get(insert, 'dynamicField.text', '')}`;
2448
-
2449
- if (!insert.emoji && !attributes && !insert.dynamicField) {
2450
- text = insert || '';
2451
- text = text.replace(/\n/g, '<br/>');
2452
- }
2453
-
2454
- output += text;
2455
- });
2456
- return output;
2457
- }
2458
-
2459
- const emojiCodes = {
2460
- like: '👍',
2461
- unlike: '👎',
2462
- angry: '😠',
2463
- confused: '😕',
2464
- crying: '😢',
2465
- grinning: '😀',
2466
- 'heart-eyes': '😍',
2467
- neutral: '😐',
2468
- sleepy: '😪',
2469
- sad: '😞',
2470
- smiling: '😄',
2471
- 'tongue-out': '😛',
2472
- tired: '😩',
2473
- surprised: '😮',
2474
- wink: '😉'
2475
- };
2476
2344
  ;// CONCATENATED MODULE: ./src/chatbox/time.js
2477
2345
 
2478
2346
  var g_pub = new util/* default.Pubsub */.Z.Pubsub();
@@ -2756,18 +2624,6 @@ class Event extends common/* Com */.up {
2756
2624
 
2757
2625
  var uri = acc.logo_url || __webpack_require__(9895);
2758
2626
 
2759
- if (util/* default.get */.Z.get(this.props, 'chatbox.hide_agent_profile')) {
2760
- return (0,preact_module.h)("div", {
2761
- class: "message-sender"
2762
- }, (0,preact_module.h)("img", {
2763
- alt: "sender",
2764
- class: "message-sender-avatar",
2765
- src: this.props.store.replaceFileUrl(uri)
2766
- }), (0,preact_module.h)("p", {
2767
- class: "message-sender-name"
2768
- }, acc.name));
2769
- }
2770
-
2771
2627
  let agentM = this.props.store.matchAgent('*');
2772
2628
 
2773
2629
  if (byid !== 'system' || bytype !== 'dummy') {
@@ -2823,8 +2679,7 @@ class Event extends common/* Com */.up {
2823
2679
  ev: ev
2824
2680
  }), (0,preact_module.h)(ButtonAttachments, {
2825
2681
  store: this.props.store,
2826
- ev: ev,
2827
- t: this.props.t
2682
+ ev: ev
2828
2683
  }), (0,preact_module.h)(FormAttachments, {
2829
2684
  store: this.props.store,
2830
2685
  onSubmit: this.props.onFormSubmit,
@@ -2838,11 +2693,9 @@ class Event extends common/* Com */.up {
2838
2693
  }), (0,preact_module.h)(GenericTemplateAttachments, {
2839
2694
  store: this.props.store,
2840
2695
  ev: ev,
2841
- onSelect: e => this.choosePostbackBtn(e),
2842
- t: this.props.t
2696
+ onSelect: e => this.choosePostbackBtn(e)
2843
2697
  }), (0,preact_module.h)(ProductAttachments, {
2844
2698
  t: this.props.t,
2845
- onPostback: e => this.choosePostbackBtn(e),
2846
2699
  store: this.props.store,
2847
2700
  ev: ev
2848
2701
  }), (0,preact_module.h)(OrderAttachments_ProductAttachments, {
@@ -2914,8 +2767,7 @@ class Event extends common/* Com */.up {
2914
2767
  ev: ev
2915
2768
  }), (0,preact_module.h)(ButtonAttachments, {
2916
2769
  store: this.props.store,
2917
- ev: ev,
2918
- t: this.props.t
2770
+ ev: ev
2919
2771
  }), (0,preact_module.h)(FormAttachments, {
2920
2772
  store: this.props.store,
2921
2773
  onSubmit: this.props.onFormSubmit,
@@ -3064,7 +2916,6 @@ class Events extends common/* Com */.up {
3064
2916
  }));
3065
2917
  processEvents(convo, events);
3066
2918
  let $events = util/* default.map */.Z.map(events, ev => (0,preact_module.h)(Event, {
3067
- chatbox: this.props.chatbox,
3068
2919
  onLink: this.props.onLink,
3069
2920
  store: this.props.store,
3070
2921
  onFormSubmit: this.props.onFormSubmit,
@@ -3298,8 +3149,6 @@ class Typing extends common/* Com */.up {
3298
3149
  return;
3299
3150
  }
3300
3151
 
3301
- let ag = this.props.store.matchAgent(ev.by.id) || {};
3302
- if (ag.type == 'agent') return;
3303
3152
  if (util/* default.get */.Z.get(ev, 'type') !== 'conversation_typing') return;
3304
3153
  this.setState({
3305
3154
  ev: ev,
@@ -3312,7 +3161,7 @@ class Typing extends common/* Com */.up {
3312
3161
  this.setState({
3313
3162
  isShow: false
3314
3163
  });
3315
- }, 5000);
3164
+ }, 10000);
3316
3165
  });
3317
3166
  }
3318
3167
 
@@ -4212,7 +4061,6 @@ class order_Order extends common/* Com */.up {
4212
4061
  loading: true,
4213
4062
  order: {},
4214
4063
  err: {},
4215
- shipping_address: 'new',
4216
4064
  selectedProvince: null,
4217
4065
  selectedDistrict: null,
4218
4066
  selectedWard: null,
@@ -4505,17 +4353,16 @@ class order_Order extends common/* Com */.up {
4505
4353
 
4506
4354
  order_defineProperty(this, "onCancel", () => {
4507
4355
  if (this.props.onResponse) this.props.onResponse('rejected');
4356
+ this.close();
4357
+ });
4508
4358
 
4359
+ order_defineProperty(this, "close", () => {
4509
4360
  if (this.props.cid && !this.state.order.user_confirmation) {
4510
4361
  let order = util/* default.cloneDeep */.Z.cloneDeep(this.state.order);
4511
4362
  order.user_confirmation = 'rejected';
4512
4363
  this.props.store.updateOrder(order);
4513
4364
  }
4514
4365
 
4515
- this.close();
4516
- });
4517
-
4518
- order_defineProperty(this, "close", () => {
4519
4366
  if (this.props.onClose) this.props.onClose();
4520
4367
  });
4521
4368
 
@@ -4585,7 +4432,7 @@ class order_Order extends common/* Com */.up {
4585
4432
  return null;
4586
4433
  let editmode = false;
4587
4434
 
4588
- if (!order.status || order.status == 'open') {
4435
+ if (!order.status || order.status == 'new') {
4589
4436
  editmode = !order.user_confirmation;
4590
4437
  }
4591
4438
 
@@ -4676,7 +4523,7 @@ class order_Order extends common/* Com */.up {
4676
4523
  renderDesktopShipping(order) {
4677
4524
  let editmode = false;
4678
4525
 
4679
- if (!order.status || order.status == 'open') {
4526
+ if (!order.status || order.status == 'new') {
4680
4527
  editmode = !order.user_confirmation;
4681
4528
  }
4682
4529
 
@@ -4977,7 +4824,7 @@ class order_Order extends common/* Com */.up {
4977
4824
  }, (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"));
4978
4825
  let editmode = false;
4979
4826
 
4980
- if (!order.status || order.status == 'open') {
4827
+ if (!order.status || order.status == 'new') {
4981
4828
  editmode = !order.user_confirmation;
4982
4829
  }
4983
4830
 
@@ -5013,7 +4860,7 @@ class order_Order extends common/* Com */.up {
5013
4860
  }
5014
4861
 
5015
4862
  renderStatusBadge(order) {
5016
- let status = order.status || 'open';
4863
+ let status = order.status || 'new';
5017
4864
  return (0,preact_module.h)("div", {
5018
4865
  style: "float: right !important;",
5019
4866
  class: 'order_status order_status__' + status
@@ -5021,7 +4868,7 @@ class order_Order extends common/* Com */.up {
5021
4868
  }
5022
4869
 
5023
4870
  renderShippingInfo(order) {
5024
- if (order.status != 'open' || order.user_confirmation) {}
4871
+ if (order.status != 'new' || order.user_confirmation) {}
5025
4872
 
5026
4873
  let shipping_provider = util/* default.get */.Z.get(order, 'shipping.shipping_provider');
5027
4874
  if (!shipping_provider) return null;
@@ -5121,7 +4968,7 @@ class order_Order extends common/* Com */.up {
5121
4968
  let $products = null;
5122
4969
  let editmode = false;
5123
4970
 
5124
- if (!order.status || order.status == 'open') {
4971
+ if (!order.status || order.status == 'new') {
5125
4972
  editmode = !order.user_confirmation;
5126
4973
  }
5127
4974
 
@@ -5225,7 +5072,7 @@ class order_Order extends common/* Com */.up {
5225
5072
  onClick: this.onCancel
5226
5073
  }, this.props.t('cancel_order'));
5227
5074
 
5228
- if (order.user_confirmation || order.status != 'open') {
5075
+ if (order.user_confirmation || order.status != 'new') {
5229
5076
  $status = null;
5230
5077
  if (this.props.cid) $close = (0,preact_module.h)("div", {
5231
5078
  class: "order_btn order__btn__light mt-3",
@@ -5257,7 +5104,7 @@ class order_Order extends common/* Com */.up {
5257
5104
  let $actions = null;
5258
5105
  let editmode = false;
5259
5106
 
5260
- if (!order.status || order.status == 'open') {
5107
+ if (!order.status || order.status == 'new') {
5261
5108
  editmode = !order.user_confirmation;
5262
5109
  }
5263
5110
 
@@ -5665,48 +5512,6 @@ class Widget extends common/* Com */.up {
5665
5512
  constructor(props) {
5666
5513
  super(props);
5667
5514
 
5668
- Widget_defineProperty(this, "msgInput", (0,preact_module/* createRef */.Vf)());
5669
-
5670
- Widget_defineProperty(this, "sendMessage", async message => {
5671
- let hasPostback = util/* default.find */.Z.find(message.attachments, att => att.type === 'postback');
5672
-
5673
- if (this.isFormRequired() && hasPostback) {
5674
- this.onStartConvoClick();
5675
- this.fillQuickReplyToQuestion(message);
5676
- return;
5677
- }
5678
-
5679
- let text = message.text;
5680
-
5681
- if (!this.props.cid) {
5682
- this.creating = true;
5683
- const {
5684
- convo,
5685
- error
5686
- } = await this.props.store.startConvo({
5687
- locale: this.props.t.locale(),
5688
- message: text,
5689
- initial_by: this.props.store.matchUser().id
5690
- });
5691
-
5692
- if (error) {}
5693
-
5694
- this.creating = false;
5695
- this.props.store.sendConvoEvent(convo.id, 'message_sent', {
5696
- message
5697
- });
5698
- this.props.onGo({
5699
- view: 'chat',
5700
- cid: convo.id
5701
- });
5702
- return;
5703
- }
5704
-
5705
- this.props.store.sendConvoEvent(this.props.cid, 'message_sent', {
5706
- message
5707
- });
5708
- });
5709
-
5710
5515
  Widget_defineProperty(this, "onLink", (e, url) => {
5711
5516
  if (!url) return e.preventDefault();
5712
5517
  let noschemeurl = url.replace(/(^\w+:|^)\/\//, '');
@@ -5737,8 +5542,7 @@ class Widget extends common/* Com */.up {
5737
5542
  clickedJoin: false,
5738
5543
  formData: {},
5739
5544
  showOrder: false,
5740
- order_id: '',
5741
- quickReplyMessage: ''
5545
+ order_id: ''
5742
5546
  });
5743
5547
  this.props.store.onUpdate(this, _ => this.forceUpdate());
5744
5548
  }
@@ -5756,8 +5560,7 @@ class Widget extends common/* Com */.up {
5756
5560
  if (prevProp.cid !== this.props.cid) {
5757
5561
  this.closeOrder();
5758
5562
  this.setState({
5759
- clickedJoin: false,
5760
- quickReplyMessage: ''
5563
+ clickedJoin: false
5761
5564
  });
5762
5565
  setTimeout(() => {
5763
5566
  this.events && this.events.focus();
@@ -5769,13 +5572,6 @@ class Widget extends common/* Com */.up {
5769
5572
  }
5770
5573
 
5771
5574
  shouldShowForm() {
5772
- let form;
5773
- let accountSetting = this.props.plugin.chatbox || {};
5774
- let acc = this.props.store.matchAccount() || {};
5775
- if (util/* default.get */.Z.get(accountSetting, 'prechat_form.enabled')) form = accountSetting.prechat_form;
5776
- let offlineEnabled = util/* default.get */.Z.get(accountSetting, 'offline_form.enabled');
5777
- if (this.isOffline(acc, accountSetting) && offlineEnabled) form = accountSetting.offline_form;
5778
- if (!this.hasSentMessage(this.props.cid) && form && (util/* default.size */.Z.size(form.groups) || form.group_required)) return true;
5779
5575
  let formRequired = this.isFormRequired();
5780
5576
  return formRequired && !this.props.cid || formRequired && this.props.cid && this.state.clickedJoin;
5781
5577
  }
@@ -5848,23 +5644,17 @@ class Widget extends common/* Com */.up {
5848
5644
  if (hasError) return this.forceUpdate();
5849
5645
  let data = util/* default.cloneDeep */.Z.cloneDeep(this.state.formData);
5850
5646
  let user = util/* default.cloneDeep */.Z.cloneDeep(this.props.store.matchUser());
5851
- let is_lead = false;
5852
5647
  util/* default.map */.Z.map(data, (field, key) => {
5853
5648
  if (!key.startsWith('attr:')) return;
5854
5649
  var attr = {
5855
5650
  key: key.substr(5)
5856
5651
  };
5857
- is_lead = is_lead || key == 'emails' || key == 'phones';
5858
5652
  if (field.type === 'number') attr.number = parseInt(field.value);
5859
5653
  if (field.type === 'datetime') attr.datetime = new util/* default.Date */.Z.Date(field.value).toISOString();
5860
5654
  if (field.type === 'list') attr.list = field.value;
5861
5655
  if (field.type === 'text' || field.type === 'boolean') attr[field.type] = field.value;
5862
5656
  util/* default.setUserAttr */.Z.setUserAttr(user, attr);
5863
5657
  });
5864
- if (is_lead) util/* default.setUserAttr */.Z.setUserAttr(user, {
5865
- key: 'lead_source',
5866
- text: 'widget'
5867
- });
5868
5658
  let firstmsg = util/* default.get */.Z.get(data, 'question.value');
5869
5659
  let groupid = util/* default.get */.Z.get(data, 'group.value', '');
5870
5660
 
@@ -5883,9 +5673,6 @@ class Widget extends common/* Com */.up {
5883
5673
  }]
5884
5674
  }
5885
5675
  });
5886
- this.setState({
5887
- quickReplyMessage: ''
5888
- });
5889
5676
  if (form.end_conversation_after_submit) await this.props.store.endConvo(this.props.cid);
5890
5677
  return;
5891
5678
  }
@@ -5906,11 +5693,11 @@ class Widget extends common/* Com */.up {
5906
5693
  this.setState({
5907
5694
  creatingError: null
5908
5695
  });
5909
- await this.props.store.setUser(user);
5910
5696
  const {
5911
5697
  error,
5912
5698
  convo
5913
5699
  } = await this.props.store.startConvo(req);
5700
+ this.props.store.setUser(user);
5914
5701
 
5915
5702
  if (error) {
5916
5703
  this.setState({
@@ -5931,8 +5718,7 @@ class Widget extends common/* Com */.up {
5931
5718
  });
5932
5719
  this.setState({
5933
5720
  creating: false,
5934
- clickedJoin: false,
5935
- quickReplyMessage: ''
5721
+ clickedJoin: false
5936
5722
  });
5937
5723
  if (!this.props.store.isMobile()) this.focusInput();
5938
5724
  }
@@ -5943,8 +5729,7 @@ class Widget extends common/* Com */.up {
5943
5729
  key: 'question',
5944
5730
  is_required: true,
5945
5731
  label: this.props.t.i18n(util/* default.get */.Z.get(form, `i18n_question_label`, {})) || form.question_label,
5946
- type: 'text',
5947
- value: this.state.quickReplyMessage
5732
+ type: 'text'
5948
5733
  };
5949
5734
  this.setState({
5950
5735
  formData
@@ -5997,7 +5782,6 @@ class Widget extends common/* Com */.up {
5997
5782
  renderFields() {
5998
5783
  if (util/* default.size */.Z.size(this.state.formData) === 0) return null;
5999
5784
  let $fields = util/* default.map */.Z.map(this.state.formData, (field, key) => {
6000
- if (this.state.quickReplyMessage && key === 'question') return null;
6001
5785
  let $field = null;
6002
5786
  var errclass = field.error ? 'input--error' : '';
6003
5787
 
@@ -6214,7 +5998,7 @@ class Widget extends common/* Com */.up {
6214
5998
 
6215
5999
  blur() {
6216
6000
  if (this.props.store.isPreview) return;
6217
- var $input = this.msgInput.current;
6001
+ var $input = this.msgInput;
6218
6002
  if (!$input) return;
6219
6003
  setTimeout(() => $input && $input.blur());
6220
6004
  setTimeout(() => $input && $input.blur(), 300);
@@ -6238,7 +6022,7 @@ class Widget extends common/* Com */.up {
6238
6022
  return;
6239
6023
  }
6240
6024
 
6241
- var $input = this.msgInput.current;
6025
+ var $input = this.msgInput;
6242
6026
  if (!$input) return;
6243
6027
  setTimeout(() => $input.focus());
6244
6028
  setTimeout(() => $input.focus(), 300);
@@ -6254,16 +6038,35 @@ class Widget extends common/* Com */.up {
6254
6038
  this.focusInput();
6255
6039
  }
6256
6040
 
6257
- fillQuickReplyToQuestion(message) {
6258
- let formData = this.state.formData;
6041
+ async sendMessage(message) {
6042
+ let text = message.text;
6043
+
6044
+ if (!this.props.cid) {
6045
+ this.creating = true;
6046
+ const {
6047
+ convo,
6048
+ error
6049
+ } = await this.props.store.startConvo({
6050
+ locale: this.props.t.locale(),
6051
+ message: text,
6052
+ initial_by: this.props.store.matchUser().id
6053
+ });
6259
6054
 
6260
- if (formData) {
6261
- util/* default.set */.Z.set(formData, 'question.value', message.text);
6055
+ if (error) {}
6056
+
6057
+ this.creating = false;
6058
+ this.props.store.sendConvoEvent(convo.id, 'message_sent', {
6059
+ message
6060
+ });
6061
+ this.props.onGo({
6062
+ view: 'chat',
6063
+ cid: convo.id
6064
+ });
6065
+ return;
6262
6066
  }
6263
6067
 
6264
- this.setState({
6265
- formData,
6266
- quickReplyMessage: message.text
6068
+ this.props.store.sendConvoEvent(this.props.cid, 'message_sent', {
6069
+ message
6267
6070
  });
6268
6071
  }
6269
6072
 
@@ -6274,9 +6077,9 @@ class Widget extends common/* Com */.up {
6274
6077
  renderChat() {
6275
6078
  let $input = (0,preact_module.h)(MessageInput, {
6276
6079
  store: this.props.store,
6277
- ref: this.msgInput,
6080
+ ref: ref => this.msgInput = ref,
6278
6081
  cid: this.props.cid,
6279
- onSend: this.sendMessage,
6082
+ onSend: e => this.sendMessage(e),
6280
6083
  t: this.props.t
6281
6084
  });
6282
6085
  let convo = this.props.store.matchConvo(this.props.cid) || {};
@@ -6299,7 +6102,6 @@ class Widget extends common/* Com */.up {
6299
6102
  isShow: this.props.isShow,
6300
6103
  onLink: this.onLink,
6301
6104
  store: this.props.store,
6302
- chatbox: this.props.plugin.chatbox || {},
6303
6105
  onFormSubmit: e => this.onEventFormSubmit(e),
6304
6106
  ref: ref => this.events = ref,
6305
6107
  cid: this.props.cid,
@@ -6337,8 +6139,7 @@ class Widget extends common/* Com */.up {
6337
6139
  cid: ''
6338
6140
  });
6339
6141
  this.setState({
6340
- clickedJoin: true,
6341
- quickReplyMessage: ''
6142
+ clickedJoin: true
6342
6143
  });
6343
6144
  }
6344
6145
 
@@ -6363,12 +6164,12 @@ class Widget extends common/* Com */.up {
6363
6164
  let formData = this.fillForm(form);
6364
6165
  let convo = this.props.store.matchConvo(this.props.cid) || {};
6365
6166
  if (convo.state === 'ended') return true;
6167
+ if (this.userHasSent(this.props.cid)) return false;
6366
6168
  if (convo.state && convo.state !== 'pending') delete formData.group;
6367
6169
  return !!util/* default.find */.Z.find(formData, field => field.value == null || field.value === '');
6368
6170
  }
6369
6171
 
6370
6172
  renderConvoSummary(convo) {
6371
- let accountSetting = this.props.plugin.chatbox || {};
6372
6173
  let agentM = this.props.store.matchAgent('*');
6373
6174
  let ags = util/* default.filter */.Z.filter(convo.members, m => {
6374
6175
  return (m.type === 'agent' || m.type === 'bot') && m.membership === 'active';
@@ -6380,7 +6181,7 @@ class Widget extends common/* Com */.up {
6380
6181
  fullname: 'Offline Agent'
6381
6182
  });
6382
6183
  var name = util/* default.each */.Z.each(agents, ag => ag.fullname).join(', ');
6383
- if (accountSetting.hide_agent_profile || !name) name = this.props.store.matchAccount().name;
6184
+ if (!name) name = this.props.store.matchAccount().name;
6384
6185
  if (!name) name = this.props.t('agent');
6385
6186
  var $you = null;
6386
6187
 
@@ -6467,15 +6268,6 @@ class Widget extends common/* Com */.up {
6467
6268
  return joined;
6468
6269
  }
6469
6270
 
6470
- hasSentMessage(cid) {
6471
- let convo = this.props.store.matchConvo(cid) || {};
6472
- let joined = util/* default.find */.Z.find(convo.members, mem => {
6473
- if (mem.type === 'bot') return true;
6474
- return mem.last_sent;
6475
- });
6476
- return joined;
6477
- }
6478
-
6479
6271
  isOffline(acc, accSetting) {
6480
6272
  let enableWhen = util/* default.get */.Z.get(accSetting, 'offline_form.enable_when');
6481
6273
  let isonline = true;
@@ -6731,14 +6523,6 @@ class Main extends common/* Com */.up {
6731
6523
  }
6732
6524
 
6733
6525
  p = p || {};
6734
-
6735
- if (!p.view && !p.cid) {
6736
- let convoM = this.props.store.matchConvo('*');
6737
- let redconvo = util/* default.find */.Z.find(convoM, convo => !util/* default.isConvoSeen */.Z.isConvoSeen(convo, this.props.store.matchUser().id));
6738
- p.cid = util/* default.get */.Z.get(redconvo, 'id', util/* default.get */.Z.get(convoM, '0.id'));
6739
- p.view = 'chat';
6740
- }
6741
-
6742
6526
  if (this.props.store.isMobile()) modifyViewport();
6743
6527
  this.setState({
6744
6528
  widgetConvoId: p.cid,
@@ -6779,13 +6563,11 @@ class Main extends common/* Com */.up {
6779
6563
  }
6780
6564
 
6781
6565
  function restoreViewport() {
6782
- if (document.body && document.body.classList) document.body.classList.remove('sbz_no_scroll');
6783
6566
  let metatag = document.getElementById('subiz-meta-viewport');
6784
6567
  if (metatag) metatag.remove();
6785
6568
  }
6786
6569
 
6787
6570
  function modifyViewport() {
6788
- if (document.body && document.body.classList) document.body.classList.add('sbz_no_scroll');
6789
6571
  let metatag = document.createElement('meta');
6790
6572
  metatag.httpEquiv = 'X-UA-Compatible';
6791
6573
  metatag.name = 'viewport';