@subiz/widget-v4 4.1.210 → 4.1.211
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/README.md +21 -2
- package/assets/less/chatbox.less +9 -0
- package/assets/less/form.less +10 -0
- package/assets/less/message.less +114 -13
- package/assets/less/widget.less +21 -16
- package/compiled_src/call/css.js +1 -1
- package/compiled_src/chatbox/Buttons.js +7 -4
- package/compiled_src/chatbox/ChatButton.js +115 -29
- package/compiled_src/chatbox/Event.js +37 -5
- package/compiled_src/chatbox/Events.js +348 -129
- package/compiled_src/chatbox/FormAttachment.js +1 -1
- package/compiled_src/chatbox/Header.js +6 -2
- package/compiled_src/chatbox/InfoMessage.js +1 -1
- package/compiled_src/chatbox/MessageInput.js +24 -9
- package/compiled_src/chatbox/OrderAttachments.js +13 -13
- package/compiled_src/chatbox/QuoteMessage.js +3 -2
- package/compiled_src/chatbox/TextMessage.js +22 -18
- package/compiled_src/chatbox/Widget.js +200 -129
- package/compiled_src/chatbox/block.js +39 -29
- package/compiled_src/chatbox/conversation-history.js +44 -0
- package/compiled_src/chatbox/event-layout.js +59 -0
- package/compiled_src/chatbox/greeting.js +32 -0
- package/compiled_src/common.js +13 -9
- package/compiled_src/form/css.js +1 -1
- package/compiled_src/lib.js +22 -32
- package/compiled_src/notif/css.js +1 -1
- package/compiled_src/plugin.js +11 -18
- package/compiled_src/popup/css.js +1 -1
- package/compiled_src/popup/popup.js +1 -1
- package/compiled_src/store/api.js +0 -2
- package/compiled_src/store/api_fake.js +1 -1
- package/compiled_src/store/attachments.js +28 -0
- package/compiled_src/store/chain.js +24 -10
- package/compiled_src/store/kv.js +9 -13
- package/compiled_src/store/lsdb.js +1 -1
- package/compiled_src/store/store.js +356 -117
- package/compiled_src/util/common.js +48 -41
- package/compiled_src/util/event.js +15 -0
- package/compiled_src/util/pubsub.js +28 -13
- package/compiled_src/util/url.js +18 -0
- package/dist/.HASH +1 -0
- package/dist/127.js +13 -13
- package/dist/132.js +1 -1
- package/dist/1a0ddc53cbb.127.js +1 -0
- package/dist/{1a0d80f6e72.132.js → 1a0ddc53cbb.132.js} +1 -1
- package/dist/1a0ddc53cbb.278.js +1 -0
- package/dist/{1a0d80f6e72.339.js → 1a0ddc53cbb.339.js} +1 -1
- package/dist/1a0ddc53cbb.app.js +1 -0
- package/dist/{1a0d80f6e72.chat.html → 1a0ddc53cbb.chat.html} +1 -1
- package/dist/1a0ddc53cbb.chat.js +1 -0
- package/dist/{1a0d80f6e72.form.html → 1a0ddc53cbb.form.html} +1 -1
- package/dist/1a0ddc53cbb.form.js +1 -0
- package/dist/{1a0d80f6e72.index.html → 1a0ddc53cbb.index.html} +1 -1
- package/dist/{1a0d80f6e72.library.html → 1a0ddc53cbb.library.html} +1 -1
- package/dist/1a0ddc53cbb.library.js +1 -0
- package/dist/{1a0d80f6e72.preview.html → 1a0ddc53cbb.preview.html} +1 -1
- package/dist/1a0ddc53cbb.preview.js +1 -0
- package/dist/1a0ddc53cbb.webview.js +1 -0
- package/dist/screenshoot.js +1492 -616
- package/package.json +10 -3
- package/src/chatbox/Buttons.js +5 -4
- package/src/chatbox/ChatButton.js +120 -39
- package/src/chatbox/Event.js +38 -5
- package/src/chatbox/Events.js +306 -134
- package/src/chatbox/FormAttachment.js +1 -1
- package/src/chatbox/Header.js +4 -4
- package/src/chatbox/InfoMessage.js +1 -1
- package/src/chatbox/MessageInput.js +15 -10
- package/src/chatbox/OrderAttachments.js +13 -13
- package/src/chatbox/QuoteMessage.js +3 -2
- package/src/chatbox/TextMessage.js +21 -20
- package/src/chatbox/Widget.js +150 -150
- package/src/chatbox/block.js +29 -27
- package/src/chatbox/conversation-history.js +37 -0
- package/src/chatbox/event-layout.js +72 -0
- package/src/chatbox/greeting.js +13 -0
- package/src/common.js +15 -9
- package/src/lib.js +22 -35
- package/src/plugin.js +11 -13
- package/src/popup/popup.js +1 -1
- package/src/store/api.js +0 -2
- package/src/store/api_fake.js +1 -1
- package/src/store/attachments.js +21 -0
- package/src/store/chain.js +25 -12
- package/src/store/kv.js +10 -19
- package/src/store/lsdb.js +1 -1
- package/src/store/store.js +313 -130
- package/src/util/common.js +48 -43
- package/src/util/event.js +7 -0
- package/src/util/pubsub.js +27 -8
- package/src/util/url.js +14 -0
- package/test.cjs +59 -0
- package/assets/less/contact.less +0 -126
- package/compiled_src/util/common.test.js +0 -414
- package/compiled_src/util/event.test.js +0 -38
- package/compiled_src/util/extractor.test.js +0 -299
- package/compiled_src/util/extractor.test2.js +0 -61
- package/compiled_src/util/gate.test.js +0 -18
- package/compiled_src/util/pubsub.test.js +0 -35
- package/dist/1a0d80f6e72.127.js +0 -1
- package/dist/1a0d80f6e72.278.js +0 -1
- package/dist/1a0d80f6e72.74.js +0 -1
- package/dist/1a0d80f6e72.997.js +0 -1
- package/dist/1a0d80f6e72.app.js +0 -1
- package/dist/1a0d80f6e72.chat.js +0 -1
- package/dist/1a0d80f6e72.form.js +0 -1
- package/dist/1a0d80f6e72.library.js +0 -1
- package/dist/1a0d80f6e72.preview.js +0 -1
- package/dist/1a0d80f6e72.webview.js +0 -1
- package/dist/74.js +0 -376
- package/dist/997.js +0 -37
- package/dist/HASH +0 -1
- package/src/contact/contact.js +0 -400
- package/src/contact/css.js +0 -1
- package/src/util/common.test.js +0 -301
- package/src/util/event.test.js +0 -31
- package/src/util/extractor.test.js +0 -240
- package/src/util/extractor.test2.js +0 -56
- package/src/util/gate.test.js +0 -20
- package/src/util/pubsub.test.js +0 -37
- /package/dist/{1a0d80f6e72.185.js → 1a0ddc53cbb.185.js} +0 -0
- /package/dist/{1a0d80f6e72.27.js → 1a0ddc53cbb.27.js} +0 -0
- /package/dist/{1a0d80f6e72.459.js → 1a0ddc53cbb.459.js} +0 -0
- /package/dist/{1a0d80f6e72.490.js → 1a0ddc53cbb.490.js} +0 -0
|
@@ -242,7 +242,16 @@ function pipeExtracts(text, extractors) {
|
|
|
242
242
|
return out;
|
|
243
243
|
}
|
|
244
244
|
function extractText(text) {
|
|
245
|
-
var link =
|
|
245
|
+
var link = value => {
|
|
246
|
+
const emails = extractEmails(value);
|
|
247
|
+
return extractLinks(value).map(span => {
|
|
248
|
+
const matched = value.substr(span.index, span.length);
|
|
249
|
+
return {
|
|
250
|
+
...span,
|
|
251
|
+
length: matched.replace(/[.,;!?]+$/, '').length
|
|
252
|
+
};
|
|
253
|
+
}).filter(span => !emails.some(email => span.index >= email.index && span.index + span.length <= email.index + email.length));
|
|
254
|
+
};
|
|
246
255
|
link.type = 'link';
|
|
247
256
|
var email = extractEmails;
|
|
248
257
|
email.type = 'email';
|
|
@@ -514,8 +523,14 @@ function orderByF(a, f, d) {
|
|
|
514
523
|
return clone;
|
|
515
524
|
}
|
|
516
525
|
function isPhone(phone) {
|
|
517
|
-
|
|
518
|
-
|
|
526
|
+
if (typeof phone !== 'string' && typeof phone !== 'number') return false;
|
|
527
|
+
const value = String(phone).trim();
|
|
528
|
+
const ungrouped = value.replace(/\((\d+)\)/g, '$1');
|
|
529
|
+
if (!/^\+?\d+(?:[ .-]\d+)*$/.test(ungrouped)) return false;
|
|
530
|
+
const digits = value.replace(/\D/g, '');
|
|
531
|
+
if (digits.length < 7 || digits.length > 15 || /^(\d)\1+$/.test(digits)) return false;
|
|
532
|
+
if (value.startsWith('+') && digits.startsWith('0')) return false;
|
|
533
|
+
return true;
|
|
519
534
|
}
|
|
520
535
|
function isURL(url) {
|
|
521
536
|
var re = /[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/gi;
|
|
@@ -526,8 +541,17 @@ function isNumber(num) {
|
|
|
526
541
|
return re.test(String(num));
|
|
527
542
|
}
|
|
528
543
|
function isEmail(email) {
|
|
544
|
+
if (typeof email !== 'string') return false;
|
|
545
|
+
const value = email.trim();
|
|
546
|
+
if (value.length > 254) return false;
|
|
547
|
+
const at = value.lastIndexOf('@');
|
|
548
|
+
const local = value.slice(0, at);
|
|
549
|
+
const domain = value.slice(at + 1);
|
|
550
|
+
if (!local || local.length > 64) return false;
|
|
551
|
+
if (!local.startsWith('"') && (local.startsWith('.') || local.endsWith('.') || local.includes('..'))) return false;
|
|
552
|
+
if (!domain.startsWith('[') && domain.split('.').some(label => label.length > 63 || !/^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test(label))) return false;
|
|
529
553
|
const re = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
|
530
|
-
return re.test(
|
|
554
|
+
return re.test(value.toLowerCase());
|
|
531
555
|
}
|
|
532
556
|
function last(array) {
|
|
533
557
|
var length = array == null ? 0 : array.length;
|
|
@@ -796,7 +820,7 @@ function js2css(js, onlyprops, variables) {
|
|
|
796
820
|
return style;
|
|
797
821
|
}
|
|
798
822
|
function browserName() {
|
|
799
|
-
var isOpera = !!window.opr && !!opr.addons || !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0;
|
|
823
|
+
var isOpera = !!window.opr && !!window.opr.addons || !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0;
|
|
800
824
|
var isFirefox = typeof InstallTrigger !== 'undefined';
|
|
801
825
|
var isSafari = /constructor/i.test(window.HTMLElement) || function (p) {
|
|
802
826
|
return p.toString() === '[object SafariRemoteNotification]';
|
|
@@ -915,8 +939,8 @@ function checkRunConditions(freq, conds, lastrun, store) {
|
|
|
915
939
|
break;
|
|
916
940
|
case 'user_is_a_contact':
|
|
917
941
|
let attributes = op.get(store.matchUser(), 'attributes', []);
|
|
918
|
-
let emailAttr = find(attributes, att => att.key === 'emails'
|
|
919
|
-
let phoneAttr = find(attributes, att => att.key === 'phones'
|
|
942
|
+
let emailAttr = find(attributes, att => (att.key === 'emails' || att.key === 'related_email') && att.text);
|
|
943
|
+
let phoneAttr = find(attributes, att => (att.key === 'phones' || att.key === 'related_phone') && att.text);
|
|
920
944
|
let hasContact = emailAttr || phoneAttr;
|
|
921
945
|
if (cond.user_is_a_contact) {
|
|
922
946
|
if (!hasContact) return false;
|
|
@@ -1213,8 +1237,7 @@ function unicodeToAscii(str) {
|
|
|
1213
1237
|
str = str.replaceAll('đ', 'd').replaceAll('Đ', 'D');
|
|
1214
1238
|
return str.normalize('NFD').replace(/[\u0300-\u036f]/g, '');
|
|
1215
1239
|
}
|
|
1216
|
-
function scrollIntoViewIfNeeded($ele) {
|
|
1217
|
-
centerIfNeeded = arguments.length === 0 ? true : !!centerIfNeeded;
|
|
1240
|
+
function scrollIntoViewIfNeeded($ele, centerIfNeeded = true) {
|
|
1218
1241
|
var parent = $ele.parentNode;
|
|
1219
1242
|
var parentComputedStyle = window.getComputedStyle(parent, null);
|
|
1220
1243
|
var parentBorderTopWidth = parseInt(parentComputedStyle.getPropertyValue('border-top-width'));
|
|
@@ -1245,51 +1268,31 @@ function blockToText(block) {
|
|
|
1245
1268
|
return _blockToText(block).trim();
|
|
1246
1269
|
}
|
|
1247
1270
|
function isBlockEmpty(block) {
|
|
1248
|
-
return
|
|
1249
|
-
}
|
|
1250
|
-
function _isBlockEmpty(block = {}) {
|
|
1251
|
-
if (!size(block.content)) {
|
|
1252
|
-
if ((block.text || '').trim()) return false;
|
|
1253
|
-
return true;
|
|
1254
|
-
}
|
|
1255
|
-
let result = true;
|
|
1256
|
-
map(block.content, content => {
|
|
1257
|
-
result = result && _isBlockEmpty(content);
|
|
1258
|
-
});
|
|
1259
|
-
return result;
|
|
1271
|
+
return isEmptyBlock(block);
|
|
1260
1272
|
}
|
|
1261
1273
|
function _blockToText(block) {
|
|
1262
|
-
if (!block
|
|
1274
|
+
if (!block) return '';
|
|
1263
1275
|
let out = '';
|
|
1264
1276
|
if (block.type == 'bullet_list' || block.type == 'ordered_list') {
|
|
1265
|
-
map(block.content, item => {
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
prefix = i + '\n. ';
|
|
1269
|
-
}
|
|
1270
|
-
out += prefix + blockToText(item).trim();
|
|
1277
|
+
map(block.content, (item, i) => {
|
|
1278
|
+
let prefix = block.type == 'ordered_list' ? '\n' + (Number(i) + 1) + '. ' : '\n* ';
|
|
1279
|
+
out += prefix + _blockToText(item).trim();
|
|
1271
1280
|
});
|
|
1272
1281
|
return out;
|
|
1273
1282
|
}
|
|
1274
1283
|
if (block.type == 'heading' || block.type == 'paragraph') {
|
|
1275
1284
|
out += '\n';
|
|
1276
1285
|
}
|
|
1277
|
-
if (block.type == '' || block.type == 'text' || block.type == 'link' || block.type == 'mention-agent' || block.type == 'dynamic-field') {
|
|
1278
|
-
return out + block.text;
|
|
1286
|
+
if (block.type == '' || block.type == 'text' || block.type == 'link' || block.type == 'mention-agent' || block.type == 'mention' || block.type == 'dynamic-field') {
|
|
1287
|
+
if (!size(block.content)) return out + (block.text || '');
|
|
1279
1288
|
}
|
|
1280
1289
|
if (block.type == 'horizontal_rule') return out + '\n---\n';
|
|
1281
1290
|
if (block.type == 'emoji') {
|
|
1282
|
-
|
|
1283
|
-
if (size(block.attrs) > 0) code = block.attrs['code'];
|
|
1284
|
-
if (code == '') code = block.text;
|
|
1285
|
-
if (code != '') {
|
|
1286
|
-
let emoji = find(LEXICAL_EMOJI_LIST, emoji => emoji.code === code);
|
|
1287
|
-
out + op.get(emoji, 'text', code);
|
|
1288
|
-
}
|
|
1289
|
-
return out;
|
|
1291
|
+
return out + (op.get(block, 'attrs.code') || block.text || block.Text || '');
|
|
1290
1292
|
}
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
+
if (!size(block.content)) return out + (block.text || '');
|
|
1294
|
+
map(block.content, child => {
|
|
1295
|
+
out += _blockToText(child);
|
|
1293
1296
|
});
|
|
1294
1297
|
return out;
|
|
1295
1298
|
}
|
|
@@ -1315,12 +1318,16 @@ function absLink(url) {
|
|
|
1315
1318
|
return url;
|
|
1316
1319
|
}
|
|
1317
1320
|
function isEmptyBlock(block) {
|
|
1318
|
-
if (!block
|
|
1321
|
+
if (!block) return true;
|
|
1322
|
+
if (block.type === 'image' && op.get(block, 'image.url')) return false;
|
|
1323
|
+
if (block.type === 'emoji' && (op.get(block, 'attrs.code') || block.Text)) return false;
|
|
1324
|
+
if (block.type === 'horizontal_rule') return false;
|
|
1319
1325
|
let hasContent = size(filter(map(block.content, block => isEmptyBlock(block)), isEmpty => !isEmpty)) > 0;
|
|
1320
1326
|
return !trim(block.text) && !hasContent;
|
|
1321
1327
|
}
|
|
1322
1328
|
function isEmptyMessage(msg) {
|
|
1323
1329
|
if (!msg) return true;
|
|
1330
|
+
if (msg.deleted) return false;
|
|
1324
1331
|
if (!msg.text && isEmptyBlock(msg.block) && isEmptyAttachment(msg)) return true;
|
|
1325
1332
|
return false;
|
|
1326
1333
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.normalizeCdpEvent = normalizeCdpEvent;
|
|
7
|
+
function normalizeCdpEvent(type, payload, options) {
|
|
8
|
+
if (type && typeof type === 'object') return type;
|
|
9
|
+
let data = {
|
|
10
|
+
type
|
|
11
|
+
};
|
|
12
|
+
if (payload !== undefined) data.payload = payload;
|
|
13
|
+
if (options && typeof options === 'object') data = Object.assign({}, options, data);
|
|
14
|
+
return data;
|
|
15
|
+
}
|
|
@@ -4,26 +4,41 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var {
|
|
8
|
-
filter,
|
|
9
|
-
map
|
|
10
|
-
} = require('./common.js');
|
|
11
7
|
class Pubsub {
|
|
12
8
|
constructor() {
|
|
13
9
|
this.listeners = {};
|
|
14
10
|
}
|
|
15
|
-
publish(topic, payload
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
11
|
+
publish(topic, ...payload) {
|
|
12
|
+
const subscriptions = (this.listeners[topic] || []).slice();
|
|
13
|
+
for (const subscription of subscriptions) {
|
|
14
|
+
if (!subscription.obj._isMounted) subscription.unsubscribe();
|
|
15
|
+
if (subscription.active) subscription.cb(...payload);
|
|
16
|
+
}
|
|
20
17
|
}
|
|
21
18
|
on2(obj, topic, cb) {
|
|
22
|
-
|
|
23
|
-
this.listeners[topic].push({
|
|
19
|
+
const subscription = {
|
|
24
20
|
obj,
|
|
25
|
-
cb
|
|
26
|
-
|
|
21
|
+
cb,
|
|
22
|
+
active: true
|
|
23
|
+
};
|
|
24
|
+
let release = () => {};
|
|
25
|
+
const unsubscribe = () => {
|
|
26
|
+
if (!subscription.active) return;
|
|
27
|
+
subscription.active = false;
|
|
28
|
+
this.listeners[topic] = (this.listeners[topic] || []).filter(sub => sub !== subscription);
|
|
29
|
+
if (!this.listeners[topic].length) delete this.listeners[topic];
|
|
30
|
+
release();
|
|
31
|
+
};
|
|
32
|
+
subscription.unsubscribe = unsubscribe;
|
|
33
|
+
if (!this.listeners[topic]) this.listeners[topic] = [];
|
|
34
|
+
this.listeners[topic].push(subscription);
|
|
35
|
+
if (typeof obj.onDispose === 'function') release = obj.onDispose(unsubscribe);
|
|
36
|
+
return unsubscribe;
|
|
37
|
+
}
|
|
38
|
+
clear() {
|
|
39
|
+
for (const subscriptions of Object.values(this.listeners)) {
|
|
40
|
+
for (const subscription of subscriptions.slice()) subscription.unsubscribe();
|
|
41
|
+
}
|
|
27
42
|
}
|
|
28
43
|
}
|
|
29
44
|
exports.default = Pubsub;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.safeUrl = safeUrl;
|
|
7
|
+
function safeUrl(value, image = false) {
|
|
8
|
+
if (typeof value !== 'string') return '';
|
|
9
|
+
const url = value.trim();
|
|
10
|
+
const normalized = url.replace(/[\u0000-\u0020\u007f]/g, '');
|
|
11
|
+
const scheme = normalized.match(/^([a-z][a-z0-9+.-]*):/i);
|
|
12
|
+
if (!scheme) return url;
|
|
13
|
+
if (/^https?$/i.test(scheme[1])) return url;
|
|
14
|
+
if (!image && /^(mailto|tel)$/i.test(scheme[1])) return url;
|
|
15
|
+
if (image && /^blob$/i.test(scheme[1])) return url;
|
|
16
|
+
if (image && /^data:image\/(png|jpe?g|gif|webp|avif);base64,/i.test(normalized)) return url;
|
|
17
|
+
return '';
|
|
18
|
+
}
|
package/dist/.HASH
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
1a0ddc53cbb
|
package/dist/127.js
CHANGED
|
@@ -172,12 +172,12 @@ class ProductAttachments extends _common_js__WEBPACK_IMPORTED_MODULE_1__/* .Com
|
|
|
172
172
|
}
|
|
173
173
|
}
|
|
174
174
|
function getProductPropName(product, seperator = ' - ') {
|
|
175
|
-
let options =
|
|
176
|
-
let props =
|
|
177
|
-
let multiPropsOptions =
|
|
175
|
+
let options = _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.get(product, 'options', []);
|
|
176
|
+
let props = _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.get(product, 'props', []);
|
|
177
|
+
let multiPropsOptions = _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.filter(options, option => _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.size(option.values) > 1);
|
|
178
178
|
let names = [];
|
|
179
|
-
|
|
180
|
-
let prop =
|
|
179
|
+
_util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.each(multiPropsOptions, option => {
|
|
180
|
+
let prop = _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.find(props, prop => prop.key === option.key) || {};
|
|
181
181
|
if (prop.value) names.push(prop.value);
|
|
182
182
|
});
|
|
183
183
|
return names.join(seperator);
|
|
@@ -186,7 +186,7 @@ function getOrderDisplayName(order = {}) {
|
|
|
186
186
|
return order.number || order.id || '';
|
|
187
187
|
}
|
|
188
188
|
function displayOrderShippingAddress(order, isShorten) {
|
|
189
|
-
let addr =
|
|
189
|
+
let addr = _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.get(order, 'shipping.address', {});
|
|
190
190
|
let fulladdr = [addr.address, addr.ward, addr.district, addr.province].filter(a => a).join(', ').trim();
|
|
191
191
|
if (isShorten) fulladdr = shortenAddr(fulladdr);
|
|
192
192
|
return fulladdr;
|
|
@@ -202,9 +202,9 @@ function calcOrderTotal(order) {
|
|
|
202
202
|
let subtotal = 0;
|
|
203
203
|
let beforeTaxDiscount = 0;
|
|
204
204
|
let ordervalue = 0;
|
|
205
|
-
|
|
205
|
+
_util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.map(order.items, item => {
|
|
206
206
|
if (!item.product) return 0;
|
|
207
|
-
let price =
|
|
207
|
+
let price = _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.get(item, 'product.price', 0) * (item.quantity || 0);
|
|
208
208
|
ordervalue += price;
|
|
209
209
|
if (item.discount_type == 'percentage') {
|
|
210
210
|
if (item.discount_percentage > 0) {
|
|
@@ -222,7 +222,7 @@ function calcOrderTotal(order) {
|
|
|
222
222
|
subtotal += price;
|
|
223
223
|
});
|
|
224
224
|
let taxM = {};
|
|
225
|
-
|
|
225
|
+
_util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.map(order.items, (item, i) => {
|
|
226
226
|
if (!item.product) return;
|
|
227
227
|
let tax = item.product.tax;
|
|
228
228
|
if (!tax) return;
|
|
@@ -235,16 +235,16 @@ function calcOrderTotal(order) {
|
|
|
235
235
|
};
|
|
236
236
|
});
|
|
237
237
|
let totaltax = 0;
|
|
238
|
-
|
|
238
|
+
_util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.map(taxM, t => totaltax += t.taxprice);
|
|
239
239
|
let computed_discount = 0;
|
|
240
240
|
if (order.discount_type == 'percentage' && order.discount_percentage > 0) {
|
|
241
241
|
computed_discount = (subtotal + totaltax) * order.discount_percentage / 10000;
|
|
242
242
|
} else if (order.discount_type == 'amount') {
|
|
243
243
|
computed_discount = order.discount_amount || 0;
|
|
244
244
|
}
|
|
245
|
-
let shippingfee =
|
|
245
|
+
let shippingfee = _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.get(order, 'shipping.nominal_fee', 0);
|
|
246
246
|
if (shippingfee > 0) {
|
|
247
|
-
if (
|
|
247
|
+
if (_util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.get(order, 'shipping.tax.id')) {
|
|
248
248
|
let tax = order.shipping.tax;
|
|
249
249
|
let taxprice = shippingfee * (tax.percentage / 10000);
|
|
250
250
|
taxM['ship'] = {
|
|
@@ -255,7 +255,7 @@ function calcOrderTotal(order) {
|
|
|
255
255
|
}
|
|
256
256
|
}
|
|
257
257
|
totaltax = 0;
|
|
258
|
-
|
|
258
|
+
_util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.map(taxM, t => totaltax += t.taxprice);
|
|
259
259
|
let total = subtotal + totaltax - computed_discount + shippingfee;
|
|
260
260
|
total += order.adjustment || 0;
|
|
261
261
|
if (total < 0) total = 0;
|
package/dist/132.js
CHANGED
|
@@ -1675,7 +1675,7 @@ class Popup extends common/* Com */.Mw {
|
|
|
1675
1675
|
for (var i = 0; i < fonts.length; i++) {
|
|
1676
1676
|
try {
|
|
1677
1677
|
if (document.fonts.check('normal 16px ' + fonts[i])) ready[fonts[i]] = true;
|
|
1678
|
-
if (Object.keys(
|
|
1678
|
+
if (Object.keys(ready).length == fonts.length) return;
|
|
1679
1679
|
} catch (e) {}
|
|
1680
1680
|
}
|
|
1681
1681
|
await util/* default */.A.sleep(200);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(self.webpackChunk_subiz_widget_v4=self.webpackChunk_subiz_widget_v4||[]).push([[127],{6127(t,e,n){n.r(e),n.d(e,{default:()=>i});var a=n(5922),r=n(2840),s=n(172);class i extends r.Mw{render(){let t=a.A.get(this.props.ev,"by.type");if("user"===t)return null;this.props.store.matchAccount();var e=a.A.get(this.props.ev,"data.message.attachments",[]);let r=a.A.filter(e,t=>"order"===t.type&&t.order).map(t=>t.order);return 0===r.length?null:a.A.map(r,(e,r)=>{!function(t){let e=0,n=0,r=0;a.A.map(t.items,t=>{if(!t.product)return 0;let s=a.A.get(t,"product.price",0)*(t.quantity||0);r+=s,"percentage"==t.discount_type?t.discount_percentage>0&&(n+=s*t.discount_percentage/1e4,s*=1-(t.discount_percentage||0)/1e4):"amount"==t.discount_type&&t.discount_amount>0&&(n+=t.discount_amount,s-=t.discount_amount||0,s<=0&&(s=0)),t.total=s,e+=s});let s={};a.A.map(t.items,(t,e)=>{if(!t.product)return;let n=t.product.tax;if(!n)return;if(!n.id)return;let a=t.total*n.percentage/1e4;t.total_tax=a,s[e]={tax:n,taxprice:a}});let i=0;a.A.map(s,t=>i+=t.taxprice);let o=0;"percentage"==t.discount_type&&t.discount_percentage>0?o=(e+i)*t.discount_percentage/1e4:"amount"==t.discount_type&&(o=t.discount_amount||0);let l=a.A.get(t,"shipping.nominal_fee",0);if(l>0&&a.A.get(t,"shipping.tax.id")){let e=t.shipping.tax,n=l*(e.percentage/1e4);s.ship={tax:e,taxprice:n},t.shipping.total_tax=n}i=0,a.A.map(s,t=>i+=t.taxprice);let c=e+i-o+l;c+=t.adjustment||0,c<0&&(c=0),t.subtotal=e,t._computed_discount=o,t._taxM=s,t.total=c,t.total_tax=i,t._discount_before_tax=n,t._order_value=r}(e);let i=null;e.note&&(i=(0,s.h)("div",null,(0,s.h)("div",{class:"order_attachment__label"},this.props.t("note")),(0,s.h)("div",{class:"order_attachment__note",title:e.note},e.note)));let l=null;a.A.size(e.items)>0&&(l=(0,s.h)("div",null,(0,s.h)("div",{class:"order_attachment__label"},this.props.t("product")),a.A.map(e.items,t=>{let e=t.product||{};return(0,s.h)("div",{class:"order_attachment__product"},(0,s.h)("img",{class:"order_attachment__product_img",alt:""+a.A.get(e,"id"),src:a.A.get(e,"image",n(2876))}),(0,s.h)("div",{style:"overflow: hidden !important;"},(0,s.h)("div",{class:"order_attachment__product_name",title:this.props.t.i18n(e.i18n_name)||e.name},this.props.t.i18n(e.i18n_name)||e.name),(0,s.h)("div",{class:"order_attachment__product_desc"},function(t,e=" - "){let n=a.A.get(t,"options",[]),r=a.A.get(t,"props",[]),s=a.A.filter(n,t=>a.A.size(t.values)>1),i=[];return a.A.each(s,t=>{let e=a.A.find(r,e=>e.key===t.key)||{};e.value&&i.push(e.value)}),i.join(e)}(e," / ")),(0,s.h)("div",{class:"order_attachment__product_desc"},this.props.t("qty")," ",t.quantity," · ",a.A.formatCurrency(e.price))))})));let c=(0,s.h)("div",{class:"order_attachment__footer"},(0,s.h)("div",{class:"d-flex align-items-center justify-content-between"},(0,s.h)("div",null,this.props.t("total"))," ",(0,s.h)("div",null,(0,s.h)("b",{class:"order_attachment__total"},a.A.formatCurrency(e.total))))),d=a.A.find(a.A.get(e,"user.attributes",[]),t=>"phones"===t.key)||{key:"phones",text:""},_=a.A.get(e,"shipping.address.phone","").trim();_=_||a.A.trim(d.text),_&&(_=this.props.t("phn")+": "+_);let u=null;(o(e)||_)&&(u=(0,s.h)("div",null,(0,s.h)("div",{class:"order_attachment__label"},this.props.t("ship_to")),(0,s.h)("div",null,o(e)),(0,s.h)("div",{class:"order_attachment__text_truncate"},_)));let h=null;e._discount_before_tax&&(h=(0,s.h)("div",{class:"order_attachment__footer"},(0,s.h)("div",{class:"d-flex align-items-center justify-content-between"},(0,s.h)("div",{class:"order_attachment__label no_margin"},this.props.t("subtotal_before_tax"))," ",(0,s.h)("div",null,a.A.formatCurrency(e._order_value))),(0,s.h)("div",{class:"d-flex align-items-center justify-content-between"},(0,s.h)("div",{class:"order_attachment__label no_margin"},this.props.t("discount_before_tax"))," ",(0,s.h)("div",null,"-",a.A.formatCurrency(e._discount_before_tax)))));let p=(0,s.h)("div",{class:"d-flex align-items-center justify-content-between"},(0,s.h)("div",{class:"order_attachment__label no_margin"},this.props.t("subtotal"))," ",(0,s.h)("div",{style:""},a.A.formatCurrency(e.subtotal))),m=null;if(e.total_tax){let t="";if(1===a.A.size(e._taxM)){let n=a.A.get(e._taxM,"0.tax",{});n.name&&n.percentage&&(t=`(${n.name} ${Math.round(n.percentage||0)/100}%)`)}m=(0,s.h)("div",{class:"d-flex align-items-center justify-content-between"},(0,s.h)("div",{class:"order_attachment__label no_margin"},this.props.t("tax")," ",t),(0,s.h)("div",{style:""},a.A.formatCurrency(e.total_tax)))}let g=null;"percentage"===e.discount_type&&e.discount_percentage&&(g=(0,s.h)("div",{class:"d-flex align-items-center justify-content-between"},(0,s.h)("div",{class:"order_attachment__label no_margin"},this.props.t("discount_after_tax")," (",Math.round(e.discount_percentage/100),"%)")," ",(0,s.h)("div",{style:""},"-",a.A.formatCurrency(e._computed_discount)))),"amount"===e.discount_type&&e.discount_amount&&(g=(0,s.h)("div",{class:"d-flex align-items-center justify-content-between"},(0,s.h)("div",{class:"order_attachment__label no_margin"},this.props.t("discount_after_tax"))," ",(0,s.h)("div",{class:"no-shrink"},"-",a.A.formatCurrency(e._computed_discount))));let f=null;a.A.get(e,"shipping.nominal_fee")&&(f=(0,s.h)("div",{class:"d-flex align-items-center justify-content-between"},(0,s.h)("div",{class:"order_attachment__label no_margin"},this.props.t("shipping_fee"))," ",(0,s.h)("div",{style:""},a.A.formatCurrency(a.A.get(e,"shipping.nominal_fee",0)))));let v=null;return e.adjustment&&(v=(0,s.h)("div",{class:"d-flex align-items-center justify-content-between"},(0,s.h)("div",{class:"order_attachment__label no_margin"},e.adjustment_description)," ",(0,s.h)("div",{class:"no-shrink"},a.A.formatCurrency(e.adjustment)))),p=(0,s.h)("div",{class:"order_attachment__footer"},p,m,f,g,v),f||v||g||m||(p=null),(0,s.h)("div",{class:`order_attachment order_attachment__${t}`},(0,s.h)("div",{class:"order_attachment__header"},this.props.t("order"),(0,s.h)("span",{class:"order_attachment__text_muted order_attachment__text_sm"},function(t={}){return t.number||t.id||""}(e))),l,u,i,h,p,c)})}}function o(t,e){let n=a.A.get(t,"shipping.address",{}),r=[n.address,n.ward,n.district,n.province].filter(t=>t).join(", ").trim();return e&&(r=(r||"").replace(/Hà Nội/gi,"HN").replace(/Hồ Chí Minh/gi,"HCM").replace(/Thành Phố/gi,"TP")),r}}}]);
|