@subiz/widget-v4 4.1.143 → 4.1.145
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 +5 -1
- package/compiled_src/bot.js +1 -2
- package/compiled_src/call/call.js +1 -2
- package/compiled_src/chatbox/Event.js +1 -2
- package/compiled_src/chatbox/Header.js +18 -1
- package/compiled_src/chatbox/Widget.js +1 -2
- package/compiled_src/chatbox/main.js +1 -2
- package/compiled_src/contact/contact.js +1 -2
- package/compiled_src/form/FormPage.js +1 -2
- package/compiled_src/form/index.js +1 -2
- package/compiled_src/form.js +1 -2
- package/compiled_src/notif/notif.js +1 -2
- package/compiled_src/order/icon.js +1 -2
- package/compiled_src/order/index.js +1 -2
- package/compiled_src/order/order.js +1 -2
- package/compiled_src/plugin.js +1 -2
- package/compiled_src/popup/popup.js +1 -2
- package/compiled_src/store/store.js +1 -3
- package/compiled_src/util/index.js +1 -2
- package/config.js +1 -1
- package/dist/196d399136f.278.js +1 -0
- package/dist/196d399136f.339.js +1 -0
- package/dist/196d399136f.app.js +1 -0
- package/dist/{19680dc0775.form.html → 196d399136f.form.html} +1 -1
- package/dist/196d399136f.form.js +1 -0
- package/dist/{19680dc0775.index.html → 196d399136f.index.html} +15 -1
- package/dist/{19680dc0775.library.html → 196d399136f.library.html} +15 -1
- package/dist/196d399136f.library.js +1 -0
- package/dist/{19680dc0775.preview.html → 196d399136f.preview.html} +1 -1
- package/dist/196d399136f.preview.js +1 -0
- package/dist/196d399136f.webview.js +1 -0
- package/dist/278.js +81 -70
- package/dist/HASH +1 -1
- package/dist/assets/img/stars_v2.79cf728.png +0 -0
- package/dist/screenshoot.js +244 -36
- package/index.html +14 -0
- package/package.json +10 -10
- package/src/chatbox/Header.js +20 -1
- package/src/store/store.js +1 -1
- package/dist/19680dc0775.278.js +0 -1
- package/dist/19680dc0775.app.js +0 -1
- package/dist/19680dc0775.form.js +0 -1
- package/dist/19680dc0775.library.js +0 -1
- package/dist/19680dc0775.preview.js +0 -1
- package/dist/19680dc0775.webview.js +0 -1
- /package/dist/{19680dc0775.127.js → 196d399136f.127.js} +0 -0
- /package/dist/{19680dc0775.132.js → 196d399136f.132.js} +0 -0
- /package/dist/{19680dc0775.185.js → 196d399136f.185.js} +0 -0
- /package/dist/{19680dc0775.27.js → 196d399136f.27.js} +0 -0
- /package/dist/{19680dc0775.459.js → 196d399136f.459.js} +0 -0
- /package/dist/{19680dc0775.490.js → 196d399136f.490.js} +0 -0
- /package/dist/{19680dc0775.74.js → 196d399136f.74.js} +0 -0
- /package/dist/{19680dc0775.997.js → 196d399136f.997.js} +0 -0
package/dist/HASH
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
196d399136f
|
|
Binary file
|
package/dist/screenshoot.js
CHANGED
|
@@ -691,13 +691,11 @@ var {xhrsend, parseJSON, Pubsub} = __webpack_require__(7695)
|
|
|
691
691
|
function Conn(apiUrl, credential, onDead, onEvents, callAPI, accid) {
|
|
692
692
|
callAPI = callAPI || xhrsend // allow hook
|
|
693
693
|
credential = credential || {}
|
|
694
|
-
|
|
695
694
|
var lastToken = ''
|
|
696
695
|
if (!accid) accid = ''
|
|
697
|
-
|
|
698
696
|
var is_dead = false // tell if the connection is dead
|
|
699
697
|
var is_polling_stuck = false // tell if we've having trouble doing /poll
|
|
700
|
-
var is_sub_stuck =
|
|
698
|
+
var is_sub_stuck = true // tell if we've having trouble doing /subscribe
|
|
701
699
|
|
|
702
700
|
// The long polling loop runs sequentially, with each poll starting immediately
|
|
703
701
|
// after the previous one completes. If an error occurs, the loop will pause
|
|
@@ -706,7 +704,7 @@ function Conn(apiUrl, credential, onDead, onEvents, callAPI, accid) {
|
|
|
706
704
|
// The first loop begins after the first subscription call completes successfully
|
|
707
705
|
var polling = function (backoff) {
|
|
708
706
|
if (is_dead) return
|
|
709
|
-
callAPI('get', apiUrl + 'poll?token=' + lastToken + '&account-id=' + accid, undefined, function (body, code) {
|
|
707
|
+
callAPI('get', apiUrl + 'poll?token=' + lastToken + '&v=5&account-id=' + accid, undefined, function (body, code) {
|
|
710
708
|
if (is_dead) return
|
|
711
709
|
if (retryable(code)) {
|
|
712
710
|
is_polling_stuck = true
|
|
@@ -751,6 +749,7 @@ function Conn(apiUrl, credential, onDead, onEvents, callAPI, accid) {
|
|
|
751
749
|
// too long, kill
|
|
752
750
|
if (done) return
|
|
753
751
|
done = true
|
|
752
|
+
is_sub_stuck = true
|
|
754
753
|
resolve(repeat('dead', topics.length))
|
|
755
754
|
if (is_dead) return
|
|
756
755
|
kill('subs')
|
|
@@ -774,7 +773,8 @@ function Conn(apiUrl, credential, onDead, onEvents, callAPI, accid) {
|
|
|
774
773
|
else if (credential.user_mask) query += '&user-mask=' + encodeURIComponent(credential.user_mask)
|
|
775
774
|
else if (access_token) query += '&access-token=' + access_token
|
|
776
775
|
|
|
777
|
-
var fullurl =
|
|
776
|
+
var fullurl =
|
|
777
|
+
apiUrl + 'subs' + query + '&v=5&account-id=' + encodeURIComponent(accid || credential.account_id)
|
|
778
778
|
callAPI('post', fullurl, JSON.stringify({events: topics}), function (body, code) {
|
|
779
779
|
if (done) return
|
|
780
780
|
if (is_dead) {
|
|
@@ -884,7 +884,7 @@ function Realtime(apiUrls, credential, callAPI, accid, skipautoreconnect) {
|
|
|
884
884
|
return conn.getStatus()
|
|
885
885
|
}
|
|
886
886
|
|
|
887
|
-
|
|
887
|
+
var subscribe = function (events) {
|
|
888
888
|
if (!conn) return Promise.resolve({error: 'dead'})
|
|
889
889
|
if (typeof events === 'string') events = [events]
|
|
890
890
|
if (!Array.isArray(events)) return Promise.resolve({error: 'param should be an array or string'})
|
|
@@ -904,20 +904,22 @@ function Realtime(apiUrls, credential, callAPI, accid, skipautoreconnect) {
|
|
|
904
904
|
return {}
|
|
905
905
|
})
|
|
906
906
|
}
|
|
907
|
+
this.subscribe = subscribe
|
|
907
908
|
|
|
908
909
|
// reconnect make sure there is alway a Conn running in the background
|
|
909
910
|
// if the Conn is dead, it recreate a new one
|
|
910
911
|
var conn
|
|
911
|
-
|
|
912
|
+
var reconnect = function () {
|
|
912
913
|
var randomUrl = apiUrls[Math.floor(Math.random() * apiUrls.length)]
|
|
913
914
|
if (conn) conn.kill() // kill old connection
|
|
914
|
-
|
|
915
|
+
var myconn = new Conn(
|
|
915
916
|
randomUrl,
|
|
916
917
|
credential,
|
|
917
918
|
function (code, body, status) {
|
|
918
|
-
if (myconn != conn) return // outdated
|
|
919
|
+
if (conn === undefined || myconn != conn) return // outdated
|
|
920
|
+
conn = undefined // prevent dupplicate dead fire
|
|
919
921
|
pubsub.emit('interrupted', code, body, status)
|
|
920
|
-
if (!skipautoreconnect) setTimeout(
|
|
922
|
+
if (!skipautoreconnect) setTimeout(reconnect, 2000) // reconnect and resubscribe after 2 sec
|
|
921
923
|
},
|
|
922
924
|
function (events) {
|
|
923
925
|
if (myconn != conn) return
|
|
@@ -927,13 +929,13 @@ function Realtime(apiUrls, credential, callAPI, accid, skipautoreconnect) {
|
|
|
927
929
|
accid,
|
|
928
930
|
)
|
|
929
931
|
conn = myconn
|
|
930
|
-
|
|
931
932
|
var copyTopics = Object.keys(topics)
|
|
932
933
|
topics = {}
|
|
933
934
|
// resubscribe all subscribed events
|
|
934
|
-
return
|
|
935
|
+
return subscribe(copyTopics)
|
|
935
936
|
}
|
|
936
|
-
this.reconnect
|
|
937
|
+
this.reconnect = reconnect
|
|
938
|
+
reconnect()
|
|
937
939
|
}
|
|
938
940
|
|
|
939
941
|
// calcNextBackoff returns number of seconds we must wait
|
|
@@ -2772,6 +2774,13 @@ function replaceCssVariable(css, setting) {
|
|
|
2772
2774
|
tokens = tokenize(tokens, "'@z_index_3'");
|
|
2773
2775
|
tokens = tokenize(tokens, "'@z_index_4'");
|
|
2774
2776
|
tokens = tokenize(tokens, "'@z_index_5'");
|
|
2777
|
+
tokens = tokenize(tokens, "'@form_background_color'");
|
|
2778
|
+
tokens = tokenize(tokens, "'@form_header_font_size'");
|
|
2779
|
+
tokens = tokenize(tokens, "'@form_header_font_family'");
|
|
2780
|
+
tokens = tokenize(tokens, "'@form_desc_font_size'");
|
|
2781
|
+
tokens = tokenize(tokens, "'@form_desc_font_family'");
|
|
2782
|
+
tokens = tokenize(tokens, "'@form_input_label_font_size'");
|
|
2783
|
+
tokens = tokenize(tokens, "'@form_input_label_font_family'");
|
|
2775
2784
|
var primary_color = op.get(setting, 'primary_color') || op.get(DEFVAL, 'primary_color');
|
|
2776
2785
|
let parseColor = parseCssColor(primary_color);
|
|
2777
2786
|
if (!parseColor) parseColor = {
|
|
@@ -2817,7 +2826,7 @@ function replaceCssVariable(css, setting) {
|
|
|
2817
2826
|
var path = item.type.substr(2, item.type.length - 3);
|
|
2818
2827
|
var val = op.get(setting, path) || op.get(DEFVAL, path) || '';
|
|
2819
2828
|
val = norm2(val);
|
|
2820
|
-
if (['mobile_button.width', 'mobile_button.height', 'mobile_button.margin_x', 'mobile_button.margin_y', 'desktop_button.width', 'desktop_button.height', 'desktop_button.margin_x', 'desktop_button.margin_y', 'width', 'height'].includes(path)) {
|
|
2829
|
+
if (['mobile_button.width', 'mobile_button.height', 'mobile_button.margin_x', 'mobile_button.margin_y', 'desktop_button.width', 'desktop_button.height', 'desktop_button.margin_x', 'desktop_button.margin_y', 'form_header_font_size', 'form_desc_font_size', 'form_input_label_font_size', 'width', 'height'].includes(path)) {
|
|
2821
2830
|
val += 'px';
|
|
2822
2831
|
}
|
|
2823
2832
|
if (path === 'height' && op.get(setting, 'window_mode') === 'full') {
|
|
@@ -4994,9 +5003,7 @@ class Store {
|
|
|
4994
5003
|
await util/* default */.A.sleep(this.CONNECTION_CHECK_INTERVAL);
|
|
4995
5004
|
if (!this.realtime) continue;
|
|
4996
5005
|
if (!this.realtime.getStatus || !this.realtime.reconnect) continue;
|
|
4997
|
-
if (this.connectionStatus === 'dead') {
|
|
4998
|
-
await this.realtime.reconnect();
|
|
4999
|
-
}
|
|
5006
|
+
if (this.connectionStatus === 'dead') {}
|
|
5000
5007
|
let currentStatus = this.connectionStatus;
|
|
5001
5008
|
this.connectionStatus = this.realtime.getStatus();
|
|
5002
5009
|
if (currentStatus !== this.connectionStatus) {
|
|
@@ -7395,6 +7402,128 @@ class QuickReplies extends common/* Com */.Mw {
|
|
|
7395
7402
|
}, $replies);
|
|
7396
7403
|
}
|
|
7397
7404
|
}
|
|
7405
|
+
;// ./src/form/rating-stars.js
|
|
7406
|
+
function rating_stars_defineProperty(e, r, t) { return (r = rating_stars_toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
7407
|
+
function rating_stars_toPropertyKey(t) { var i = rating_stars_toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
7408
|
+
function rating_stars_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); }
|
|
7409
|
+
|
|
7410
|
+
|
|
7411
|
+
|
|
7412
|
+
class rating_stars_Form2 extends common/* Com */.Mw {
|
|
7413
|
+
constructor(props) {
|
|
7414
|
+
super(props);
|
|
7415
|
+
rating_stars_defineProperty(this, "state", {
|
|
7416
|
+
hovering: 0,
|
|
7417
|
+
selected: 0
|
|
7418
|
+
});
|
|
7419
|
+
rating_stars_defineProperty(this, "onMouseEnter", v => {
|
|
7420
|
+
let {
|
|
7421
|
+
selected,
|
|
7422
|
+
hovering
|
|
7423
|
+
} = this.state;
|
|
7424
|
+
if (v <= selected) {
|
|
7425
|
+
this.setState({
|
|
7426
|
+
hovering: selected
|
|
7427
|
+
});
|
|
7428
|
+
return;
|
|
7429
|
+
}
|
|
7430
|
+
this.setState({
|
|
7431
|
+
hovering: v
|
|
7432
|
+
});
|
|
7433
|
+
});
|
|
7434
|
+
rating_stars_defineProperty(this, "onMouseLeave", () => {
|
|
7435
|
+
let {
|
|
7436
|
+
selected,
|
|
7437
|
+
hovering
|
|
7438
|
+
} = this.state;
|
|
7439
|
+
this.setState({
|
|
7440
|
+
hovering: 0
|
|
7441
|
+
});
|
|
7442
|
+
});
|
|
7443
|
+
}
|
|
7444
|
+
onToggleValue(v) {
|
|
7445
|
+
let {
|
|
7446
|
+
selected
|
|
7447
|
+
} = this.state;
|
|
7448
|
+
let newVal = v;
|
|
7449
|
+
if (v === selected) newVal = 0;
|
|
7450
|
+
this.setState({
|
|
7451
|
+
selected: newVal,
|
|
7452
|
+
hovering: newVal
|
|
7453
|
+
});
|
|
7454
|
+
this.props.onChange(newVal);
|
|
7455
|
+
}
|
|
7456
|
+
render() {
|
|
7457
|
+
let {
|
|
7458
|
+
selected,
|
|
7459
|
+
hovering
|
|
7460
|
+
} = this.state;
|
|
7461
|
+
let star1Cls = 'star-wrapper';
|
|
7462
|
+
if (selected >= 1) {
|
|
7463
|
+
star1Cls += ' selected';
|
|
7464
|
+
} else if (hovering >= 1) {
|
|
7465
|
+
star1Cls += ' hovering';
|
|
7466
|
+
}
|
|
7467
|
+
let star2Cls = 'star-wrapper';
|
|
7468
|
+
if (selected >= 2) {
|
|
7469
|
+
star2Cls += ' selected';
|
|
7470
|
+
} else if (hovering >= 2) {
|
|
7471
|
+
star2Cls += ' hovering';
|
|
7472
|
+
}
|
|
7473
|
+
let star3Cls = 'star-wrapper';
|
|
7474
|
+
if (selected >= 3) {
|
|
7475
|
+
star3Cls += ' selected';
|
|
7476
|
+
} else if (hovering >= 3) {
|
|
7477
|
+
star3Cls += ' hovering';
|
|
7478
|
+
}
|
|
7479
|
+
let star4Cls = 'star-wrapper';
|
|
7480
|
+
if (selected >= 4) {
|
|
7481
|
+
star4Cls += ' selected';
|
|
7482
|
+
} else if (hovering >= 4) {
|
|
7483
|
+
star4Cls += ' hovering';
|
|
7484
|
+
}
|
|
7485
|
+
let star5Cls = 'star-wrapper';
|
|
7486
|
+
if (selected >= 5) {
|
|
7487
|
+
star5Cls += ' selected';
|
|
7488
|
+
} else if (hovering >= 5) {
|
|
7489
|
+
star5Cls += ' hovering';
|
|
7490
|
+
}
|
|
7491
|
+
return (0,preact_module.h)("div", {
|
|
7492
|
+
class: "form-ratings-wrapper",
|
|
7493
|
+
onMouseLeave: () => this.onMouseLeave()
|
|
7494
|
+
}, (0,preact_module.h)("div", {
|
|
7495
|
+
class: star1Cls,
|
|
7496
|
+
onClick: () => this.onToggleValue(1),
|
|
7497
|
+
onMouseEnter: () => this.onMouseEnter(1)
|
|
7498
|
+
}, (0,preact_module.h)("div", {
|
|
7499
|
+
class: "star"
|
|
7500
|
+
})), (0,preact_module.h)("div", {
|
|
7501
|
+
class: star2Cls,
|
|
7502
|
+
onClick: () => this.onToggleValue(2),
|
|
7503
|
+
onMouseEnter: () => this.onMouseEnter(2)
|
|
7504
|
+
}, (0,preact_module.h)("div", {
|
|
7505
|
+
class: "star"
|
|
7506
|
+
})), (0,preact_module.h)("div", {
|
|
7507
|
+
class: star3Cls,
|
|
7508
|
+
onClick: () => this.onToggleValue(3),
|
|
7509
|
+
onMouseEnter: () => this.onMouseEnter(3)
|
|
7510
|
+
}, (0,preact_module.h)("div", {
|
|
7511
|
+
class: "star"
|
|
7512
|
+
})), (0,preact_module.h)("div", {
|
|
7513
|
+
class: star4Cls,
|
|
7514
|
+
onClick: () => this.onToggleValue(4),
|
|
7515
|
+
onMouseEnter: () => this.onMouseEnter(4)
|
|
7516
|
+
}, (0,preact_module.h)("div", {
|
|
7517
|
+
class: "star"
|
|
7518
|
+
})), (0,preact_module.h)("div", {
|
|
7519
|
+
class: star5Cls,
|
|
7520
|
+
onClick: () => this.onToggleValue(5),
|
|
7521
|
+
onMouseEnter: () => this.onMouseEnter(5)
|
|
7522
|
+
}, (0,preact_module.h)("div", {
|
|
7523
|
+
class: "star"
|
|
7524
|
+
})));
|
|
7525
|
+
}
|
|
7526
|
+
}
|
|
7398
7527
|
;// ./src/form/Form.js
|
|
7399
7528
|
function Form_defineProperty(e, r, t) { return (r = Form_toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
7400
7529
|
function Form_toPropertyKey(t) { var i = Form_toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
@@ -7403,6 +7532,7 @@ function Form_toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var
|
|
|
7403
7532
|
|
|
7404
7533
|
|
|
7405
7534
|
|
|
7535
|
+
|
|
7406
7536
|
class Form2 extends common/* Com */.Mw {
|
|
7407
7537
|
constructor(props) {
|
|
7408
7538
|
super(props);
|
|
@@ -7454,7 +7584,7 @@ class Form2 extends common/* Com */.Mw {
|
|
|
7454
7584
|
class: "label"
|
|
7455
7585
|
}, com.label, " ", com.is_required && (0,preact_module.h)("span", {
|
|
7456
7586
|
class: "red"
|
|
7457
|
-
}, "*")), com.input_type === 'text' && this.renderFieldTextInput(com, idx), com.input_type === '
|
|
7587
|
+
}, "*")), com.input_type === 'text' && this.renderFieldTextInput(com, idx), com.input_type === 'textarea' && this.renderFieldTextareaInput(com, idx), com.input_type === 'date' && this.renderFieldDateInput(com, idx), com.input_type === 'radio' && this.renderFieldRadioInput(com, idx), com.input_type === 'checkbox' && this.renderFieldCheckboxInput(com, idx), (com.input_type === 'dropdown' || com.input_type === 'select') && this.renderFieldDropdownInput(com, idx), com.input_type === 'rating' && this.renderFieldRatingInput(com, idx), errorMsg && (0,preact_module.h)("div", {
|
|
7458
7588
|
class: "form-control--valid-input--error"
|
|
7459
7589
|
}, errorMsg));
|
|
7460
7590
|
});
|
|
@@ -7497,7 +7627,11 @@ class Form2 extends common/* Com */.Mw {
|
|
|
7497
7627
|
let val = util/* default */.A.find(this.props.submission.values, f => f.key === com.key) || {};
|
|
7498
7628
|
val = val.value || '""';
|
|
7499
7629
|
val = util/* default */.A.parseJSON(val);
|
|
7500
|
-
|
|
7630
|
+
let wrappercls = 'form-radios-wrapper';
|
|
7631
|
+
if (util/* default */.A.size(com.input_options) >= 3 && this.props.mode !== 'attachment') wrappercls += ' horizontal';
|
|
7632
|
+
return (0,preact_module.h)("div", {
|
|
7633
|
+
class: wrappercls
|
|
7634
|
+
}, util/* default */.A.map(com.input_options, (option, oidx) => {
|
|
7501
7635
|
let id = com.key + '_' + oidx;
|
|
7502
7636
|
return (0,preact_module.h)("div", {
|
|
7503
7637
|
class: "radio"
|
|
@@ -7513,13 +7647,17 @@ class Form2 extends common/* Com */.Mw {
|
|
|
7513
7647
|
}, option.label), (0,preact_module.h)("div", {
|
|
7514
7648
|
class: "radio--check"
|
|
7515
7649
|
}));
|
|
7516
|
-
});
|
|
7650
|
+
}));
|
|
7517
7651
|
});
|
|
7518
7652
|
Form_defineProperty(this, "renderFieldCheckboxInput", (com, idx) => {
|
|
7519
7653
|
let val = util/* default */.A.find(this.props.submission.values, f => f.key === com.key) || {};
|
|
7520
7654
|
val = val.value || '[]';
|
|
7521
7655
|
val = util/* default */.A.parseJSON(val);
|
|
7522
|
-
|
|
7656
|
+
let wrappercls = 'form-checkboxes-wrapper';
|
|
7657
|
+
if (util/* default */.A.size(com.input_options) >= 3 && this.props.mode !== 'attachment') wrappercls += ' horizontal';
|
|
7658
|
+
return (0,preact_module.h)("div", {
|
|
7659
|
+
class: wrappercls
|
|
7660
|
+
}, util/* default */.A.map(com.input_options, (option, oidx) => {
|
|
7523
7661
|
let id = com.key + '_' + oidx;
|
|
7524
7662
|
return (0,preact_module.h)("div", {
|
|
7525
7663
|
class: "checkbox"
|
|
@@ -7535,20 +7673,25 @@ class Form2 extends common/* Com */.Mw {
|
|
|
7535
7673
|
}, option.label), (0,preact_module.h)("div", {
|
|
7536
7674
|
class: "checkbox--check"
|
|
7537
7675
|
}));
|
|
7538
|
-
});
|
|
7676
|
+
}));
|
|
7539
7677
|
});
|
|
7540
7678
|
Form_defineProperty(this, "renderFieldDropdownInput", (com, idx) => {
|
|
7541
7679
|
let val = util/* default */.A.find(this.props.submission.values, f => f.key === com.key) || {};
|
|
7542
7680
|
val = val.value || '""';
|
|
7543
7681
|
val = util/* default */.A.parseJSON(val);
|
|
7682
|
+
let cls = 'form-control';
|
|
7683
|
+
if (this.state.errorFields[com.key]) cls += ' input--error';
|
|
7684
|
+
if (!val) cls += ' form-control--empty';
|
|
7544
7685
|
return (0,preact_module.h)("select", {
|
|
7545
|
-
class:
|
|
7686
|
+
class: cls,
|
|
7546
7687
|
ref: this[`${com.key}_input`],
|
|
7547
7688
|
onChange: e => {
|
|
7548
7689
|
this.onChangeValue(com.key, e.target.value);
|
|
7549
7690
|
this.clearError(com.key);
|
|
7550
7691
|
}
|
|
7551
|
-
},
|
|
7692
|
+
}, (0,preact_module.h)("option", {
|
|
7693
|
+
value: ""
|
|
7694
|
+
}, "-- ", this.props.t('no_select'), " --"), util/* default */.A.map(com.input_options, option => {
|
|
7552
7695
|
return (0,preact_module.h)("option", {
|
|
7553
7696
|
value: option.value
|
|
7554
7697
|
}, option.label);
|
|
@@ -7569,6 +7712,11 @@ class Form2 extends common/* Com */.Mw {
|
|
|
7569
7712
|
placeholder: com.placeholder
|
|
7570
7713
|
});
|
|
7571
7714
|
});
|
|
7715
|
+
Form_defineProperty(this, "renderFieldRatingInput", (com, idx) => {
|
|
7716
|
+
return (0,preact_module.h)(rating_stars_Form2, {
|
|
7717
|
+
onChange: v => this.onChangeValue(com.key, v)
|
|
7718
|
+
});
|
|
7719
|
+
});
|
|
7572
7720
|
Form_defineProperty(this, "onSubmit", e => {
|
|
7573
7721
|
e.preventDefault();
|
|
7574
7722
|
if (!this.validateForm()) return;
|
|
@@ -7581,18 +7729,42 @@ class Form2 extends common/* Com */.Mw {
|
|
|
7581
7729
|
let components = util/* default */.A.get(this.props.formSetting, 'components') || [];
|
|
7582
7730
|
util/* default */.A.each(components, com => {
|
|
7583
7731
|
if (com.type === 'input') {
|
|
7732
|
+
let val = util/* default */.A.find(this.props.submission.values, f => f.key === com.key) || {};
|
|
7733
|
+
val = val.value || '""';
|
|
7734
|
+
val = util/* default */.A.parseJSON(val);
|
|
7584
7735
|
if (com.is_required) {
|
|
7585
|
-
let
|
|
7586
|
-
val
|
|
7587
|
-
val
|
|
7588
|
-
if (
|
|
7736
|
+
let isEmpty = false;
|
|
7737
|
+
if (typeof val === 'string' && !val.trim()) isEmpty = true;
|
|
7738
|
+
if (Array.isArray(val) && val.length === 0) isEmpty = true;
|
|
7739
|
+
if (isEmpty) {
|
|
7589
7740
|
result = false;
|
|
7590
7741
|
errors[com.key] = this.props.t('cannot_be_empty');
|
|
7591
|
-
|
|
7742
|
+
ref = `${com.key}_input`;
|
|
7743
|
+
}
|
|
7744
|
+
}
|
|
7745
|
+
if (com.validation && !Array.isArray(val)) {
|
|
7746
|
+
let isInvalid = false;
|
|
7747
|
+
let validationText = '';
|
|
7748
|
+
if (com.validation === 'email' && !util/* default */.A.isEmail(val)) {
|
|
7749
|
+
validationText = 'Email';
|
|
7750
|
+
isInvalid = true;
|
|
7751
|
+
}
|
|
7752
|
+
if (com.validation === 'phone' && !util/* default */.A.isPhone(val)) {
|
|
7753
|
+
validationText = this.props.t('phn');
|
|
7754
|
+
isInvalid = true;
|
|
7755
|
+
}
|
|
7756
|
+
if (com.validation === 'number' && !util/* default */.A.isNumber(val)) {
|
|
7757
|
+
validationText = this.props.t('number');
|
|
7758
|
+
isInvalid = true;
|
|
7759
|
+
}
|
|
7760
|
+
if (com.validation === 'url' && !util/* default */.A.isURL(val)) {
|
|
7761
|
+
isInvalid = true;
|
|
7762
|
+
validationText = 'URL';
|
|
7592
7763
|
}
|
|
7593
|
-
if (
|
|
7764
|
+
if (isInvalid) {
|
|
7594
7765
|
result = false;
|
|
7595
|
-
errors[com.key] = this.props.t('
|
|
7766
|
+
errors[com.key] = this.props.t('format_is_invalid') + ' ' + validationText;
|
|
7767
|
+
ref = `${com.key}_input`;
|
|
7596
7768
|
}
|
|
7597
7769
|
}
|
|
7598
7770
|
}
|
|
@@ -7625,6 +7797,43 @@ class Form2 extends common/* Com */.Mw {
|
|
|
7625
7797
|
errorFields: errors
|
|
7626
7798
|
});
|
|
7627
7799
|
});
|
|
7800
|
+
Form_defineProperty(this, "renderFormHeader", () => {
|
|
7801
|
+
let title = util/* default */.A.get(this.props.formSetting, 'title') || '';
|
|
7802
|
+
let desc = util/* default */.A.get(this.props.formSetting, 'description') || '';
|
|
7803
|
+
if (this.props.mode === 'attachment') {
|
|
7804
|
+
if (title.trim() || desc.trim()) {
|
|
7805
|
+
return (0,preact_module.h)("div", {
|
|
7806
|
+
class: "form-component form-component-block"
|
|
7807
|
+
}, title && (0,preact_module.h)("div", null, title), desc && (0,preact_module.h)("div", {
|
|
7808
|
+
class: "text-sm text-muted"
|
|
7809
|
+
}, desc));
|
|
7810
|
+
}
|
|
7811
|
+
}
|
|
7812
|
+
let brandLogo = util/* default */.A.get(this.props.formSetting, 'logo.url');
|
|
7813
|
+
let brandUrl = util/* default */.A.get(this.props.formSetting, 'brand_url');
|
|
7814
|
+
let $logo = null;
|
|
7815
|
+
if (brandLogo) {
|
|
7816
|
+
$logo = (0,preact_module.h)("div", {
|
|
7817
|
+
class: "form-page-logo-wrapper"
|
|
7818
|
+
}, (0,preact_module.h)("a", {
|
|
7819
|
+
href: brandUrl || 'javascript:;'
|
|
7820
|
+
}, (0,preact_module.h)("img", {
|
|
7821
|
+
src: brandLogo,
|
|
7822
|
+
class: "form-page-logo"
|
|
7823
|
+
})));
|
|
7824
|
+
}
|
|
7825
|
+
let $header = null;
|
|
7826
|
+
if (title.trim() || desc.trim()) {
|
|
7827
|
+
$header = (0,preact_module.h)("div", {
|
|
7828
|
+
class: "form-page-header"
|
|
7829
|
+
}, (0,preact_module.h)("div", {
|
|
7830
|
+
class: "form-page-title"
|
|
7831
|
+
}, title), desc && (0,preact_module.h)("div", {
|
|
7832
|
+
class: "form-page-desc"
|
|
7833
|
+
}, desc));
|
|
7834
|
+
}
|
|
7835
|
+
return (0,preact_module.h)(preact_module/* Fragment */.FK, null, $logo, $header);
|
|
7836
|
+
});
|
|
7628
7837
|
let _components = util/* default */.A.get(this.props.formSetting, 'components') || [];
|
|
7629
7838
|
util/* default */.A.each(_components, com => {
|
|
7630
7839
|
if (com.type === 'input' && com.input_type !== 'checkbox' && com.input_type !== 'radio') {
|
|
@@ -7651,6 +7860,7 @@ class Form2 extends common/* Com */.Mw {
|
|
|
7651
7860
|
render() {
|
|
7652
7861
|
let components = util/* default */.A.get(this.props.formSetting, 'components') || [];
|
|
7653
7862
|
let title = util/* default */.A.get(this.props.formSetting, 'title') || '';
|
|
7863
|
+
let desc = util/* default */.A.get(this.props.formSetting, 'description') || '';
|
|
7654
7864
|
let cls = 'form-wrapper form';
|
|
7655
7865
|
if (this.props.mode === 'attachment') cls += ' form-wrapper-attachment';
|
|
7656
7866
|
return (0,preact_module.h)("div", {
|
|
@@ -7659,9 +7869,7 @@ class Form2 extends common/* Com */.Mw {
|
|
|
7659
7869
|
class: "form-component"
|
|
7660
7870
|
}, this.props.t('you_have_submitted_info_successfully')), (0,preact_module.h)("form", {
|
|
7661
7871
|
onSubmit: this.onSubmit
|
|
7662
|
-
}, (
|
|
7663
|
-
class: "form-component form-component-block"
|
|
7664
|
-
}, title), util/* default */.A.map(components, this.renderFormComponent)));
|
|
7872
|
+
}, this.renderFormHeader(), util/* default */.A.map(components, this.renderFormComponent)));
|
|
7665
7873
|
}
|
|
7666
7874
|
}
|
|
7667
7875
|
;// ./src/chatbox/FormAttachment2.js
|
|
@@ -9974,9 +10182,9 @@ class Widget extends common/* Com */.Mw {
|
|
|
9974
10182
|
});
|
|
9975
10183
|
} else if (util/* default */.A.get(field, 'def.select') === 'checkbox') {
|
|
9976
10184
|
$field = this.renderCheckboxField(field);
|
|
9977
|
-
} else if (util/* default */.A.get(field, 'def.select') === 'radio') {
|
|
10185
|
+
} else if (util/* default */.A.get(field, 'def.select') === 'radio' && util/* default */.A.size(util/* default */.A.get(field, 'def.items', [])) < 5) {
|
|
9978
10186
|
$field = this.renderRadioField(field);
|
|
9979
|
-
} else if (util/* default */.A.get(field, 'def.select') === 'dropdown') {
|
|
10187
|
+
} else if (util/* default */.A.get(field, 'def.select') === 'dropdown' || util/* default */.A.size(util/* default */.A.get(field, 'def.items', [])) >= 5) {
|
|
9980
10188
|
$field = this.renderDropdownField(field);
|
|
9981
10189
|
} else {
|
|
9982
10190
|
$field = (0,preact_module.h)("input", {
|
package/index.html
CHANGED
|
@@ -70,6 +70,20 @@
|
|
|
70
70
|
})
|
|
71
71
|
})
|
|
72
72
|
})
|
|
73
|
+
setTimeout(function () {
|
|
74
|
+
if (accid === 'acshaomzfkhqtwlxmtfo' && getUrlParameter('chat-only')) {
|
|
75
|
+
subiz('overrideChatbox', {
|
|
76
|
+
chatbox: {
|
|
77
|
+
offline_form: {
|
|
78
|
+
enabled: false,
|
|
79
|
+
},
|
|
80
|
+
prechat_form: {
|
|
81
|
+
enabled: false,
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
})
|
|
85
|
+
}
|
|
86
|
+
})
|
|
73
87
|
</script>
|
|
74
88
|
</body>
|
|
75
89
|
</html>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@subiz/widget-v4",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.145",
|
|
4
4
|
"main": "./compiled_src/lib.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "npx webpack serve --config webpack.dev.js",
|
|
@@ -11,27 +11,27 @@
|
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@subiz/ajax": "^3.0.19",
|
|
13
13
|
"@subiz/flow": "^1.1.0",
|
|
14
|
-
"@subiz/wsclient": "^4.0.
|
|
14
|
+
"@subiz/wsclient": "^4.0.34",
|
|
15
15
|
"cookie_js": "1.4.2",
|
|
16
|
-
"core-js": "^3.
|
|
16
|
+
"core-js": "^3.42.0",
|
|
17
17
|
"css-loader": "5.2.7",
|
|
18
18
|
"file-loader": "^6.2.0",
|
|
19
19
|
"less": "^4.3.0",
|
|
20
|
-
"less-loader": "^12.
|
|
20
|
+
"less-loader": "^12.3.0",
|
|
21
21
|
"preact": "10.19.3"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@babel/cli": "^7.27.
|
|
25
|
-
"@babel/core": "^7.
|
|
24
|
+
"@babel/cli": "^7.27.2",
|
|
25
|
+
"@babel/core": "^7.27.1",
|
|
26
26
|
"@babel/plugin-proposal-class-properties": "^7.18.6",
|
|
27
|
-
"@babel/plugin-transform-react-jsx": "^7.
|
|
28
|
-
"@babel/preset-env": "^7.
|
|
27
|
+
"@babel/plugin-transform-react-jsx": "^7.27.1",
|
|
28
|
+
"@babel/preset-env": "^7.27.2",
|
|
29
29
|
"babel-loader": "^10.0.0",
|
|
30
30
|
"babel-plugin-syntax-jsx": "^6.18.0",
|
|
31
31
|
"html-webpack-plugin": "^5.6.3",
|
|
32
32
|
"prettier": "^3.5.3",
|
|
33
|
-
"puppeteer": "^24.
|
|
34
|
-
"webpack": "^5.99.
|
|
33
|
+
"puppeteer": "^24.9.0",
|
|
34
|
+
"webpack": "^5.99.9",
|
|
35
35
|
"webpack-bundle-analyzer": "^4.10.2",
|
|
36
36
|
"webpack-cli": "^6.0.1",
|
|
37
37
|
"webpack-dev-server": "^5.2.1"
|
package/src/chatbox/Header.js
CHANGED
|
@@ -23,6 +23,23 @@ export default class Header extends Com {
|
|
|
23
23
|
)
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
renderAgentAvatar = () => {
|
|
27
|
+
let accSetting = this.props.plugin.chatbox || {}
|
|
28
|
+
let agids = sb.get(accSetting, 'header.agent_ids') || []
|
|
29
|
+
let agent = sb.get(this.props.store.matchAgent(agids[0]))
|
|
30
|
+
let logoUrl = sb.get(agent, 'avatar_url_128') || sb.get(agent, 'avatar_url')
|
|
31
|
+
|
|
32
|
+
if (!logoUrl) return
|
|
33
|
+
return (
|
|
34
|
+
<img
|
|
35
|
+
width={38}
|
|
36
|
+
height={38}
|
|
37
|
+
class='avatar avatar__account'
|
|
38
|
+
src={this.props.store.replaceFileUrl(logoUrl) || require('../../assets/img/image_default.png')}
|
|
39
|
+
/>
|
|
40
|
+
)
|
|
41
|
+
}
|
|
42
|
+
|
|
26
43
|
render() {
|
|
27
44
|
let headerMode = 'collapsed'
|
|
28
45
|
|
|
@@ -66,10 +83,12 @@ export default class Header extends Com {
|
|
|
66
83
|
let style = ''
|
|
67
84
|
if (!classic) $back = this.renderBackButton()
|
|
68
85
|
else style = 'padding-bottom: 75px !important;'
|
|
86
|
+
|
|
87
|
+
let layout = sb.get(accSetting, 'header.layout')
|
|
69
88
|
return (
|
|
70
89
|
<div class={cls} style={style}>
|
|
71
90
|
{$back}
|
|
72
|
-
{this.renderAccountAvatar()}
|
|
91
|
+
{layout === 'agent' ? this.renderAgentAvatar() : this.renderAccountAvatar()}
|
|
73
92
|
<div class='widget-header--title-container'>
|
|
74
93
|
<div class='widget-header--title'>{this.getTitle()}</div>
|
|
75
94
|
<div class='widget-header--description' title={desc}>
|
package/src/store/store.js
CHANGED
|
@@ -134,7 +134,7 @@ export default class Store {
|
|
|
134
134
|
if (!this.realtime.getStatus || !this.realtime.reconnect) continue
|
|
135
135
|
|
|
136
136
|
if (this.connectionStatus === 'dead') {
|
|
137
|
-
await this.realtime.reconnect()
|
|
137
|
+
//await this.realtime.reconnect()
|
|
138
138
|
}
|
|
139
139
|
|
|
140
140
|
let currentStatus = this.connectionStatus
|