@nyaruka/temba-components 0.133.0 → 0.134.1

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 (72) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/demo/components/webchat/example.html +1 -1
  3. package/dist/locales/es.js +5 -5
  4. package/dist/locales/es.js.map +1 -1
  5. package/dist/locales/fr.js +5 -5
  6. package/dist/locales/fr.js.map +1 -1
  7. package/dist/locales/locale-codes.js +2 -11
  8. package/dist/locales/locale-codes.js.map +1 -1
  9. package/dist/locales/pt.js +5 -5
  10. package/dist/locales/pt.js.map +1 -1
  11. package/dist/temba-components.js +307 -259
  12. package/dist/temba-components.js.map +1 -1
  13. package/out-tsc/src/display/Chat.js +223 -90
  14. package/out-tsc/src/display/Chat.js.map +1 -1
  15. package/out-tsc/src/display/TembaUser.js +3 -3
  16. package/out-tsc/src/display/TembaUser.js.map +1 -1
  17. package/out-tsc/src/events.js.map +1 -1
  18. package/out-tsc/src/flow/CanvasNode.js +8 -0
  19. package/out-tsc/src/flow/CanvasNode.js.map +1 -1
  20. package/out-tsc/src/flow/Editor.js +117 -28
  21. package/out-tsc/src/flow/Editor.js.map +1 -1
  22. package/out-tsc/src/flow/utils.js +141 -0
  23. package/out-tsc/src/flow/utils.js.map +1 -1
  24. package/out-tsc/src/interfaces.js.map +1 -1
  25. package/out-tsc/src/live/ContactChat.js +122 -170
  26. package/out-tsc/src/live/ContactChat.js.map +1 -1
  27. package/out-tsc/src/locales/es.js +5 -5
  28. package/out-tsc/src/locales/es.js.map +1 -1
  29. package/out-tsc/src/locales/fr.js +5 -5
  30. package/out-tsc/src/locales/fr.js.map +1 -1
  31. package/out-tsc/src/locales/locale-codes.js +2 -11
  32. package/out-tsc/src/locales/locale-codes.js.map +1 -1
  33. package/out-tsc/src/locales/pt.js +5 -5
  34. package/out-tsc/src/locales/pt.js.map +1 -1
  35. package/out-tsc/src/store/AppState.js +3 -0
  36. package/out-tsc/src/store/AppState.js.map +1 -1
  37. package/out-tsc/src/store/Store.js +5 -5
  38. package/out-tsc/src/store/Store.js.map +1 -1
  39. package/out-tsc/src/webchat/WebChat.js +22 -9
  40. package/out-tsc/src/webchat/WebChat.js.map +1 -1
  41. package/out-tsc/test/actions/send_broadcast.test.js +9 -4
  42. package/out-tsc/test/actions/send_broadcast.test.js.map +1 -1
  43. package/out-tsc/test/temba-flow-collision.test.js +673 -0
  44. package/out-tsc/test/temba-flow-collision.test.js.map +1 -0
  45. package/out-tsc/test/temba-flow-editor-node.test.js +128 -42
  46. package/out-tsc/test/temba-flow-editor-node.test.js.map +1 -1
  47. package/package.json +1 -1
  48. package/screenshots/truth/contacts/chat-failure.png +0 -0
  49. package/screenshots/truth/contacts/chat-for-archived-contact.png +0 -0
  50. package/screenshots/truth/contacts/chat-for-blocked-contact.png +0 -0
  51. package/screenshots/truth/contacts/chat-for-stopped-contact.png +0 -0
  52. package/screenshots/truth/contacts/chat-sends-attachments-only.png +0 -0
  53. package/screenshots/truth/contacts/chat-sends-text-and-attachments.png +0 -0
  54. package/screenshots/truth/contacts/chat-sends-text-only.png +0 -0
  55. package/src/display/Chat.ts +303 -129
  56. package/src/display/TembaUser.ts +3 -2
  57. package/src/events.ts +11 -8
  58. package/src/flow/CanvasNode.ts +10 -0
  59. package/src/flow/Editor.ts +156 -28
  60. package/src/flow/utils.ts +207 -1
  61. package/src/interfaces.ts +7 -0
  62. package/src/live/ContactChat.ts +129 -180
  63. package/src/locales/es.ts +13 -18
  64. package/src/locales/fr.ts +13 -18
  65. package/src/locales/locale-codes.ts +2 -11
  66. package/src/locales/pt.ts +13 -18
  67. package/src/store/AppState.ts +2 -0
  68. package/src/store/Store.ts +5 -5
  69. package/src/webchat/WebChat.ts +24 -10
  70. package/test/actions/send_broadcast.test.ts +2 -1
  71. package/test/temba-flow-collision.test.ts +833 -0
  72. package/test/temba-flow-editor-node.test.ts +142 -47
@@ -1,9 +1,9 @@
1
1
  /* eslint-disable @typescript-eslint/no-this-alias */
2
2
  import { LitElement, TemplateResult, html, css, PropertyValueMap } from 'lit';
3
3
  import { property } from 'lit/decorators.js';
4
- import { getCookie, setCookie } from '../utils';
4
+ import { generateUUIDv7, getCookie, setCookie } from '../utils';
5
5
  import { DEFAULT_AVATAR } from './assets';
6
- import { Chat, ChatEvent, Message, MessageType } from '../display/Chat';
6
+ import { Chat, MsgEvent } from '../display/Chat';
7
7
 
8
8
  interface User {
9
9
  avatar?: string;
@@ -83,17 +83,24 @@ enum ChatStatus {
83
83
  CONNECTED = 'connected'
84
84
  }
85
85
 
86
- const sockToChat = function (msg: any): ChatEvent | Message {
87
- const type = msg.msg_in ? MessageType.MsgIn : MessageType.MsgOut;
86
+ const sockToChat = function (msg: any): MsgEvent {
87
+ const type = msg.msg_in ? 'msg_created' : 'msg_received';
88
88
  const msgContent = msg.msg_in || msg.msg_out;
89
89
 
90
90
  return {
91
- id: msgContent.id,
91
+ uuid: msgContent.id,
92
92
  type,
93
- text: msgContent.text,
94
- date: new Date(msgContent.time),
95
- user: msgContent.user,
96
- attachments: msgContent.attachments
93
+ created_on: new Date(msgContent.time),
94
+ _user: msgContent.user,
95
+ msg: {
96
+ text: msgContent.text,
97
+ channel: undefined,
98
+ quick_replies: [],
99
+ urn: '',
100
+ direction: '',
101
+ type: '',
102
+ attachments: msgContent.attachments
103
+ }
97
104
  };
98
105
  };
99
106
 
@@ -570,7 +577,14 @@ export class WebChat extends LitElement {
570
577
  const date = new Date();
571
578
 
572
579
  this.chat.addMessages(
573
- [{ type: MessageType.MsgIn, text, date }],
580
+ [
581
+ {
582
+ uuid: generateUUIDv7(),
583
+ type: 'msg_received',
584
+ msg: { text },
585
+ created_on: date
586
+ } as MsgEvent
587
+ ],
574
588
  date,
575
589
  true
576
590
  );
@@ -68,6 +68,7 @@ describe('send_broadcast action config', () => {
68
68
  'multiline-text'
69
69
  );
70
70
 
71
+ /* TODO: flaky test having to do with attachment render times
71
72
  helper.testAction(
72
73
  {
73
74
  uuid: 'test-action-5',
@@ -82,7 +83,7 @@ describe('send_broadcast action config', () => {
82
83
  } as SendBroadcast,
83
84
  'with-attachments',
84
85
  true
85
- );
86
+ );*/
86
87
 
87
88
  helper.testAction(
88
89
  {