@subiz/widget-v4 4.1.70 → 4.1.72
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/app.js +0 -42
- package/assets/less/widget.less +6 -5
- package/assets/less/widget_header.less +5 -3
- package/compiled_src/chatbox/AgentsAvatar.js +102 -108
- package/compiled_src/chatbox/AudioAttachments.js +25 -32
- package/compiled_src/chatbox/ButtonAttachments.js +16 -23
- package/compiled_src/chatbox/Buttons.js +36 -43
- package/compiled_src/chatbox/ChatButton.js +5 -1
- package/compiled_src/chatbox/Event.js +19 -3
- package/compiled_src/chatbox/InfoMessage.js +2 -1
- package/compiled_src/chatbox/OrderAttachments.js +102 -6
- package/compiled_src/chatbox/PoweredBy.js +20 -27
- package/compiled_src/chatbox/Rating.js +1 -1
- package/compiled_src/chatbox/TextMessage.js +0 -14
- package/compiled_src/chatbox/VideoAttachments.js +1 -0
- package/compiled_src/chatbox/Widget.js +21 -21
- package/compiled_src/chatbox/time.js +46 -28
- package/compiled_src/lib.js +2 -2
- package/compiled_src/order/icon.js +2 -2
- package/compiled_src/order/index.js +2 -2
- package/compiled_src/plugin.js +2 -4
- package/compiled_src/store/api.js +1 -16
- package/compiled_src/store/store.js +1 -4
- package/compiled_src/util/common.js +12 -494
- package/compiled_src/util/index.js +0 -2
- package/dist/127.js +273 -0
- package/dist/132.js +2 -2
- package/dist/185.js +1885 -0
- package/dist/18eaf7ad0c6.127.js +1 -0
- package/dist/{18e74ca84ff.132.js → 18eaf7ad0c6.132.js} +1 -1
- package/dist/18eaf7ad0c6.185.js +1 -0
- package/dist/18eaf7ad0c6.278.js +1 -0
- package/dist/{18e74ca84ff.490.js → 18eaf7ad0c6.490.js} +1 -1
- package/dist/{18e74ca84ff.74.js → 18eaf7ad0c6.74.js} +1 -1
- package/dist/18eaf7ad0c6.app.js +1 -0
- package/dist/{18e74ca84ff.index.html → 18eaf7ad0c6.index.html} +1 -1
- package/dist/{18e74ca84ff.library.html → 18eaf7ad0c6.library.html} +1 -1
- package/dist/18eaf7ad0c6.library.js +1 -0
- package/dist/{18e74ca84ff.preview.html → 18eaf7ad0c6.preview.html} +1 -1
- package/dist/18eaf7ad0c6.preview.js +1 -0
- package/dist/18eaf7ad0c6.screenshoot.js +1 -0
- package/dist/18eaf7ad0c6.webview.js +1 -0
- package/dist/278.js +1 -1
- package/dist/490.js +1 -1
- package/dist/74.js +1 -1
- package/dist/HASH +1 -1
- package/dist/screenshoot.html +1 -1
- package/dist/screenshoot.js +4740 -627
- package/inject.js +3 -3
- package/package.json +6 -6
- package/src/chatbox/AgentsAvatar.js +118 -134
- package/src/chatbox/AudioAttachments.js +19 -26
- package/src/chatbox/ButtonAttachments.js +13 -20
- package/src/chatbox/Buttons.js +29 -37
- package/src/chatbox/ChatButton.js +6 -1
- package/src/chatbox/Event.js +22 -3
- package/src/chatbox/InfoMessage.js +11 -11
- package/src/chatbox/OrderAttachments.js +118 -5
- package/src/chatbox/PoweredBy.js +14 -22
- package/src/chatbox/Rating.js +1 -1
- package/src/chatbox/TextMessage.js +0 -14
- package/src/chatbox/VideoAttachments.js +1 -1
- package/src/chatbox/Widget.js +16 -20
- package/src/chatbox/time.js +54 -24
- package/src/lib.js +2 -2
- package/src/order/icon.js +2 -2
- package/src/order/index.js +2 -2
- package/src/plugin.js +4 -3
- package/src/store/api.js +1 -14
- package/src/store/store.js +1 -9
- package/src/util/common.js +13 -215
- package/src/util/index.js +0 -3
- package/compiled_src/util/order.js +0 -112
- package/dist/18e74ca84ff.278.js +0 -1
- package/dist/18e74ca84ff.497.js +0 -1
- package/dist/18e74ca84ff.app.js +0 -1
- package/dist/18e74ca84ff.library.js +0 -1
- package/dist/18e74ca84ff.preview.js +0 -1
- package/dist/18e74ca84ff.screenshoot.js +0 -1
- package/dist/18e74ca84ff.webview.js +0 -1
- package/dist/497.js +0 -6721
- package/src/util/order.js +0 -120
- /package/dist/{18e74ca84ff.27.js → 18eaf7ad0c6.27.js} +0 -0
- /package/dist/{18e74ca84ff.459.js → 18eaf7ad0c6.459.js} +0 -0
- /package/dist/{18e74ca84ff.997.js → 18eaf7ad0c6.997.js} +0 -0
|
@@ -17,7 +17,7 @@ class ProductAttachments extends _common.Com {
|
|
|
17
17
|
let orders = _index.default.filter(attachments, att => att.type === 'order' && att.order).map(att => att.order);
|
|
18
18
|
if (orders.length === 0) return null;
|
|
19
19
|
let $orders = _index.default.map(orders, (order, index) => {
|
|
20
|
-
|
|
20
|
+
calcOrderTotal(order);
|
|
21
21
|
let $note = null;
|
|
22
22
|
if (order.note) {
|
|
23
23
|
$note = (0, _preact.h)("div", null, (0, _preact.h)("div", {
|
|
@@ -46,7 +46,7 @@ class ProductAttachments extends _common.Com {
|
|
|
46
46
|
title: this.props.t.i18n(product.i18n_name) || product.name
|
|
47
47
|
}, this.props.t.i18n(product.i18n_name) || product.name), (0, _preact.h)("div", {
|
|
48
48
|
class: "order_attachment__product_desc"
|
|
49
|
-
},
|
|
49
|
+
}, getProductPropName(product, ' / ')), (0, _preact.h)("div", {
|
|
50
50
|
class: "order_attachment__product_desc"
|
|
51
51
|
}, this.props.t('qty'), " ", item.quantity, "\xA0\xB7\xA0", _index.default.formatCurrency(product.price))));
|
|
52
52
|
}));
|
|
@@ -66,10 +66,10 @@ class ProductAttachments extends _common.Com {
|
|
|
66
66
|
phone = phone || _index.default.trim(phoneattr.text);
|
|
67
67
|
if (phone) phone = this.props.t('phn') + ': ' + phone;
|
|
68
68
|
let $shipto = null;
|
|
69
|
-
if (
|
|
69
|
+
if (displayOrderShippingAddress(order) || phone) {
|
|
70
70
|
$shipto = (0, _preact.h)("div", null, (0, _preact.h)("div", {
|
|
71
71
|
class: "order_attachment__label"
|
|
72
|
-
}, this.props.t('ship_to')), (0, _preact.h)("div", null,
|
|
72
|
+
}, this.props.t('ship_to')), (0, _preact.h)("div", null, displayOrderShippingAddress(order)), (0, _preact.h)("div", {
|
|
73
73
|
class: "order_attachment__text_truncate"
|
|
74
74
|
}, phone));
|
|
75
75
|
}
|
|
@@ -160,9 +160,105 @@ class ProductAttachments extends _common.Com {
|
|
|
160
160
|
class: "order_attachment__header"
|
|
161
161
|
}, this.props.t('order'), (0, _preact.h)("span", {
|
|
162
162
|
class: "order_attachment__text_muted order_attachment__text_sm"
|
|
163
|
-
},
|
|
163
|
+
}, getOrderDisplayName(order))), $products, $shipto, $note, $beforeTax, $subtotal, $total);
|
|
164
164
|
});
|
|
165
165
|
return $orders;
|
|
166
166
|
}
|
|
167
167
|
}
|
|
168
|
-
exports.default = ProductAttachments;
|
|
168
|
+
exports.default = ProductAttachments;
|
|
169
|
+
function getProductPropName(product, seperator = ' - ') {
|
|
170
|
+
let options = op.get(product, 'options', []);
|
|
171
|
+
let props = op.get(product, 'props', []);
|
|
172
|
+
let multiPropsOptions = op.filter(options, option => op.size(option.values) > 1);
|
|
173
|
+
let names = [];
|
|
174
|
+
op.each(multiPropsOptions, option => {
|
|
175
|
+
let prop = op.find(props, prop => prop.key === option.key) || {};
|
|
176
|
+
if (prop.value) names.push(prop.value);
|
|
177
|
+
});
|
|
178
|
+
return names.join(seperator);
|
|
179
|
+
}
|
|
180
|
+
function getOrderDisplayName(order = {}) {
|
|
181
|
+
return order.number || order.id || '';
|
|
182
|
+
}
|
|
183
|
+
function displayOrderShippingAddress(order, isShorten) {
|
|
184
|
+
let addr = op.get(order, 'shipping.address', {});
|
|
185
|
+
let fulladdr = [addr.address, addr.ward, addr.district, addr.province].filter(a => a).join(', ').trim();
|
|
186
|
+
if (isShorten) fulladdr = shortenAddr(fulladdr);
|
|
187
|
+
return fulladdr;
|
|
188
|
+
}
|
|
189
|
+
function shortenAddr(str) {
|
|
190
|
+
str = str || '';
|
|
191
|
+
str = str.replace(/Hà Nội/gi, 'HN');
|
|
192
|
+
str = str.replace(/Hồ Chí Minh/gi, 'HCM');
|
|
193
|
+
str = str.replace(/Thành Phố/gi, 'TP');
|
|
194
|
+
return str;
|
|
195
|
+
}
|
|
196
|
+
function calcOrderTotal(order) {
|
|
197
|
+
let subtotal = 0;
|
|
198
|
+
let beforeTaxDiscount = 0;
|
|
199
|
+
let ordervalue = 0;
|
|
200
|
+
op.map(order.items, item => {
|
|
201
|
+
if (!item.product) return 0;
|
|
202
|
+
let price = op.get(item, 'product.price', 0) * (item.quantity || 0);
|
|
203
|
+
ordervalue += price;
|
|
204
|
+
if (item.discount_type == 'percentage') {
|
|
205
|
+
if (item.discount_percentage > 0) {
|
|
206
|
+
beforeTaxDiscount += price * item.discount_percentage / 10000;
|
|
207
|
+
price = price * (1 - (item.discount_percentage || 0) / 10000);
|
|
208
|
+
}
|
|
209
|
+
} else if (item.discount_type == 'amount') {
|
|
210
|
+
if (item.discount_amount > 0) {
|
|
211
|
+
beforeTaxDiscount += item.discount_amount;
|
|
212
|
+
price = price - (item.discount_amount || 0);
|
|
213
|
+
if (price <= 0) price = 0;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
item.total = price;
|
|
217
|
+
subtotal += price;
|
|
218
|
+
});
|
|
219
|
+
let taxM = {};
|
|
220
|
+
op.map(order.items, (item, i) => {
|
|
221
|
+
if (!item.product) return;
|
|
222
|
+
let tax = item.product.tax;
|
|
223
|
+
if (!tax) return;
|
|
224
|
+
if (!tax.id) return;
|
|
225
|
+
let taxprice = item.total * tax.percentage / 10000;
|
|
226
|
+
item.total_tax = taxprice;
|
|
227
|
+
taxM[i] = {
|
|
228
|
+
tax: tax,
|
|
229
|
+
taxprice: taxprice
|
|
230
|
+
};
|
|
231
|
+
});
|
|
232
|
+
let totaltax = 0;
|
|
233
|
+
op.map(taxM, t => totaltax += t.taxprice);
|
|
234
|
+
let computed_discount = 0;
|
|
235
|
+
if (order.discount_type == 'percentage' && order.discount_percentage > 0) {
|
|
236
|
+
computed_discount = (subtotal + totaltax) * order.discount_percentage / 10000;
|
|
237
|
+
} else if (order.discount_type == 'amount') {
|
|
238
|
+
computed_discount = order.discount_amount || 0;
|
|
239
|
+
}
|
|
240
|
+
let shippingfee = op.get(order, 'shipping.nominal_fee', 0);
|
|
241
|
+
if (shippingfee > 0) {
|
|
242
|
+
if (op.get(order, 'shipping.tax.id')) {
|
|
243
|
+
let tax = order.shipping.tax;
|
|
244
|
+
let taxprice = shippingfee * (tax.percentage / 10000);
|
|
245
|
+
taxM['ship'] = {
|
|
246
|
+
tax: tax,
|
|
247
|
+
taxprice: taxprice
|
|
248
|
+
};
|
|
249
|
+
order.shipping.total_tax = taxprice;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
totaltax = 0;
|
|
253
|
+
op.map(taxM, t => totaltax += t.taxprice);
|
|
254
|
+
let total = subtotal + totaltax - computed_discount + shippingfee;
|
|
255
|
+
total += order.adjustment || 0;
|
|
256
|
+
if (total < 0) total = 0;
|
|
257
|
+
order.subtotal = subtotal;
|
|
258
|
+
order._computed_discount = computed_discount;
|
|
259
|
+
order._taxM = taxM;
|
|
260
|
+
order.total = total;
|
|
261
|
+
order.total_tax = totaltax;
|
|
262
|
+
order._discount_before_tax = beforeTaxDiscount;
|
|
263
|
+
order._order_value = ordervalue;
|
|
264
|
+
}
|
|
@@ -3,32 +3,25 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default =
|
|
7
|
-
var _common = require("../common.js");
|
|
6
|
+
exports.default = PoweredBy;
|
|
8
7
|
var _preact = require("preact");
|
|
9
8
|
var logo = require('../../assets/img/subiz-mono.svg');
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
src: logo,
|
|
30
|
-
alt: "power by subiz"
|
|
31
|
-
}), " Subiz"));
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
exports.default = PoweredBy;
|
|
9
|
+
function PoweredBy(props) {
|
|
10
|
+
if (props.store.isMobile()) return null;
|
|
11
|
+
let user = props.store.matchUser() || {};
|
|
12
|
+
var link = `https://subiz.com.vn/?utm_source=${window.location.host || `id-${user.account_id}`}&utm_medium=widget&utm_campaign=widget_referral`;
|
|
13
|
+
return (0, _preact.h)("div", {
|
|
14
|
+
class: "poweredby"
|
|
15
|
+
}, (0, _preact.h)("a", {
|
|
16
|
+
href: link,
|
|
17
|
+
class: "poweredby--text",
|
|
18
|
+
target: "_blank",
|
|
19
|
+
title: "Subiz"
|
|
20
|
+
}, (0, _preact.h)("img", {
|
|
21
|
+
width: "14",
|
|
22
|
+
height: "10",
|
|
23
|
+
class: "poweredby--subiz-logo",
|
|
24
|
+
src: logo,
|
|
25
|
+
alt: "powerred by subiz"
|
|
26
|
+
}), " Subiz"));
|
|
27
|
+
}
|
|
@@ -145,7 +145,7 @@ class Rating extends _common.Com {
|
|
|
145
145
|
let foundUser = false;
|
|
146
146
|
_index.default.map(this.props.store.listEvents(this.props.cid), ev => {
|
|
147
147
|
if (!ev || !ev.by) return;
|
|
148
|
-
if (ev.by.type == 'user') foundUser = true;
|
|
148
|
+
if (ev.by.type == 'user' && ev.type == 'message_sent') foundUser = true;
|
|
149
149
|
if (ev.type === 'conversation_state_updated' && _index.default.get(ev, 'data.conversation.state') === 'ended') {
|
|
150
150
|
ended = ev;
|
|
151
151
|
}
|
|
@@ -66,20 +66,6 @@ class TextMessage extends _common.Com {
|
|
|
66
66
|
if (insert.dynamicField) {
|
|
67
67
|
return _index.default.get(insert, 'dynamicField.text', '');
|
|
68
68
|
}
|
|
69
|
-
if (insert.mention) {
|
|
70
|
-
if (insert.mention.id == '*' || insert.mention.id == 'all') {
|
|
71
|
-
return (0, _preact.h)("span", {
|
|
72
|
-
class: "mention"
|
|
73
|
-
}, "@", this.$t('all'));
|
|
74
|
-
}
|
|
75
|
-
let ag = store.matchAgent(insert.mention.id);
|
|
76
|
-
let name = _index.default.getAgentDisplayName(ag, insert.mention.fullname);
|
|
77
|
-
return (0, _preact.h)("span", {
|
|
78
|
-
class: "mention",
|
|
79
|
-
"data-agent-id": ag.id,
|
|
80
|
-
"data-agent-fullname": name
|
|
81
|
-
}, "@", name);
|
|
82
|
-
}
|
|
83
69
|
if (insert.emoji) return (0, _preact.h)(_Emoji.default, {
|
|
84
70
|
emojiCode: `:${insert.emoji}:`
|
|
85
71
|
});
|
|
@@ -23,6 +23,7 @@ class VideoAttachments extends _common.Com {
|
|
|
23
23
|
if (videos.length === 0) return null;
|
|
24
24
|
var $videos = _index.default.map(videos, (video, index) => {
|
|
25
25
|
return (0, _preact.h)("div", {
|
|
26
|
+
key: index,
|
|
26
27
|
class: `video-attachment video-attachment--${byType}`
|
|
27
28
|
}, (0, _preact.h)("video", {
|
|
28
29
|
class: "video-attachment__video",
|
|
@@ -13,7 +13,6 @@ var _MessageInput = _interopRequireDefault(require("./MessageInput.js"));
|
|
|
13
13
|
var _Events = _interopRequireDefault(require("./Events.js"));
|
|
14
14
|
var _Typing = _interopRequireDefault(require("./Typing.js"));
|
|
15
15
|
var _Rating = _interopRequireDefault(require("./Rating.js"));
|
|
16
|
-
var _Order = _interopRequireDefault(require("./Order.js"));
|
|
17
16
|
var _ListField = _interopRequireDefault(require("./ListField.js"));
|
|
18
17
|
var _spinner = _interopRequireDefault(require("./spinner.js"));
|
|
19
18
|
var _time = _interopRequireDefault(require("./time.js"));
|
|
@@ -23,9 +22,13 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
23
22
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
24
23
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
25
24
|
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
25
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
26
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
26
27
|
var send = require('../../assets/img/send.svg');
|
|
27
28
|
var checkedimg = require('../../assets/img/done_gray.svg');
|
|
28
29
|
var empty = require('../../assets/img/empty.svg');
|
|
30
|
+
let Order = false;
|
|
31
|
+
const LoadOrder = () => Promise.resolve().then(() => _interopRequireWildcard(require('./Order.js')));
|
|
29
32
|
const defaultAvatar = 'https://file-subiz.com/fiqoahedjbgwclpouoml-avatar_default_baa8a1d7.png';
|
|
30
33
|
class Widget extends _common.Com {
|
|
31
34
|
constructor(props) {
|
|
@@ -95,9 +98,12 @@ class Widget extends _common.Com {
|
|
|
95
98
|
if (noschemeurl.startsWith('widget.subiz.com.vn/orders/')) {
|
|
96
99
|
let orderid = noschemeurl.substr('widget.subiz.com.vn/orders/'.length);
|
|
97
100
|
orderid = orderid.split('/')[0];
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
+
_index.default.setTimeout(async () => {
|
|
102
|
+
if (!Order) Order = (await LoadOrder()).default;
|
|
103
|
+
this.setState({
|
|
104
|
+
showOrder: true,
|
|
105
|
+
order_id: orderid
|
|
106
|
+
});
|
|
101
107
|
});
|
|
102
108
|
e.preventDefault();
|
|
103
109
|
return;
|
|
@@ -462,14 +468,16 @@ class Widget extends _common.Com {
|
|
|
462
468
|
let $field = null;
|
|
463
469
|
var errclass = field.error ? 'input--error' : '';
|
|
464
470
|
if (field.type === 'text') {
|
|
465
|
-
if (key
|
|
471
|
+
if (key == 'question' || _index.default.get(field, 'def.multiple_line')) {
|
|
466
472
|
$field = (0, _preact.h)("textarea", {
|
|
467
473
|
class: "form-control",
|
|
468
474
|
ref: ref => {
|
|
469
475
|
this['form_' + encode(key)] = ref;
|
|
470
476
|
},
|
|
477
|
+
id: 'form_' + encode(key),
|
|
471
478
|
value: field.value || '',
|
|
472
479
|
onInput: e => this.onInputChange(key, e.target.value),
|
|
480
|
+
onChange: e => this.onInputChange(key, e.target.value),
|
|
473
481
|
row: "4",
|
|
474
482
|
class: "form-control"
|
|
475
483
|
});
|
|
@@ -479,20 +487,9 @@ class Widget extends _common.Com {
|
|
|
479
487
|
$field = this.renderRadioField(field);
|
|
480
488
|
} else if (_index.default.get(field, 'def.select') === 'dropdown') {
|
|
481
489
|
$field = this.renderDropdownField(field);
|
|
482
|
-
} else if (_index.default.get(field, 'def.multiple_line')) {
|
|
483
|
-
$field = (0, _preact.h)("textarea", {
|
|
484
|
-
class: "form-control",
|
|
485
|
-
ref: ref => {
|
|
486
|
-
this['form_' + encode(key)] = ref;
|
|
487
|
-
},
|
|
488
|
-
value: field.value || '',
|
|
489
|
-
onInput: e => this.onInputChange(key, e.target.value),
|
|
490
|
-
onChange: e => this.onInputChange(key, e.target.value),
|
|
491
|
-
row: "4",
|
|
492
|
-
class: "form-control"
|
|
493
|
-
});
|
|
494
490
|
} else {
|
|
495
491
|
$field = (0, _preact.h)("input", {
|
|
492
|
+
id: 'form_' + encode(key),
|
|
496
493
|
value: field.value || '',
|
|
497
494
|
onInput: e => this.onInputChange(key, e.target.value),
|
|
498
495
|
onChange: e => this.onInputChange(key, e.target.value),
|
|
@@ -505,6 +502,7 @@ class Widget extends _common.Com {
|
|
|
505
502
|
}
|
|
506
503
|
} else if (field.type === 'number') {
|
|
507
504
|
$field = (0, _preact.h)("input", {
|
|
505
|
+
id: 'form_' + encode(key),
|
|
508
506
|
value: field.value,
|
|
509
507
|
onInput: e => this.onInputChange(key, e.target.value),
|
|
510
508
|
ref: ref => {
|
|
@@ -557,6 +555,7 @@ class Widget extends _common.Com {
|
|
|
557
555
|
$field = this.renderDropdownField(field);
|
|
558
556
|
} else if (field.type === 'datetime') {
|
|
559
557
|
$field = (0, _preact.h)("input", {
|
|
558
|
+
id: 'form_' + encode(key),
|
|
560
559
|
value: field.value,
|
|
561
560
|
onInput: e => this.onInputChange(key, e.target.value),
|
|
562
561
|
class: `form-control ${errclass}`,
|
|
@@ -576,8 +575,9 @@ class Widget extends _common.Com {
|
|
|
576
575
|
if (field.label) label = field.label;
|
|
577
576
|
return (0, _preact.h)("div", {
|
|
578
577
|
key: 'form_' + encode(key)
|
|
579
|
-
}, (0, _preact.h)("
|
|
580
|
-
class: "label"
|
|
578
|
+
}, (0, _preact.h)("label", {
|
|
579
|
+
class: "label",
|
|
580
|
+
for: 'form_' + encode(key)
|
|
581
581
|
}, label, field.is_required ? (0, _preact.h)("span", {
|
|
582
582
|
class: "ml-1 red"
|
|
583
583
|
}, "*") : ''), field.error ? (0, _preact.h)("div", {
|
|
@@ -779,7 +779,7 @@ class Widget extends _common.Com {
|
|
|
779
779
|
onRate: e => this.onRate(e),
|
|
780
780
|
cid: this.props.cid,
|
|
781
781
|
t: this.props.t
|
|
782
|
-
}), (0, _preact.h)(
|
|
782
|
+
}), (0, _preact.h)(Order, {
|
|
783
783
|
forceView: this.props.view,
|
|
784
784
|
plugin: this.props.plugin,
|
|
785
785
|
show: this.state.showOrder,
|
|
@@ -872,7 +872,7 @@ class Widget extends _common.Com {
|
|
|
872
872
|
}, (0, _preact.h)(_time.default, {
|
|
873
873
|
ago: true,
|
|
874
874
|
time: time,
|
|
875
|
-
|
|
875
|
+
t: this.props.t,
|
|
876
876
|
short: true
|
|
877
877
|
}))), (0, _preact.h)("div", {
|
|
878
878
|
class: "d-flex flex-row"
|
|
@@ -20,21 +20,16 @@ class Time extends _common.Com {
|
|
|
20
20
|
}
|
|
21
21
|
updateTime() {
|
|
22
22
|
var t = '';
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
let tzyear = tim.getFullYear();
|
|
28
|
-
let locale = _index.default.get(navigator, 'languages.0', 'en-US');
|
|
29
|
-
let tzmonthname = tim.toLocaleDateString(locale, {
|
|
30
|
-
month: 'short'
|
|
31
|
-
});
|
|
32
|
-
let tzdate = tim.getDate();
|
|
33
|
-
t = tzdate + ' ' + tzmonthname + ' ' + tzyear;
|
|
34
|
-
}
|
|
23
|
+
let forceLocale = '';
|
|
24
|
+
if (this.props.t) {
|
|
25
|
+
if (this.props.t.locale && typeof this.props.t.locale === 'function') {
|
|
26
|
+
forceLocale = this.props.t.locale();
|
|
35
27
|
}
|
|
36
|
-
|
|
37
|
-
|
|
28
|
+
}
|
|
29
|
+
if (this.props.ago) {
|
|
30
|
+
if (this.props.short) {}
|
|
31
|
+
if (!t && this.props.time > 0) t = ago(this.props.time, new _index.default.Date().getTime(), this.props.t);
|
|
32
|
+
} else t = _index.default.shortTime(this.props.time, this.props.tzoffset, Date.now(), forceLocale);
|
|
38
33
|
if (this.props.uppercase) t = t.toUpperCase();
|
|
39
34
|
if (t === this.state.t) return;
|
|
40
35
|
this.setState({
|
|
@@ -46,26 +41,49 @@ class Time extends _common.Com {
|
|
|
46
41
|
this.updateTime();
|
|
47
42
|
}
|
|
48
43
|
render() {
|
|
44
|
+
let locale = _index.default.get(navigator, 'languages.0', 'en-US');
|
|
45
|
+
if (this.props.t) {
|
|
46
|
+
if (this.props.t.locale && typeof this.props.t.locale === 'function') {
|
|
47
|
+
locale = this.props.t.locale();
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
let title = new Date(this.props.time).toLocaleString(locale);
|
|
49
51
|
return (0, _preact.h)("span", {
|
|
50
|
-
style: this.props.style
|
|
52
|
+
style: this.props.style,
|
|
53
|
+
title: title
|
|
51
54
|
}, this.state.t);
|
|
52
55
|
}
|
|
53
56
|
}
|
|
54
57
|
exports.default = Time;
|
|
55
|
-
function ago(timeA, timeB) {
|
|
56
|
-
|
|
57
|
-
s: '%d
|
|
58
|
-
m: '
|
|
59
|
-
mm: '%
|
|
60
|
-
h: '
|
|
61
|
-
hh: '%
|
|
62
|
-
d: '
|
|
63
|
-
dd: '%
|
|
64
|
-
M: '
|
|
65
|
-
MM: '%
|
|
66
|
-
y: '
|
|
67
|
-
yy: '%
|
|
58
|
+
function ago(timeA, timeB, t) {
|
|
59
|
+
let relObj = {
|
|
60
|
+
s: '%d sec',
|
|
61
|
+
m: '1 min',
|
|
62
|
+
mm: '%d mins',
|
|
63
|
+
h: '1 hour',
|
|
64
|
+
hh: '%d hours',
|
|
65
|
+
d: '1 day',
|
|
66
|
+
dd: '%d days',
|
|
67
|
+
M: '1 month',
|
|
68
|
+
MM: '%d months',
|
|
69
|
+
y: '1 year',
|
|
70
|
+
yy: '%d years'
|
|
68
71
|
};
|
|
72
|
+
if (t) {
|
|
73
|
+
relObj = {
|
|
74
|
+
s: `%d ${t('second_short')}`,
|
|
75
|
+
m: `1 ${t('minute_short')}`,
|
|
76
|
+
mm: `%d ${t('minutes_short')}`,
|
|
77
|
+
h: `1 ${t('hour_short')}`,
|
|
78
|
+
hh: `%d ${t('hours_short')}`,
|
|
79
|
+
d: `1 ${t('day_short')}`,
|
|
80
|
+
dd: `%d ${t('days_short')}`,
|
|
81
|
+
M: `1 ${t('month_short')}`,
|
|
82
|
+
MM: `%d ${t('months_short')}`,
|
|
83
|
+
y: `1 ${t('year_short')}`,
|
|
84
|
+
yy: `%d ${t('years_short')}`
|
|
85
|
+
};
|
|
86
|
+
}
|
|
69
87
|
const loc = relObj;
|
|
70
88
|
const T = [{
|
|
71
89
|
l: 's',
|
package/compiled_src/lib.js
CHANGED
|
@@ -12,10 +12,10 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
|
12
12
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
13
13
|
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
14
14
|
var $link = document.createElement('link');
|
|
15
|
-
$link.href = 'https://fonts.googleapis.com/css2?family=Inter:wght@400;500
|
|
15
|
+
$link.href = 'https://fonts.googleapis.com/css2?family=Inter:wght@400;500&display=swap';
|
|
16
16
|
$link.rel = 'stylesheet';
|
|
17
17
|
document.head.append($link);
|
|
18
|
-
_index.default.preloadWebfonts(['Inter'], [400, 500
|
|
18
|
+
_index.default.preloadWebfonts(['Inter'], [400, 500]);
|
|
19
19
|
class Widget {
|
|
20
20
|
constructor(ApiURL, FileURL, RealtimeURL, inmem, fake) {
|
|
21
21
|
_defineProperty(this, "version", () => '4.5');
|
|
@@ -14,10 +14,10 @@ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return
|
|
|
14
14
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
15
15
|
let promiseMainCSS = (() => Promise.resolve().then(() => _interopRequireWildcard(require('../chatbox/css.js'))))();
|
|
16
16
|
var $link = document.createElement('link');
|
|
17
|
-
$link.href = 'https://fonts.googleapis.com/css2?family=
|
|
17
|
+
$link.href = 'https://fonts.googleapis.com/css2?family=Inter:wght@400;500&display=swap';
|
|
18
18
|
$link.rel = 'stylesheet';
|
|
19
19
|
document.head.append($link);
|
|
20
|
-
_index.default.preloadWebfonts(['
|
|
20
|
+
_index.default.preloadWebfonts(['Inter'], [400, 500]);
|
|
21
21
|
let defaultAvatar = require('../../assets/img/default_avatar.png');
|
|
22
22
|
class Icon extends common.Com {
|
|
23
23
|
render() {
|
|
@@ -26,10 +26,10 @@ function getUrlParameter(name) {
|
|
|
26
26
|
return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
|
|
27
27
|
}
|
|
28
28
|
var $link = document.createElement('link');
|
|
29
|
-
$link.href = 'https://fonts.googleapis.com/css2?family=
|
|
29
|
+
$link.href = 'https://fonts.googleapis.com/css2?family=Inter:wght@400;500&display=swap';
|
|
30
30
|
$link.rel = 'stylesheet';
|
|
31
31
|
document.head.append($link);
|
|
32
|
-
_index.default.preloadWebfonts(['
|
|
32
|
+
_index.default.preloadWebfonts(['Inter'], [400, 500]);
|
|
33
33
|
async function load() {
|
|
34
34
|
let store = new _store.default(config.ApiURL, config.FileURL, config.RealtimeURL, true);
|
|
35
35
|
let signkey = getUrlParameter('x-signed-key');
|
package/compiled_src/plugin.js
CHANGED
|
@@ -7,10 +7,10 @@ exports.default = void 0;
|
|
|
7
7
|
var _index = _interopRequireDefault(require("./util/index.js"));
|
|
8
8
|
var common = _interopRequireWildcard(require("./common.js"));
|
|
9
9
|
var _preact = require("preact");
|
|
10
|
+
var _main = _interopRequireDefault(require("./chatbox/main.js"));
|
|
10
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
12
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
12
13
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
13
|
-
const LoadChatbox = () => Promise.resolve().then(() => _interopRequireWildcard(require('./chatbox/main.js')));
|
|
14
14
|
const LoadContact = () => Promise.resolve().then(() => _interopRequireWildcard(require('./contact/contact.js')));
|
|
15
15
|
const LoadPopup = () => Promise.resolve().then(() => _interopRequireWildcard(require('./popup/popup.js')));
|
|
16
16
|
const LoadNotif = () => Promise.resolve().then(() => _interopRequireWildcard(require('./notif/notif.js')));
|
|
@@ -49,7 +49,6 @@ function Plugin(plugin, store, $container, lib) {
|
|
|
49
49
|
}
|
|
50
50
|
};
|
|
51
51
|
var _ref = (0, _preact.createRef)();
|
|
52
|
-
let Chatbox = null;
|
|
53
52
|
let Popup = null;
|
|
54
53
|
let Contact = null;
|
|
55
54
|
let Notif = null;
|
|
@@ -62,8 +61,7 @@ function Plugin(plugin, store, $container, lib) {
|
|
|
62
61
|
if (_destroy) return;
|
|
63
62
|
if (!$div) return;
|
|
64
63
|
if (plugin.type === 'chatbox') {
|
|
65
|
-
|
|
66
|
-
(0, _preact.render)((0, _preact.h)(Chatbox, {
|
|
64
|
+
(0, _preact.render)((0, _preact.h)(_main.default, {
|
|
67
65
|
destroy: _destroy,
|
|
68
66
|
plugin: plugin,
|
|
69
67
|
store: store,
|
|
@@ -58,22 +58,7 @@ class _default {
|
|
|
58
58
|
}
|
|
59
59
|
}));
|
|
60
60
|
_defineProperty(this, "sendTyping", cid => this.apireq.post(`/accounts/${this.accid}/conversations/${cid}/typing`));
|
|
61
|
-
_defineProperty(this, "sendLostFocus", (
|
|
62
|
-
by: {
|
|
63
|
-
id: this.uid,
|
|
64
|
-
device: device
|
|
65
|
-
},
|
|
66
|
-
type: 'presence_updated',
|
|
67
|
-
data: {
|
|
68
|
-
presence: {
|
|
69
|
-
viewing_product_sku: sku,
|
|
70
|
-
viewing_product_source_id: source_id,
|
|
71
|
-
viewing_product_id: productid,
|
|
72
|
-
pinged: _index.default.Date.now(),
|
|
73
|
-
is_focused: false
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}));
|
|
61
|
+
_defineProperty(this, "sendLostFocus", () => this.apireq.post(`/accounts/${this.accid}/focuses/${this.uid}/delete`));
|
|
77
62
|
_defineProperty(this, "uploadToS3", async file => {
|
|
78
63
|
let {
|
|
79
64
|
body: signed,
|
|
@@ -126,10 +126,7 @@ class Store {
|
|
|
126
126
|
if (_index.default.isUserBanned(this.cache.match('user'))) return;
|
|
127
127
|
if (!this._track_page_view) return;
|
|
128
128
|
let hasfocus = this.browserVisibility === 'visible' && document.hasFocus();
|
|
129
|
-
if (!hasfocus)
|
|
130
|
-
this.api.sendLostFocus(this.device, this._currentViewingProduct.id, this._currentViewingProduct.source_id, this._currentViewingProduct.sku);
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
129
|
+
if (!hasfocus) return this.api.sendLostFocus();
|
|
133
130
|
this.api.sendContentView(this.device, location.href, document.title, this._currentViewingProduct.id, this._currentViewingProduct.source_id, this._currentViewingProduct.sku);
|
|
134
131
|
}, 1000, {
|
|
135
132
|
leading: false
|