@subiz/widget-v4 4.0.59 → 4.0.64

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 (152) 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/babel.config.js +2 -4
  25. package/compiled_src/bot.js +7 -1
  26. package/compiled_src/chatbox/DropdownSelect.js +248 -0
  27. package/compiled_src/chatbox/Event.js +4 -2
  28. package/compiled_src/chatbox/Events.js +1 -0
  29. package/compiled_src/chatbox/Order.js +285 -0
  30. package/compiled_src/chatbox/OrderAttachments.js +2 -1
  31. package/compiled_src/chatbox/TextMessage.js +9 -2
  32. package/compiled_src/chatbox/Widget.js +44 -3
  33. package/compiled_src/chatbox/main.js +2 -1
  34. package/compiled_src/chatbox/spinner.js +1 -1
  35. package/compiled_src/chatbox/time.js +3 -1
  36. package/compiled_src/common.js +40 -1
  37. package/compiled_src/contact/contact.js +1 -3
  38. package/compiled_src/order/address_picker.js +249 -0
  39. package/compiled_src/order/icon.js +62 -0
  40. package/compiled_src/order/index.js +113 -0
  41. package/compiled_src/order/order.js +1234 -0
  42. package/compiled_src/plugin.js +9 -42
  43. package/compiled_src/popup/popup.js +2 -2
  44. package/compiled_src/store/api.js +20 -0
  45. package/compiled_src/store/store.js +42 -0
  46. package/compiled_src/util/common.js +36 -2
  47. package/dist/0b82fa7e5c3b07b40a44.png +1 -0
  48. package/dist/0f4af006e38ee8b93633.png +1 -0
  49. package/dist/{74.js → 132.js} +2322 -279
  50. package/dist/178.js +341 -174
  51. package/dist/17ee31b89ac.132.js +1 -0
  52. package/dist/17ee31b89ac.178.js +1 -0
  53. package/dist/17ee31b89ac.213.js +1 -0
  54. package/dist/17ee31b89ac.335.js +1 -0
  55. package/dist/17ee31b89ac.362.js +1 -0
  56. package/dist/17ee31b89ac.441.js +1 -0
  57. package/dist/17ee31b89ac.605.js +1 -0
  58. package/dist/17ee31b89ac.678.js +1 -0
  59. package/dist/17ee31b89ac.782.js +1 -0
  60. package/dist/17ee31b89ac.app.js +1 -0
  61. package/dist/{17d939953e0.index.html → 17ee31b89ac.index.html} +3 -18
  62. package/dist/{17d939953e0.library.html → 17ee31b89ac.library.html} +3 -18
  63. package/dist/17ee31b89ac.library.js +1 -0
  64. package/dist/{17d939953e0.preview.html → 17ee31b89ac.preview.html} +1 -1
  65. package/dist/17ee31b89ac.preview.js +1 -0
  66. package/dist/17ee31b89ac.screenshoot.js +1 -0
  67. package/dist/1ea1c6cd21d25176810c.png +1 -0
  68. package/dist/213.js +35 -70
  69. package/dist/292d42404e1b03398f61.png +1 -0
  70. package/dist/312d376370831b7bea83.png +1 -0
  71. package/dist/313d1bfc1cf776d1aefe.png +1 -0
  72. package/dist/335.js +411 -0
  73. package/dist/362.js +71 -21
  74. package/dist/441.js +70 -44
  75. package/dist/4aa58bb7a66bb44975aa.png +1 -0
  76. package/dist/56ce063bc6c81adb7322.png +1 -0
  77. package/dist/605.js +1 -64
  78. package/dist/678.js +70 -20
  79. package/dist/6a411166ef5cc79e0714.png +1 -0
  80. package/dist/6faf403782fefacc1649.png +1 -0
  81. package/dist/782.js +118 -21
  82. package/dist/79dca33c68fab79c067f.png +1 -0
  83. package/dist/82da1578fa84f9debaeb.png +1 -0
  84. package/dist/8b8e0f0824743974b282.png +1 -0
  85. package/dist/8d551390d81e39130a3c.png +1 -0
  86. package/dist/9fc61b9479877ebdb6c7.png +1 -0
  87. package/dist/HASH +1 -1
  88. package/dist/a165d31dcb3dc90f1057.png +1 -0
  89. package/dist/a98d4a5698812c4426b3.png +1 -0
  90. package/dist/assets/img/caret.998eb8f.svg +1 -0
  91. package/dist/assets/img/done_green.b817fd4.svg +4 -0
  92. package/dist/assets/img/empty_1.0b98af0.svg +11 -0
  93. package/dist/assets/img/ghn.070f8e3.svg +17 -0
  94. package/dist/assets/img/ghtk.326eac1.svg +18 -0
  95. package/dist/assets/img/info.ebce7ea.svg +1 -0
  96. package/dist/assets/img/loader.37000a7.svg +1 -0
  97. package/dist/assets/img/not_found_search.2ddb8d1.png +0 -0
  98. package/dist/assets/img/package.8d37d0f.svg +5 -0
  99. package/dist/assets/img/package_fade.763c001.svg +1 -0
  100. package/dist/assets/img/search.f9705ff.svg +1 -0
  101. package/dist/assets/img/shop.f7dc7d8.svg +1 -0
  102. package/dist/assets/img/shop_faded.df7845a.svg +1 -0
  103. package/dist/assets/img/x.26fdfa3.svg +5 -0
  104. package/dist/c41606bf9d1b604e46d5.png +1 -0
  105. package/dist/ce1f7450ce6c1aacd330.png +1 -0
  106. package/dist/cf8c01e88f4770a6e3e5.png +1 -0
  107. package/dist/dfbcfeab1d5622a737e2.png +1 -0
  108. package/dist/e4893ed8c2f7b8329919.png +1 -0
  109. package/dist/ec2ab4eb4ef73d186186.png +1 -0
  110. package/dist/screenshoot.html +1 -1
  111. package/dist/screenshoot.js +211 -48
  112. package/index.html +3 -18
  113. package/order.html +32 -0
  114. package/package.json +14 -15
  115. package/src/bot.js +2 -1
  116. package/src/chatbox/DropdownSelect.js +229 -0
  117. package/src/chatbox/Event.js +2 -2
  118. package/src/chatbox/Events.js +43 -42
  119. package/src/chatbox/Order.js +232 -0
  120. package/src/chatbox/OrderAttachments.js +2 -1
  121. package/src/chatbox/TextMessage.js +21 -12
  122. package/src/chatbox/Widget.js +34 -4
  123. package/src/chatbox/main.js +2 -2
  124. package/src/chatbox/spinner.js +1 -1
  125. package/src/chatbox/time.js +1 -1
  126. package/src/common.js +52 -8
  127. package/src/contact/contact.js +1 -1
  128. package/src/order/address_picker.js +235 -0
  129. package/src/order/icon.js +32 -0
  130. package/src/order/index.js +86 -0
  131. package/src/order/order.js +1157 -0
  132. package/src/order/scratch +211 -0
  133. package/src/plugin.js +7 -52
  134. package/src/popup/popup.js +2 -2
  135. package/src/store/api.js +26 -1
  136. package/src/store/store.js +46 -9
  137. package/src/util/common.js +48 -2
  138. package/webpack.dev.js +2 -0
  139. package/dist/17d939953e0.178.js +0 -1
  140. package/dist/17d939953e0.213.js +0 -1
  141. package/dist/17d939953e0.362.js +0 -1
  142. package/dist/17d939953e0.441.js +0 -1
  143. package/dist/17d939953e0.605.js +0 -1
  144. package/dist/17d939953e0.619.js +0 -1
  145. package/dist/17d939953e0.678.js +0 -1
  146. package/dist/17d939953e0.74.js +0 -1
  147. package/dist/17d939953e0.782.js +0 -1
  148. package/dist/17d939953e0.app.js +0 -1
  149. package/dist/17d939953e0.library.js +0 -1
  150. package/dist/17d939953e0.preview.js +0 -1
  151. package/dist/17d939953e0.screenshoot.js +0 -1
  152. package/dist/619.js +0 -777
@@ -0,0 +1,248 @@
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
+ 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
+ class DropdownSelect extends _common.Com {
21
+ constructor(props) {
22
+ super(props);
23
+
24
+ _defineProperty(this, "state", {
25
+ show: false,
26
+ searchValue: ''
27
+ });
28
+
29
+ _defineProperty(this, "filterRef", (0, _preact.createRef)());
30
+
31
+ _defineProperty(this, "overlayRef", (0, _preact.createRef)());
32
+
33
+ _defineProperty(this, "onTouchMove", e => {
34
+ if (e.target === this.overlayRef.current) {
35
+ e.preventDefault();
36
+ e.stopPropagation();
37
+ }
38
+ });
39
+
40
+ _defineProperty(this, "hideDropdown", () => {
41
+ this.setState({
42
+ show: false,
43
+ searchValue: ''
44
+ });
45
+ });
46
+
47
+ _defineProperty(this, "onKeydown", e => {
48
+ if (e.key === 'Escape') {
49
+ if (!this.state.show) return;
50
+ if (this.state.searchValue) this.setState({
51
+ searchValue: ''
52
+ });else this.hideDropdown();
53
+ e.preventDefault();
54
+ e.stopPropagation();
55
+ }
56
+ });
57
+
58
+ _defineProperty(this, "hasSearch", () => {
59
+ if (this.props.has_search) return true;
60
+ return _index.default.size(this.props.items) >= 10;
61
+ });
62
+
63
+ _defineProperty(this, "getFilteredOptions", () => {
64
+ let items = this.props.items;
65
+
66
+ if (this.state.searchValue && this.hasSearch()) {
67
+ items = _index.default.filter(items, item => {
68
+ let optionName = _index.default.unicodeToAscii(item.name).toLowerCase().replace(/ /g, '');
69
+
70
+ let optionDesc = _index.default.unicodeToAscii(item.desc).toLowerCase().replace(/ /g, '');
71
+
72
+ let searchValue = _index.default.unicodeToAscii(this.state.searchValue).toLowerCase().replace(/ /g, '');
73
+
74
+ return optionName.indexOf(searchValue) != -1 || optionDesc.indexOf(searchValue) != -1;
75
+ });
76
+ }
77
+
78
+ return items;
79
+ });
80
+
81
+ _defineProperty(this, "onChangeSearchValue", e => {
82
+ this.setState({
83
+ searchValue: e.target.value
84
+ });
85
+ });
86
+
87
+ _defineProperty(this, "toogleDropdown", async () => {
88
+ await this.setState({
89
+ show: true,
90
+ searchValue: ''
91
+ });
92
+ this.focusFilter();
93
+ });
94
+
95
+ _defineProperty(this, "onSelect", item => {
96
+ this.props.onSelect(item);
97
+ this.hideDropdown();
98
+ });
99
+
100
+ _defineProperty(this, "onBackgroundScroll", e => {
101
+ console.log('EEEEEEE', e);
102
+ alert('y');
103
+ });
104
+
105
+ document.addEventListener('touchmove', function (e) {});
106
+ }
107
+
108
+ componentDidMount() {
109
+ window.addEventListener('keydown', this.onKeydown);
110
+ }
111
+
112
+ componentWillUnmount() {
113
+ window.removeEventListener('keydown', this.onKeydown);
114
+ }
115
+
116
+ renderEmpty() {
117
+ return (0, _preact.h)("div", {
118
+ class: "dropdown_select_filter__empty"
119
+ }, (0, _preact.h)("img", {
120
+ class: "dropdown_select_filter__empty_img",
121
+ src: require('../../assets/img/not_found_search.png')
122
+ }), (0, _preact.h)("div", {
123
+ class: "muted",
124
+ style: "text-align: center !important;"
125
+ }, "Kh\xF4ng c\xF3 k\u1EBFt qu\u1EA3"));
126
+ }
127
+
128
+ renderLoading() {
129
+ return (0, _preact.h)("div", {
130
+ class: "dropdown_select_filter__empty pt-3"
131
+ }, (0, _preact.h)(_spinner.default, {
132
+ size: "40",
133
+ static: true
134
+ }), (0, _preact.h)("div", {
135
+ class: "muted mt-2",
136
+ style: "text-align: center !important;"
137
+ }, "\u0110ang t\u1EA3i d\u1EEF li\u1EC7u"));
138
+ }
139
+
140
+ focusFilter() {
141
+ if (!this.filterRef.current) return;
142
+ this.filterRef.current.focus();
143
+ setTimeout(() => {
144
+ if (!this.filterRef.current) return;
145
+ this.filterRef.current.focus();
146
+ }, 100);
147
+ }
148
+
149
+ renderDropdown() {
150
+ if (!this.state.show) return null;
151
+ let items = this.getFilteredOptions();
152
+
153
+ let $items = _index.default.map(items, item => {
154
+ return (0, _preact.h)("div", {
155
+ class: "dropdown_select__item",
156
+ onClick: _ => this.onSelect(item)
157
+ }, item.name);
158
+ });
159
+
160
+ let $filter = null;
161
+
162
+ if (this.hasSearch()) {
163
+ let $img = (0, _preact.h)("img", {
164
+ class: "dropdown_select_filter__icon",
165
+ src: require('../../assets/img/search.svg')
166
+ });
167
+
168
+ if (this.props.loading) {
169
+ $img = (0, _preact.h)("img", {
170
+ class: "dropdown_select_filter__icon",
171
+ src: require('../../assets/img/loader.svg')
172
+ });
173
+ }
174
+
175
+ $filter = (0, _preact.h)("div", {
176
+ class: "dropdown_select_filter"
177
+ }, $img, (0, _preact.h)("input", {
178
+ ref: this.filterRef,
179
+ value: this.state.searchValue,
180
+ onInput: this.onChangeSearchValue,
181
+ type: "text",
182
+ class: "dropdown_select_filter_input "
183
+ }));
184
+ }
185
+
186
+ if ($items.length == 0) $items = this.renderEmpty();
187
+ if (this.props.loading) $items = this.renderLoading();
188
+ let style = `width: ${this.props.width || '150px'} !important;`;
189
+
190
+ if (this.props.full) {
191
+ style = ` top: 20px !important; left: 20px !important; right: 20px !important; width: unset !important; `;
192
+ return (0, _preact.h)("div", {
193
+ class: "dropdown_select__overlay",
194
+ ref: this.overlayRef,
195
+ onClick: this.hideDropdown,
196
+ onTouchMove: this.onTouchMove
197
+ }, (0, _preact.h)("div", {
198
+ class: "dropdown_select",
199
+ style: style,
200
+ onClick: e => {
201
+ e.preventDefault();
202
+ e.stopPropagation();
203
+ }
204
+ }, $filter, (0, _preact.h)("div", {
205
+ class: "dropdown_select__items"
206
+ }, $items)));
207
+ }
208
+
209
+ return (0, _preact.h)("div", {
210
+ class: "dropdown_select",
211
+ style: style
212
+ }, $filter, (0, _preact.h)("div", {
213
+ class: "dropdown_select__items"
214
+ }, $items));
215
+ }
216
+
217
+ render() {
218
+ let $name = (0, _preact.h)("div", {
219
+ class: "muted text-truncate",
220
+ style: "flex: 1 !important;"
221
+ }, "Ch\u1ECDn m\u1ED9t ph\u1EA7n t\u1EED");
222
+ if (_index.default.get(this.props, 'selected.name')) $name = (0, _preact.h)("div", {
223
+ class: "text-truncate",
224
+ style: "flex: 1 !important;"
225
+ }, _index.default.get(this.props, 'selected.name'));
226
+ let style = 'position: relative !important;';
227
+
228
+ if (this.props.full) {
229
+ style = '';
230
+ }
231
+
232
+ return (0, _preact.h)("div", {
233
+ style: style
234
+ }, (0, _preact.h)(_common.Clickaway, {
235
+ onClickaway: this.hideDropdown
236
+ }, (0, _preact.h)("div", {
237
+ type: "text",
238
+ class: 'dropdown_select_input ' + this.props.extra_cls,
239
+ onClick: this.toogleDropdown
240
+ }, $name, "\xA0", (0, _preact.h)("img", {
241
+ class: "dropdown_select__caret",
242
+ src: require('../../assets/img/caret.svg')
243
+ })), this.renderDropdown()));
244
+ }
245
+
246
+ }
247
+
248
+ 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,
@@ -0,0 +1,285 @@
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
+ 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; }
23
+
24
+ const POPUP_MAX_HEIGHT = 400;
25
+ const POPUP_HARD_MAX_HEIGHT = 500;
26
+ const POPUP_MIN_HEIGHT = 0;
27
+
28
+ let defaultAvatar = require('../../assets/img/default_avatar.png');
29
+
30
+ class Order extends _common.Com {
31
+ constructor(props) {
32
+ super(props);
33
+
34
+ _defineProperty(this, "state", {
35
+ hide: true,
36
+ ratingHeight: 0,
37
+ overlayOpacity: 0.3
38
+ });
39
+
40
+ _defineProperty(this, "onResponse", response => {
41
+ this.setState({
42
+ response
43
+ });
44
+ });
45
+
46
+ _defineProperty(this, "confirm", () => {
47
+ this.props.store.sendConvoEvent(this.props.cid, 'message_sent', {
48
+ message: {
49
+ format: 'plaintext',
50
+ text: 'confirm',
51
+ attachments: [{
52
+ type: 'postback',
53
+ postback: {
54
+ payload: JSON.stringify({
55
+ type: 'order_confirmation',
56
+ status: 'confirmed'
57
+ })
58
+ }
59
+ }]
60
+ }
61
+ });
62
+ });
63
+
64
+ _defineProperty(this, "close", async () => {
65
+ await _index.default.sleep(100);
66
+
67
+ if (this.state.response === 'confirmed') {
68
+ this.props.store.sendConvoEvent(this.props.cid, 'message_sent', {
69
+ message: {
70
+ format: 'plaintext',
71
+ text: this.props.t('confirm_order'),
72
+ attachments: [{
73
+ type: 'postback',
74
+ postback: {
75
+ payload: JSON.stringify({
76
+ type: 'order_confirmation',
77
+ status: 'confirmed'
78
+ })
79
+ }
80
+ }]
81
+ }
82
+ });
83
+ } else if (this.state.response === 'rejected') {
84
+ this.props.store.sendConvoEvent(this.props.cid, 'message_sent', {
85
+ message: {
86
+ format: 'plaintext',
87
+ text: this.props.t('cancel_order'),
88
+ attachments: [{
89
+ type: 'postback',
90
+ postback: {
91
+ payload: JSON.stringify({
92
+ type: 'order_confirmation',
93
+ status: 'cancelled'
94
+ })
95
+ }
96
+ }]
97
+ }
98
+ });
99
+ } else {}
100
+
101
+ this.setState({
102
+ response: ''
103
+ });
104
+ if (this.state.hide) return;
105
+ if (!this.refRating.current) return;
106
+ var popupStyle = this.refRating.current.currentStyle || window.getComputedStyle(this.refRating.current);
107
+ var h0 = parseFloat(popupStyle.height);
108
+ this.animation.play(20, h0, h => {
109
+ this.setState({
110
+ ratingHeight: h,
111
+ overlayOpacity: Math.min(1, (h - POPUP_MIN_HEIGHT) / (POPUP_HARD_MAX_HEIGHT - POPUP_MIN_HEIGHT))
112
+ });
113
+
114
+ if (h < POPUP_MIN_HEIGHT + 10) {
115
+ if (!this.state.hide) {
116
+ this.setState({
117
+ hide: true
118
+ });
119
+ }
120
+ }
121
+ });
122
+ this.props.onClose();
123
+ });
124
+
125
+ this.refRating = (0, _preact.createRef)();
126
+ this.refHandle = (0, _preact.createRef)();
127
+ }
128
+
129
+ componentDidMount() {
130
+ this.mouseUp = e => this.onMouseUp(e);
131
+
132
+ this.mouseMove = e => this.onMouseMove(e);
133
+
134
+ this.mouseDown = e => this.onMouseDown(e);
135
+
136
+ var $ratingHandle = this.refHandle.current;
137
+ $ratingHandle.addEventListener('mousedown', this.mouseDown, {
138
+ passive: true
139
+ });
140
+ $ratingHandle.addEventListener('touchstart', this.mouseDown, {
141
+ passive: true
142
+ });
143
+ window.addEventListener('mouseup', this.mouseUp, {
144
+ passive: true
145
+ });
146
+ window.addEventListener('touchend', this.mouseUp, {
147
+ passive: true
148
+ });
149
+ window.addEventListener('mousemove', this.mouseMove, {
150
+ passive: true
151
+ });
152
+ window.addEventListener('touchmove', this.mouseMove, {
153
+ passive: true
154
+ });
155
+ this.animation = new _releaseAnimation.default({
156
+ maxY: POPUP_MAX_HEIGHT,
157
+ minY: POPUP_MIN_HEIGHT,
158
+ duration: 150
159
+ });
160
+ this.close();
161
+ }
162
+
163
+ componentWillUnmount() {
164
+ var $ratingHandle = this.refHandle.current;
165
+ $ratingHandle.removeEventListener('mousedown', this.mouseDown, 0);
166
+ $ratingHandle.removeEventListener('touchstart', this.mouseDown, 0);
167
+ window.removeEventListener('mouseup', this.mouseUp, 0);
168
+ window.removeEventListener('touchend', this.mouseUp, 0);
169
+ window.removeEventListener('mousemove', this.mouseMove, 0);
170
+ window.removeEventListener('touchmove', this.mouseMove, 0);
171
+ }
172
+
173
+ render() {
174
+ if (this._show != this.props.show) {
175
+ this._show = this.props.show;
176
+ setTimeout(() => {
177
+ if (!this._show) this.close();else this.open();
178
+ });
179
+ }
180
+
181
+ let cls = this.state.hide ? 'd-none' : '';
182
+ return (0, _preact.h)("div", {
183
+ class: cls
184
+ }, (0, _preact.h)("div", {
185
+ class: "extension--overlay",
186
+ style: `opacity: ${this.state.overlayOpacity * 0.5} !important;`
187
+ }), (0, _preact.h)("div", {
188
+ class: "extension",
189
+ ref: this.refRating,
190
+ style: `height: ${this.state.ratingHeight}px !important;`
191
+ }, (0, _preact.h)("div", {
192
+ class: "extension--close-btn",
193
+ onClick: this.close
194
+ }, this.props.t('close')), (0, _preact.h)("div", {
195
+ class: "extension--handle",
196
+ ref: this.refHandle
197
+ }, (0, _preact.h)("div", {
198
+ class: "extension--thumb"
199
+ })), (0, _preact.h)("div", {
200
+ style: "overflow-x: hidden !important; overflow-y: scroll !important; height: 100% !important;"
201
+ }, (0, _preact.h)(_order.default, {
202
+ key: this.props.order_id,
203
+ store: this.props.store,
204
+ onResponse: this.onResponse,
205
+ onClose: this.close,
206
+ t: this.props.t,
207
+ order_id: this.props.order_id,
208
+ cid: this.props.cid
209
+ }))));
210
+ }
211
+
212
+ open() {
213
+ if (!this.state.hide) return;
214
+ if (!this.props.order_id) return;
215
+ this.setState({
216
+ hide: false
217
+ });
218
+ if (!this.refRating.current) return;
219
+ var popupStyle = this.refRating.current.currentStyle || window.getComputedStyle(this.refRating.current);
220
+ var h0 = parseFloat(popupStyle.height);
221
+ this.animation.play(-20, h0, h => {
222
+ this.setState({
223
+ ratingHeight: h,
224
+ overlayOpacity: Math.min(1, (h - POPUP_MIN_HEIGHT) / (POPUP_HARD_MAX_HEIGHT - POPUP_MIN_HEIGHT))
225
+ });
226
+ });
227
+ }
228
+
229
+ onMouseDown(e) {
230
+ this.mousePushed = true;
231
+ this.animation.stop();
232
+ e.preventDefault();
233
+ if (e.touches && e.touches[0]) e = e.touches[0];
234
+ this.mousePushedDy = e.pageY - window.pageYOffset - this.refRating.current.getBoundingClientRect().y;
235
+ }
236
+
237
+ onMouseUp(e) {
238
+ if (!this.mousePushed) return;
239
+ if (e.touches && e.touches[0]) e = e.touches[0];
240
+ this.mousePushed = false;
241
+ var popupStyle = this.refRating.current.currentStyle || window.getComputedStyle(this.refRating.current);
242
+ var h0 = parseFloat(popupStyle.height);
243
+ this.animation.play(this.mouseVelocity, h0, h => {
244
+ this.setState({
245
+ ratingHeight: h,
246
+ overlayOpacity: Math.min(1, (h - POPUP_MIN_HEIGHT) / (POPUP_HARD_MAX_HEIGHT - POPUP_MIN_HEIGHT))
247
+ });
248
+
249
+ if (h < POPUP_MIN_HEIGHT + 10) {
250
+ if (!this.state.hide) {
251
+ this.setState({
252
+ hide: true
253
+ });
254
+ this.props.onRate && this.props.onRate({
255
+ no_rating: true
256
+ });
257
+ }
258
+ }
259
+ });
260
+ }
261
+
262
+ onMouseMove(e) {
263
+ if (!this.mousePushed) return;
264
+ if (e.touches && e.touches[0]) e = e.touches[0];
265
+ var my = e.pageY;
266
+ this.mouseVelocity = my - this.lastMouseY;
267
+ this.lastMouseY = my;
268
+ my = my - this.mousePushedDy;
269
+ var K = 10000;
270
+ var height = this.refRating.current.getBoundingClientRect().bottom - my;
271
+
272
+ if (height > POPUP_MAX_HEIGHT) {
273
+ var beta = K / (POPUP_HARD_MAX_HEIGHT - POPUP_MAX_HEIGHT) - POPUP_MAX_HEIGHT;
274
+ height = POPUP_HARD_MAX_HEIGHT - K / (height + beta);
275
+ }
276
+
277
+ this.setState({
278
+ ratingHeight: height,
279
+ overlayOpacity: Math.min(1, (height - POPUP_MIN_HEIGHT) / (POPUP_HARD_MAX_HEIGHT - POPUP_MIN_HEIGHT))
280
+ });
281
+ }
282
+
283
+ }
284
+
285
+ 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", {
@@ -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
 
@@ -23,6 +23,8 @@ var _Typing = _interopRequireDefault(require("./Typing.js"));
23
23
 
24
24
  var _Rating = _interopRequireDefault(require("./Rating.js"));
25
25
 
26
+ var _Order = _interopRequireDefault(require("./Order.js"));
27
+
26
28
  var _ListField = _interopRequireDefault(require("./ListField.js"));
27
29
 
28
30
  var _spinner = _interopRequireDefault(require("./spinner.js"));
@@ -35,6 +37,8 @@ var _preact = require("preact");
35
37
 
36
38
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
37
39
 
40
+ 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; }
41
+
38
42
  var send = require('../../assets/img/send.svg');
39
43
 
40
44
  var checkedimg = require('../../assets/img/done_gray.svg');
@@ -46,11 +50,38 @@ const defaultAvatar = 'https://file-subiz.com/fiqoahedjbgwclpouoml-avatar_defaul
46
50
  class Widget extends _common.Com {
47
51
  constructor(props) {
48
52
  super(props);
53
+
54
+ _defineProperty(this, "onLink", (e, url) => {
55
+ if (!url) return e.preventDefault();
56
+ let noschemeurl = url.replace(/(^\w+:|^)\/\//, '');
57
+
58
+ if (noschemeurl.startsWith('widget.subiz.com.vn/orders/')) {
59
+ let orderid = noschemeurl.substr('widget.subiz.com.vn/orders/'.length);
60
+ orderid = orderid.split('/')[0];
61
+ this.setState({
62
+ showOrder: true,
63
+ order_id: orderid
64
+ });
65
+ e.preventDefault();
66
+ return;
67
+ }
68
+ });
69
+
70
+ _defineProperty(this, "closeOrder", e => {
71
+ this.setState({
72
+ showOrder: false,
73
+ order_id: ''
74
+ });
75
+ this.focusInput();
76
+ });
77
+
49
78
  this.userSent = {};
50
79
  this.setState({
51
80
  creating: false,
52
81
  clickedJoin: false,
53
- formData: {}
82
+ formData: {},
83
+ showOrder: false,
84
+ order_id: ''
54
85
  });
55
86
  this.props.store.onUpdate(this, _ => this.forceUpdate());
56
87
  }
@@ -66,6 +97,7 @@ class Widget extends _common.Com {
66
97
  }
67
98
 
68
99
  if (prevProp.cid !== this.props.cid) {
100
+ this.closeOrder();
69
101
  this.setState({
70
102
  clickedJoin: false
71
103
  });
@@ -84,7 +116,6 @@ class Widget extends _common.Com {
84
116
  }
85
117
 
86
118
  render() {
87
- let formRequired = this.isFormRequired();
88
119
  let showform = this.shouldShowForm();
89
120
  let form;
90
121
  let accountSetting = this.props.plugin.chatbox || {};
@@ -637,6 +668,7 @@ class Widget extends _common.Com {
637
668
  onClick: e => this.onContainerClick(e)
638
669
  }, (0, _preact.h)(_Events.default, {
639
670
  isShow: this.props.isShow,
671
+ onLink: this.onLink,
640
672
  store: this.props.store,
641
673
  onFormSubmit: e => this.onEventFormSubmit(e),
642
674
  ref: ref => this.events = ref,
@@ -656,6 +688,15 @@ class Widget extends _common.Com {
656
688
  onRate: e => this.onRate(e),
657
689
  cid: this.props.cid,
658
690
  t: this.props.t
691
+ }), (0, _preact.h)(_Order.default, {
692
+ forceView: this.props.view,
693
+ plugin: this.props.plugin,
694
+ show: this.state.showOrder,
695
+ order_id: this.state.order_id,
696
+ store: this.props.store,
697
+ onClose: this.closeOrder,
698
+ cid: this.props.cid,
699
+ t: this.props.t
659
700
  }), $input);
660
701
  }
661
702
 
@@ -952,5 +993,5 @@ class FormMounter extends _common.Com {
952
993
  }
953
994
 
954
995
  function encode(key) {
955
- return btoa(key).split('=').join('');
996
+ return encodeURIComponent(key);
956
997
  }
@@ -77,7 +77,8 @@ class Main extends _common.Com {
77
77
  view: this.props.store.matchLastview().view
78
78
  }));
79
79
  } else {
80
- this.hideWidget();
80
+ restoreViewport();
81
+ if (!this.state.isShowWidget) this.hideWidget();
81
82
  }
82
83
  }
83
84