@subiz/widget-v4 4.0.63 → 4.0.67

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 (100) hide show
  1. package/assets/less/chatbox.less +6 -1
  2. package/babel.config.js +2 -4
  3. package/compiled_src/bot.js +7 -1
  4. package/compiled_src/call/call.js +15 -12
  5. package/compiled_src/chatbox/ChatButton.js +3 -1
  6. package/compiled_src/chatbox/DropdownSelect.js +75 -66
  7. package/compiled_src/chatbox/Event.js +1 -0
  8. package/compiled_src/chatbox/MessageInput.js +7 -4
  9. package/compiled_src/chatbox/Order.js +94 -90
  10. package/compiled_src/chatbox/ProductAttachments.js +40 -4
  11. package/compiled_src/chatbox/Rating.js +10 -7
  12. package/compiled_src/chatbox/Typing.js +3 -1
  13. package/compiled_src/chatbox/Widget.js +27 -23
  14. package/compiled_src/chatbox/main.js +2 -0
  15. package/compiled_src/contact/contact.js +9 -6
  16. package/compiled_src/lib.js +14 -9
  17. package/compiled_src/notif/notif.js +15 -12
  18. package/compiled_src/order/address_picker.js +71 -63
  19. package/compiled_src/order/order.js +330 -316
  20. package/compiled_src/popup/countdown.js +7 -4
  21. package/compiled_src/popup/popup.js +12 -9
  22. package/compiled_src/store/api.js +110 -80
  23. package/compiled_src/store/api_fake.js +82 -55
  24. package/compiled_src/store/store.js +194 -135
  25. package/compiled_src/util/common.js +1 -1
  26. package/dist/132.js +678 -591
  27. package/dist/178.js +174 -341
  28. package/dist/17ff367201e.132.js +1 -0
  29. package/dist/17ff367201e.178.js +1 -0
  30. package/dist/17ff367201e.213.js +1 -0
  31. package/dist/17ff367201e.335.js +1 -0
  32. package/dist/17ff367201e.362.js +1 -0
  33. package/dist/17ff367201e.441.js +1 -0
  34. package/dist/17ff367201e.605.js +1 -0
  35. package/dist/17ff367201e.678.js +1 -0
  36. package/dist/17ff367201e.782.js +1 -0
  37. package/dist/17ff367201e.app.js +1 -0
  38. package/dist/{17e757ccadd.index.html → 17ff367201e.index.html} +1 -1
  39. package/dist/{17e757ccadd.library.html → 17ff367201e.library.html} +1 -1
  40. package/dist/17ff367201e.library.js +1 -0
  41. package/dist/{17e757ccadd.preview.html → 17ff367201e.preview.html} +1 -1
  42. package/dist/17ff367201e.preview.js +1 -0
  43. package/dist/17ff367201e.screenshoot.js +1 -0
  44. package/dist/213.js +19 -13
  45. package/dist/335.js +11 -8
  46. package/dist/362.js +21 -71
  47. package/dist/441.js +2 -2
  48. package/dist/605.js +15 -12
  49. package/dist/678.js +20 -70
  50. package/dist/782.js +21 -118
  51. package/dist/HASH +1 -1
  52. package/dist/screenshoot.html +1 -1
  53. package/dist/screenshoot.js +453 -332
  54. package/package.json +14 -14
  55. package/src/bot.js +2 -1
  56. package/src/chatbox/Buttons.js +8 -8
  57. package/src/chatbox/ChatButton.js +2 -2
  58. package/src/chatbox/Event.js +1 -1
  59. package/src/chatbox/ProductAttachments.js +41 -5
  60. package/src/chatbox/Typing.js +5 -1
  61. package/src/chatbox/main.js +4 -1
  62. package/src/store/store.js +24 -11
  63. package/src/util/common.js +1 -1
  64. package/up +1 -1
  65. package/dist/0b82fa7e5c3b07b40a44.png +0 -1
  66. package/dist/0f4af006e38ee8b93633.png +0 -1
  67. package/dist/17e757ccadd.132.js +0 -1
  68. package/dist/17e757ccadd.178.js +0 -1
  69. package/dist/17e757ccadd.213.js +0 -1
  70. package/dist/17e757ccadd.335.js +0 -1
  71. package/dist/17e757ccadd.362.js +0 -1
  72. package/dist/17e757ccadd.441.js +0 -1
  73. package/dist/17e757ccadd.605.js +0 -1
  74. package/dist/17e757ccadd.678.js +0 -1
  75. package/dist/17e757ccadd.782.js +0 -1
  76. package/dist/17e757ccadd.app.js +0 -1
  77. package/dist/17e757ccadd.library.js +0 -1
  78. package/dist/17e757ccadd.preview.js +0 -1
  79. package/dist/17e757ccadd.screenshoot.js +0 -1
  80. package/dist/1ea1c6cd21d25176810c.png +0 -1
  81. package/dist/292d42404e1b03398f61.png +0 -1
  82. package/dist/312d376370831b7bea83.png +0 -1
  83. package/dist/313d1bfc1cf776d1aefe.png +0 -1
  84. package/dist/4aa58bb7a66bb44975aa.png +0 -1
  85. package/dist/56ce063bc6c81adb7322.png +0 -1
  86. package/dist/6a411166ef5cc79e0714.png +0 -1
  87. package/dist/6faf403782fefacc1649.png +0 -1
  88. package/dist/79dca33c68fab79c067f.png +0 -1
  89. package/dist/82da1578fa84f9debaeb.png +0 -1
  90. package/dist/8b8e0f0824743974b282.png +0 -1
  91. package/dist/8d551390d81e39130a3c.png +0 -1
  92. package/dist/9fc61b9479877ebdb6c7.png +0 -1
  93. package/dist/a165d31dcb3dc90f1057.png +0 -1
  94. package/dist/a98d4a5698812c4426b3.png +0 -1
  95. package/dist/c41606bf9d1b604e46d5.png +0 -1
  96. package/dist/ce1f7450ce6c1aacd330.png +0 -1
  97. package/dist/cf8c01e88f4770a6e3e5.png +0 -1
  98. package/dist/dfbcfeab1d5622a737e2.png +0 -1
  99. package/dist/e4893ed8c2f7b8329919.png +0 -1
  100. package/dist/ec2ab4eb4ef73d186186.png +0 -1
@@ -37,6 +37,8 @@ var _preact = require("preact");
37
37
 
38
38
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
39
39
 
40
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
41
+
40
42
  var send = require('../../assets/img/send.svg');
41
43
 
42
44
  var checkedimg = require('../../assets/img/done_gray.svg');
@@ -48,6 +50,31 @@ const defaultAvatar = 'https://file-subiz.com/fiqoahedjbgwclpouoml-avatar_defaul
48
50
  class Widget extends _common.Com {
49
51
  constructor(props) {
50
52
  super(props);
53
+
54
+ _defineProperty(this, "onLink", (e, url) => {
55
+ if (!url) return e.preventDefault();
56
+ let noschemeurl = url.replace(/(^\w+:|^)\/\//, '');
57
+
58
+ if (noschemeurl.startsWith('widget.subiz.com.vn/orders/')) {
59
+ let orderid = noschemeurl.substr('widget.subiz.com.vn/orders/'.length);
60
+ orderid = orderid.split('/')[0];
61
+ this.setState({
62
+ showOrder: true,
63
+ order_id: orderid
64
+ });
65
+ e.preventDefault();
66
+ return;
67
+ }
68
+ });
69
+
70
+ _defineProperty(this, "closeOrder", e => {
71
+ this.setState({
72
+ showOrder: false,
73
+ order_id: ''
74
+ });
75
+ this.focusInput();
76
+ });
77
+
51
78
  this.userSent = {};
52
79
  this.setState({
53
80
  creating: false,
@@ -673,29 +700,6 @@ class Widget extends _common.Com {
673
700
  }), $input);
674
701
  }
675
702
 
676
- onLink = (e, url) => {
677
- if (!url) return e.preventDefault();
678
- let noschemeurl = url.replace(/(^\w+:|^)\/\//, '');
679
-
680
- if (noschemeurl.startsWith('widget.subiz.com.vn/orders/')) {
681
- let orderid = noschemeurl.substr('widget.subiz.com.vn/orders/'.length);
682
- orderid = orderid.split('/')[0];
683
- this.setState({
684
- showOrder: true,
685
- order_id: orderid
686
- });
687
- e.preventDefault();
688
- return;
689
- }
690
- };
691
- closeOrder = e => {
692
- this.setState({
693
- showOrder: false,
694
- order_id: ''
695
- });
696
- this.focusInput();
697
- };
698
-
699
703
  async onStartConvoClick() {
700
704
  var convo = this.props.store.matchConvo(this.props.cid) || {};
701
705
  if (convo.state === 'ended') return this.props.onGo({
@@ -184,11 +184,13 @@ class Main extends _common.Com {
184
184
  exports.default = Main;
185
185
 
186
186
  function restoreViewport() {
187
+ if (document.body && document.body.classList) document.body.classList.remove('sbz_no_scroll');
187
188
  let metatag = document.getElementById('subiz-meta-viewport');
188
189
  if (metatag) metatag.remove();
189
190
  }
190
191
 
191
192
  function modifyViewport() {
193
+ if (document.body && document.body.classList) document.body.classList.add('sbz_no_scroll');
192
194
  let metatag = document.createElement('meta');
193
195
  metatag.httpEquiv = 'X-UA-Compatible';
194
196
  metatag.name = 'viewport';
@@ -14,6 +14,8 @@ var _common = require("../common.js");
14
14
 
15
15
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
16
 
17
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
18
+
17
19
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
18
20
 
19
21
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -21,14 +23,15 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
21
23
  let CSS = (() => Promise.resolve().then(() => _interopRequireWildcard(require('./css.js'))))();
22
24
 
23
25
  class Contact extends _common.Com {
24
- state = {
25
- map: false,
26
- map_loading: false,
27
- map_initialized: false
28
- };
29
-
30
26
  constructor(props) {
31
27
  super(props);
28
+
29
+ _defineProperty(this, "state", {
30
+ map: false,
31
+ map_loading: false,
32
+ map_initialized: false
33
+ });
34
+
32
35
  this.showMap = this.showMap.bind(this);
33
36
  this.hideMap = this.hideMap.bind(this);
34
37
  }
@@ -13,6 +13,8 @@ var _plugin = _interopRequireDefault(require("./plugin.js"));
13
13
 
14
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
15
 
16
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
17
+
16
18
  var $link = document.createElement('link');
17
19
  $link.href = 'https://fonts.googleapis.com/css2?family=Roboto:wght@400;500&display=swap';
18
20
  $link.rel = 'stylesheet';
@@ -22,6 +24,18 @@ _index.default.preloadWebfonts(['Roboto'], [400, 500]);
22
24
 
23
25
  class Widget {
24
26
  constructor(ApiURL, FileURL, RealtimeURL, inmem, fake, agenttoken) {
27
+ _defineProperty(this, "version", () => '4.4');
28
+
29
+ _defineProperty(this, "setSetting", setting => this.store.setSetting({
30
+ account_setting: setting
31
+ }));
32
+
33
+ _defineProperty(this, "getSetting", _ => ({
34
+ account_setting: _index.default.cloneDeep(this.store.matchAccountSetting())
35
+ }));
36
+
37
+ _defineProperty(this, "getUser", () => _index.default.parseJSON(_index.default.stringify(this.store.matchUser())));
38
+
25
39
  this.domGate = new _index.default.Gate();
26
40
  this.store = new _store.default(ApiURL, FileURL, RealtimeURL, inmem, fake, agenttoken);
27
41
  window.sbz_store = this.store;
@@ -126,15 +140,6 @@ class Widget {
126
140
  this.pluginMgr.hideCurrentChatbox();
127
141
  }
128
142
 
129
- version = () => '4.4';
130
- setSetting = setting => this.store.setSetting({
131
- account_setting: setting
132
- });
133
- getSetting = _ => ({
134
- account_setting: _index.default.cloneDeep(this.store.matchAccountSetting())
135
- });
136
- getUser = () => _index.default.parseJSON(_index.default.stringify(this.store.matchUser()));
137
-
138
143
  async setLocale(locale) {
139
144
  await this.domGate.entry();
140
145
  return this.pluginMgr.setCurrentChatboxLocale(locale);
@@ -13,6 +13,8 @@ var _common = require("../common.js");
13
13
 
14
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
15
 
16
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
17
+
16
18
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
17
19
 
18
20
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -20,20 +22,21 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
20
22
  let notifCSS = (() => Promise.resolve().then(() => _interopRequireWildcard(require('./css.js'))))();
21
23
 
22
24
  class Notif extends _common.Com {
23
- state = {
24
- close: true,
25
- cssready: false,
26
- closeAnimation: true,
27
- imageReady: false,
28
- user: {},
29
- timestamp: '',
30
- message: '',
31
- title: '',
32
- last_show: 0
33
- };
34
-
35
25
  constructor(props) {
36
26
  super(props);
27
+
28
+ _defineProperty(this, "state", {
29
+ close: true,
30
+ cssready: false,
31
+ closeAnimation: true,
32
+ imageReady: false,
33
+ user: {},
34
+ timestamp: '',
35
+ message: '',
36
+ title: '',
37
+ last_show: 0
38
+ });
39
+
37
40
  setTimeout(async () => {
38
41
  let {
39
42
  body: impression
@@ -15,53 +15,86 @@ var _spinner = _interopRequireDefault(require("../chatbox/spinner.js"));
15
15
 
16
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
17
 
18
- class AddressPicker extends _common.Com {
19
- state = {
20
- show: false,
21
- searchValue: '',
22
- addresses: []
23
- };
24
- filterRef = (0, _preact.createRef)();
25
- overlayRef = (0, _preact.createRef)();
18
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
26
19
 
20
+ class AddressPicker extends _common.Com {
27
21
  constructor(props) {
28
22
  super(props);
29
- document.addEventListener('touchmove', function (e) {});
30
- }
31
23
 
32
- onTouchMove = e => {
33
- if (e.target === this.overlayRef.current) {
34
- e.preventDefault();
35
- e.stopPropagation();
36
- }
37
- };
38
- hideDropdown = () => {
39
- this.setState({
24
+ _defineProperty(this, "state", {
40
25
  show: false,
41
- searchValue: ''
26
+ searchValue: '',
27
+ addresses: []
28
+ });
29
+
30
+ _defineProperty(this, "filterRef", (0, _preact.createRef)());
31
+
32
+ _defineProperty(this, "overlayRef", (0, _preact.createRef)());
33
+
34
+ _defineProperty(this, "onTouchMove", e => {
35
+ if (e.target === this.overlayRef.current) {
36
+ e.preventDefault();
37
+ e.stopPropagation();
38
+ }
42
39
  });
43
- };
44
- onKeydown = e => {
45
- if (e.key === 'Escape') {
46
- if (!this.state.show) return;
47
- if (this.state.searchValue) this.setState({
40
+
41
+ _defineProperty(this, "hideDropdown", () => {
42
+ this.setState({
43
+ show: false,
48
44
  searchValue: ''
49
- });else this.hideDropdown();
50
- e.preventDefault();
51
- e.stopPropagation();
52
- }
45
+ });
46
+ });
47
+
48
+ _defineProperty(this, "onKeydown", e => {
49
+ if (e.key === 'Escape') {
50
+ if (!this.state.show) return;
51
+ if (this.state.searchValue) this.setState({
52
+ searchValue: ''
53
+ });else this.hideDropdown();
54
+ e.preventDefault();
55
+ e.stopPropagation();
56
+ }
57
+
58
+ if (e.key == 'Enter') {}
59
+ });
60
+
61
+ _defineProperty(this, "doSearch", _index.default.throttle(async () => {
62
+ let requestId = Date.now();
63
+ this.requestId = requestId;
64
+ let res = await this.props.store.suggest_addresses(this.state.searchValue);
65
+ if (this.requestId !== requestId) return;
66
+ this.setState({
67
+ addresses: _index.default.get(res, 'body.addresses', [])
68
+ });
69
+ }, 100));
53
70
 
54
- if (e.key == 'Enter') {}
55
- };
56
- doSearch = _index.default.throttle(async () => {
57
- let requestId = Date.now();
58
- this.requestId = requestId;
59
- let res = await this.props.store.suggest_addresses(this.state.searchValue);
60
- if (this.requestId !== requestId) return;
61
- this.setState({
62
- addresses: _index.default.get(res, 'body.addresses', [])
71
+ _defineProperty(this, "onChangeSearchValue", e => {
72
+ this.setState({
73
+ searchValue: e.target.value
74
+ });
75
+ this.props.onChangeAddress(e.target.value);
76
+ this.doSearch();
63
77
  });
64
- }, 100);
78
+
79
+ _defineProperty(this, "toogleDropdown", async () => {
80
+ await this.setState({
81
+ show: true,
82
+ searchValue: this.props.initAddress || ''
83
+ });
84
+ this.focusFilter();
85
+ });
86
+
87
+ _defineProperty(this, "onSelect", item => {
88
+ this.props.onSelect(item);
89
+ this.hideDropdown();
90
+ });
91
+
92
+ _defineProperty(this, "onBackgroundScroll", e => {
93
+ console.log('EEEEEEE', e);
94
+ });
95
+
96
+ document.addEventListener('touchmove', function (e) {});
97
+ }
65
98
 
66
99
  componentDidMount() {
67
100
  window.addEventListener('keydown', this.onKeydown);
@@ -71,14 +104,6 @@ class AddressPicker extends _common.Com {
71
104
  window.removeEventListener('keydown', this.onKeydown);
72
105
  }
73
106
 
74
- onChangeSearchValue = e => {
75
- this.setState({
76
- searchValue: e.target.value
77
- });
78
- this.props.onChangeAddress(e.target.value);
79
- this.doSearch();
80
- };
81
-
82
107
  renderEmpty() {
83
108
  return (0, _preact.h)("div", {
84
109
  class: "dropdown_select_filter__empty"
@@ -103,14 +128,6 @@ class AddressPicker extends _common.Com {
103
128
  }, "\u0110ang t\u1EA3i d\u1EEF li\u1EC7u"));
104
129
  }
105
130
 
106
- toogleDropdown = async () => {
107
- await this.setState({
108
- show: true,
109
- searchValue: this.props.initAddress || ''
110
- });
111
- this.focusFilter();
112
- };
113
-
114
131
  focusFilter() {
115
132
  if (!this.filterRef.current) return;
116
133
  this.filterRef.current.focus();
@@ -120,11 +137,6 @@ class AddressPicker extends _common.Com {
120
137
  }, 100);
121
138
  }
122
139
 
123
- onSelect = item => {
124
- this.props.onSelect(item);
125
- this.hideDropdown();
126
- };
127
-
128
140
  renderDropdown() {
129
141
  if (!this.state.show) return null;
130
142
 
@@ -193,10 +205,6 @@ class AddressPicker extends _common.Com {
193
205
  }, $items));
194
206
  }
195
207
 
196
- onBackgroundScroll = e => {
197
- console.log('EEEEEEE', e);
198
- };
199
-
200
208
  render() {
201
209
  let $name = (0, _preact.h)("div", {
202
210
  class: "text-truncate",