@subiz/widget-v4 4.0.58 → 4.0.63

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 (156) hide show
  1. package/assets/img/caret.svg +1 -0
  2. package/assets/img/done_green.svg +4 -0
  3. package/assets/img/empty_1.svg +11 -0
  4. package/assets/img/ghn.svg +17 -0
  5. package/assets/img/ghtk.svg +18 -0
  6. package/assets/img/home.svg +1 -0
  7. package/assets/img/info.svg +1 -0
  8. package/assets/img/loader.svg +1 -0
  9. package/assets/img/map-pin.svg +1 -0
  10. package/assets/img/not_found_search.png +0 -0
  11. package/assets/img/package.svg +5 -0
  12. package/assets/img/package_fade.svg +1 -0
  13. package/assets/img/phone.svg +1 -0
  14. package/assets/img/search.svg +1 -0
  15. package/assets/img/shop.svg +1 -0
  16. package/assets/img/shop_faded.svg +1 -0
  17. package/assets/img/user.svg +1 -0
  18. package/assets/img/x.svg +5 -0
  19. package/assets/less/chatbox.less +35 -0
  20. package/assets/less/dropdown_select.less +130 -0
  21. package/assets/less/form.less +7 -20
  22. package/assets/less/order.less +489 -0
  23. package/assets/less/rating.less +3 -8
  24. package/compiled_src/call/call.js +12 -15
  25. package/compiled_src/chatbox/DropdownSelect.js +239 -0
  26. package/compiled_src/chatbox/Event.js +4 -2
  27. package/compiled_src/chatbox/Events.js +1 -0
  28. package/compiled_src/chatbox/MessageInput.js +4 -7
  29. package/compiled_src/chatbox/Order.js +281 -0
  30. package/compiled_src/chatbox/OrderAttachments.js +2 -1
  31. package/compiled_src/chatbox/Rating.js +7 -10
  32. package/compiled_src/chatbox/TextMessage.js +9 -2
  33. package/compiled_src/chatbox/Widget.js +40 -3
  34. package/compiled_src/chatbox/main.js +2 -1
  35. package/compiled_src/chatbox/spinner.js +1 -1
  36. package/compiled_src/chatbox/time.js +3 -1
  37. package/compiled_src/common.js +40 -1
  38. package/compiled_src/contact/contact.js +7 -12
  39. package/compiled_src/lib.js +9 -14
  40. package/compiled_src/notif/notif.js +12 -15
  41. package/compiled_src/order/address_picker.js +241 -0
  42. package/compiled_src/order/icon.js +62 -0
  43. package/compiled_src/order/index.js +113 -0
  44. package/compiled_src/order/order.js +1220 -0
  45. package/compiled_src/plugin.js +9 -42
  46. package/compiled_src/popup/countdown.js +4 -7
  47. package/compiled_src/popup/popup.js +40 -13
  48. package/compiled_src/store/api.js +80 -90
  49. package/compiled_src/store/api_fake.js +55 -82
  50. package/compiled_src/store/store.js +163 -158
  51. package/compiled_src/util/common.js +40 -4
  52. package/dist/0b82fa7e5c3b07b40a44.png +1 -0
  53. package/dist/0f4af006e38ee8b93633.png +1 -0
  54. package/dist/{74.js → 132.js} +2234 -236
  55. package/dist/178.js +341 -174
  56. package/dist/17e757ccadd.132.js +1 -0
  57. package/dist/17e757ccadd.178.js +1 -0
  58. package/dist/17e757ccadd.213.js +1 -0
  59. package/dist/17e757ccadd.335.js +1 -0
  60. package/dist/17e757ccadd.362.js +1 -0
  61. package/dist/17e757ccadd.441.js +1 -0
  62. package/dist/17e757ccadd.605.js +1 -0
  63. package/dist/17e757ccadd.678.js +1 -0
  64. package/dist/17e757ccadd.782.js +1 -0
  65. package/dist/17e757ccadd.app.js +1 -0
  66. package/dist/{17d938a5acb.index.html → 17e757ccadd.index.html} +3 -18
  67. package/dist/{17d938a5acb.library.html → 17e757ccadd.library.html} +3 -18
  68. package/dist/17e757ccadd.library.js +1 -0
  69. package/dist/{17d938a5acb.preview.html → 17e757ccadd.preview.html} +1 -1
  70. package/dist/17e757ccadd.preview.js +1 -0
  71. package/dist/17e757ccadd.screenshoot.js +1 -0
  72. package/dist/1ea1c6cd21d25176810c.png +1 -0
  73. package/dist/213.js +46 -87
  74. package/dist/292d42404e1b03398f61.png +1 -0
  75. package/dist/312d376370831b7bea83.png +1 -0
  76. package/dist/313d1bfc1cf776d1aefe.png +1 -0
  77. package/dist/335.js +408 -0
  78. package/dist/362.js +71 -21
  79. package/dist/441.js +69 -43
  80. package/dist/4aa58bb7a66bb44975aa.png +1 -0
  81. package/dist/56ce063bc6c81adb7322.png +1 -0
  82. package/dist/605.js +13 -79
  83. package/dist/678.js +70 -20
  84. package/dist/6a411166ef5cc79e0714.png +1 -0
  85. package/dist/6faf403782fefacc1649.png +1 -0
  86. package/dist/782.js +118 -21
  87. package/dist/79dca33c68fab79c067f.png +1 -0
  88. package/dist/82da1578fa84f9debaeb.png +1 -0
  89. package/dist/8b8e0f0824743974b282.png +1 -0
  90. package/dist/8d551390d81e39130a3c.png +1 -0
  91. package/dist/9fc61b9479877ebdb6c7.png +1 -0
  92. package/dist/HASH +1 -1
  93. package/dist/a165d31dcb3dc90f1057.png +1 -0
  94. package/dist/a98d4a5698812c4426b3.png +1 -0
  95. package/dist/assets/img/caret.998eb8f.svg +1 -0
  96. package/dist/assets/img/done_green.b817fd4.svg +4 -0
  97. package/dist/assets/img/empty_1.0b98af0.svg +11 -0
  98. package/dist/assets/img/ghn.070f8e3.svg +17 -0
  99. package/dist/assets/img/ghtk.326eac1.svg +18 -0
  100. package/dist/assets/img/info.ebce7ea.svg +1 -0
  101. package/dist/assets/img/loader.37000a7.svg +1 -0
  102. package/dist/assets/img/not_found_search.2ddb8d1.png +0 -0
  103. package/dist/assets/img/package.8d37d0f.svg +5 -0
  104. package/dist/assets/img/package_fade.763c001.svg +1 -0
  105. package/dist/assets/img/search.f9705ff.svg +1 -0
  106. package/dist/assets/img/shop.f7dc7d8.svg +1 -0
  107. package/dist/assets/img/shop_faded.df7845a.svg +1 -0
  108. package/dist/assets/img/x.26fdfa3.svg +5 -0
  109. package/dist/c41606bf9d1b604e46d5.png +1 -0
  110. package/dist/ce1f7450ce6c1aacd330.png +1 -0
  111. package/dist/cf8c01e88f4770a6e3e5.png +1 -0
  112. package/dist/dfbcfeab1d5622a737e2.png +1 -0
  113. package/dist/e4893ed8c2f7b8329919.png +1 -0
  114. package/dist/ec2ab4eb4ef73d186186.png +1 -0
  115. package/dist/screenshoot.html +1 -1
  116. package/dist/screenshoot.js +452 -389
  117. package/index.html +3 -18
  118. package/order.html +32 -0
  119. package/package.json +13 -14
  120. package/src/chatbox/DropdownSelect.js +229 -0
  121. package/src/chatbox/Event.js +2 -2
  122. package/src/chatbox/Events.js +43 -42
  123. package/src/chatbox/Order.js +232 -0
  124. package/src/chatbox/OrderAttachments.js +2 -1
  125. package/src/chatbox/TextMessage.js +21 -12
  126. package/src/chatbox/Widget.js +34 -4
  127. package/src/chatbox/main.js +2 -2
  128. package/src/chatbox/spinner.js +1 -1
  129. package/src/chatbox/time.js +1 -1
  130. package/src/common.js +52 -8
  131. package/src/contact/contact.js +1 -1
  132. package/src/order/address_picker.js +235 -0
  133. package/src/order/icon.js +32 -0
  134. package/src/order/index.js +86 -0
  135. package/src/order/order.js +1157 -0
  136. package/src/order/scratch +211 -0
  137. package/src/plugin.js +7 -52
  138. package/src/popup/popup.js +27 -2
  139. package/src/store/api.js +26 -1
  140. package/src/store/store.js +46 -9
  141. package/src/util/common.js +52 -4
  142. package/webpack.dev.js +2 -0
  143. package/dist/17d938a5acb.178.js +0 -1
  144. package/dist/17d938a5acb.213.js +0 -1
  145. package/dist/17d938a5acb.362.js +0 -1
  146. package/dist/17d938a5acb.441.js +0 -1
  147. package/dist/17d938a5acb.605.js +0 -1
  148. package/dist/17d938a5acb.619.js +0 -1
  149. package/dist/17d938a5acb.678.js +0 -1
  150. package/dist/17d938a5acb.74.js +0 -1
  151. package/dist/17d938a5acb.782.js +0 -1
  152. package/dist/17d938a5acb.app.js +0 -1
  153. package/dist/17d938a5acb.library.js +0 -1
  154. package/dist/17d938a5acb.preview.js +0 -1
  155. package/dist/17d938a5acb.screenshoot.js +0 -1
  156. package/dist/619.js +0 -777
@@ -0,0 +1,239 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _index = _interopRequireDefault(require("../util/index.js"));
9
+
10
+ var _common = require("../common.js");
11
+
12
+ var _preact = require("preact");
13
+
14
+ var _spinner = _interopRequireDefault(require("./spinner.js"));
15
+
16
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
+
18
+ class DropdownSelect extends _common.Com {
19
+ state = {
20
+ show: false,
21
+ searchValue: ''
22
+ };
23
+ filterRef = (0, _preact.createRef)();
24
+ overlayRef = (0, _preact.createRef)();
25
+
26
+ constructor(props) {
27
+ super(props);
28
+ document.addEventListener('touchmove', function (e) {});
29
+ }
30
+
31
+ onTouchMove = e => {
32
+ if (e.target === this.overlayRef.current) {
33
+ e.preventDefault();
34
+ e.stopPropagation();
35
+ }
36
+ };
37
+ hideDropdown = () => {
38
+ this.setState({
39
+ show: false,
40
+ searchValue: ''
41
+ });
42
+ };
43
+ onKeydown = e => {
44
+ if (e.key === 'Escape') {
45
+ if (!this.state.show) return;
46
+ if (this.state.searchValue) this.setState({
47
+ searchValue: ''
48
+ });else this.hideDropdown();
49
+ e.preventDefault();
50
+ e.stopPropagation();
51
+ }
52
+ };
53
+ hasSearch = () => {
54
+ if (this.props.has_search) return true;
55
+ return _index.default.size(this.props.items) >= 10;
56
+ };
57
+ getFilteredOptions = () => {
58
+ let items = this.props.items;
59
+
60
+ if (this.state.searchValue && this.hasSearch()) {
61
+ items = _index.default.filter(items, item => {
62
+ let optionName = _index.default.unicodeToAscii(item.name).toLowerCase().replace(/ /g, '');
63
+
64
+ let optionDesc = _index.default.unicodeToAscii(item.desc).toLowerCase().replace(/ /g, '');
65
+
66
+ let searchValue = _index.default.unicodeToAscii(this.state.searchValue).toLowerCase().replace(/ /g, '');
67
+
68
+ return optionName.indexOf(searchValue) != -1 || optionDesc.indexOf(searchValue) != -1;
69
+ });
70
+ }
71
+
72
+ return items;
73
+ };
74
+
75
+ componentDidMount() {
76
+ window.addEventListener('keydown', this.onKeydown);
77
+ }
78
+
79
+ componentWillUnmount() {
80
+ window.removeEventListener('keydown', this.onKeydown);
81
+ }
82
+
83
+ onChangeSearchValue = e => {
84
+ this.setState({
85
+ searchValue: e.target.value
86
+ });
87
+ };
88
+
89
+ renderEmpty() {
90
+ return (0, _preact.h)("div", {
91
+ class: "dropdown_select_filter__empty"
92
+ }, (0, _preact.h)("img", {
93
+ class: "dropdown_select_filter__empty_img",
94
+ src: require('../../assets/img/not_found_search.png')
95
+ }), (0, _preact.h)("div", {
96
+ class: "muted",
97
+ style: "text-align: center !important;"
98
+ }, "Kh\xF4ng c\xF3 k\u1EBFt qu\u1EA3"));
99
+ }
100
+
101
+ renderLoading() {
102
+ return (0, _preact.h)("div", {
103
+ class: "dropdown_select_filter__empty pt-3"
104
+ }, (0, _preact.h)(_spinner.default, {
105
+ size: "40",
106
+ static: true
107
+ }), (0, _preact.h)("div", {
108
+ class: "muted mt-2",
109
+ style: "text-align: center !important;"
110
+ }, "\u0110ang t\u1EA3i d\u1EEF li\u1EC7u"));
111
+ }
112
+
113
+ toogleDropdown = async () => {
114
+ await this.setState({
115
+ show: true,
116
+ searchValue: ''
117
+ });
118
+ this.focusFilter();
119
+ };
120
+
121
+ focusFilter() {
122
+ if (!this.filterRef.current) return;
123
+ this.filterRef.current.focus();
124
+ setTimeout(() => {
125
+ if (!this.filterRef.current) return;
126
+ this.filterRef.current.focus();
127
+ }, 100);
128
+ }
129
+
130
+ onSelect = item => {
131
+ this.props.onSelect(item);
132
+ this.hideDropdown();
133
+ };
134
+
135
+ renderDropdown() {
136
+ if (!this.state.show) return null;
137
+ let items = this.getFilteredOptions();
138
+
139
+ let $items = _index.default.map(items, item => {
140
+ return (0, _preact.h)("div", {
141
+ class: "dropdown_select__item",
142
+ onClick: _ => this.onSelect(item)
143
+ }, item.name);
144
+ });
145
+
146
+ let $filter = null;
147
+
148
+ if (this.hasSearch()) {
149
+ let $img = (0, _preact.h)("img", {
150
+ class: "dropdown_select_filter__icon",
151
+ src: require('../../assets/img/search.svg')
152
+ });
153
+
154
+ if (this.props.loading) {
155
+ $img = (0, _preact.h)("img", {
156
+ class: "dropdown_select_filter__icon",
157
+ src: require('../../assets/img/loader.svg')
158
+ });
159
+ }
160
+
161
+ $filter = (0, _preact.h)("div", {
162
+ class: "dropdown_select_filter"
163
+ }, $img, (0, _preact.h)("input", {
164
+ ref: this.filterRef,
165
+ value: this.state.searchValue,
166
+ onInput: this.onChangeSearchValue,
167
+ type: "text",
168
+ class: "dropdown_select_filter_input "
169
+ }));
170
+ }
171
+
172
+ if ($items.length == 0) $items = this.renderEmpty();
173
+ if (this.props.loading) $items = this.renderLoading();
174
+ let style = `width: ${this.props.width || '150px'} !important;`;
175
+
176
+ if (this.props.full) {
177
+ style = ` top: 20px !important; left: 20px !important; right: 20px !important; width: unset !important; `;
178
+ return (0, _preact.h)("div", {
179
+ class: "dropdown_select__overlay",
180
+ ref: this.overlayRef,
181
+ onClick: this.hideDropdown,
182
+ onTouchMove: this.onTouchMove
183
+ }, (0, _preact.h)("div", {
184
+ class: "dropdown_select",
185
+ style: style,
186
+ onClick: e => {
187
+ e.preventDefault();
188
+ e.stopPropagation();
189
+ }
190
+ }, $filter, (0, _preact.h)("div", {
191
+ class: "dropdown_select__items"
192
+ }, $items)));
193
+ }
194
+
195
+ return (0, _preact.h)("div", {
196
+ class: "dropdown_select",
197
+ style: style
198
+ }, $filter, (0, _preact.h)("div", {
199
+ class: "dropdown_select__items"
200
+ }, $items));
201
+ }
202
+
203
+ onBackgroundScroll = e => {
204
+ console.log('EEEEEEE', e);
205
+ alert('y');
206
+ };
207
+
208
+ render() {
209
+ let $name = (0, _preact.h)("div", {
210
+ class: "muted text-truncate",
211
+ style: "flex: 1 !important;"
212
+ }, "Ch\u1ECDn m\u1ED9t ph\u1EA7n t\u1EED");
213
+ if (_index.default.get(this.props, 'selected.name')) $name = (0, _preact.h)("div", {
214
+ class: "text-truncate",
215
+ style: "flex: 1 !important;"
216
+ }, _index.default.get(this.props, 'selected.name'));
217
+ let style = 'position: relative !important;';
218
+
219
+ if (this.props.full) {
220
+ style = '';
221
+ }
222
+
223
+ return (0, _preact.h)("div", {
224
+ style: style
225
+ }, (0, _preact.h)(_common.Clickaway, {
226
+ onClickaway: this.hideDropdown
227
+ }, (0, _preact.h)("div", {
228
+ type: "text",
229
+ class: 'dropdown_select_input ' + this.props.extra_cls,
230
+ onClick: this.toogleDropdown
231
+ }, $name, "\xA0", (0, _preact.h)("img", {
232
+ class: "dropdown_select__caret",
233
+ src: require('../../assets/img/caret.svg')
234
+ })), this.renderDropdown()));
235
+ }
236
+
237
+ }
238
+
239
+ exports.default = DropdownSelect;
@@ -167,7 +167,8 @@ class Event extends _common.Com {
167
167
  title: t
168
168
  }, $time, $sender, (0, _preact.h)(_TextMessage.default, {
169
169
  store: this.props.store,
170
- ev: ev
170
+ ev: ev,
171
+ onLink: this.props.onLink
171
172
  }), (0, _preact.h)(_ImageAttachments.default, {
172
173
  store: this.props.store,
173
174
  ev: ev
@@ -254,7 +255,8 @@ class Event extends _common.Com {
254
255
  }, $dot, (0, _preact.h)(_TextMessage.default, {
255
256
  store: this.props.store,
256
257
  ev: ev,
257
- refresh: this.state.refresh
258
+ refresh: this.state.refresh,
259
+ onLink: this.props.onLink
258
260
  }), (0, _preact.h)(_ImageAttachments.default, {
259
261
  store: this.props.store,
260
262
  ev: ev
@@ -68,6 +68,7 @@ class Events extends _common.Com {
68
68
  processEvents(convo, events);
69
69
 
70
70
  let $events = _index.default.map(events, ev => (0, _preact.h)(_Event.default, {
71
+ onLink: this.props.onLink,
71
72
  store: this.props.store,
72
73
  onFormSubmit: this.props.onFormSubmit,
73
74
  onSend: this.props.onSend,
@@ -15,16 +15,9 @@ var _Emoji = _interopRequireDefault(require("./Emoji.js"));
15
15
 
16
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
17
 
18
- 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
18
  class MessageInput extends _common.Com {
21
19
  constructor(props) {
22
20
  super(props);
23
-
24
- _defineProperty(this, "onEnter", _index.default.throttle(function () {
25
- this.submitMessage();
26
- }, 50));
27
-
28
21
  this.refFileInput = (0, _preact.createRef)();
29
22
  this.refMessageInput = (0, _preact.createRef)();
30
23
  this.props.store.onUpdate(this, _ => this.forceUpdate());
@@ -269,6 +262,10 @@ class MessageInput extends _common.Com {
269
262
  input.focus();
270
263
  }
271
264
 
265
+ onEnter = _index.default.throttle(function () {
266
+ this.submitMessage();
267
+ }, 50);
268
+
272
269
  onKeydown(e) {
273
270
  if (e.keyCode === 13 && e.shiftKey === false) {
274
271
  this.onEnter();
@@ -0,0 +1,281 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _index = _interopRequireDefault(require("../util/index.js"));
9
+
10
+ var _releaseAnimation = _interopRequireDefault(require("./releaseAnimation.js"));
11
+
12
+ var _time = _interopRequireDefault(require("./time.js"));
13
+
14
+ var _common = require("../common.js");
15
+
16
+ var _preact = require("preact");
17
+
18
+ var _order = _interopRequireDefault(require("../order/order.js"));
19
+
20
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
+
22
+ const POPUP_MAX_HEIGHT = 400;
23
+ const POPUP_HARD_MAX_HEIGHT = 500;
24
+ const POPUP_MIN_HEIGHT = 0;
25
+
26
+ let defaultAvatar = require('../../assets/img/default_avatar.png');
27
+
28
+ class Order extends _common.Com {
29
+ constructor(props) {
30
+ super(props);
31
+ this.refRating = (0, _preact.createRef)();
32
+ this.refHandle = (0, _preact.createRef)();
33
+ }
34
+
35
+ state = {
36
+ hide: true,
37
+ ratingHeight: 0,
38
+ overlayOpacity: 0.3
39
+ };
40
+
41
+ componentDidMount() {
42
+ this.mouseUp = e => this.onMouseUp(e);
43
+
44
+ this.mouseMove = e => this.onMouseMove(e);
45
+
46
+ this.mouseDown = e => this.onMouseDown(e);
47
+
48
+ var $ratingHandle = this.refHandle.current;
49
+ $ratingHandle.addEventListener('mousedown', this.mouseDown, {
50
+ passive: true
51
+ });
52
+ $ratingHandle.addEventListener('touchstart', this.mouseDown, {
53
+ passive: true
54
+ });
55
+ window.addEventListener('mouseup', this.mouseUp, {
56
+ passive: true
57
+ });
58
+ window.addEventListener('touchend', this.mouseUp, {
59
+ passive: true
60
+ });
61
+ window.addEventListener('mousemove', this.mouseMove, {
62
+ passive: true
63
+ });
64
+ window.addEventListener('touchmove', this.mouseMove, {
65
+ passive: true
66
+ });
67
+ this.animation = new _releaseAnimation.default({
68
+ maxY: POPUP_MAX_HEIGHT,
69
+ minY: POPUP_MIN_HEIGHT,
70
+ duration: 150
71
+ });
72
+ this.close();
73
+ }
74
+
75
+ componentWillUnmount() {
76
+ var $ratingHandle = this.refHandle.current;
77
+ $ratingHandle.removeEventListener('mousedown', this.mouseDown, 0);
78
+ $ratingHandle.removeEventListener('touchstart', this.mouseDown, 0);
79
+ window.removeEventListener('mouseup', this.mouseUp, 0);
80
+ window.removeEventListener('touchend', this.mouseUp, 0);
81
+ window.removeEventListener('mousemove', this.mouseMove, 0);
82
+ window.removeEventListener('touchmove', this.mouseMove, 0);
83
+ }
84
+
85
+ render() {
86
+ if (this._show != this.props.show) {
87
+ this._show = this.props.show;
88
+ setTimeout(() => {
89
+ if (!this._show) this.close();else this.open();
90
+ });
91
+ }
92
+
93
+ let cls = this.state.hide ? 'd-none' : '';
94
+ return (0, _preact.h)("div", {
95
+ class: cls
96
+ }, (0, _preact.h)("div", {
97
+ class: "extension--overlay",
98
+ style: `opacity: ${this.state.overlayOpacity * 0.5} !important;`
99
+ }), (0, _preact.h)("div", {
100
+ class: "extension",
101
+ ref: this.refRating,
102
+ style: `height: ${this.state.ratingHeight}px !important;`
103
+ }, (0, _preact.h)("div", {
104
+ class: "extension--close-btn",
105
+ onClick: this.close
106
+ }, this.props.t('close')), (0, _preact.h)("div", {
107
+ class: "extension--handle",
108
+ ref: this.refHandle
109
+ }, (0, _preact.h)("div", {
110
+ class: "extension--thumb"
111
+ })), (0, _preact.h)("div", {
112
+ style: "overflow-x: hidden !important; overflow-y: scroll !important; height: 100% !important;"
113
+ }, (0, _preact.h)(_order.default, {
114
+ key: this.props.order_id,
115
+ store: this.props.store,
116
+ onResponse: this.onResponse,
117
+ onClose: this.close,
118
+ t: this.props.t,
119
+ order_id: this.props.order_id,
120
+ cid: this.props.cid
121
+ }))));
122
+ }
123
+
124
+ onResponse = response => {
125
+ this.setState({
126
+ response
127
+ });
128
+ };
129
+
130
+ open() {
131
+ if (!this.state.hide) return;
132
+ if (!this.props.order_id) return;
133
+ this.setState({
134
+ hide: false
135
+ });
136
+ if (!this.refRating.current) return;
137
+ var popupStyle = this.refRating.current.currentStyle || window.getComputedStyle(this.refRating.current);
138
+ var h0 = parseFloat(popupStyle.height);
139
+ this.animation.play(-20, h0, h => {
140
+ this.setState({
141
+ ratingHeight: h,
142
+ overlayOpacity: Math.min(1, (h - POPUP_MIN_HEIGHT) / (POPUP_HARD_MAX_HEIGHT - POPUP_MIN_HEIGHT))
143
+ });
144
+ });
145
+ }
146
+
147
+ confirm = () => {
148
+ this.props.store.sendConvoEvent(this.props.cid, 'message_sent', {
149
+ message: {
150
+ format: 'plaintext',
151
+ text: 'confirm',
152
+ attachments: [{
153
+ type: 'postback',
154
+ postback: {
155
+ payload: JSON.stringify({
156
+ type: 'order_confirmation',
157
+ status: 'confirmed'
158
+ })
159
+ }
160
+ }]
161
+ }
162
+ });
163
+ };
164
+ close = async () => {
165
+ await _index.default.sleep(100);
166
+
167
+ if (this.state.response === 'confirmed') {
168
+ this.props.store.sendConvoEvent(this.props.cid, 'message_sent', {
169
+ message: {
170
+ format: 'plaintext',
171
+ text: this.props.t('confirm_order'),
172
+ attachments: [{
173
+ type: 'postback',
174
+ postback: {
175
+ payload: JSON.stringify({
176
+ type: 'order_confirmation',
177
+ status: 'confirmed'
178
+ })
179
+ }
180
+ }]
181
+ }
182
+ });
183
+ } else if (this.state.response === 'rejected') {
184
+ this.props.store.sendConvoEvent(this.props.cid, 'message_sent', {
185
+ message: {
186
+ format: 'plaintext',
187
+ text: this.props.t('cancel_order'),
188
+ attachments: [{
189
+ type: 'postback',
190
+ postback: {
191
+ payload: JSON.stringify({
192
+ type: 'order_confirmation',
193
+ status: 'cancelled'
194
+ })
195
+ }
196
+ }]
197
+ }
198
+ });
199
+ } else {}
200
+
201
+ this.setState({
202
+ response: ''
203
+ });
204
+ if (this.state.hide) return;
205
+ if (!this.refRating.current) return;
206
+ var popupStyle = this.refRating.current.currentStyle || window.getComputedStyle(this.refRating.current);
207
+ var h0 = parseFloat(popupStyle.height);
208
+ this.animation.play(20, h0, h => {
209
+ this.setState({
210
+ ratingHeight: h,
211
+ overlayOpacity: Math.min(1, (h - POPUP_MIN_HEIGHT) / (POPUP_HARD_MAX_HEIGHT - POPUP_MIN_HEIGHT))
212
+ });
213
+
214
+ if (h < POPUP_MIN_HEIGHT + 10) {
215
+ if (!this.state.hide) {
216
+ this.setState({
217
+ hide: true
218
+ });
219
+ }
220
+ }
221
+ });
222
+ this.props.onClose();
223
+ };
224
+
225
+ onMouseDown(e) {
226
+ this.mousePushed = true;
227
+ this.animation.stop();
228
+ e.preventDefault();
229
+ if (e.touches && e.touches[0]) e = e.touches[0];
230
+ this.mousePushedDy = e.pageY - window.pageYOffset - this.refRating.current.getBoundingClientRect().y;
231
+ }
232
+
233
+ onMouseUp(e) {
234
+ if (!this.mousePushed) return;
235
+ if (e.touches && e.touches[0]) e = e.touches[0];
236
+ this.mousePushed = false;
237
+ var popupStyle = this.refRating.current.currentStyle || window.getComputedStyle(this.refRating.current);
238
+ var h0 = parseFloat(popupStyle.height);
239
+ this.animation.play(this.mouseVelocity, h0, h => {
240
+ this.setState({
241
+ ratingHeight: h,
242
+ overlayOpacity: Math.min(1, (h - POPUP_MIN_HEIGHT) / (POPUP_HARD_MAX_HEIGHT - POPUP_MIN_HEIGHT))
243
+ });
244
+
245
+ if (h < POPUP_MIN_HEIGHT + 10) {
246
+ if (!this.state.hide) {
247
+ this.setState({
248
+ hide: true
249
+ });
250
+ this.props.onRate && this.props.onRate({
251
+ no_rating: true
252
+ });
253
+ }
254
+ }
255
+ });
256
+ }
257
+
258
+ onMouseMove(e) {
259
+ if (!this.mousePushed) return;
260
+ if (e.touches && e.touches[0]) e = e.touches[0];
261
+ var my = e.pageY;
262
+ this.mouseVelocity = my - this.lastMouseY;
263
+ this.lastMouseY = my;
264
+ my = my - this.mousePushedDy;
265
+ var K = 10000;
266
+ var height = this.refRating.current.getBoundingClientRect().bottom - my;
267
+
268
+ if (height > POPUP_MAX_HEIGHT) {
269
+ var beta = K / (POPUP_HARD_MAX_HEIGHT - POPUP_MAX_HEIGHT) - POPUP_MAX_HEIGHT;
270
+ height = POPUP_HARD_MAX_HEIGHT - K / (height + beta);
271
+ }
272
+
273
+ this.setState({
274
+ ratingHeight: height,
275
+ overlayOpacity: Math.min(1, (height - POPUP_MIN_HEIGHT) / (POPUP_HARD_MAX_HEIGHT - POPUP_MIN_HEIGHT))
276
+ });
277
+ }
278
+
279
+ }
280
+
281
+ exports.default = Order;
@@ -48,7 +48,8 @@ class ProductAttachments extends _common.Com {
48
48
  class: "order_attachment__product"
49
49
  }, (0, _preact.h)("img", {
50
50
  class: "order_attachment__product_img",
51
- src: (_index.default.get(product, 'images.0'), require('../../assets/img/default.jpg'))
51
+ alt: '' + _index.default.get(product, 'id'),
52
+ src: _index.default.get(product, 'images.0', require('../../assets/img/default.jpg'))
52
53
  }), (0, _preact.h)("div", {
53
54
  style: "overflow: hidden !important;"
54
55
  }, (0, _preact.h)("div", {
@@ -15,8 +15,6 @@ var _preact = require("preact");
15
15
 
16
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
17
 
18
- 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
18
  const POPUP_MAX_HEIGHT = 400;
21
19
  const POPUP_HARD_MAX_HEIGHT = 500;
22
20
  const POPUP_MIN_HEIGHT = 0;
@@ -24,19 +22,18 @@ const POPUP_MIN_HEIGHT = 0;
24
22
  class Rating extends _common.Com {
25
23
  constructor(props) {
26
24
  super(props);
27
-
28
- _defineProperty(this, "state", {
29
- hide: true,
30
- ratingHeight: 0,
31
- overlayOpacity: 0.3,
32
- comment: ''
33
- });
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
29
 
30
+ state = {
31
+ hide: true,
32
+ ratingHeight: 0,
33
+ overlayOpacity: 0.3,
34
+ comment: ''
35
+ };
36
+
40
37
  componentDidMount() {
41
38
  this.props.store.onUpdate(this, () => {
42
39
  if (this.shoudDisplay()) this.open();
@@ -60,9 +60,16 @@ class TextMessage extends _common.Com {
60
60
  });
61
61
 
62
62
  if (tag.type === 'link') {
63
+ let url = tag.text || '';
64
+
65
+ if (!url.startsWith('//') && !url.startsWith('https://') && !url.startsWith('http://') && !url.startsWith('data:')) {
66
+ url = '//' + url;
67
+ }
68
+
63
69
  return (0, _preact.h)("a", {
64
- href: tag.text,
65
- target: "_blank"
70
+ href: url,
71
+ target: "_blank",
72
+ onClick: e => this.props.onLink(e, url)
66
73
  }, tag.text);
67
74
  }
68
75