@subiz/widget-v4 4.1.146 → 4.1.147

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.
Files changed (114) hide show
  1. package/assets/less/form.less +13 -2
  2. package/assets/less/message_input.less +19 -10
  3. package/assets/less/widget.less +21 -17
  4. package/chat.html +10 -0
  5. package/chat.js +50 -0
  6. package/compiled_src/chatbox/FileAttachments.js +1 -0
  7. package/compiled_src/chatbox/Header.js +1 -0
  8. package/compiled_src/chatbox/ImageAttachments.js +2 -0
  9. package/compiled_src/chatbox/Widget.js +6 -2
  10. package/compiled_src/lib.js +6 -1
  11. package/compiled_src/store/store.js +10 -1
  12. package/package.json +5 -5
  13. package/src/chatbox/FileAttachments.js +7 -6
  14. package/src/chatbox/Header.js +1 -0
  15. package/src/chatbox/ImageAttachments.js +2 -0
  16. package/src/chatbox/Widget.js +6 -2
  17. package/src/lib.js +5 -1
  18. package/src/store/store.js +13 -2
  19. package/webpack.dev.js +2 -0
  20. package/webpack.prod.js +7 -0
  21. package/dist/.HASH +0 -1
  22. package/dist/127.js +0 -273
  23. package/dist/132.js +0 -2802
  24. package/dist/185.js +0 -1827
  25. package/dist/1970d063f3c.127.js +0 -1
  26. package/dist/1970d063f3c.132.js +0 -1
  27. package/dist/1970d063f3c.185.js +0 -1
  28. package/dist/1970d063f3c.27.js +0 -1
  29. package/dist/1970d063f3c.278.js +0 -1
  30. package/dist/1970d063f3c.339.js +0 -1
  31. package/dist/1970d063f3c.459.js +0 -1
  32. package/dist/1970d063f3c.490.js +0 -1
  33. package/dist/1970d063f3c.74.js +0 -1
  34. package/dist/1970d063f3c.997.js +0 -1
  35. package/dist/1970d063f3c.app.js +0 -1
  36. package/dist/1970d063f3c.form.html +0 -1
  37. package/dist/1970d063f3c.form.js +0 -1
  38. package/dist/1970d063f3c.index.html +0 -71
  39. package/dist/1970d063f3c.library.html +0 -71
  40. package/dist/1970d063f3c.library.js +0 -1
  41. package/dist/1970d063f3c.preview.html +0 -759
  42. package/dist/1970d063f3c.preview.js +0 -1
  43. package/dist/1970d063f3c.webview.js +0 -1
  44. package/dist/27.js +0 -107
  45. package/dist/278.js +0 -417
  46. package/dist/459.js +0 -107
  47. package/dist/490.js +0 -305
  48. package/dist/74.js +0 -372
  49. package/dist/997.js +0 -107
  50. package/dist/assets/img/Facebook.64607ec.png +0 -0
  51. package/dist/assets/img/Zalo.6845707.png +0 -0
  52. package/dist/assets/img/award1a.1a58e10.png +0 -0
  53. package/dist/assets/img/award3a.3b74423.png +0 -0
  54. package/dist/assets/img/award4a.ed6ccd4.png +0 -0
  55. package/dist/assets/img/award5.39eb7ae.png +0 -0
  56. package/dist/assets/img/bubble_default.7d5e4ab.svg +0 -20
  57. package/dist/assets/img/caret.998eb8f.svg +0 -1
  58. package/dist/assets/img/convos_empty.2353007.svg +0 -72
  59. package/dist/assets/img/default.06e6ee0.jpg +0 -0
  60. package/dist/assets/img/default_avatar.5b74dc1.png +0 -0
  61. package/dist/assets/img/done_gray.d7e8203.svg +0 -4
  62. package/dist/assets/img/done_green.b817fd4.svg +0 -4
  63. package/dist/assets/img/emoji/messenger/sub_23.529_58.824.d5faf14.png +0 -0
  64. package/dist/assets/img/emoji/messenger/sub_23.529_60.784.1420241.png +0 -0
  65. package/dist/assets/img/emoji/messenger/sub_25.490_0.000.1e6b2c0.png +0 -0
  66. package/dist/assets/img/emoji/messenger/sub_25.490_45.098.3dfbc08.png +0 -0
  67. package/dist/assets/img/emoji/messenger/sub_25.490_5.882.4b49e94.png +0 -0
  68. package/dist/assets/img/emoji/messenger/sub_27.451_72.549.7114f58.png +0 -0
  69. package/dist/assets/img/emoji/messenger/sub_27.451_84.314.231e2b7.png +0 -0
  70. package/dist/assets/img/emoji/messenger/sub_27.451_96.078.ddbb008.png +0 -0
  71. package/dist/assets/img/emoji/messenger/sub_29.412_5.882.61f3359.png +0 -0
  72. package/dist/assets/img/emoji/messenger/sub_58.824_100.000.6df72bc.png +0 -0
  73. package/dist/assets/img/emoji/messenger/sub_58.824_45.098.3d7a7ad.png +0 -0
  74. package/dist/assets/img/emoji/messenger/sub_58.824_47.059.0f4d6e2.png +0 -0
  75. package/dist/assets/img/emoji/messenger/sub_58.824_54.902.65724c1.png +0 -0
  76. package/dist/assets/img/emoji/messenger/sub_58.824_64.706.9da3cba.png +0 -0
  77. package/dist/assets/img/emoji/messenger/sub_58.824_72.549.edca5cf.png +0 -0
  78. package/dist/assets/img/emoji/messenger/sub_58.824_78.431.f910f2a.png +0 -0
  79. package/dist/assets/img/emoji/messenger/sub_58.824_88.235.def4e71.png +0 -0
  80. package/dist/assets/img/emoji/messenger/sub_60.784_11.765.49c03d0.png +0 -0
  81. package/dist/assets/img/emoji/messenger/sub_60.784_27.451.46b54e5.png +0 -0
  82. package/dist/assets/img/emoji/messenger/sub_60.784_29.412.e36d284.png +0 -0
  83. package/dist/assets/img/emoji/messenger/sub_60.784_3.922.bb191b0.png +0 -0
  84. package/dist/assets/img/emoji/messenger/sub_60.784_35.294.af7b927.png +0 -0
  85. package/dist/assets/img/emoji/messenger/sub_60.784_7.843.98f2a99.png +0 -0
  86. package/dist/assets/img/empty.29bed2d.svg +0 -23
  87. package/dist/assets/img/empty_1.0b98af0.svg +0 -11
  88. package/dist/assets/img/examplte_logo.f86535f.svg +0 -1
  89. package/dist/assets/img/external-link.90577cc.svg +0 -1
  90. package/dist/assets/img/fb_inverse_circle.36c2cfc.png +0 -0
  91. package/dist/assets/img/ghn.070f8e3.svg +0 -17
  92. package/dist/assets/img/ghtk.326eac1.svg +0 -18
  93. package/dist/assets/img/image_default.be0698b.png +0 -0
  94. package/dist/assets/img/info.ebce7ea.svg +0 -1
  95. package/dist/assets/img/loader.37000a7.svg +0 -1
  96. package/dist/assets/img/loading_static.a27f0ac.svg +0 -10
  97. package/dist/assets/img/main-service1.d536cc2.png +0 -0
  98. package/dist/assets/img/main-service2.9b99549.png +0 -0
  99. package/dist/assets/img/not_found_search.2ddb8d1.png +0 -0
  100. package/dist/assets/img/package.8d37d0f.svg +0 -5
  101. package/dist/assets/img/package_fade.763c001.svg +0 -1
  102. package/dist/assets/img/rating--average.1ea492c.svg +0 -12
  103. package/dist/assets/img/rating--great.e3d712e.svg +0 -16
  104. package/dist/assets/img/rating--poor.2938a25.svg +0 -12
  105. package/dist/assets/img/search.f9705ff.svg +0 -1
  106. package/dist/assets/img/send.6db52a9.svg +0 -3
  107. package/dist/assets/img/shop.f7dc7d8.svg +0 -1
  108. package/dist/assets/img/shop_faded.df7845a.svg +0 -1
  109. package/dist/assets/img/stars_v2.79cf728.png +0 -0
  110. package/dist/assets/img/subiz-mono.8fbc067.svg +0 -3
  111. package/dist/assets/img/x.26fdfa3.svg +0 -5
  112. package/dist/malicious-app.js +0 -15
  113. package/dist/screenshoot.html +0 -7
  114. package/dist/screenshoot.js +0 -11601
@@ -75,6 +75,17 @@ select.form-control {
75
75
  select.form-control {
76
76
  padding: 1px 8px;
77
77
  }
78
+ input[type='date'].form-control {
79
+ height: 40px;
80
+ width: 100%;
81
+ background-color: #fff;
82
+ }
83
+ .form-wrapper-attachment input[type='date'].form-control {
84
+ height: 32px;
85
+ padding-top: 6px;
86
+ padding-bottom: 6px;
87
+ }
88
+
78
89
  input[type='text'].form-control:focus,
79
90
  input[type='number'].form-control:focus,
80
91
  input[type='date'].form-control:focus,
@@ -548,11 +559,11 @@ select.form-control.form-control--empty {
548
559
  height: 30px;
549
560
  background-image: url('../img/stars_v2.png');
550
561
  background-position: 0px 0px;
551
- background-size: cover;
562
+ background-size: cover;
552
563
  }
553
564
 
554
565
  .form-wrapper-attachment .star-wrapper {
555
- padding-right: 12px;
566
+ padding-right: 12px;
556
567
  }
557
568
 
558
569
  .star-wrapper {
@@ -7,17 +7,19 @@
7
7
  }
8
8
 
9
9
  .message-input--disabled {
10
- background: #F0F0F0;
10
+ background: #f0f0f0;
11
11
  opacity: 0.6;
12
12
  filter: grayscale(1);
13
13
  }
14
14
 
15
- textarea[disabled=disabled] {
16
- &::-webkit-input-placeholder { // Edge
15
+ textarea[disabled='disabled'] {
16
+ &::-webkit-input-placeholder {
17
+ // Edge
17
18
  .color(#a4a4a4);
18
19
  }
19
20
 
20
- &:-ms-input-placeholder { // Internet Explorer 10-11
21
+ &:-ms-input-placeholder {
22
+ // Internet Explorer 10-11
21
23
  .color(#a4a4a4);
22
24
  }
23
25
 
@@ -36,15 +38,16 @@ textarea[disabled=disabled] {
36
38
  }
37
39
 
38
40
  .message-input--input::placeholder {
39
- opacity: 0.5; /* Firefox */
41
+ opacity: 0.5; /* Firefox */
40
42
  }
41
43
 
42
- .message-input--input::-ms-input-placeholder { /* Edge 12 -18 */
43
- opacity: 0.5; /* Firefox */
44
+ .message-input--input::-ms-input-placeholder {
45
+ /* Edge 12 -18 */
46
+ opacity: 0.5; /* Firefox */
44
47
  }
45
48
 
46
49
  .message-input--emoji-button {
47
- background-image: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9ImdyYXkiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIiBjbGFzcz0iZmVhdGhlciBmZWF0aGVyLXNtaWxlIj48Y2lyY2xlIGN4PSIxMiIgY3k9IjEyIiByPSIxMCI+PC9jaXJjbGU+PHBhdGggZD0iTTggMTRzMS41IDIgNCAyIDQtMiA0LTIiPjwvcGF0aD48bGluZSB4MT0iOSIgeTE9IjkiIHgyPSI5LjAxIiB5Mj0iOSI+PC9saW5lPjxsaW5lIHgxPSIxNSIgeTE9IjkiIHgyPSIxNS4wMSIgeTI9IjkiPjwvbGluZT48L3N2Zz4K");
50
+ background-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9ImdyYXkiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIiBjbGFzcz0iZmVhdGhlciBmZWF0aGVyLXNtaWxlIj48Y2lyY2xlIGN4PSIxMiIgY3k9IjEyIiByPSIxMCI+PC9jaXJjbGU+PHBhdGggZD0iTTggMTRzMS41IDIgNCAyIDQtMiA0LTIiPjwvcGF0aD48bGluZSB4MT0iOSIgeTE9IjkiIHgyPSI5LjAxIiB5Mj0iOSI+PC9saW5lPjxsaW5lIHgxPSIxNSIgeTE9IjkiIHgyPSIxNS4wMSIgeTI9IjkiPjwvbGluZT48L3N2Zz4K');
48
51
  }
49
52
 
50
53
  .message-input--button {
@@ -72,7 +75,7 @@ textarea[disabled=disabled] {
72
75
  }
73
76
 
74
77
  .message-input--attachment-button {
75
- background-image: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9ImdyYXkiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIiBjbGFzcz0iZmVhdGhlciBmZWF0aGVyLXBhcGVyY2xpcCI+PHBhdGggZD0iTTIxLjQ0IDExLjA1bC05LjE5IDkuMTlhNiA2IDAgMCAxLTguNDktOC40OWw5LjE5LTkuMTlhNCA0IDAgMCAxIDUuNjYgNS42NmwtOS4yIDkuMTlhMiAyIDAgMCAxLTIuODMtMi44M2w4LjQ5LTguNDgiPjwvcGF0aD48L3N2Zz4K");
78
+ background-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9ImdyYXkiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIiBjbGFzcz0iZmVhdGhlciBmZWF0aGVyLXBhcGVyY2xpcCI+PHBhdGggZD0iTTIxLjQ0IDExLjA1bC05LjE5IDkuMTlhNiA2IDAgMCAxLTguNDktOC40OWw5LjE5LTkuMTlhNCA0IDAgMCAxIDUuNjYgNS42NmwtOS4yIDkuMTlhMiAyIDAgMCAxLTIuODMtMi44M2w4LjQ5LTguNDgiPjwvcGF0aD48L3N2Zz4K');
76
79
  }
77
80
 
78
81
  .message-input--send-button {
@@ -94,7 +97,13 @@ textarea[disabled=disabled] {
94
97
  .color(@white);
95
98
  font-size: 14px;
96
99
  line-height: 20px;
97
- text-align: center;;
100
+ text-align: center;
98
101
  background: @primary-color;
99
102
  width: 60%;
100
103
  }
104
+
105
+ .widget-body.embed-chat .message-input {
106
+ border: 1px solid #e3e3e3;
107
+ border-radius: 8px;
108
+ margin-bottom: 20px;
109
+ }
@@ -291,6 +291,10 @@
291
291
  position: relative;
292
292
  }
293
293
 
294
+ .widget-body.embed-chat {
295
+ max-width: 600px;
296
+ }
297
+
294
298
  .widget-body--content {
295
299
  overflow-y: auto;
296
300
  overflow-x: hidden;
@@ -543,21 +547,21 @@
543
547
  }
544
548
 
545
549
  .widget-internet-status {
546
- position: absolute;
547
- bottom: 0;
548
- left: 0;
549
- width: 100%;
550
- font-size: 14px;
551
- z-index: 10;
552
- text-align: center;
553
- padding: 6px 5px;
554
-
555
- &.negative {
556
- background-color: #212325;
557
- color: #fff;
558
- }
559
- &.positive {
560
- background-color: #19b600;
561
- color: #fff;
562
- }
550
+ position: absolute;
551
+ bottom: 0;
552
+ left: 0;
553
+ width: 100%;
554
+ font-size: 14px;
555
+ z-index: 10;
556
+ text-align: center;
557
+ padding: 6px 5px;
558
+
559
+ &.negative {
560
+ background-color: #212325;
561
+ color: #fff;
562
+ }
563
+ &.positive {
564
+ background-color: #19b600;
565
+ color: #fff;
566
+ }
563
567
  }
package/chat.html ADDED
@@ -0,0 +1,10 @@
1
+ <html>
2
+ <head>
3
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
4
+ </head>
5
+ <body style="margin: 0">
6
+ <div style="overflow: hidden; width: 100%; height: 100%" class="container">
7
+ <div id="result_text" style="color: #f00; padding-top: 120px; text-align: center; font-size: 24px"></div>
8
+ </div>
9
+ </body>
10
+ </html>
package/chat.js ADDED
@@ -0,0 +1,50 @@
1
+ // TODO: lam bo test template
2
+ // chu ngan, chu dai, anh ngan, anh dai voi tung template
3
+ import ApiV4 from './src/lib.js'
4
+ const config = require('./config.js')
5
+
6
+ function getUrlParameter(name) {
7
+ name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]')
8
+ var regex = new RegExp('[\\?&]' + name + '=([^&#]*)')
9
+ var results = regex.exec(location.search)
10
+ return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '))
11
+ }
12
+
13
+ function runChatbox(subiz) {
14
+ let popup = {
15
+ type: 'chatbox',
16
+ enabled: true,
17
+ chatbox: {
18
+ window_mode: 'full',
19
+ },
20
+ }
21
+ subiz._overridePlugin([popup])
22
+
23
+ setTimeout(() => {
24
+ subiz.showWidget()
25
+ }, 1)
26
+ }
27
+
28
+ async function run() {
29
+ let accid = getUrlParameter('id') || getUrlParameter('acc_id') || getUrlParameter('account_id')
30
+
31
+ let subiz = new ApiV4(config.ApiURL, config.FileURL, config.RealtimeURL, true, false)
32
+ window.subiz = subiz
33
+ subiz._overrideDeviceType('mobile')
34
+ if (window.innerWidth > 760) {
35
+ // table or wider screen
36
+ subiz.setEmbebedChatMode()
37
+ }
38
+
39
+ //runChatbox(subiz)
40
+ let res = await subiz.setAccount(accid, document.querySelector('.container'))
41
+ if (res.error) {
42
+ document.querySelector('#result_text').textContent = `ERROR: ${res.error} with account id "${accid}"`
43
+ return
44
+ }
45
+ setTimeout(() => {
46
+ subiz.showWidget()
47
+ }, 1)
48
+ }
49
+
50
+ run()
@@ -11,6 +11,7 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
11
11
  class FileAttachments extends _common.Com {
12
12
  render() {
13
13
  var byType = _index.default.get(this.props.ev, 'by.type', 'agent');
14
+ if (byType !== 'user') byType = 'agent';
14
15
  var attachments = _index.default.get(this.props.ev, 'data.message.attachments', []);
15
16
  var files = [];
16
17
  _index.default.each(attachments, att => {
@@ -211,6 +211,7 @@ Vui lòng hỏi chúng tôi bất cứ điều gì hoặc chia sẻ phản hồi
211
211
  renderCloseButton() {
212
212
  let accSetting = this.props.plugin.chatbox || {};
213
213
  if (accSetting.hide_close_button) return null;
214
+ if (this.props.store.isEmbededChatMode()) return;
214
215
  return (0, _preact.h)("div", {
215
216
  class: "widget-header--button-close",
216
217
  "data-tooltip": this.props.t('close'),
@@ -70,6 +70,7 @@ class ImageAttachment extends _common.Com {
70
70
  return;
71
71
  }
72
72
  let byType = _index.default.get(this.props.ev, 'by.type');
73
+ if (byType !== 'user') byType = 'agent';
73
74
  if (!image.width || !image.height) {
74
75
  return (0, _preact.h)("div", {
75
76
  class: `image-attachment image-attachment--${byType}`
@@ -116,6 +117,7 @@ class ImageAttachment extends _common.Com {
116
117
  var attachments = _index.default.get(this.props.ev, 'data.message.attachments', []);
117
118
  var images = [];
118
119
  let byType = _index.default.get(this.props.ev, 'by.type');
120
+ if (byType !== 'user') byType = 'agent';
119
121
  _index.default.each(attachments, (att, i) => {
120
122
  if (!att) return;
121
123
  if (!_index.default.includes(att.mimetype, 'image')) return;
@@ -654,8 +654,10 @@ class Widget extends _common.Com {
654
654
  let hasError = _index.default.find(this.state.formData, field => !!field.error);
655
655
  let newData = this.validateForm(this.state.formData);
656
656
  let hasEmptyError = _index.default.find(newData, field => !!field.is_empty_error);
657
+ let bodycls = 'widget-body';
658
+ if (this.props.store.isEmbededChatMode()) bodycls += ' embed-chat';
657
659
  return (0, _preact.h)("div", {
658
- class: "widget-body"
660
+ class: bodycls
659
661
  }, (0, _preact.h)(FormMounter, {
660
662
  key: form._updated,
661
663
  form: form,
@@ -816,8 +818,10 @@ class Widget extends _common.Com {
816
818
  onClick: e => this.onStartConvoClick(e)
817
819
  }, this.props.t('offline_preform_btn')));
818
820
  }
821
+ let bodycls = 'widget-body';
822
+ if (this.props.store.isEmbededChatMode()) bodycls += ' embed-chat';
819
823
  return (0, _preact.h)("div", {
820
- class: "widget-body"
824
+ class: bodycls
821
825
  }, (0, _preact.h)("div", {
822
826
  class: "widget-body--content",
823
827
  onClick: e => this.onContainerClick(e)
@@ -44,6 +44,9 @@ class Widget {
44
44
  setAIDevMode(mode) {
45
45
  this.store.setAIDevMode(mode);
46
46
  }
47
+ setEmbebedChatMode() {
48
+ this.store.setEmbebedChatMode();
49
+ }
47
50
  setTrackPageView(val) {
48
51
  this.store.setTrackPageview(val);
49
52
  }
@@ -105,7 +108,9 @@ class Widget {
105
108
  return outmask;
106
109
  }
107
110
  async setAccount(id, $container, mask, cb) {
108
- if (!id) return;
111
+ if (!id) return {
112
+ error: 'empty_account_id'
113
+ };
109
114
  let outmask = await this.store.init(id, mask);
110
115
  _index.default.setTimeout(() => window.postMessage({
111
116
  type: 'widget_loaded',
@@ -362,9 +362,15 @@ class Store {
362
362
  setAIDevMode(mode) {
363
363
  this.ai_dev_mode = mode;
364
364
  }
365
+ setEmbebedChatMode() {
366
+ this.is_embed_chat_mode = true;
367
+ }
365
368
  isAIDevMode() {
366
369
  return this.ai_dev_mode;
367
370
  }
371
+ isEmbededChatMode() {
372
+ return this.is_embed_chat_mode;
373
+ }
368
374
  overrideDeviceType(type) {
369
375
  this.forceDevice = type;
370
376
  this.pubsub.publish('account');
@@ -449,7 +455,10 @@ class Store {
449
455
  mask: mask,
450
456
  ref: userRef
451
457
  });
452
- if (user.error) return console.error(user);
458
+ if (user.error) {
459
+ console.error(user);
460
+ return user;
461
+ }
453
462
  if (this.realtime) this.realtime.stop();
454
463
  if (this.fake) this.realtime = new _realtime_fake.default();else this.realtime = new Realtime(this.RealtimeURL, {
455
464
  account_id: accid,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@subiz/widget-v4",
3
- "version": "4.1.146",
3
+ "version": "4.1.147",
4
4
  "main": "./compiled_src/lib.js",
5
5
  "scripts": {
6
6
  "dev": "npx webpack serve --config webpack.dev.js",
@@ -13,7 +13,7 @@
13
13
  "@subiz/flow": "^1.1.0",
14
14
  "@subiz/wsclient": "^4.0.34",
15
15
  "cookie_js": "1.4.2",
16
- "core-js": "^3.42.0",
16
+ "core-js": "^3.43.0",
17
17
  "css-loader": "5.2.7",
18
18
  "file-loader": "^6.2.0",
19
19
  "less": "^4.3.0",
@@ -22,7 +22,7 @@
22
22
  },
23
23
  "devDependencies": {
24
24
  "@babel/cli": "^7.27.2",
25
- "@babel/core": "^7.27.1",
25
+ "@babel/core": "^7.27.4",
26
26
  "@babel/plugin-proposal-class-properties": "^7.18.6",
27
27
  "@babel/plugin-transform-react-jsx": "^7.27.1",
28
28
  "@babel/preset-env": "^7.27.2",
@@ -30,10 +30,10 @@
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.9.0",
33
+ "puppeteer": "^24.10.1",
34
34
  "webpack": "^5.99.9",
35
35
  "webpack-bundle-analyzer": "^4.10.2",
36
36
  "webpack-cli": "^6.0.1",
37
- "webpack-dev-server": "^5.2.1"
37
+ "webpack-dev-server": "^5.2.2"
38
38
  }
39
39
  }
@@ -1,10 +1,11 @@
1
1
  import sb from '../util/index.js'
2
- import { Com } from '../common.js'
3
- import { h } from 'preact'
2
+ import {Com} from '../common.js'
3
+ import {h} from 'preact'
4
4
 
5
5
  export default class FileAttachments extends Com {
6
- render () {
6
+ render() {
7
7
  var byType = sb.get(this.props.ev, 'by.type', 'agent')
8
+ if (byType !== 'user') byType = 'agent'
8
9
  var attachments = sb.get(this.props.ev, 'data.message.attachments', [])
9
10
  var files = []
10
11
  sb.each(attachments, (att) => {
@@ -28,9 +29,9 @@ export default class FileAttachments extends Com {
28
29
  var $files = sb.map(files, (file, index) => {
29
30
  return (
30
31
  <div key={index} class={`file-attachment file-attachment--${byType}`}>
31
- <a class="file-attachment--link" href={this.props.store.replaceFileUrl(file.url)} target="_blank">
32
- <span class="file-attachment--download mr-2"></span>
33
- <span class="file-attachment--filename">{file.name}</span>
32
+ <a class='file-attachment--link' href={this.props.store.replaceFileUrl(file.url)} target='_blank'>
33
+ <span class='file-attachment--download mr-2'></span>
34
+ <span class='file-attachment--filename'>{file.name}</span>
34
35
  </a>
35
36
  </div>
36
37
  )
@@ -233,6 +233,7 @@ Vui lòng hỏi chúng tôi bất cứ điều gì hoặc chia sẻ phản hồi
233
233
  renderCloseButton() {
234
234
  let accSetting = this.props.plugin.chatbox || {}
235
235
  if (accSetting.hide_close_button) return null
236
+ if (this.props.store.isEmbededChatMode()) return
236
237
  return (
237
238
  <div
238
239
  class='widget-header--button-close'
@@ -58,6 +58,7 @@ export default class ImageAttachment extends Com {
58
58
  return
59
59
  }
60
60
  let byType = sb.get(this.props.ev, 'by.type')
61
+ if (byType !== 'user') byType = 'agent'
61
62
 
62
63
  if (!image.width || !image.height) {
63
64
  return (
@@ -108,6 +109,7 @@ export default class ImageAttachment extends Com {
108
109
  var attachments = sb.get(this.props.ev, 'data.message.attachments', [])
109
110
  var images = []
110
111
  let byType = sb.get(this.props.ev, 'by.type')
112
+ if (byType !== 'user') byType = 'agent'
111
113
 
112
114
  sb.each(attachments, (att, i) => {
113
115
  if (!att) return
@@ -629,8 +629,10 @@ export default class Widget extends Com {
629
629
  let hasError = sb.find(this.state.formData, (field) => !!field.error)
630
630
  let newData = this.validateForm(this.state.formData)
631
631
  let hasEmptyError = sb.find(newData, (field) => !!field.is_empty_error)
632
+ let bodycls = 'widget-body'
633
+ if (this.props.store.isEmbededChatMode()) bodycls += ' embed-chat'
632
634
  return (
633
- <div class='widget-body'>
635
+ <div class={bodycls}>
634
636
  <FormMounter key={form._updated} form={form} onMount={this.formMounted} />
635
637
  <div class='widget-body--content flex-grow-1 pl-3 pr-3 pb-2 d-flex flex-column'>
636
638
  <div class='mt-2 d-flex flex-column'>
@@ -832,8 +834,10 @@ export default class Widget extends Com {
832
834
  </div>
833
835
  )
834
836
  }
837
+ let bodycls = 'widget-body'
838
+ if (this.props.store.isEmbededChatMode()) bodycls += ' embed-chat'
835
839
  return (
836
- <div class='widget-body'>
840
+ <div class={bodycls}>
837
841
  <div class='widget-body--content' onClick={(e) => this.onContainerClick(e)}>
838
842
  <Events
839
843
  isShow={this.props.isShow}
package/src/lib.js CHANGED
@@ -41,6 +41,10 @@ class Widget {
41
41
  this.store.setAIDevMode(mode)
42
42
  }
43
43
 
44
+ setEmbebedChatMode() {
45
+ this.store.setEmbebedChatMode()
46
+ }
47
+
44
48
  setTrackPageView(val) {
45
49
  this.store.setTrackPageview(val)
46
50
  }
@@ -114,7 +118,7 @@ class Widget {
114
118
  }
115
119
 
116
120
  async setAccount(id, $container, mask, cb) {
117
- if (!id) return // do nothing
121
+ if (!id) return {error: 'empty_account_id'} // do nothing
118
122
  let outmask = await this.store.init(id, mask)
119
123
  sb.setTimeout(() => window.postMessage({type: 'widget_loaded', account_id: id}, '*'), 0) // send to chrome extension
120
124
  // add container to client site
@@ -243,10 +243,18 @@ export default class Store {
243
243
  this.ai_dev_mode = mode
244
244
  }
245
245
 
246
+ setEmbebedChatMode() {
247
+ this.is_embed_chat_mode = true
248
+ }
249
+
246
250
  isAIDevMode() {
247
251
  return this.ai_dev_mode
248
252
  }
249
253
 
254
+ isEmbededChatMode() {
255
+ return this.is_embed_chat_mode
256
+ }
257
+
250
258
  overrideDeviceType(type) {
251
259
  this.forceDevice = type
252
260
  this.pubsub.publish('account')
@@ -435,7 +443,7 @@ export default class Store {
435
443
  matchClosePreviewAt = () => this.kv.match('close_preview_at') || 0
436
444
 
437
445
  checkFormToken = (accid, token) => this.api.checkFormToken(accid, token)
438
- submitForm2 = (accid, token, data) => this.api.submitForm2(accid, token, data)
446
+ submitForm2 = (accid, token, data) => this.api.submitForm2(accid, token, data)
439
447
  sendPresence = sb.throttle(
440
448
  async () => {
441
449
  if (this._die) return dieErr
@@ -511,7 +519,10 @@ export default class Store {
511
519
  // set cookie forever
512
520
  if (userRef) this.cookie.set('__sbref', userRef)
513
521
  let user = await this.api.setAuth({accid: accid, mask: mask, ref: userRef})
514
- if (user.error) return console.error(user)
522
+ if (user.error) {
523
+ console.error(user)
524
+ return user
525
+ }
515
526
 
516
527
  if (this.realtime) this.realtime.stop()
517
528
  if (this.fake) this.realtime = new RealtimeFake()
package/webpack.dev.js CHANGED
@@ -11,6 +11,7 @@ module.exports = {
11
11
  library: './library.js',
12
12
  order: './src/order/index.js',
13
13
  screenshoot: './screenshoot.js',
14
+ chat: './chat.js',
14
15
  },
15
16
  output: {publicPath: '/'},
16
17
  devServer: {port: 8082, host: '0.0.0.0', hot: false, liveReload: false},
@@ -22,6 +23,7 @@ module.exports = {
22
23
  new HtmlWebpackPlugin({filename: './inject.html', template: './inject.html', inject: 'body', chunks: ['inject']}),
23
24
  new HtmlWebpackPlugin({filename: './library.html', template: './index.html', inject: 'body', chunks: ['library']}),
24
25
  new HtmlWebpackPlugin({filename: './form.html', template: './form.html', inject: 'body', chunks: ['form']}),
26
+ new HtmlWebpackPlugin({filename: './chat.html', template: './chat.html', inject: 'body', chunks: ['chat']}),
25
27
  new HtmlWebpackPlugin({
26
28
  filename: './screenshoot.html',
27
29
  template: './screenshoot.html',
package/webpack.prod.js CHANGED
@@ -11,6 +11,7 @@ webpackconfig.entry = {
11
11
  preview: './preview.js',
12
12
  form: './src/form/index.js',
13
13
  library: './library.js',
14
+ chat: './chat.js',
14
15
  }
15
16
 
16
17
  const HASH = Date.now().toString(16)
@@ -46,6 +47,12 @@ webpackconfig.plugins = [
46
47
  inject: 'body',
47
48
  chunks: ['form'],
48
49
  }),
50
+ new HtmlWebpackPlugin({
51
+ filename: HASH + '.chat.html',
52
+ template: './chat.html',
53
+ inject: 'body',
54
+ chunks: ['chat'],
55
+ }),
49
56
  new HtmlWebpackPlugin({
50
57
  filename: HASH + '.library.html',
51
58
  template: './index.html',
package/dist/.HASH DELETED
@@ -1 +0,0 @@
1
- 1970d063f3c