@subiz/widget-v4 4.0.63 → 4.0.67
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/less/chatbox.less +6 -1
- package/babel.config.js +2 -4
- package/compiled_src/bot.js +7 -1
- package/compiled_src/call/call.js +15 -12
- package/compiled_src/chatbox/ChatButton.js +3 -1
- package/compiled_src/chatbox/DropdownSelect.js +75 -66
- package/compiled_src/chatbox/Event.js +1 -0
- package/compiled_src/chatbox/MessageInput.js +7 -4
- package/compiled_src/chatbox/Order.js +94 -90
- package/compiled_src/chatbox/ProductAttachments.js +40 -4
- package/compiled_src/chatbox/Rating.js +10 -7
- package/compiled_src/chatbox/Typing.js +3 -1
- package/compiled_src/chatbox/Widget.js +27 -23
- package/compiled_src/chatbox/main.js +2 -0
- package/compiled_src/contact/contact.js +9 -6
- package/compiled_src/lib.js +14 -9
- package/compiled_src/notif/notif.js +15 -12
- package/compiled_src/order/address_picker.js +71 -63
- package/compiled_src/order/order.js +330 -316
- package/compiled_src/popup/countdown.js +7 -4
- package/compiled_src/popup/popup.js +12 -9
- package/compiled_src/store/api.js +110 -80
- package/compiled_src/store/api_fake.js +82 -55
- package/compiled_src/store/store.js +194 -135
- package/compiled_src/util/common.js +1 -1
- package/dist/132.js +678 -591
- package/dist/178.js +174 -341
- package/dist/17ff367201e.132.js +1 -0
- package/dist/17ff367201e.178.js +1 -0
- package/dist/17ff367201e.213.js +1 -0
- package/dist/17ff367201e.335.js +1 -0
- package/dist/17ff367201e.362.js +1 -0
- package/dist/17ff367201e.441.js +1 -0
- package/dist/17ff367201e.605.js +1 -0
- package/dist/17ff367201e.678.js +1 -0
- package/dist/17ff367201e.782.js +1 -0
- package/dist/17ff367201e.app.js +1 -0
- package/dist/{17e757ccadd.index.html → 17ff367201e.index.html} +1 -1
- package/dist/{17e757ccadd.library.html → 17ff367201e.library.html} +1 -1
- package/dist/17ff367201e.library.js +1 -0
- package/dist/{17e757ccadd.preview.html → 17ff367201e.preview.html} +1 -1
- package/dist/17ff367201e.preview.js +1 -0
- package/dist/17ff367201e.screenshoot.js +1 -0
- package/dist/213.js +19 -13
- package/dist/335.js +11 -8
- package/dist/362.js +21 -71
- package/dist/441.js +2 -2
- package/dist/605.js +15 -12
- package/dist/678.js +20 -70
- package/dist/782.js +21 -118
- package/dist/HASH +1 -1
- package/dist/screenshoot.html +1 -1
- package/dist/screenshoot.js +453 -332
- package/package.json +14 -14
- package/src/bot.js +2 -1
- package/src/chatbox/Buttons.js +8 -8
- package/src/chatbox/ChatButton.js +2 -2
- package/src/chatbox/Event.js +1 -1
- package/src/chatbox/ProductAttachments.js +41 -5
- package/src/chatbox/Typing.js +5 -1
- package/src/chatbox/main.js +4 -1
- package/src/store/store.js +24 -11
- package/src/util/common.js +1 -1
- package/up +1 -1
- package/dist/0b82fa7e5c3b07b40a44.png +0 -1
- package/dist/0f4af006e38ee8b93633.png +0 -1
- package/dist/17e757ccadd.132.js +0 -1
- package/dist/17e757ccadd.178.js +0 -1
- package/dist/17e757ccadd.213.js +0 -1
- package/dist/17e757ccadd.335.js +0 -1
- package/dist/17e757ccadd.362.js +0 -1
- package/dist/17e757ccadd.441.js +0 -1
- package/dist/17e757ccadd.605.js +0 -1
- package/dist/17e757ccadd.678.js +0 -1
- package/dist/17e757ccadd.782.js +0 -1
- package/dist/17e757ccadd.app.js +0 -1
- package/dist/17e757ccadd.library.js +0 -1
- package/dist/17e757ccadd.preview.js +0 -1
- package/dist/17e757ccadd.screenshoot.js +0 -1
- package/dist/1ea1c6cd21d25176810c.png +0 -1
- package/dist/292d42404e1b03398f61.png +0 -1
- package/dist/312d376370831b7bea83.png +0 -1
- package/dist/313d1bfc1cf776d1aefe.png +0 -1
- package/dist/4aa58bb7a66bb44975aa.png +0 -1
- package/dist/56ce063bc6c81adb7322.png +0 -1
- package/dist/6a411166ef5cc79e0714.png +0 -1
- package/dist/6faf403782fefacc1649.png +0 -1
- package/dist/79dca33c68fab79c067f.png +0 -1
- package/dist/82da1578fa84f9debaeb.png +0 -1
- package/dist/8b8e0f0824743974b282.png +0 -1
- package/dist/8d551390d81e39130a3c.png +0 -1
- package/dist/9fc61b9479877ebdb6c7.png +0 -1
- package/dist/a165d31dcb3dc90f1057.png +0 -1
- package/dist/a98d4a5698812c4426b3.png +0 -1
- package/dist/c41606bf9d1b604e46d5.png +0 -1
- package/dist/ce1f7450ce6c1aacd330.png +0 -1
- package/dist/cf8c01e88f4770a6e3e5.png +0 -1
- package/dist/dfbcfeab1d5622a737e2.png +0 -1
- package/dist/e4893ed8c2f7b8329919.png +0 -1
- package/dist/ec2ab4eb4ef73d186186.png +0 -1
package/assets/less/chatbox.less
CHANGED
|
@@ -47,12 +47,17 @@
|
|
|
47
47
|
@z-index-4: '@z_index_4';
|
|
48
48
|
@z-index-5: '@z_index_5';
|
|
49
49
|
|
|
50
|
-
|
|
51
50
|
// stop client css rule on all elements inside #subiz
|
|
52
51
|
#sbz92 * {
|
|
53
52
|
all: unset !important;
|
|
54
53
|
}
|
|
55
54
|
|
|
55
|
+
.sbz_no_scroll {
|
|
56
|
+
overflow: hidden !important;
|
|
57
|
+
overflow-x: hidden !important;
|
|
58
|
+
overflow-y: hidden !important;
|
|
59
|
+
}
|
|
60
|
+
|
|
56
61
|
#sbz92 {
|
|
57
62
|
#makeImportant() !important;
|
|
58
63
|
}
|
package/babel.config.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
-
plugins: [
|
|
3
|
-
['@babel/plugin-transform-react-jsx', { pragma: 'h' }],
|
|
4
|
-
],
|
|
2
|
+
plugins: [['@babel/plugin-transform-react-jsx', {pragma: 'h'}], '@babel/plugin-proposal-class-properties'],
|
|
5
3
|
comments: false,
|
|
6
|
-
presets: [['@babel/preset-env', {
|
|
4
|
+
presets: [['@babel/preset-env', {useBuiltIns: 'usage', corejs: 3, targets: '> 5%, not dead'}]],
|
|
7
5
|
}
|
package/compiled_src/bot.js
CHANGED
|
@@ -7,6 +7,12 @@ exports.default = _default;
|
|
|
7
7
|
|
|
8
8
|
var _index = _interopRequireDefault(require("./util/index.js"));
|
|
9
9
|
|
|
10
|
+
var common = _interopRequireWildcard(require("./common.js"));
|
|
11
|
+
|
|
12
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
13
|
+
|
|
14
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
15
|
+
|
|
10
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
17
|
|
|
12
18
|
function _default(store) {
|
|
@@ -24,7 +30,7 @@ function _default(store) {
|
|
|
24
30
|
error
|
|
25
31
|
} = await store.startConvo({
|
|
26
32
|
initial_by: bot.id,
|
|
27
|
-
locale: _index.default.detectLang(),
|
|
33
|
+
locale: common.getLocale(bot, _index.default.detectLang()),
|
|
28
34
|
state: 'active',
|
|
29
35
|
members: [{
|
|
30
36
|
type: 'bot',
|
|
@@ -13,6 +13,8 @@ var _common = require("../common.js");
|
|
|
13
13
|
|
|
14
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
15
|
|
|
16
|
+
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; }
|
|
17
|
+
|
|
16
18
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
17
19
|
|
|
18
20
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -20,20 +22,21 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
20
22
|
let notifCSS = (() => Promise.resolve().then(() => _interopRequireWildcard(require('./css.js'))))();
|
|
21
23
|
|
|
22
24
|
class Notif extends _common.Com {
|
|
23
|
-
state = {
|
|
24
|
-
close: true,
|
|
25
|
-
cssready: false,
|
|
26
|
-
closeAnimation: true,
|
|
27
|
-
imageReady: false,
|
|
28
|
-
user: {},
|
|
29
|
-
timestamp: '',
|
|
30
|
-
message: '',
|
|
31
|
-
title: '',
|
|
32
|
-
last_show: 0
|
|
33
|
-
};
|
|
34
|
-
|
|
35
25
|
constructor(props) {
|
|
36
26
|
super(props);
|
|
27
|
+
|
|
28
|
+
_defineProperty(this, "state", {
|
|
29
|
+
close: true,
|
|
30
|
+
cssready: false,
|
|
31
|
+
closeAnimation: true,
|
|
32
|
+
imageReady: false,
|
|
33
|
+
user: {},
|
|
34
|
+
timestamp: '',
|
|
35
|
+
message: '',
|
|
36
|
+
title: '',
|
|
37
|
+
last_show: 0
|
|
38
|
+
});
|
|
39
|
+
|
|
37
40
|
setTimeout(async () => {
|
|
38
41
|
let {
|
|
39
42
|
body: impression
|
|
@@ -146,7 +146,9 @@ class ChatButton extends _common.Com {
|
|
|
146
146
|
|
|
147
147
|
let greeting = _index.default.get(accountSetting, 'greeting', {});
|
|
148
148
|
|
|
149
|
-
|
|
149
|
+
let text = this.props.t.i18n(_index.default.get(greeting, 'greeting', {})) || greeting.message;
|
|
150
|
+
|
|
151
|
+
if (!text || !greeting.enabled) {
|
|
150
152
|
this.setState({
|
|
151
153
|
previewEvent: {}
|
|
152
154
|
});
|
|
@@ -15,62 +15,95 @@ var _spinner = _interopRequireDefault(require("./spinner.js"));
|
|
|
15
15
|
|
|
16
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
state = {
|
|
20
|
-
show: false,
|
|
21
|
-
searchValue: ''
|
|
22
|
-
};
|
|
23
|
-
filterRef = (0, _preact.createRef)();
|
|
24
|
-
overlayRef = (0, _preact.createRef)();
|
|
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; }
|
|
25
19
|
|
|
20
|
+
class DropdownSelect extends _common.Com {
|
|
26
21
|
constructor(props) {
|
|
27
22
|
super(props);
|
|
28
|
-
document.addEventListener('touchmove', function (e) {});
|
|
29
|
-
}
|
|
30
23
|
|
|
31
|
-
|
|
32
|
-
if (e.target === this.overlayRef.current) {
|
|
33
|
-
e.preventDefault();
|
|
34
|
-
e.stopPropagation();
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
hideDropdown = () => {
|
|
38
|
-
this.setState({
|
|
24
|
+
_defineProperty(this, "state", {
|
|
39
25
|
show: false,
|
|
40
26
|
searchValue: ''
|
|
41
27
|
});
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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,
|
|
47
43
|
searchValue: ''
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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, '');
|
|
59
71
|
|
|
60
|
-
|
|
61
|
-
items = _index.default.filter(items, item => {
|
|
62
|
-
let optionName = _index.default.unicodeToAscii(item.name).toLowerCase().replace(/ /g, '');
|
|
72
|
+
let searchValue = _index.default.unicodeToAscii(this.state.searchValue).toLowerCase().replace(/ /g, '');
|
|
63
73
|
|
|
64
|
-
|
|
74
|
+
return optionName.indexOf(searchValue) != -1 || optionDesc.indexOf(searchValue) != -1;
|
|
75
|
+
});
|
|
76
|
+
}
|
|
65
77
|
|
|
66
|
-
|
|
78
|
+
return items;
|
|
79
|
+
});
|
|
67
80
|
|
|
68
|
-
|
|
81
|
+
_defineProperty(this, "onChangeSearchValue", e => {
|
|
82
|
+
this.setState({
|
|
83
|
+
searchValue: e.target.value
|
|
69
84
|
});
|
|
70
|
-
}
|
|
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
|
+
});
|
|
71
99
|
|
|
72
|
-
|
|
73
|
-
|
|
100
|
+
_defineProperty(this, "onBackgroundScroll", e => {
|
|
101
|
+
console.log('EEEEEEE', e);
|
|
102
|
+
alert('y');
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
document.addEventListener('touchmove', function (e) {});
|
|
106
|
+
}
|
|
74
107
|
|
|
75
108
|
componentDidMount() {
|
|
76
109
|
window.addEventListener('keydown', this.onKeydown);
|
|
@@ -80,12 +113,6 @@ class DropdownSelect extends _common.Com {
|
|
|
80
113
|
window.removeEventListener('keydown', this.onKeydown);
|
|
81
114
|
}
|
|
82
115
|
|
|
83
|
-
onChangeSearchValue = e => {
|
|
84
|
-
this.setState({
|
|
85
|
-
searchValue: e.target.value
|
|
86
|
-
});
|
|
87
|
-
};
|
|
88
|
-
|
|
89
116
|
renderEmpty() {
|
|
90
117
|
return (0, _preact.h)("div", {
|
|
91
118
|
class: "dropdown_select_filter__empty"
|
|
@@ -110,14 +137,6 @@ class DropdownSelect extends _common.Com {
|
|
|
110
137
|
}, "\u0110ang t\u1EA3i d\u1EEF li\u1EC7u"));
|
|
111
138
|
}
|
|
112
139
|
|
|
113
|
-
toogleDropdown = async () => {
|
|
114
|
-
await this.setState({
|
|
115
|
-
show: true,
|
|
116
|
-
searchValue: ''
|
|
117
|
-
});
|
|
118
|
-
this.focusFilter();
|
|
119
|
-
};
|
|
120
|
-
|
|
121
140
|
focusFilter() {
|
|
122
141
|
if (!this.filterRef.current) return;
|
|
123
142
|
this.filterRef.current.focus();
|
|
@@ -127,11 +146,6 @@ class DropdownSelect extends _common.Com {
|
|
|
127
146
|
}, 100);
|
|
128
147
|
}
|
|
129
148
|
|
|
130
|
-
onSelect = item => {
|
|
131
|
-
this.props.onSelect(item);
|
|
132
|
-
this.hideDropdown();
|
|
133
|
-
};
|
|
134
|
-
|
|
135
149
|
renderDropdown() {
|
|
136
150
|
if (!this.state.show) return null;
|
|
137
151
|
let items = this.getFilteredOptions();
|
|
@@ -200,11 +214,6 @@ class DropdownSelect extends _common.Com {
|
|
|
200
214
|
}, $items));
|
|
201
215
|
}
|
|
202
216
|
|
|
203
|
-
onBackgroundScroll = e => {
|
|
204
|
-
console.log('EEEEEEE', e);
|
|
205
|
-
alert('y');
|
|
206
|
-
};
|
|
207
|
-
|
|
208
217
|
render() {
|
|
209
218
|
let $name = (0, _preact.h)("div", {
|
|
210
219
|
class: "muted text-truncate",
|
|
@@ -200,6 +200,7 @@ class Event extends _common.Com {
|
|
|
200
200
|
onSelect: e => this.choosePostbackBtn(e)
|
|
201
201
|
}), (0, _preact.h)(_ProductAttachments.default, {
|
|
202
202
|
t: this.props.t,
|
|
203
|
+
onPostback: e => this.choosePostbackBtn(e),
|
|
203
204
|
store: this.props.store,
|
|
204
205
|
ev: ev
|
|
205
206
|
}), (0, _preact.h)(_OrderAttachments.default, {
|
|
@@ -15,9 +15,16 @@ 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
|
+
|
|
18
20
|
class MessageInput extends _common.Com {
|
|
19
21
|
constructor(props) {
|
|
20
22
|
super(props);
|
|
23
|
+
|
|
24
|
+
_defineProperty(this, "onEnter", _index.default.throttle(function () {
|
|
25
|
+
this.submitMessage();
|
|
26
|
+
}, 50));
|
|
27
|
+
|
|
21
28
|
this.refFileInput = (0, _preact.createRef)();
|
|
22
29
|
this.refMessageInput = (0, _preact.createRef)();
|
|
23
30
|
this.props.store.onUpdate(this, _ => this.forceUpdate());
|
|
@@ -262,10 +269,6 @@ class MessageInput extends _common.Com {
|
|
|
262
269
|
input.focus();
|
|
263
270
|
}
|
|
264
271
|
|
|
265
|
-
onEnter = _index.default.throttle(function () {
|
|
266
|
-
this.submitMessage();
|
|
267
|
-
}, 50);
|
|
268
|
-
|
|
269
272
|
onKeydown(e) {
|
|
270
273
|
if (e.keyCode === 13 && e.shiftKey === false) {
|
|
271
274
|
this.onEnter();
|
|
@@ -19,6 +19,8 @@ var _order = _interopRequireDefault(require("../order/order.js"));
|
|
|
19
19
|
|
|
20
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
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
|
+
|
|
22
24
|
const POPUP_MAX_HEIGHT = 400;
|
|
23
25
|
const POPUP_HARD_MAX_HEIGHT = 500;
|
|
24
26
|
const POPUP_MIN_HEIGHT = 0;
|
|
@@ -28,16 +30,102 @@ let defaultAvatar = require('../../assets/img/default_avatar.png');
|
|
|
28
30
|
class Order extends _common.Com {
|
|
29
31
|
constructor(props) {
|
|
30
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
|
+
|
|
31
125
|
this.refRating = (0, _preact.createRef)();
|
|
32
126
|
this.refHandle = (0, _preact.createRef)();
|
|
33
127
|
}
|
|
34
128
|
|
|
35
|
-
state = {
|
|
36
|
-
hide: true,
|
|
37
|
-
ratingHeight: 0,
|
|
38
|
-
overlayOpacity: 0.3
|
|
39
|
-
};
|
|
40
|
-
|
|
41
129
|
componentDidMount() {
|
|
42
130
|
this.mouseUp = e => this.onMouseUp(e);
|
|
43
131
|
|
|
@@ -121,12 +209,6 @@ class Order extends _common.Com {
|
|
|
121
209
|
}))));
|
|
122
210
|
}
|
|
123
211
|
|
|
124
|
-
onResponse = response => {
|
|
125
|
-
this.setState({
|
|
126
|
-
response
|
|
127
|
-
});
|
|
128
|
-
};
|
|
129
|
-
|
|
130
212
|
open() {
|
|
131
213
|
if (!this.state.hide) return;
|
|
132
214
|
if (!this.props.order_id) return;
|
|
@@ -144,84 +226,6 @@ class Order extends _common.Com {
|
|
|
144
226
|
});
|
|
145
227
|
}
|
|
146
228
|
|
|
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
229
|
onMouseDown(e) {
|
|
226
230
|
this.mousePushed = true;
|
|
227
231
|
this.animation.stop();
|
|
@@ -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;
|
|
@@ -15,6 +15,8 @@ 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
|
+
|
|
18
20
|
const POPUP_MAX_HEIGHT = 400;
|
|
19
21
|
const POPUP_HARD_MAX_HEIGHT = 500;
|
|
20
22
|
const POPUP_MIN_HEIGHT = 0;
|
|
@@ -22,18 +24,19 @@ const POPUP_MIN_HEIGHT = 0;
|
|
|
22
24
|
class Rating extends _common.Com {
|
|
23
25
|
constructor(props) {
|
|
24
26
|
super(props);
|
|
27
|
+
|
|
28
|
+
_defineProperty(this, "state", {
|
|
29
|
+
hide: true,
|
|
30
|
+
ratingHeight: 0,
|
|
31
|
+
overlayOpacity: 0.3,
|
|
32
|
+
comment: ''
|
|
33
|
+
});
|
|
34
|
+
|
|
25
35
|
this.refComment = (0, _preact.createRef)();
|
|
26
36
|
this.refRating = (0, _preact.createRef)();
|
|
27
37
|
this.refHandle = (0, _preact.createRef)();
|
|
28
38
|
}
|
|
29
39
|
|
|
30
|
-
state = {
|
|
31
|
-
hide: true,
|
|
32
|
-
ratingHeight: 0,
|
|
33
|
-
overlayOpacity: 0.3,
|
|
34
|
-
comment: ''
|
|
35
|
-
};
|
|
36
|
-
|
|
37
40
|
componentDidMount() {
|
|
38
41
|
this.props.store.onUpdate(this, () => {
|
|
39
42
|
if (this.shoudDisplay()) this.open();
|
|
@@ -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
|
|