@subiz/widget-v4 4.1.215 → 4.1.217

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 (57) hide show
  1. package/README.md +6 -0
  2. package/api.md +9 -5
  3. package/assets/img/bubble_default.svg +1 -0
  4. package/assets/less/message.less +83 -0
  5. package/assets/less/widget.less +12 -0
  6. package/compiled_src/chatbox/AudioAttachments.js +5 -0
  7. package/compiled_src/chatbox/ChatButton.js +19 -17
  8. package/compiled_src/chatbox/Event.js +9 -2
  9. package/compiled_src/chatbox/FileAttachments.js +9 -3
  10. package/compiled_src/chatbox/ImageAttachments.js +16 -6
  11. package/compiled_src/chatbox/UploadProgress.js +44 -0
  12. package/compiled_src/chatbox/VideoAttachments.js +5 -0
  13. package/compiled_src/store/api.js +77 -78
  14. package/compiled_src/store/api_fake.js +1 -1
  15. package/compiled_src/store/attachments.js +5 -1
  16. package/compiled_src/store/store.js +25 -4
  17. package/dist/{1a12a5ed6a9.278.js → 1a12ed33347.278.js} +1 -1
  18. package/dist/1a12ed33347.app.js +1 -0
  19. package/dist/{1a12a5ed6a9.chat.html → 1a12ed33347.chat.html} +1 -1
  20. package/dist/1a12ed33347.chat.js +1 -0
  21. package/dist/{1a12a5ed6a9.form.html → 1a12ed33347.form.html} +1 -1
  22. package/dist/{1a12a5ed6a9.form.js → 1a12ed33347.form.js} +1 -1
  23. package/dist/{1a12a5ed6a9.index.html → 1a12ed33347.index.html} +1 -1
  24. package/dist/{1a12a5ed6a9.library.html → 1a12ed33347.library.html} +1 -1
  25. package/dist/1a12ed33347.library.js +1 -0
  26. package/dist/{1a12a5ed6a9.preview.html → 1a12ed33347.preview.html} +1 -1
  27. package/dist/1a12ed33347.preview.js +1 -0
  28. package/dist/1a12ed33347.webview.js +1 -0
  29. package/dist/HASH +1 -0
  30. package/dist/assets/img/{bubble_default.7d5e4ab.svg → bubble_default.6f6eec8.svg} +1 -0
  31. package/dist/screenshoot.js +25 -20
  32. package/package.json +11 -10
  33. package/src/chatbox/AudioAttachments.js +2 -0
  34. package/src/chatbox/ChatButton.js +22 -20
  35. package/src/chatbox/Event.js +8 -4
  36. package/src/chatbox/FileAttachments.js +5 -2
  37. package/src/chatbox/ImageAttachments.js +6 -2
  38. package/src/chatbox/UploadProgress.js +21 -0
  39. package/src/chatbox/VideoAttachments.js +2 -0
  40. package/src/store/api.js +66 -81
  41. package/src/store/api_fake.js +1 -1
  42. package/src/store/attachments.js +5 -1
  43. package/src/store/store.js +13 -5
  44. package/up +18 -0
  45. package/dist/.HASH +0 -1
  46. package/dist/1a12a5ed6a9.app.js +0 -1
  47. package/dist/1a12a5ed6a9.chat.js +0 -1
  48. package/dist/1a12a5ed6a9.library.js +0 -1
  49. package/dist/1a12a5ed6a9.preview.js +0 -1
  50. package/dist/1a12a5ed6a9.webview.js +0 -1
  51. /package/dist/{1a12a5ed6a9.127.js → 1a12ed33347.127.js} +0 -0
  52. /package/dist/{1a12a5ed6a9.132.js → 1a12ed33347.132.js} +0 -0
  53. /package/dist/{1a12a5ed6a9.185.js → 1a12ed33347.185.js} +0 -0
  54. /package/dist/{1a12a5ed6a9.27.js → 1a12ed33347.27.js} +0 -0
  55. /package/dist/{1a12a5ed6a9.339.js → 1a12ed33347.339.js} +0 -0
  56. /package/dist/{1a12a5ed6a9.459.js → 1a12ed33347.459.js} +0 -0
  57. /package/dist/{1a12a5ed6a9.490.js → 1a12ed33347.490.js} +0 -0
@@ -885,10 +885,12 @@ class Store {
885
885
  await this.readyGate.entry();
886
886
  const key = websiteFormStorageKey(this.api, formid);
887
887
  const kv = this.kv;
888
+ const values = _index.default.cloneDeep(payload.values);
888
889
  const result = formResult(await this.api.submitWebsiteForm(formid, payload));
889
890
  try {
890
891
  kv.put(key, {
891
892
  conversation_id: result.conversation_id,
893
+ values,
892
894
  expires_at: _index.default.Date.now() + 7 * 24 * 60 * 60 * 1000
893
895
  });
894
896
  } catch (_) {}
@@ -919,7 +921,8 @@ class Store {
919
921
  return {
920
922
  submitted: true,
921
923
  status: 'found',
922
- conversation_id: receipt.conversation_id
924
+ conversation_id: receipt.conversation_id,
925
+ values: Array.isArray(receipt.values) ? _index.default.cloneDeep(receipt.values) : []
923
926
  };
924
927
  } catch (_) {
925
928
  return {
@@ -1365,7 +1368,7 @@ class Store {
1365
1368
  if (att.type !== 'file') return;
1366
1369
  if (!att._file) return;
1367
1370
  files.push(att);
1368
- if (ImageTypes.includes(att._file.type)) {
1371
+ if (!att._upload?.file && ImageTypes.includes(att._file.type)) {
1369
1372
  let {
1370
1373
  width,
1371
1374
  height,
@@ -1379,15 +1382,33 @@ class Store {
1379
1382
  }
1380
1383
  this.onWs(event);
1381
1384
  await this.convoGate.entry();
1382
- const uploaded = await (0, _attachments.uploadAttachments)(files, file => this.api.uploadToS3(file));
1385
+ const uploaded = await (0, _attachments.uploadAttachments)(files, (file, state) => this.api.uploadAttachment(file, state, () => this.pubsub.publish('events', event)));
1383
1386
  event._error = uploaded.error;
1384
1387
  if (uploaded.errorMessage) event._error_message = uploaded.errorMessage;
1385
1388
  if (event._error) return this.onWs(event);
1386
1389
  if (cid && cid.startsWith('cslight')) return;
1390
+ const outgoing = {
1391
+ ...event,
1392
+ data: {
1393
+ ...event.data
1394
+ }
1395
+ };
1396
+ if (event.data.message) outgoing.data.message = {
1397
+ ...event.data.message,
1398
+ attachments: event.data.message.attachments?.map(att => {
1399
+ const {
1400
+ _file,
1401
+ _upload,
1402
+ ...attachment
1403
+ } = att;
1404
+ return attachment;
1405
+ })
1406
+ };
1387
1407
  let {
1388
1408
  body: ret,
1389
1409
  error
1390
- } = await this.api.sendConvoEvent(cid, event);
1410
+ } = await this.api.sendConvoEvent(cid, outgoing);
1411
+ error = error || ret?.error;
1391
1412
  if (error) {
1392
1413
  event._error = error;
1393
1414
  this.onWs(event);