@subiz/widget-v4 4.0.61 → 4.0.66
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.
- package/assets/img/caret.svg +1 -0
- package/assets/img/done_green.svg +4 -0
- package/assets/img/empty_1.svg +11 -0
- package/assets/img/ghn.svg +17 -0
- package/assets/img/ghtk.svg +18 -0
- package/assets/img/home.svg +1 -0
- package/assets/img/info.svg +1 -0
- package/assets/img/loader.svg +1 -0
- package/assets/img/map-pin.svg +1 -0
- package/assets/img/not_found_search.png +0 -0
- package/assets/img/package.svg +5 -0
- package/assets/img/package_fade.svg +1 -0
- package/assets/img/phone.svg +1 -0
- package/assets/img/search.svg +1 -0
- package/assets/img/shop.svg +1 -0
- package/assets/img/shop_faded.svg +1 -0
- package/assets/img/user.svg +1 -0
- package/assets/img/x.svg +5 -0
- package/assets/less/chatbox.less +39 -1
- package/assets/less/dropdown_select.less +130 -0
- package/assets/less/form.less +7 -20
- package/assets/less/order.less +489 -0
- package/assets/less/rating.less +3 -8
- package/babel.config.js +2 -4
- package/compiled_src/bot.js +7 -1
- package/compiled_src/chatbox/ChatButton.js +3 -1
- package/compiled_src/chatbox/DropdownSelect.js +248 -0
- package/compiled_src/chatbox/Event.js +5 -2
- package/compiled_src/chatbox/Events.js +1 -0
- package/compiled_src/chatbox/Order.js +285 -0
- package/compiled_src/chatbox/OrderAttachments.js +2 -1
- package/compiled_src/chatbox/ProductAttachments.js +40 -4
- package/compiled_src/chatbox/TextMessage.js +9 -2
- package/compiled_src/chatbox/Typing.js +3 -1
- package/compiled_src/chatbox/Widget.js +44 -3
- package/compiled_src/chatbox/main.js +2 -0
- package/compiled_src/chatbox/spinner.js +1 -1
- package/compiled_src/chatbox/time.js +3 -1
- package/compiled_src/common.js +40 -1
- package/compiled_src/contact/contact.js +1 -3
- package/compiled_src/order/address_picker.js +249 -0
- package/compiled_src/order/icon.js +62 -0
- package/compiled_src/order/index.js +113 -0
- package/compiled_src/order/order.js +1234 -0
- package/compiled_src/plugin.js +9 -42
- package/compiled_src/store/api.js +20 -0
- package/compiled_src/store/store.js +67 -3
- package/compiled_src/util/common.js +36 -2
- package/dist/{74.js → 132.js} +2355 -271
- package/dist/178.js +1 -1
- package/dist/17fdfed03d1.132.js +1 -0
- package/dist/17fdfed03d1.178.js +1 -0
- package/dist/17fdfed03d1.213.js +1 -0
- package/dist/17fdfed03d1.335.js +1 -0
- package/dist/17fdfed03d1.362.js +1 -0
- package/dist/17fdfed03d1.441.js +1 -0
- package/dist/17fdfed03d1.605.js +1 -0
- package/dist/{17db8166252.678.js → 17fdfed03d1.678.js} +0 -0
- package/dist/17fdfed03d1.782.js +1 -0
- package/dist/17fdfed03d1.app.js +1 -0
- package/dist/{17db8166252.index.html → 17fdfed03d1.index.html} +1 -1
- package/dist/{17db8166252.library.html → 17fdfed03d1.library.html} +1 -1
- package/dist/17fdfed03d1.library.js +1 -0
- package/dist/{17db8166252.preview.html → 17fdfed03d1.preview.html} +1 -1
- package/dist/17fdfed03d1.preview.js +1 -0
- package/dist/17fdfed03d1.screenshoot.js +1 -0
- package/dist/213.js +5 -69
- package/dist/335.js +411 -0
- package/dist/362.js +1 -1
- package/dist/441.js +70 -44
- package/dist/605.js +1 -64
- package/dist/782.js +1 -1
- package/dist/HASH +1 -1
- package/dist/assets/img/caret.998eb8f.svg +1 -0
- package/dist/assets/img/done_green.b817fd4.svg +4 -0
- package/dist/assets/img/empty_1.0b98af0.svg +11 -0
- package/dist/assets/img/ghn.070f8e3.svg +17 -0
- package/dist/assets/img/ghtk.326eac1.svg +18 -0
- package/dist/assets/img/info.ebce7ea.svg +1 -0
- package/dist/assets/img/loader.37000a7.svg +1 -0
- package/dist/assets/img/not_found_search.2ddb8d1.png +0 -0
- package/dist/assets/img/package.8d37d0f.svg +5 -0
- package/dist/assets/img/package_fade.763c001.svg +1 -0
- package/dist/assets/img/search.f9705ff.svg +1 -0
- package/dist/assets/img/shop.f7dc7d8.svg +1 -0
- package/dist/assets/img/shop_faded.df7845a.svg +1 -0
- package/dist/assets/img/x.26fdfa3.svg +5 -0
- package/dist/screenshoot.html +1 -1
- package/dist/screenshoot.js +281 -98
- package/order.html +19 -771
- package/package.json +15 -16
- package/src/bot.js +2 -1
- package/src/chatbox/Buttons.js +8 -8
- package/src/chatbox/ChatButton.js +2 -2
- package/src/chatbox/DropdownSelect.js +229 -0
- package/src/chatbox/Event.js +3 -3
- package/src/chatbox/Events.js +43 -42
- package/src/chatbox/Order.js +232 -0
- package/src/chatbox/OrderAttachments.js +2 -1
- package/src/chatbox/ProductAttachments.js +41 -5
- package/src/chatbox/TextMessage.js +21 -12
- package/src/chatbox/Typing.js +5 -1
- package/src/chatbox/Widget.js +34 -4
- package/src/chatbox/main.js +4 -1
- package/src/chatbox/spinner.js +1 -1
- package/src/chatbox/time.js +1 -1
- package/src/common.js +52 -8
- package/src/contact/contact.js +1 -1
- package/src/order/address_picker.js +235 -0
- package/src/order/icon.js +32 -0
- package/src/order/index.js +86 -0
- package/src/order/order.js +1157 -0
- package/src/order/scratch +211 -0
- package/src/plugin.js +7 -52
- package/src/store/api.js +26 -1
- package/src/store/store.js +53 -3
- package/src/util/common.js +48 -2
- package/up +1 -1
- package/webpack.dev.js +2 -0
- package/dist/17db8166252.178.js +0 -1
- package/dist/17db8166252.213.js +0 -1
- package/dist/17db8166252.362.js +0 -1
- package/dist/17db8166252.441.js +0 -1
- package/dist/17db8166252.605.js +0 -1
- package/dist/17db8166252.619.js +0 -1
- package/dist/17db8166252.74.js +0 -1
- package/dist/17db8166252.782.js +0 -1
- package/dist/17db8166252.app.js +0 -1
- package/dist/17db8166252.library.js +0 -1
- package/dist/17db8166252.preview.js +0 -1
- package/dist/17db8166252.screenshoot.js +0 -1
- package/dist/619.js +0 -777
- package/order.js +0 -0
- package/test.js +0 -1
|
@@ -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
|
|
@@ -199,6 +200,7 @@ class Event extends _common.Com {
|
|
|
199
200
|
onSelect: e => this.choosePostbackBtn(e)
|
|
200
201
|
}), (0, _preact.h)(_ProductAttachments.default, {
|
|
201
202
|
t: this.props.t,
|
|
203
|
+
onPostback: e => this.choosePostbackBtn(e),
|
|
202
204
|
store: this.props.store,
|
|
203
205
|
ev: ev
|
|
204
206
|
}), (0, _preact.h)(_OrderAttachments.default, {
|
|
@@ -254,7 +256,8 @@ class Event extends _common.Com {
|
|
|
254
256
|
}, $dot, (0, _preact.h)(_TextMessage.default, {
|
|
255
257
|
store: this.props.store,
|
|
256
258
|
ev: ev,
|
|
257
|
-
refresh: this.state.refresh
|
|
259
|
+
refresh: this.state.refresh,
|
|
260
|
+
onLink: this.props.onLink
|
|
258
261
|
}), (0, _preact.h)(_ImageAttachments.default, {
|
|
259
262
|
store: this.props.store,
|
|
260
263
|
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
|
-
|
|
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", {
|
|
@@ -29,17 +29,53 @@ class ProductAttachments extends _common.Com {
|
|
|
29
29
|
|
|
30
30
|
let $products = _index.default.map(products, (att, index) => {
|
|
31
31
|
let product = att.product;
|
|
32
|
-
let $
|
|
32
|
+
let $detailbtns = [];
|
|
33
33
|
let url = product.url || product.mobile_url;
|
|
34
34
|
if (this.props.store.isMobile()) url = product.mobile_url || product.url;
|
|
35
|
-
if (url)
|
|
35
|
+
if (url && _index.default.size(product.buttons) == 0) $detailbtns.push((0, _preact.h)("a", {
|
|
36
36
|
class: "product_attachment__btn",
|
|
37
37
|
href: url,
|
|
38
38
|
target: "_blank"
|
|
39
39
|
}, this.props.t('detail'), (0, _preact.h)("img", {
|
|
40
40
|
src: require('../../assets/img/external-link.svg'),
|
|
41
41
|
class: "product_attachment__btn_external_link"
|
|
42
|
-
}));
|
|
42
|
+
})));
|
|
43
|
+
console.log("P", product);
|
|
44
|
+
|
|
45
|
+
if (_index.default.size(product.buttons) > 0) {
|
|
46
|
+
$detailbtns = $detailbtns.concat(_index.default.map(product.buttons, (button, index) => {
|
|
47
|
+
if (button.type === 'call_button') {
|
|
48
|
+
return (0, _preact.h)("a", {
|
|
49
|
+
class: "product_attachment__btn",
|
|
50
|
+
href: 'tel:' + button.phone_number,
|
|
51
|
+
key: index,
|
|
52
|
+
title: button.title
|
|
53
|
+
}, button.title);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (button.type === 'url_button') {
|
|
57
|
+
return (0, _preact.h)("a", {
|
|
58
|
+
class: "product_attachment__btn",
|
|
59
|
+
href: button.url,
|
|
60
|
+
target: "_blank",
|
|
61
|
+
key: index,
|
|
62
|
+
title: button.title
|
|
63
|
+
}, button.title || this.props.t('detail'), ' ', (0, _preact.h)("img", {
|
|
64
|
+
src: require('../../assets/img/external-link.svg'),
|
|
65
|
+
class: "product_attachment__btn_external_link"
|
|
66
|
+
}));
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (button.type === 'postback_button') {
|
|
70
|
+
return (0, _preact.h)("a", {
|
|
71
|
+
class: "product_attachment__btn",
|
|
72
|
+
href: "javascript:;",
|
|
73
|
+
onClick: _ => this.props.onPostback(button)
|
|
74
|
+
}, button.title);
|
|
75
|
+
}
|
|
76
|
+
}));
|
|
77
|
+
}
|
|
78
|
+
|
|
43
79
|
let $title = (0, _preact.h)("a", {
|
|
44
80
|
href: url,
|
|
45
81
|
class: "product_attachment__title",
|
|
@@ -68,7 +104,7 @@ class ProductAttachments extends _common.Com {
|
|
|
68
104
|
src: this.props.store.replaceFileUrl(product.image)
|
|
69
105
|
}))), $title, $subtitle, $price, (0, _preact.h)("div", {
|
|
70
106
|
class: "product_attachment__btns"
|
|
71
|
-
}, $
|
|
107
|
+
}, $detailbtns));
|
|
72
108
|
});
|
|
73
109
|
|
|
74
110
|
return $products;
|
|
@@ -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:
|
|
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
|
|
|
@@ -41,6 +41,8 @@ class Typing extends _common.Com {
|
|
|
41
41
|
return;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
let ag = this.props.store.matchAgent(ev.by.id);
|
|
45
|
+
if (ag.type == 'agent') return;
|
|
44
46
|
if (_index.default.get(ev, 'type') !== 'conversation_typing') return;
|
|
45
47
|
this.setState({
|
|
46
48
|
ev: ev,
|
|
@@ -53,7 +55,7 @@ class Typing extends _common.Com {
|
|
|
53
55
|
this.setState({
|
|
54
56
|
isShow: false
|
|
55
57
|
});
|
|
56
|
-
},
|
|
58
|
+
}, 5000);
|
|
57
59
|
});
|
|
58
60
|
}
|
|
59
61
|
|