@subiz/widget-v4 4.0.63 → 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.
- 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/DropdownSelect.js +75 -66
- package/compiled_src/chatbox/MessageInput.js +7 -4
- package/compiled_src/chatbox/Order.js +94 -90
- package/compiled_src/chatbox/Rating.js +10 -7
- package/compiled_src/chatbox/Widget.js +27 -23
- 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 +170 -133
- package/dist/132.js +633 -588
- package/dist/17ee31b89ac.132.js +1 -0
- package/dist/{17e757ccadd.178.js → 17ee31b89ac.178.js} +0 -0
- package/dist/17ee31b89ac.213.js +1 -0
- package/dist/17ee31b89ac.335.js +1 -0
- package/dist/{17e757ccadd.362.js → 17ee31b89ac.362.js} +1 -1
- package/dist/17ee31b89ac.441.js +1 -0
- package/dist/17ee31b89ac.605.js +1 -0
- package/dist/{17e757ccadd.678.js → 17ee31b89ac.678.js} +0 -0
- package/dist/{17e757ccadd.782.js → 17ee31b89ac.782.js} +1 -1
- package/dist/17ee31b89ac.app.js +1 -0
- package/dist/{17e757ccadd.index.html → 17ee31b89ac.index.html} +1 -1
- package/dist/{17e757ccadd.library.html → 17ee31b89ac.library.html} +1 -1
- package/dist/17ee31b89ac.library.js +1 -0
- package/dist/{17e757ccadd.preview.html → 17ee31b89ac.preview.html} +1 -1
- package/dist/17ee31b89ac.preview.js +1 -0
- package/dist/17ee31b89ac.screenshoot.js +1 -0
- package/dist/213.js +19 -13
- package/dist/335.js +9 -6
- package/dist/362.js +1 -1
- package/dist/441.js +2 -2
- package/dist/605.js +15 -12
- package/dist/782.js +1 -1
- package/dist/HASH +1 -1
- package/dist/screenshoot.html +1 -1
- package/dist/screenshoot.js +372 -273
- package/package.json +12 -12
- package/src/bot.js +2 -1
- package/dist/17e757ccadd.132.js +0 -1
- package/dist/17e757ccadd.213.js +0 -1
- package/dist/17e757ccadd.335.js +0 -1
- package/dist/17e757ccadd.441.js +0 -1
- package/dist/17e757ccadd.605.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/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
|
|
@@ -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",
|
|
@@ -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();
|
|
@@ -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();
|
|
@@ -37,6 +37,8 @@ var _preact = require("preact");
|
|
|
37
37
|
|
|
38
38
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
39
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
|
+
|
|
40
42
|
var send = require('../../assets/img/send.svg');
|
|
41
43
|
|
|
42
44
|
var checkedimg = require('../../assets/img/done_gray.svg');
|
|
@@ -48,6 +50,31 @@ const defaultAvatar = 'https://file-subiz.com/fiqoahedjbgwclpouoml-avatar_defaul
|
|
|
48
50
|
class Widget extends _common.Com {
|
|
49
51
|
constructor(props) {
|
|
50
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
|
+
|
|
51
78
|
this.userSent = {};
|
|
52
79
|
this.setState({
|
|
53
80
|
creating: false,
|
|
@@ -673,29 +700,6 @@ class Widget extends _common.Com {
|
|
|
673
700
|
}), $input);
|
|
674
701
|
}
|
|
675
702
|
|
|
676
|
-
onLink = (e, url) => {
|
|
677
|
-
if (!url) return e.preventDefault();
|
|
678
|
-
let noschemeurl = url.replace(/(^\w+:|^)\/\//, '');
|
|
679
|
-
|
|
680
|
-
if (noschemeurl.startsWith('widget.subiz.com.vn/orders/')) {
|
|
681
|
-
let orderid = noschemeurl.substr('widget.subiz.com.vn/orders/'.length);
|
|
682
|
-
orderid = orderid.split('/')[0];
|
|
683
|
-
this.setState({
|
|
684
|
-
showOrder: true,
|
|
685
|
-
order_id: orderid
|
|
686
|
-
});
|
|
687
|
-
e.preventDefault();
|
|
688
|
-
return;
|
|
689
|
-
}
|
|
690
|
-
};
|
|
691
|
-
closeOrder = e => {
|
|
692
|
-
this.setState({
|
|
693
|
-
showOrder: false,
|
|
694
|
-
order_id: ''
|
|
695
|
-
});
|
|
696
|
-
this.focusInput();
|
|
697
|
-
};
|
|
698
|
-
|
|
699
703
|
async onStartConvoClick() {
|
|
700
704
|
var convo = this.props.store.matchConvo(this.props.cid) || {};
|
|
701
705
|
if (convo.state === 'ended') return this.props.onGo({
|
|
@@ -14,6 +14,8 @@ var _common = require("../common.js");
|
|
|
14
14
|
|
|
15
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
16
|
|
|
17
|
+
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; }
|
|
18
|
+
|
|
17
19
|
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); }
|
|
18
20
|
|
|
19
21
|
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; }
|
|
@@ -21,14 +23,15 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
21
23
|
let CSS = (() => Promise.resolve().then(() => _interopRequireWildcard(require('./css.js'))))();
|
|
22
24
|
|
|
23
25
|
class Contact extends _common.Com {
|
|
24
|
-
state = {
|
|
25
|
-
map: false,
|
|
26
|
-
map_loading: false,
|
|
27
|
-
map_initialized: false
|
|
28
|
-
};
|
|
29
|
-
|
|
30
26
|
constructor(props) {
|
|
31
27
|
super(props);
|
|
28
|
+
|
|
29
|
+
_defineProperty(this, "state", {
|
|
30
|
+
map: false,
|
|
31
|
+
map_loading: false,
|
|
32
|
+
map_initialized: false
|
|
33
|
+
});
|
|
34
|
+
|
|
32
35
|
this.showMap = this.showMap.bind(this);
|
|
33
36
|
this.hideMap = this.hideMap.bind(this);
|
|
34
37
|
}
|
package/compiled_src/lib.js
CHANGED
|
@@ -13,6 +13,8 @@ var _plugin = _interopRequireDefault(require("./plugin.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
|
var $link = document.createElement('link');
|
|
17
19
|
$link.href = 'https://fonts.googleapis.com/css2?family=Roboto:wght@400;500&display=swap';
|
|
18
20
|
$link.rel = 'stylesheet';
|
|
@@ -22,6 +24,18 @@ _index.default.preloadWebfonts(['Roboto'], [400, 500]);
|
|
|
22
24
|
|
|
23
25
|
class Widget {
|
|
24
26
|
constructor(ApiURL, FileURL, RealtimeURL, inmem, fake, agenttoken) {
|
|
27
|
+
_defineProperty(this, "version", () => '4.4');
|
|
28
|
+
|
|
29
|
+
_defineProperty(this, "setSetting", setting => this.store.setSetting({
|
|
30
|
+
account_setting: setting
|
|
31
|
+
}));
|
|
32
|
+
|
|
33
|
+
_defineProperty(this, "getSetting", _ => ({
|
|
34
|
+
account_setting: _index.default.cloneDeep(this.store.matchAccountSetting())
|
|
35
|
+
}));
|
|
36
|
+
|
|
37
|
+
_defineProperty(this, "getUser", () => _index.default.parseJSON(_index.default.stringify(this.store.matchUser())));
|
|
38
|
+
|
|
25
39
|
this.domGate = new _index.default.Gate();
|
|
26
40
|
this.store = new _store.default(ApiURL, FileURL, RealtimeURL, inmem, fake, agenttoken);
|
|
27
41
|
window.sbz_store = this.store;
|
|
@@ -126,15 +140,6 @@ class Widget {
|
|
|
126
140
|
this.pluginMgr.hideCurrentChatbox();
|
|
127
141
|
}
|
|
128
142
|
|
|
129
|
-
version = () => '4.4';
|
|
130
|
-
setSetting = setting => this.store.setSetting({
|
|
131
|
-
account_setting: setting
|
|
132
|
-
});
|
|
133
|
-
getSetting = _ => ({
|
|
134
|
-
account_setting: _index.default.cloneDeep(this.store.matchAccountSetting())
|
|
135
|
-
});
|
|
136
|
-
getUser = () => _index.default.parseJSON(_index.default.stringify(this.store.matchUser()));
|
|
137
|
-
|
|
138
143
|
async setLocale(locale) {
|
|
139
144
|
await this.domGate.entry();
|
|
140
145
|
return this.pluginMgr.setCurrentChatboxLocale(locale);
|