@subiz/widget-v4 4.0.92 → 4.0.94

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 (175) hide show
  1. package/assets/less/chatbox.less +8 -0
  2. package/assets/less/message.less +8 -3
  3. package/assets/less/order.less +10 -0
  4. package/compiled_src/bot.js +0 -11
  5. package/compiled_src/call/call.js +0 -61
  6. package/compiled_src/call/css.js +0 -2
  7. package/compiled_src/chatbox/AgentsAvatar.js +0 -16
  8. package/compiled_src/chatbox/AudioAttachments.js +0 -14
  9. package/compiled_src/chatbox/ButtonAttachments.js +1 -14
  10. package/compiled_src/chatbox/Buttons.js +0 -13
  11. package/compiled_src/chatbox/ChatButton.js +1 -78
  12. package/compiled_src/chatbox/DropdownSelect.js +3 -44
  13. package/compiled_src/chatbox/Emoji.js +0 -7
  14. package/compiled_src/chatbox/Event.js +0 -59
  15. package/compiled_src/chatbox/Events.js +4 -44
  16. package/compiled_src/chatbox/FileAttachments.js +0 -14
  17. package/compiled_src/chatbox/FormAttachment.js +1 -52
  18. package/compiled_src/chatbox/FormAttachments.js +0 -14
  19. package/compiled_src/chatbox/FormSubmitAttachments.js +0 -11
  20. package/compiled_src/chatbox/GenericTemplateAttachments.js +1 -20
  21. package/compiled_src/chatbox/Header.js +1 -46
  22. package/compiled_src/chatbox/ImageAttachments.js +0 -16
  23. package/compiled_src/chatbox/InfoMessage.js +0 -13
  24. package/compiled_src/chatbox/ListField.js +0 -16
  25. package/compiled_src/chatbox/MessageInput.js +1 -47
  26. package/compiled_src/chatbox/Order.js +0 -35
  27. package/compiled_src/chatbox/OrderAttachments.js +98 -39
  28. package/compiled_src/chatbox/PoweredBy.js +0 -7
  29. package/compiled_src/chatbox/ProductAttachments.js +0 -19
  30. package/compiled_src/chatbox/QuickReplies.js +0 -18
  31. package/compiled_src/chatbox/Rating.js +0 -37
  32. package/compiled_src/chatbox/ShadowDomRoot.js +0 -9
  33. package/compiled_src/chatbox/TextMessage.js +0 -64
  34. package/compiled_src/chatbox/Typing.js +0 -15
  35. package/compiled_src/chatbox/VideoAttachments.js +0 -14
  36. package/compiled_src/chatbox/Widget.js +6 -167
  37. package/compiled_src/chatbox/css.js +0 -2
  38. package/compiled_src/chatbox/dragscroll.js +1 -5
  39. package/compiled_src/chatbox/main.js +1 -40
  40. package/compiled_src/chatbox/releaseAnimation.js +0 -11
  41. package/compiled_src/chatbox/spinner.js +0 -10
  42. package/compiled_src/chatbox/time.js +0 -22
  43. package/compiled_src/chatbox/touchscroll.js +0 -7
  44. package/compiled_src/common.js +0 -22
  45. package/compiled_src/contact/contact.js +2 -52
  46. package/compiled_src/contact/css.js +0 -2
  47. package/compiled_src/lib.js +19 -46
  48. package/compiled_src/notif/css.js +0 -2
  49. package/compiled_src/notif/notif.js +0 -63
  50. package/compiled_src/order/address_picker.js +4 -38
  51. package/compiled_src/order/icon.js +0 -16
  52. package/compiled_src/order/index.js +1 -34
  53. package/compiled_src/order/order.js +2 -156
  54. package/compiled_src/plugin.js +1 -77
  55. package/compiled_src/popup/countdown.js +2 -33
  56. package/compiled_src/popup/css.js +0 -2
  57. package/compiled_src/popup/popup.js +2 -165
  58. package/compiled_src/popup/tick.core.commonjs.js +72 -222
  59. package/compiled_src/popup/tick.view.flip.commonjs.js +23 -31
  60. package/compiled_src/store/api.js +99 -65
  61. package/compiled_src/store/api_fake.js +3 -39
  62. package/compiled_src/store/realtime_fake.js +0 -6
  63. package/compiled_src/store/store.js +46 -249
  64. package/compiled_src/util/campaign.js +0 -13
  65. package/compiled_src/util/common.js +15 -185
  66. package/compiled_src/util/common.test.js +0 -4
  67. package/compiled_src/util/extractor.js +1 -21
  68. package/compiled_src/util/extractor.test.js +0 -3
  69. package/compiled_src/util/gate.js +0 -7
  70. package/compiled_src/util/gate.test.js +1 -2
  71. package/compiled_src/util/index.js +3 -7
  72. package/compiled_src/util/mutex.js +31 -0
  73. package/compiled_src/util/op.js +1 -14
  74. package/compiled_src/util/order.js +118 -0
  75. package/compiled_src/util/pubsub.js +0 -6
  76. package/compiled_src/util/pubsub.test.js +0 -2
  77. package/package.json +12 -13
  78. package/src/chatbox/OrderAttachments.js +111 -18
  79. package/src/lib.js +24 -2
  80. package/src/store/api.js +110 -21
  81. package/src/store/api_fake.js +5 -6
  82. package/src/store/store.js +47 -17
  83. package/src/util/index.js +4 -0
  84. package/src/util/mutex.js +27 -0
  85. package/src/util/order.js +120 -0
  86. package/dist/132.js +0 -7092
  87. package/dist/178.js +0 -406
  88. package/dist/18364d15f37.132.js +0 -1
  89. package/dist/18364d15f37.178.js +0 -1
  90. package/dist/18364d15f37.213.js +0 -1
  91. package/dist/18364d15f37.335.js +0 -1
  92. package/dist/18364d15f37.362.js +0 -1
  93. package/dist/18364d15f37.441.js +0 -1
  94. package/dist/18364d15f37.605.js +0 -1
  95. package/dist/18364d15f37.678.js +0 -1
  96. package/dist/18364d15f37.782.js +0 -1
  97. package/dist/18364d15f37.app.js +0 -1
  98. package/dist/18364d15f37.index.html +0 -26
  99. package/dist/18364d15f37.library.html +0 -26
  100. package/dist/18364d15f37.library.js +0 -1
  101. package/dist/18364d15f37.preview.html +0 -759
  102. package/dist/18364d15f37.preview.js +0 -1
  103. package/dist/18364d15f37.screenshoot.js +0 -1
  104. package/dist/213.js +0 -3215
  105. package/dist/335.js +0 -411
  106. package/dist/362.js +0 -107
  107. package/dist/441.js +0 -2834
  108. package/dist/605.js +0 -328
  109. package/dist/678.js +0 -107
  110. package/dist/782.js +0 -107
  111. package/dist/HASH +0 -1
  112. package/dist/assets/img/Facebook.64607ec.png +0 -0
  113. package/dist/assets/img/Zalo.6845707.png +0 -0
  114. package/dist/assets/img/award1a.1a58e10.png +0 -0
  115. package/dist/assets/img/award3a.3b74423.png +0 -0
  116. package/dist/assets/img/award4a.ed6ccd4.png +0 -0
  117. package/dist/assets/img/award5.39eb7ae.png +0 -0
  118. package/dist/assets/img/bubble_default.7d5e4ab.svg +0 -20
  119. package/dist/assets/img/caret.998eb8f.svg +0 -1
  120. package/dist/assets/img/convos_empty.2353007.svg +0 -72
  121. package/dist/assets/img/default.06e6ee0.jpg +0 -0
  122. package/dist/assets/img/default_avatar.5b74dc1.png +0 -0
  123. package/dist/assets/img/done_gray.d7e8203.svg +0 -4
  124. package/dist/assets/img/done_green.b817fd4.svg +0 -4
  125. package/dist/assets/img/emoji/messenger/sub_23.529_58.824.d5faf14.png +0 -0
  126. package/dist/assets/img/emoji/messenger/sub_23.529_60.784.1420241.png +0 -0
  127. package/dist/assets/img/emoji/messenger/sub_25.490_0.000.1e6b2c0.png +0 -0
  128. package/dist/assets/img/emoji/messenger/sub_25.490_45.098.3dfbc08.png +0 -0
  129. package/dist/assets/img/emoji/messenger/sub_25.490_5.882.4b49e94.png +0 -0
  130. package/dist/assets/img/emoji/messenger/sub_27.451_72.549.7114f58.png +0 -0
  131. package/dist/assets/img/emoji/messenger/sub_27.451_84.314.231e2b7.png +0 -0
  132. package/dist/assets/img/emoji/messenger/sub_27.451_96.078.ddbb008.png +0 -0
  133. package/dist/assets/img/emoji/messenger/sub_29.412_5.882.61f3359.png +0 -0
  134. package/dist/assets/img/emoji/messenger/sub_58.824_100.000.6df72bc.png +0 -0
  135. package/dist/assets/img/emoji/messenger/sub_58.824_45.098.3d7a7ad.png +0 -0
  136. package/dist/assets/img/emoji/messenger/sub_58.824_47.059.0f4d6e2.png +0 -0
  137. package/dist/assets/img/emoji/messenger/sub_58.824_54.902.65724c1.png +0 -0
  138. package/dist/assets/img/emoji/messenger/sub_58.824_64.706.9da3cba.png +0 -0
  139. package/dist/assets/img/emoji/messenger/sub_58.824_72.549.edca5cf.png +0 -0
  140. package/dist/assets/img/emoji/messenger/sub_58.824_78.431.f910f2a.png +0 -0
  141. package/dist/assets/img/emoji/messenger/sub_58.824_88.235.def4e71.png +0 -0
  142. package/dist/assets/img/emoji/messenger/sub_60.784_11.765.49c03d0.png +0 -0
  143. package/dist/assets/img/emoji/messenger/sub_60.784_27.451.46b54e5.png +0 -0
  144. package/dist/assets/img/emoji/messenger/sub_60.784_29.412.e36d284.png +0 -0
  145. package/dist/assets/img/emoji/messenger/sub_60.784_3.922.bb191b0.png +0 -0
  146. package/dist/assets/img/emoji/messenger/sub_60.784_35.294.af7b927.png +0 -0
  147. package/dist/assets/img/emoji/messenger/sub_60.784_7.843.98f2a99.png +0 -0
  148. package/dist/assets/img/empty.29bed2d.svg +0 -23
  149. package/dist/assets/img/empty_1.0b98af0.svg +0 -11
  150. package/dist/assets/img/examplte_logo.f86535f.svg +0 -1
  151. package/dist/assets/img/external-link.90577cc.svg +0 -1
  152. package/dist/assets/img/fb_inverse_circle.36c2cfc.png +0 -0
  153. package/dist/assets/img/ghn.070f8e3.svg +0 -17
  154. package/dist/assets/img/ghtk.326eac1.svg +0 -18
  155. package/dist/assets/img/image_default.be0698b.png +0 -0
  156. package/dist/assets/img/info.ebce7ea.svg +0 -1
  157. package/dist/assets/img/loader.37000a7.svg +0 -1
  158. package/dist/assets/img/loading_static.8f403ae.svg +0 -10
  159. package/dist/assets/img/main-service1.d536cc2.png +0 -0
  160. package/dist/assets/img/main-service2.9b99549.png +0 -0
  161. package/dist/assets/img/not_found_search.2ddb8d1.png +0 -0
  162. package/dist/assets/img/package.8d37d0f.svg +0 -5
  163. package/dist/assets/img/package_fade.763c001.svg +0 -1
  164. package/dist/assets/img/rating--average.1ea492c.svg +0 -12
  165. package/dist/assets/img/rating--great.e3d712e.svg +0 -16
  166. package/dist/assets/img/rating--poor.2938a25.svg +0 -12
  167. package/dist/assets/img/search.f9705ff.svg +0 -1
  168. package/dist/assets/img/send.6db52a9.svg +0 -3
  169. package/dist/assets/img/shop.f7dc7d8.svg +0 -1
  170. package/dist/assets/img/shop_faded.df7845a.svg +0 -1
  171. package/dist/assets/img/subiz-mono.877e9f5.svg +0 -3
  172. package/dist/assets/img/x.26fdfa3.svg +0 -5
  173. package/dist/malicious-app.js +0 -13
  174. package/dist/screenshoot.html +0 -7
  175. package/dist/screenshoot.js +0 -5953
@@ -4,41 +4,31 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _index = _interopRequireDefault(require("../util/index.js"));
9
-
10
8
  var _common = require("../common.js");
11
-
12
9
  var _preact = require("preact");
13
-
14
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
-
16
11
  class ProductAttachments extends _common.Com {
17
12
  render() {
18
13
  let byType = _index.default.get(this.props.ev, 'by.type');
19
-
20
14
  if (byType === 'user') return null;
21
- let acc = this.props.store.matchAccount();
22
15
 
16
+ let acc = this.props.store.matchAccount();
23
17
  var attachments = _index.default.get(this.props.ev, 'data.message.attachments', []);
24
-
25
18
  let orders = _index.default.filter(attachments, att => att.type === 'order' && att.order).map(att => att.order);
26
-
27
19
  if (orders.length === 0) return null;
28
-
29
20
  let $orders = _index.default.map(orders, (order, index) => {
21
+ _index.default.calcOrderTotal(order);
30
22
  let $note = null;
31
-
32
23
  if (order.note) {
33
24
  $note = (0, _preact.h)("div", null, (0, _preact.h)("div", {
34
25
  class: "order_attachment__label"
35
26
  }, this.props.t('note')), (0, _preact.h)("div", {
36
- class: "order_attachment__text_truncate"
27
+ class: "order_attachment__note",
28
+ title: order.note
37
29
  }, order.note));
38
30
  }
39
-
40
31
  let $products = null;
41
-
42
32
  if (_index.default.size(order.items) > 0) {
43
33
  $products = (0, _preact.h)("div", null, (0, _preact.h)("div", {
44
34
  class: "order_attachment__label"
@@ -49,62 +39,131 @@ class ProductAttachments extends _common.Com {
49
39
  }, (0, _preact.h)("img", {
50
40
  class: "order_attachment__product_img",
51
41
  alt: '' + _index.default.get(product, 'id'),
52
- src: _index.default.get(product, 'images.0', require('../../assets/img/default.jpg'))
42
+ src: _index.default.get(product, 'image', require('../../assets/img/default.jpg'))
53
43
  }), (0, _preact.h)("div", {
54
44
  style: "overflow: hidden !important;"
55
45
  }, (0, _preact.h)("div", {
56
- class: "order_attachment__product_name"
57
- }, product.name), (0, _preact.h)("div", {
46
+ class: "order_attachment__product_name",
47
+ title: this.props.t.i18n(product.i18n_name) || product.name
48
+ }, this.props.t.i18n(product.i18n_name) || product.name), (0, _preact.h)("div", {
58
49
  class: "order_attachment__product_desc"
59
- }, product.description || product.long_description), (0, _preact.h)("div", {
50
+ }, _index.default.getProductPropName(product, ' / ')), (0, _preact.h)("div", {
60
51
  class: "order_attachment__product_desc"
61
52
  }, this.props.t('qty'), " ", item.quantity, "\xA0\xB7\xA0", _index.default.formatCurrency(product.price))));
62
53
  }));
63
54
  }
64
-
65
55
  let $total = (0, _preact.h)("div", {
66
56
  class: "order_attachment__footer"
67
- }, (0, _preact.h)("div", null, this.props.t('total')), ' ', (0, _preact.h)("div", null, (0, _preact.h)("b", null, _index.default.formatCurrency(order.total))));
68
-
69
- let addr = _index.default.get(order, 'shipping.address', {});
70
-
71
- let fulladdr = [addr.street, addr.ward, addr.district, addr.region, addr.country].filter(a => a).join(', ');
72
- let address = fulladdr;
57
+ }, (0, _preact.h)("div", {
58
+ class: "d-flex align-items-center justify-content-between"
59
+ }, (0, _preact.h)("div", null, this.props.t('total')), ' ', (0, _preact.h)("div", null, (0, _preact.h)("b", {
60
+ class: "order_attachment__total"
61
+ }, _index.default.formatCurrency(order.total)))));
73
62
  let phoneattr = _index.default.find(_index.default.get(order, 'user.attributes', []), attr => attr.key === 'phones') || {
74
63
  key: 'phones',
75
64
  text: ''
76
65
  };
77
-
78
66
  let phone = _index.default.get(order, 'shipping.address.phone', '').trim();
79
-
80
67
  phone = phone || _index.default.trim(phoneattr.text);
81
68
  if (phone) phone = this.props.t('phn') + ': ' + phone;
82
69
  let $shipto = null;
83
-
84
- if (address || phone) {
70
+ if (_index.default.displayOrderShippingAddress(order) || phone) {
85
71
  $shipto = (0, _preact.h)("div", null, (0, _preact.h)("div", {
86
72
  class: "order_attachment__label"
87
- }, this.props.t('ship_to')), (0, _preact.h)("div", {
88
- class: "order_attachment__text_truncate"
89
- }, address), (0, _preact.h)("div", {
73
+ }, this.props.t('ship_to')), (0, _preact.h)("div", null, _index.default.displayOrderShippingAddress(order)), (0, _preact.h)("div", {
90
74
  class: "order_attachment__text_truncate"
91
75
  }, phone));
92
76
  }
93
-
77
+ let $beforeTax = null;
78
+ if (order._discount_before_tax) {
79
+ $beforeTax = (0, _preact.h)("div", {
80
+ class: "order_attachment__footer"
81
+ }, (0, _preact.h)("div", {
82
+ class: "d-flex align-items-center justify-content-between"
83
+ }, (0, _preact.h)("div", {
84
+ class: "order_attachment__label no_margin"
85
+ }, this.props.t('subtotal_before_tax')), ' ', (0, _preact.h)("div", null, _index.default.formatCurrency(order._order_value))), (0, _preact.h)("div", {
86
+ class: "d-flex align-items-center justify-content-between"
87
+ }, (0, _preact.h)("div", {
88
+ class: "order_attachment__label no_margin"
89
+ }, this.props.t('discount_before_tax')), ' ', (0, _preact.h)("div", null, "-", _index.default.formatCurrency(order._discount_before_tax))));
90
+ }
91
+ let $subtotal = (0, _preact.h)("div", {
92
+ class: "d-flex align-items-center justify-content-between"
93
+ }, (0, _preact.h)("div", {
94
+ class: "order_attachment__label no_margin"
95
+ }, this.props.t('subtotal')), ' ', (0, _preact.h)("div", {
96
+ style: ""
97
+ }, _index.default.formatCurrency(order.subtotal)));
98
+ let $tax = null;
99
+ if (order.total_tax) {
100
+ let taxname = '';
101
+ if (_index.default.size(order._taxM) === 1) {
102
+ let tax = _index.default.get(order._taxM, '0.tax', {});
103
+ if (tax.name && tax.percentage) taxname = `(${tax.name} ${Math.round(tax.percentage || 0) / 100}%)`;
104
+ }
105
+ $tax = (0, _preact.h)("div", {
106
+ class: "d-flex align-items-center justify-content-between"
107
+ }, (0, _preact.h)("div", {
108
+ class: "order_attachment__label no_margin"
109
+ }, this.props.t('tax'), " ", taxname), (0, _preact.h)("div", {
110
+ style: ""
111
+ }, _index.default.formatCurrency(order.total_tax)));
112
+ }
113
+ let $discount = null;
114
+ if (order.discount_type === 'percentage' && order.discount_percentage) {
115
+ $discount = (0, _preact.h)("div", {
116
+ class: "d-flex align-items-center justify-content-between"
117
+ }, (0, _preact.h)("div", {
118
+ class: "order_attachment__label no_margin"
119
+ }, this.props.t('discount_after_tax'), " (", Math.round(order.discount_percentage / 100), "%)"), ' ', (0, _preact.h)("div", {
120
+ style: ""
121
+ }, "-", _index.default.formatCurrency(order._computed_discount)));
122
+ }
123
+ if (order.discount_type === 'amount' && order.discount_amount) {
124
+ $discount = (0, _preact.h)("div", {
125
+ class: "d-flex align-items-center justify-content-between"
126
+ }, (0, _preact.h)("div", {
127
+ class: "order_attachment__label no_margin"
128
+ }, this.props.t('discount_after_tax')), ' ', (0, _preact.h)("div", {
129
+ class: "no-shrink"
130
+ }, "-", _index.default.formatCurrency(order._computed_discount)));
131
+ }
132
+ let $shipping = null;
133
+ if (_index.default.get(order, 'shipping.nominal_fee')) {
134
+ $shipping = (0, _preact.h)("div", {
135
+ class: "d-flex align-items-center justify-content-between"
136
+ }, (0, _preact.h)("div", {
137
+ class: "order_attachment__label no_margin"
138
+ }, this.props.t('shipping_fee')), ' ', (0, _preact.h)("div", {
139
+ style: ""
140
+ }, _index.default.formatCurrency(_index.default.get(order, 'shipping.nominal_fee', 0))));
141
+ }
142
+ let $adjustment = null;
143
+ if (order.adjustment) {
144
+ $adjustment = (0, _preact.h)("div", {
145
+ class: "d-flex align-items-center justify-content-between"
146
+ }, (0, _preact.h)("div", {
147
+ class: "order_attachment__label no_margin"
148
+ }, order.adjustment_description), ' ', (0, _preact.h)("div", {
149
+ class: "no-shrink"
150
+ }, _index.default.formatCurrency(order.adjustment)));
151
+ }
152
+ $subtotal = (0, _preact.h)("div", {
153
+ class: "order_attachment__footer"
154
+ }, $subtotal, $tax, $shipping, $discount, $adjustment);
155
+ if (!$shipping && !$adjustment && !$discount && !$tax) {
156
+ $subtotal = null;
157
+ }
94
158
  return (0, _preact.h)("div", {
95
159
  class: `order_attachment order_attachment__${byType}`
96
160
  }, (0, _preact.h)("div", {
97
161
  class: "order_attachment__header"
98
162
  }, this.props.t('order'), (0, _preact.h)("span", {
99
163
  class: "order_attachment__text_muted order_attachment__text_sm"
100
- }, "#", order.id)), $products, $shipto, (0, _preact.h)("div", null, (0, _preact.h)("div", {
101
- class: "order_attachment__label"
102
- }, this.props.t('payment')), (0, _preact.h)("div", null, "COD")), $note, $total);
164
+ }, _index.default.getOrderDisplayName(order))), $products, $shipto, $note, $beforeTax, $subtotal, $total);
103
165
  });
104
-
105
166
  return $orders;
106
167
  }
107
-
108
168
  }
109
-
110
169
  exports.default = ProductAttachments;
@@ -4,18 +4,13 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _common = require("../common.js");
9
-
10
8
  var _preact = require("preact");
11
-
12
9
  var logo = require('../../assets/img/subiz-mono.svg');
13
-
14
10
  class PoweredBy extends _common.Com {
15
11
  constructor(props) {
16
12
  super(props);
17
13
  }
18
-
19
14
  render() {
20
15
  if (this.props.store.isMobile()) return null;
21
16
  let user = this.props.store.matchUser();
@@ -35,7 +30,5 @@ class PoweredBy extends _common.Com {
35
30
  alt: "power by"
36
31
  }), " Subiz"));
37
32
  }
38
-
39
33
  }
40
-
41
34
  exports.default = PoweredBy;
@@ -4,29 +4,19 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _index = _interopRequireDefault(require("../util/index.js"));
9
-
10
8
  var _common = require("../common.js");
11
-
12
9
  var _preact = require("preact");
13
-
14
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
-
16
11
  class ProductAttachments extends _common.Com {
17
12
  render() {
18
13
  let byType = _index.default.get(this.props.ev, 'by.type');
19
-
20
14
  if (byType === 'user') return null;
21
-
22
15
  let attachments = _index.default.get(this.props.ev, 'data.message.attachments', []);
23
-
24
16
  let products = _index.default.filter(attachments, att => _index.default.get(att, 'type') === 'product' || _index.default.get(att, 'type') === 'product_preview');
25
-
26
17
  products = products.filter(product => product.product && product.product.name);
27
18
  if (products.length === 0) return null;
28
19
  let acc = this.props.store.matchAccount();
29
-
30
20
  let $products = _index.default.map(products, (att, index) => {
31
21
  let product = att.product;
32
22
  let $detailbtns = [];
@@ -41,7 +31,6 @@ class ProductAttachments extends _common.Com {
41
31
  class: "product_attachment__btn_external_link"
42
32
  })));
43
33
  console.log('P', product);
44
-
45
34
  if (_index.default.size(product.buttons) > 0) {
46
35
  $detailbtns = $detailbtns.concat(_index.default.map(product.buttons, (button, index) => {
47
36
  if (button.type === 'call_button') {
@@ -52,7 +41,6 @@ class ProductAttachments extends _common.Com {
52
41
  title: button.title
53
42
  }, this.props.t.i18n(button.i18n_title) || button.title);
54
43
  }
55
-
56
44
  if (button.type === 'url_button') {
57
45
  return (0, _preact.h)("a", {
58
46
  class: "product_attachment__btn",
@@ -65,7 +53,6 @@ class ProductAttachments extends _common.Com {
65
53
  class: "product_attachment__btn_external_link"
66
54
  }));
67
55
  }
68
-
69
56
  if (button.type === 'postback_button') {
70
57
  return (0, _preact.h)("a", {
71
58
  class: "product_attachment__btn",
@@ -75,7 +62,6 @@ class ProductAttachments extends _common.Com {
75
62
  }
76
63
  }));
77
64
  }
78
-
79
65
  let $title = (0, _preact.h)("a", {
80
66
  href: url,
81
67
  class: "product_attachment__title",
@@ -87,13 +73,11 @@ class ProductAttachments extends _common.Com {
87
73
  class: "product_attachment__subtitle"
88
74
  }, desc);
89
75
  let $price = null;
90
-
91
76
  if (product.price) {
92
77
  $price = (0, _preact.h)("div", {
93
78
  class: "product_attachment__price"
94
79
  }, product.currency || _index.default.get(acc, 'currency', ''), " ", _index.default.formatCurrency(product.price));
95
80
  }
96
-
97
81
  return (0, _preact.h)("div", {
98
82
  class: 'product_attachment product_attachment__' + byType
99
83
  }, (0, _preact.h)("div", null, (0, _preact.h)("a", {
@@ -106,10 +90,7 @@ class ProductAttachments extends _common.Com {
106
90
  class: "product_attachment__btns"
107
91
  }, $detailbtns));
108
92
  });
109
-
110
93
  return $products;
111
94
  }
112
-
113
95
  }
114
-
115
96
  exports.default = ProductAttachments;
@@ -4,66 +4,48 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _index = _interopRequireDefault(require("../util/index.js"));
9
-
10
8
  var _common = require("../common.js");
11
-
12
9
  var _preact = require("preact");
13
-
14
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
-
16
11
  class QuickReplies extends _common.Com {
17
12
  constructor(props) {
18
13
  super(props);
19
14
  }
20
-
21
15
  render() {
22
16
  if (_index.default.get(this.props.ev, 'by.type') === 'user') return null;
23
17
  let quickreplies = [];
24
-
25
18
  _index.default.map(_index.default.get(this.props.ev, 'data.message.attachments', []), att => {
26
19
  if (!att) return;
27
-
28
20
  if (att.type === 'quick_replies') {
29
21
  quickreplies = _index.default.get(att, 'quick_replies', []);
30
22
  }
31
23
  });
32
-
33
24
  quickreplies = _index.default.filter(quickreplies, r => r.title);
34
25
  if (quickreplies.length === 0) return null;
35
-
36
26
  let cid = _index.default.convoOfEv(this.props.ev);
37
-
38
27
  let convo = this.props.store.matchConvo(cid);
39
28
  if (_index.default.get(convo, 'state') === 'ended') return null;
40
29
 
41
30
  let events = _index.default.map(this.props.store.listEvents(cid));
42
-
43
31
  events = _index.default.orderBy(events, 'created', 'asc').filter(ev => ev.type === 'message_sent');
44
32
  let evindex = 0;
45
-
46
33
  for (var i = 0; i < events.length; i++) {
47
34
  if (events[i].id === this.props.ev.id) {
48
35
  evindex = i;
49
36
  break;
50
37
  }
51
38
  }
52
-
53
39
  for (var i = evindex + 1; i < events.length; i++) {
54
40
  if (_index.default.get(events[i], 'by.type') === 'user') return null;
55
41
  }
56
-
57
42
  let $replies = _index.default.map(quickreplies, r => (0, _preact.h)("div", {
58
43
  class: "message_quick_reply",
59
44
  onClick: e => this.props.onSelect(r)
60
45
  }, r.title));
61
-
62
46
  return (0, _preact.h)("div", {
63
47
  class: "message_quick_replies"
64
48
  }, $replies);
65
49
  }
66
-
67
50
  }
68
-
69
51
  exports.default = QuickReplies;
@@ -4,56 +4,40 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _index = _interopRequireDefault(require("../util/index.js"));
9
-
10
8
  var _releaseAnimation = _interopRequireDefault(require("./releaseAnimation.js"));
11
-
12
9
  var _common = require("../common.js");
13
-
14
10
  var _preact = require("preact");
15
-
16
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
-
18
12
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
19
-
20
13
  const POPUP_MAX_HEIGHT = 400;
21
14
  const POPUP_HARD_MAX_HEIGHT = 500;
22
15
  const POPUP_MIN_HEIGHT = 0;
23
-
24
16
  class Rating extends _common.Com {
25
17
  constructor(props) {
26
18
  super(props);
27
-
28
19
  _defineProperty(this, "state", {
29
20
  hide: true,
30
21
  ratingHeight: 0,
31
22
  overlayOpacity: 0.3,
32
23
  comment: ''
33
24
  });
34
-
35
25
  this.refComment = (0, _preact.createRef)();
36
26
  this.refRating = (0, _preact.createRef)();
37
27
  this.refHandle = (0, _preact.createRef)();
38
28
  }
39
-
40
29
  componentDidMount() {
41
30
  this.props.store.onUpdate(this, () => {
42
31
  if (this.shoudDisplay()) this.open();
43
32
  });
44
33
  this.props.store.onConvoEvent(this, ev => {
45
34
  var cid = _index.default.convoOfEv(ev);
46
-
47
35
  if (cid !== this.props.cid) return;
48
36
  if (this.shoudDisplay()) this.open();
49
37
  });
50
-
51
38
  this.mouseUp = e => this.onMouseUp(e);
52
-
53
39
  this.mouseMove = e => this.onMouseMove(e);
54
-
55
40
  this.mouseDown = e => this.onMouseDown(e);
56
-
57
41
  var $ratingHandle = this.refHandle.current;
58
42
  $ratingHandle.addEventListener('mousedown', this.mouseDown, {
59
43
  passive: true
@@ -81,7 +65,6 @@ class Rating extends _common.Com {
81
65
  this.close();
82
66
  if (this.shoudDisplay() || this.props.forceView === 'rating') this.open();
83
67
  }
84
-
85
68
  componentWillUnmount() {
86
69
  var $ratingHandle = this.refHandle.current;
87
70
  $ratingHandle.removeEventListener('mousedown', this.mouseDown, 0);
@@ -91,7 +74,6 @@ class Rating extends _common.Com {
91
74
  window.removeEventListener('mousemove', this.mouseMove, 0);
92
75
  window.removeEventListener('touchmove', this.mouseMove, 0);
93
76
  }
94
-
95
77
  render() {
96
78
  let cls = this.state.hide ? 'd-none' : '';
97
79
  return (0, _preact.h)("div", {
@@ -152,29 +134,24 @@ class Rating extends _common.Com {
152
134
  onClick: e => this.onCloseRating(e)
153
135
  }, this.props.t('no_thanks')))));
154
136
  }
155
-
156
137
  shoudDisplay() {
157
138
  if (!this.props.cid) return false;
158
139
  var requested;
159
140
  var rated;
160
141
  var ended;
161
142
  let user = this.props.store.matchUser();
162
-
163
143
  _index.default.map(this.props.store.listEvents(this.props.cid), ev => {
164
144
  if (_index.default.get(ev, 'type') === 'conversation_state_updated' && _index.default.get(ev, 'data.conversation.state') === 'ended') {
165
145
  ended = ev;
166
146
  }
167
-
168
147
  if (_index.default.get(ev, 'type') === 'conversation_rating_requested') requested = ev;
169
148
  if (_index.default.get(ev, 'type') === 'conversation_rated' && _index.default.get(ev, 'by.id') === user.id) rated = ev;
170
149
  });
171
-
172
150
  if (rated) return false;
173
151
  let accountSetting = this.props.plugin.chatbox;
174
152
  var auto = accountSetting.auto_request_rating && ended;
175
153
  return requested || auto;
176
154
  }
177
-
178
155
  onCloseRating() {
179
156
  this.props.onRate && this.props.onRate({
180
157
  no_rating: true,
@@ -182,7 +159,6 @@ class Rating extends _common.Com {
182
159
  });
183
160
  this.close();
184
161
  }
185
-
186
162
  onRatingPoor() {
187
163
  this.props.onRate && this.props.onRate({
188
164
  rating: 1,
@@ -190,7 +166,6 @@ class Rating extends _common.Com {
190
166
  });
191
167
  this.close();
192
168
  }
193
-
194
169
  onRatingAverage() {
195
170
  this.props.onRate && this.props.onRate({
196
171
  rating: 3,
@@ -198,7 +173,6 @@ class Rating extends _common.Com {
198
173
  });
199
174
  this.close();
200
175
  }
201
-
202
176
  onRatingGreat() {
203
177
  this.props.onRate && this.props.onRate({
204
178
  rating: 5,
@@ -206,7 +180,6 @@ class Rating extends _common.Com {
206
180
  });
207
181
  this.close();
208
182
  }
209
-
210
183
  open() {
211
184
  if (!this.state.hide) return;
212
185
  this.setState({
@@ -226,7 +199,6 @@ class Rating extends _common.Com {
226
199
  });
227
200
  });
228
201
  }
229
-
230
202
  close() {
231
203
  if (this.state.hide) return;
232
204
  if (!this.refRating.current) return;
@@ -237,7 +209,6 @@ class Rating extends _common.Com {
237
209
  ratingHeight: h,
238
210
  overlayOpacity: Math.min(1, (h - POPUP_MIN_HEIGHT) / (POPUP_HARD_MAX_HEIGHT - POPUP_MIN_HEIGHT))
239
211
  });
240
-
241
212
  if (h < POPUP_MIN_HEIGHT + 10) {
242
213
  if (!this.state.hide) {
243
214
  this.setState({
@@ -247,7 +218,6 @@ class Rating extends _common.Com {
247
218
  }
248
219
  });
249
220
  }
250
-
251
221
  onMouseDown(e) {
252
222
  this.mousePushed = true;
253
223
  this.animation.stop();
@@ -255,7 +225,6 @@ class Rating extends _common.Com {
255
225
  if (e.touches && e.touches[0]) e = e.touches[0];
256
226
  this.mousePushedDy = e.pageY - window.pageYOffset - this.refRating.current.getBoundingClientRect().y;
257
227
  }
258
-
259
228
  onMouseUp(e) {
260
229
  if (!this.mousePushed) return;
261
230
  if (e.touches && e.touches[0]) e = e.touches[0];
@@ -267,7 +236,6 @@ class Rating extends _common.Com {
267
236
  ratingHeight: h,
268
237
  overlayOpacity: Math.min(1, (h - POPUP_MIN_HEIGHT) / (POPUP_HARD_MAX_HEIGHT - POPUP_MIN_HEIGHT))
269
238
  });
270
-
271
239
  if (h < POPUP_MIN_HEIGHT + 10) {
272
240
  if (!this.state.hide) {
273
241
  this.setState({
@@ -280,7 +248,6 @@ class Rating extends _common.Com {
280
248
  }
281
249
  });
282
250
  }
283
-
284
251
  onMouseMove(e) {
285
252
  if (!this.mousePushed) return;
286
253
  if (e.touches && e.touches[0]) e = e.touches[0];
@@ -290,18 +257,14 @@ class Rating extends _common.Com {
290
257
  my = my - this.mousePushedDy;
291
258
  var K = 10000;
292
259
  var height = this.refRating.current.getBoundingClientRect().bottom - my;
293
-
294
260
  if (height > POPUP_MAX_HEIGHT) {
295
261
  var beta = K / (POPUP_HARD_MAX_HEIGHT - POPUP_MAX_HEIGHT) - POPUP_MAX_HEIGHT;
296
262
  height = POPUP_HARD_MAX_HEIGHT - K / (height + beta);
297
263
  }
298
-
299
264
  this.setState({
300
265
  ratingHeight: height,
301
266
  overlayOpacity: Math.min(1, (height - POPUP_MIN_HEIGHT) / (POPUP_HARD_MAX_HEIGHT - POPUP_MIN_HEIGHT))
302
267
  });
303
268
  }
304
-
305
269
  }
306
-
307
270
  exports.default = Rating;
@@ -4,24 +4,19 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _common = require("../common.js");
9
-
10
8
  var _preact = require("preact");
11
-
12
9
  class ShadowDomRoot extends _common.Com {
13
10
  constructor(props) {
14
11
  super(props);
15
12
  this.ref = (0, _preact.createRef)();
16
13
  }
17
-
18
14
  componentDidMount() {
19
15
  this.shadowRoot = this.ref.current.attachShadow({
20
16
  mode: 'open'
21
17
  });
22
18
  this.update(this.props.html);
23
19
  }
24
-
25
20
  update(html) {
26
21
  this.shadowRoot.innerHTML = `<style type="text/css">
27
22
  body { font-family: 'Roboto', sans-serif!important; font-size: 14px!important; line-height: 20px; overflow-y: hidden; margin:0 }
@@ -35,17 +30,13 @@ p { margin-bottom: 0; margin-top: 0;}
35
30
  </style>
36
31
  <div>${html}</div>`;
37
32
  let links = this.shadowRoot.querySelectorAll('a');
38
-
39
33
  for (var i = 0; i < links.length; i++) links[i].target = '_blank';
40
34
  }
41
-
42
35
  render() {
43
36
  return (0, _preact.h)("div", {
44
37
  ref: this.ref,
45
38
  style: "white-space: normal !important"
46
39
  });
47
40
  }
48
-
49
41
  }
50
-
51
42
  exports.default = ShadowDomRoot;