@subiz/widget-v4 4.1.126 → 4.1.129

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 (62) hide show
  1. package/assets/less/avatar.less +1 -1
  2. package/assets/less/chatbox.less +25 -2
  3. package/assets/less/form.less +77 -2
  4. package/assets/less/message.less +4 -0
  5. package/assets/less/widget.less +20 -0
  6. package/assets/less/widget_header.less +0 -2
  7. package/compiled_src/chatbox/ChatButton.js +10 -4
  8. package/compiled_src/chatbox/ConnectionStatus.js +58 -0
  9. package/compiled_src/chatbox/Event.js +10 -8
  10. package/compiled_src/chatbox/FormAttachment2.js +80 -0
  11. package/compiled_src/chatbox/Widget.js +5 -0
  12. package/compiled_src/form/Form.js +274 -0
  13. package/compiled_src/form/FormPage.js +131 -0
  14. package/compiled_src/form/index.js +72 -0
  15. package/compiled_src/store/api.js +3 -0
  16. package/compiled_src/store/realtime_fake.js +4 -0
  17. package/compiled_src/store/store.js +25 -0
  18. package/compiled_src/util/campaign.js +3 -5
  19. package/compiled_src/util/common.js +2 -2
  20. package/dist/{1964f21ffc8.127.js → 1967c022bc1.127.js} +1 -1
  21. package/dist/{1964f21ffc8.132.js → 1967c022bc1.132.js} +1 -1
  22. package/dist/{1964f21ffc8.185.js → 1967c022bc1.185.js} +1 -1
  23. package/dist/1967c022bc1.278.js +1 -0
  24. package/dist/{1964f21ffc8.490.js → 1967c022bc1.490.js} +1 -1
  25. package/dist/{1964f21ffc8.74.js → 1967c022bc1.74.js} +1 -1
  26. package/dist/1967c022bc1.app.js +1 -0
  27. package/dist/1967c022bc1.form.html +1 -0
  28. package/dist/1967c022bc1.form.js +1 -0
  29. package/dist/{1964f21ffc8.index.html → 1967c022bc1.index.html} +1 -1
  30. package/dist/{1964f21ffc8.library.html → 1967c022bc1.library.html} +1 -1
  31. package/dist/1967c022bc1.library.js +1 -0
  32. package/dist/{1964f21ffc8.preview.html → 1967c022bc1.preview.html} +1 -1
  33. package/dist/1967c022bc1.preview.js +1 -0
  34. package/dist/1967c022bc1.webview.js +1 -0
  35. package/dist/278.js +1 -1
  36. package/dist/HASH +1 -1
  37. package/dist/screenshoot.js +1198 -1001
  38. package/form.html +10 -0
  39. package/package.json +5 -4
  40. package/src/chatbox/ChatButton.js +10 -8
  41. package/src/chatbox/ConnectionStatus.js +42 -0
  42. package/src/chatbox/Event.js +10 -10
  43. package/src/chatbox/FormAttachment2.js +58 -0
  44. package/src/chatbox/Widget.js +2 -0
  45. package/src/form/Form.js +293 -0
  46. package/src/form/FormPage.js +95 -0
  47. package/src/form/index.js +79 -0
  48. package/src/store/api.js +8 -0
  49. package/src/store/realtime_fake.js +8 -4
  50. package/src/store/store.js +29 -0
  51. package/src/util/campaign.js +3 -5
  52. package/src/util/common.js +2 -2
  53. package/webpack.dev.js +2 -0
  54. package/webpack.prod.js +7 -0
  55. package/dist/1964f21ffc8.278.js +0 -1
  56. package/dist/1964f21ffc8.app.js +0 -1
  57. package/dist/1964f21ffc8.library.js +0 -1
  58. package/dist/1964f21ffc8.preview.js +0 -1
  59. package/dist/1964f21ffc8.webview.js +0 -1
  60. /package/dist/{1964f21ffc8.27.js → 1967c022bc1.27.js} +0 -0
  61. /package/dist/{1964f21ffc8.459.js → 1967c022bc1.459.js} +0 -0
  62. /package/dist/{1964f21ffc8.997.js → 1967c022bc1.997.js} +0 -0
@@ -25,7 +25,7 @@
25
25
  width: 38px;
26
26
  height: 38px;
27
27
  border-radius: 8px;
28
- margin-right: @spacer1;
28
+ margin-right: @spacer2;
29
29
  }
30
30
 
31
31
  .group-avatar--primary .group-avatar--agent-middle {
@@ -133,10 +133,34 @@ body div#sbz92 {
133
133
  .align-items-end {
134
134
  align-items: flex-end;
135
135
  }
136
-
136
+ .justify-content-center {
137
+ justify-content: center;
138
+ }
139
+ .h-full {
140
+ height: 100%;
141
+ }
142
+ .w-full {
143
+ width: 100%;
144
+ }
137
145
  .text-muted {
138
146
  .color(@text-muted);
139
147
  }
148
+ .text-lg {
149
+ font-size: 18px;
150
+ }
151
+ .text-xl {
152
+ font-size: 20px;
153
+ }
154
+ .text-center {
155
+ text-align: center;
156
+ }
157
+ .text-danger {
158
+ color: #ea3d2f;
159
+ }
160
+
161
+ .text-italic {
162
+ font-style: italic;
163
+ }
140
164
 
141
165
  // display utils
142
166
  .d-none {
@@ -200,7 +224,6 @@ body div#sbz92 {
200
224
  .mb-3 {
201
225
  margin-bottom: @spacer3;
202
226
  }
203
-
204
227
  .mb-2 {
205
228
  margin-bottom: @spacer2;
206
229
  }
@@ -116,7 +116,10 @@ select.form-control.input--error:focus {
116
116
  display: block;
117
117
  position: relative;
118
118
  width: 100%;
119
- height: 25px;
119
+ margin-top: 5px;
120
+ }
121
+ .radio:first-of-type {
122
+ margin-top: 0;
120
123
  }
121
124
 
122
125
  input[type='radio'] {
@@ -180,7 +183,10 @@ select.form-control.input--error:focus {
180
183
  display: block;
181
184
  position: relative;
182
185
  width: 100%;
183
- height: 25px;
186
+ margin-top: 5px;
187
+ }
188
+ .checkbox:first-of-type {
189
+ margin-top: 0;
184
190
  }
185
191
 
186
192
  input[type='checkbox'] {
@@ -417,3 +423,72 @@ select {
417
423
  d: path('M 7 9.5 L 12 14.5 L 17 9.5 H 7 Z');
418
424
  fill: black;
419
425
  }
426
+
427
+ // css for form page
428
+ .form-component {
429
+ margin-bottom: 15px;
430
+ &:last-child {
431
+ margin-bottom: 0;
432
+ }
433
+
434
+ &.submitted {
435
+ margin-bottom: 8px;
436
+ }
437
+ }
438
+
439
+ .form-wrapper.form {
440
+ padding: 20px;
441
+ }
442
+
443
+ .form-page {
444
+ max-width: 700px;
445
+ width: 100%;
446
+ margin: 0 auto;
447
+ padding: 40px 20px;
448
+ }
449
+
450
+ .form-page-header {
451
+ margin-bottom: 30px;
452
+ font-size: 18px;
453
+ font-weight: 500;
454
+ color: #ccc;
455
+ }
456
+
457
+ .form-wrapper.form-wrapper-attachment.form {
458
+ padding: 12px 15px;
459
+ margin-top: 5px;
460
+
461
+ input[type='text'].form-control,
462
+ input[type='number'].form-control,
463
+ input[type='date'].form-control,
464
+ select.form-control,
465
+ textarea.form-control {
466
+ padding: 6px 15px;
467
+ }
468
+
469
+ .form-component {
470
+ margin-bottom: 12px;
471
+ &:last-child {
472
+ margin-bottom: 0;
473
+ }
474
+
475
+ &.submitted {
476
+ margin-bottom: 5px;
477
+ &:last-child {
478
+ margin-bottom: 0;
479
+ }
480
+ }
481
+ }
482
+
483
+ .label {
484
+ padding-bottom: 4px;
485
+ }
486
+
487
+ .form-control--valid-input--error {
488
+ padding-top: 3px;
489
+ }
490
+
491
+ .btn--start-convo {
492
+ height: 36px;
493
+ }
494
+ }
@@ -768,6 +768,10 @@ a.product_attachment__title {
768
768
  .agent-convo-event-wrapper {
769
769
  max-width: 85%;
770
770
  margin-top: 5px;
771
+
772
+ &.full {
773
+ max-width: 100%;
774
+ }
771
775
  }
772
776
 
773
777
  .agent-convo-event-inner {
@@ -541,3 +541,23 @@
541
541
  .color(@primary-color);
542
542
  margin: 0;
543
543
  }
544
+
545
+ .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
+ }
563
+ }
@@ -44,9 +44,7 @@
44
44
 
45
45
  .widget-header--description {
46
46
  font-size: 14px;
47
- white-space: nowrap;
48
47
  overflow: hidden;
49
- text-overflow: ellipsis;
50
48
  opacity: 0.7;
51
49
  flex: 1;
52
50
  .color(@text-color);
@@ -33,9 +33,15 @@ class ChatButton extends _common.Com {
33
33
  isquickreplies = true;
34
34
  }
35
35
  });
36
- if (isquickreplies) return;
37
- var tags = _index.default.filter(_index.default.map(this.renderMessagePreview(ev), tag => _index.default.trim(tag)), a => a);
38
- if (_index.default.size(tags) > 0) this.setState({
36
+ let format = _index.default.get(ev, 'data.message.format');
37
+ let block = _index.default.get(ev, 'data.message.block');
38
+ if (block || format == 'block') {
39
+ if (_index.default.isBlockEmpty(block) && isquickreplies) return;
40
+ } else {
41
+ let message = _index.default.get(ev, 'data.message.text') || '';
42
+ if (!message && isquickreplies) return;
43
+ }
44
+ this.setState({
39
45
  displayPreview: true,
40
46
  previewEvent: ev
41
47
  });
@@ -349,7 +355,7 @@ class ChatButton extends _common.Com {
349
355
  }
350
356
  renderMessagePreview(ev, defmsg) {
351
357
  defmsg = defmsg || this.props.t('sent_you_a_message');
352
- var format = _index.default.get(ev, 'data.message.format');
358
+ let format = _index.default.get(ev, 'data.message.format');
353
359
  let block = _index.default.get(ev, 'data.message.block');
354
360
  if (block || format == 'block') {
355
361
  if (_index.default.isBlockEmpty(block)) {
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _index = _interopRequireDefault(require("../util/index.js"));
8
+ var _common = require("../common.js");
9
+ var _preact = require("preact");
10
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
12
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
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
+ class ConnectionStatus extends _common.Com {
15
+ constructor(props) {
16
+ super(props);
17
+ _defineProperty(this, "onChangeConnectionStatus", () => {
18
+ let newstatus = this.props.store.getConnectionStatus();
19
+ let currentstatus = this.state.status;
20
+ this.setState({
21
+ status: newstatus
22
+ });
23
+ if (currentstatus !== 'active' && newstatus === 'active') this.changeStatusFailedToSuccess();
24
+ });
25
+ _defineProperty(this, "changeStatusFailedToSuccess", () => {
26
+ this.setState({
27
+ status: 'just_active'
28
+ });
29
+ if (this.props.cid) this.props.store.fetchMoreEvents(this.props.cid);
30
+ if (this._timeout) clearTimeout(this._timeout);
31
+ this._timeout = setTimeout(() => {
32
+ this.setState({
33
+ status: 'active'
34
+ });
35
+ }, 2000);
36
+ });
37
+ this.props.store.onConnection(this, this.onChangeConnectionStatus);
38
+ this.state = {
39
+ status: this.props.store.getConnectionStatus()
40
+ };
41
+ }
42
+ render() {
43
+ if (this.state.status === 'active') return;
44
+ let cls = 'widget-internet-status';
45
+ let text = '';
46
+ if (this.state.status !== 'just_active') {
47
+ cls += ' negative';
48
+ text = `${this.props.t('network_error')}. ${this.props.t('try_reconnecting')}...`;
49
+ } else {
50
+ cls += ' positive';
51
+ text = this.props.t('reconnect_successfully');
52
+ }
53
+ return (0, _preact.h)("div", {
54
+ class: cls
55
+ }, text);
56
+ }
57
+ }
58
+ exports.default = ConnectionStatus;
@@ -9,7 +9,7 @@ var _AudioAttachments = _interopRequireDefault(require("./AudioAttachments.js"))
9
9
  var _FileAttachments = _interopRequireDefault(require("./FileAttachments.js"));
10
10
  var _ButtonAttachments = _interopRequireDefault(require("./ButtonAttachments.js"));
11
11
  var _QuickReplies = _interopRequireDefault(require("./QuickReplies.js"));
12
- var _FormAttachments = _interopRequireDefault(require("./FormAttachments.js"));
12
+ var _FormAttachment = _interopRequireDefault(require("./FormAttachment2.js"));
13
13
  var _FormSubmitAttachments = _interopRequireDefault(require("./FormSubmitAttachments.js"));
14
14
  var _GenericTemplateAttachments = _interopRequireDefault(require("./GenericTemplateAttachments.js"));
15
15
  var _ProductAttachments = _interopRequireDefault(require("./ProductAttachments.js"));
@@ -245,6 +245,9 @@ class Event extends _common.Com {
245
245
  }
246
246
  renderMessageSent() {
247
247
  let ev = this.props.event.ev;
248
+ let attachments = _index.default.get(ev, 'data.message.attachments');
249
+ let hasForm = _index.default.find(attachments, att => att.type === 'form');
250
+ if (ev.id === 'evshpgaeetsplfqprzmynrvrl') hasForm = true;
248
251
  this.tryLoadOrder(ev);
249
252
  let t = new _index.default.Date(ev.created).toLocaleString();
250
253
  if (_index.default.get(ev, 'by.type') !== 'user') {
@@ -252,10 +255,12 @@ class Event extends _common.Com {
252
255
  if (this.props.event.mode === 'lead') $sender = this.renderAgentAvatar(ev);
253
256
  let innercls = 'agent-convo-event-inner';
254
257
  if (this.props.isLast) innercls += ' last';
258
+ let wrappercls = 'agent-convo-event-wrapper';
259
+ if (hasForm) wrappercls += ' full';
255
260
  return (0, _preact.h)("div", {
256
261
  class: "convo-event agent-message"
257
262
  }, $sender, (0, _preact.h)("div", {
258
- class: "agent-convo-event-wrapper"
263
+ class: wrappercls
259
264
  }, (0, _preact.h)("div", {
260
265
  class: innercls
261
266
  }, (0, _preact.h)(_TextMessage.default, {
@@ -280,10 +285,8 @@ class Event extends _common.Com {
280
285
  store: this.props.store,
281
286
  ev: ev,
282
287
  t: this.props.t
283
- }), (0, _preact.h)(_FormAttachments.default, {
288
+ }), (0, _preact.h)(_FormAttachment.default, {
284
289
  store: this.props.store,
285
- onSubmit: this.props.onFormSubmit,
286
- ref: this.refForm,
287
290
  ev: ev,
288
291
  t: this.props.t
289
292
  }), (0, _preact.h)(_FormSubmitAttachments.default, {
@@ -367,10 +370,9 @@ class Event extends _common.Com {
367
370
  store: this.props.store,
368
371
  ev: ev,
369
372
  t: this.props.t
370
- }), (0, _preact.h)(_FormAttachments.default, {
373
+ }), (0, _preact.h)(_FormAttachment.default, {
371
374
  store: this.props.store,
372
- onSubmit: this.props.onFormSubmit,
373
- ref: this.refForm,
375
+ t: this.props.t,
374
376
  ev: ev
375
377
  }), (0, _preact.h)(_ProductAttachments.default, {
376
378
  t: this.props.t,
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _index = _interopRequireDefault(require("../util/index.js"));
8
+ var _common = require("../common.js");
9
+ var _preact = require("preact");
10
+ var _Form = _interopRequireDefault(require("../form/Form.js"));
11
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
13
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
14
+ 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); }
15
+ class FormAttachment extends _common.Com {
16
+ constructor(props) {
17
+ super(props);
18
+ _defineProperty(this, "onChangeFormValues", values => {
19
+ this.setState({
20
+ submission: {
21
+ values
22
+ }
23
+ });
24
+ });
25
+ _defineProperty(this, "onSubmit", async () => {
26
+ this.setState({
27
+ errorMessage: ''
28
+ });
29
+ if (this.state.submiting) return;
30
+ this.setState({
31
+ submiting: true
32
+ });
33
+ let res = await this.props.store.submitForm2(this.props.token, this.state.submission);
34
+ if (res.error) {
35
+ this.setState({
36
+ submiting: false,
37
+ errorMessage: _index.default.get(res, 'error.code')
38
+ });
39
+ return;
40
+ }
41
+ this.setState({
42
+ submiting: false,
43
+ isSubmited: true
44
+ });
45
+ });
46
+ this.state = {
47
+ submission: {},
48
+ submiting: false,
49
+ errorMessage: '',
50
+ isSubmited: false
51
+ };
52
+ }
53
+ render() {
54
+ let attachments = _index.default.get(this.props.ev, 'data.message.attachments') || [];
55
+ let formAttachment = _index.default.find(attachments, att => att.type === 'form');
56
+ if (!formAttachment) return;
57
+ const {
58
+ submission,
59
+ errorMessage,
60
+ isSubmited,
61
+ submiting
62
+ } = this.state;
63
+ let formSetting = formAttachment.form || {};
64
+ return (0, _preact.h)("div", {
65
+ onClick: e => e.stopPropagation()
66
+ }, (0, _preact.h)(_Form.default, {
67
+ store: this.props.store,
68
+ formSetting: formSetting,
69
+ mode: "attachment",
70
+ t: this.props.t,
71
+ submission: submission,
72
+ errorMessage: errorMessage,
73
+ isSubmited: isSubmited,
74
+ submiting: submiting,
75
+ onChangeFormValues: this.onChangeFormValues,
76
+ onSubmit: this.onSubmit
77
+ }));
78
+ }
79
+ }
80
+ exports.default = FormAttachment;
@@ -12,6 +12,7 @@ var _Header = _interopRequireDefault(require("./Header.js"));
12
12
  var _MessageInput = _interopRequireDefault(require("./MessageInput.js"));
13
13
  var _Events = _interopRequireDefault(require("./Events.js"));
14
14
  var _Rating = _interopRequireDefault(require("./Rating.js"));
15
+ var _ConnectionStatus = _interopRequireDefault(require("./ConnectionStatus.js"));
15
16
  var _ListField = _interopRequireDefault(require("./ListField.js"));
16
17
  var _time = _interopRequireDefault(require("./time.js"));
17
18
  var _common = require("../common.js");
@@ -834,6 +835,10 @@ class Widget extends _common.Com {
834
835
  onPostback: e => this.createPostback(e),
835
836
  t: this.props.t,
836
837
  plugin: this.props.plugin
838
+ }), (0, _preact.h)(_ConnectionStatus.default, {
839
+ cid: this.props.cid,
840
+ store: this.props.store,
841
+ t: this.props.t
837
842
  })), (0, _preact.h)(_Rating.default, {
838
843
  forceView: this.props.view,
839
844
  plugin: this.props.plugin,