@nyaruka/temba-components 0.91.6 → 0.93.0

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 (83) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/demo/index.html +1 -1
  3. package/dist/temba-components.js +763 -1189
  4. package/dist/temba-components.js.map +1 -1
  5. package/out-tsc/src/chat/Chat.js +714 -0
  6. package/out-tsc/src/chat/Chat.js.map +1 -0
  7. package/out-tsc/src/completion/helpers.js +1 -29
  8. package/out-tsc/src/completion/helpers.js.map +1 -1
  9. package/out-tsc/src/compose/Compose.js +6 -2
  10. package/out-tsc/src/compose/Compose.js.map +1 -1
  11. package/out-tsc/src/contacts/ContactChat.js +530 -54
  12. package/out-tsc/src/contacts/ContactChat.js.map +1 -1
  13. package/out-tsc/src/contacts/events.js +1 -998
  14. package/out-tsc/src/contacts/events.js.map +1 -1
  15. package/out-tsc/src/lightbox/Lightbox.js +4 -0
  16. package/out-tsc/src/lightbox/Lightbox.js.map +1 -1
  17. package/out-tsc/src/list/TembaMenu.js +0 -1
  18. package/out-tsc/src/list/TembaMenu.js.map +1 -1
  19. package/out-tsc/src/markdown.js +33 -0
  20. package/out-tsc/src/markdown.js.map +1 -0
  21. package/out-tsc/src/select/Select.js +6 -1
  22. package/out-tsc/src/select/Select.js.map +1 -1
  23. package/out-tsc/src/textinput/TextInput.js +1 -1
  24. package/out-tsc/src/textinput/TextInput.js.map +1 -1
  25. package/out-tsc/src/thumbnail/Thumbnail.js +128 -81
  26. package/out-tsc/src/thumbnail/Thumbnail.js.map +1 -1
  27. package/out-tsc/src/utils/index.js +9 -11
  28. package/out-tsc/src/utils/index.js.map +1 -1
  29. package/out-tsc/src/webchat/WebChat.js +109 -358
  30. package/out-tsc/src/webchat/WebChat.js.map +1 -1
  31. package/out-tsc/src/webchat/index.js +17 -0
  32. package/out-tsc/src/webchat/index.js.map +1 -1
  33. package/out-tsc/temba-modules.js +2 -2
  34. package/out-tsc/temba-modules.js.map +1 -1
  35. package/out-tsc/temba-webchat.js +2 -0
  36. package/out-tsc/temba-webchat.js.map +1 -1
  37. package/out-tsc/test/temba-contact-chat.test.js +1 -0
  38. package/out-tsc/test/temba-contact-chat.test.js.map +1 -1
  39. package/out-tsc/test/temba-lightbox.test.js +4 -4
  40. package/out-tsc/test/temba-lightbox.test.js.map +1 -1
  41. package/package.json +1 -1
  42. package/screenshots/truth/contacts/compose-attachments-no-text-failure.png +0 -0
  43. package/screenshots/truth/contacts/compose-attachments-no-text-success.png +0 -0
  44. package/screenshots/truth/contacts/compose-text-and-attachments-failure-attachments.png +0 -0
  45. package/screenshots/truth/contacts/compose-text-and-attachments-failure-generic.png +0 -0
  46. package/screenshots/truth/contacts/compose-text-and-attachments-failure-text-and-attachments.png +0 -0
  47. package/screenshots/truth/contacts/compose-text-and-attachments-failure-text.png +0 -0
  48. package/screenshots/truth/contacts/compose-text-and-attachments-success.png +0 -0
  49. package/screenshots/truth/contacts/compose-text-no-attachments-failure.png +0 -0
  50. package/screenshots/truth/contacts/compose-text-no-attachments-success.png +0 -0
  51. package/screenshots/truth/contacts/contact-active-default.png +0 -0
  52. package/screenshots/truth/contacts/contact-active-show-chatbox.png +0 -0
  53. package/screenshots/truth/contacts/contact-archived-hide-chatbox.png +0 -0
  54. package/screenshots/truth/contacts/contact-blocked-hide-chatbox.png +0 -0
  55. package/screenshots/truth/contacts/contact-stopped-hide-chatbox.png +0 -0
  56. package/screenshots/truth/lightbox/img-zoomed.png +0 -0
  57. package/screenshots/truth/lightbox/img.png +0 -0
  58. package/src/chat/Chat.ts +791 -0
  59. package/src/completion/helpers.ts +2 -40
  60. package/src/compose/Compose.ts +6 -2
  61. package/src/contacts/ContactChat.ts +623 -59
  62. package/src/contacts/events.ts +1 -1068
  63. package/src/lightbox/Lightbox.ts +5 -0
  64. package/src/list/TembaMenu.ts +0 -1
  65. package/src/markdown.ts +41 -0
  66. package/src/select/Select.ts +5 -1
  67. package/src/textinput/TextInput.ts +1 -1
  68. package/src/thumbnail/Thumbnail.ts +130 -81
  69. package/src/utils/index.ts +12 -13
  70. package/src/webchat/WebChat.ts +196 -413
  71. package/src/webchat/index.ts +23 -1
  72. package/static/css/temba-components.css +2 -0
  73. package/temba-modules.ts +2 -2
  74. package/temba-webchat.ts +2 -0
  75. package/test/temba-contact-chat.test.ts +1 -0
  76. package/test/temba-lightbox.test.ts +4 -4
  77. package/test-assets/contacts/history.json +1 -56
  78. package/out-tsc/src/contacts/ContactHistory.js +0 -691
  79. package/out-tsc/src/contacts/ContactHistory.js.map +0 -1
  80. package/out-tsc/test/temba-contact-history.test.js +0 -69
  81. package/out-tsc/test/temba-contact-history.test.js.map +0 -1
  82. package/src/contacts/ContactHistory.ts +0 -875
  83. package/test/temba-contact-history.test.ts +0 -107
@@ -1,6 +1,28 @@
1
+ import { User } from '../interfaces';
2
+
1
3
  export const SVG_FINGERPRINT = 'febafb41c2fd60efa2bdaead993c7087';
2
4
 
3
5
  // webchat spritesheet
4
6
  export enum WebChatIcon {
5
- send = 'send-03'
7
+ send = 'send-03',
8
+ attachment = 'paperclip',
9
+ attachment_audio = 'volume-min',
10
+ attachment_document = 'file-06',
11
+ attachment_image = 'image-01',
12
+ attachment_location = 'marker-pin-01',
13
+ attachment_video = 'video-recorder'
6
14
  }
15
+
16
+ export const getUserDisplay = (user: User) => {
17
+ if (user) {
18
+ if (user.first_name && user.last_name) {
19
+ return `${user.first_name} ${user.last_name}`;
20
+ }
21
+
22
+ if (user.first_name) {
23
+ return user.first_name;
24
+ }
25
+
26
+ return user.email;
27
+ }
28
+ };
@@ -33,6 +33,8 @@
33
33
  /* primary colors, should be dark */
34
34
  --color-selection: #f0f6ff;
35
35
 
36
+
37
+ --widget-box-shadow: rgba(-1, -1, 0, .15) 0px 1px 7px 0px, rgba(0, 0, 0, 0.05) 0px 1px 2px 0px;
36
38
  --widget-box-shadow-focused: 0 0 0 3px rgba(164, 202, 254, .45);
37
39
  --widget-box-shadow-focused-error: 0 0 0 3px rgba(var(--error-rgb), 0.3);
38
40
 
package/temba-modules.ts CHANGED
@@ -11,7 +11,6 @@ import { Loading } from './src/loading/Loading';
11
11
  import { CharCount } from './src/charcount/CharCount';
12
12
  import { Options } from './src/options/Options';
13
13
  import { ContactChat } from './src/contacts/ContactChat';
14
- import { ContactHistory } from './src/contacts/ContactHistory';
15
14
  import { TicketList } from './src/list/TicketList';
16
15
  import { ContactDetails } from './src/contacts/ContactDetails';
17
16
  import { TembaList } from './src/list/TembaList';
@@ -56,6 +55,7 @@ import { Mask } from './src/mask/Mask';
56
55
  import { TembaUser } from './src/user/TembaUser';
57
56
  import { TemplateEditor } from './src/templates/TemplateEditor';
58
57
  import { Toast } from './src/toast/Toast';
58
+ import { Chat } from './src/chat/Chat';
59
59
  import { MediaPicker } from './src/mediapicker/MediaPicker';
60
60
 
61
61
  export function addCustomElement(name: string, comp: any) {
@@ -91,7 +91,6 @@ addCustomElement('temba-field', FormField);
91
91
  addCustomElement('temba-dialog', Dialog);
92
92
  addCustomElement('temba-modax', Modax);
93
93
  addCustomElement('temba-charcount', CharCount);
94
- addCustomElement('temba-contact-history', ContactHistory);
95
94
  addCustomElement('temba-contact-chat', ContactChat);
96
95
  addCustomElement('temba-contact-details', ContactDetails);
97
96
  addCustomElement('temba-ticket-list', TicketList);
@@ -123,4 +122,5 @@ addCustomElement('temba-mask', Mask);
123
122
  addCustomElement('temba-user', TembaUser);
124
123
  addCustomElement('temba-template-editor', TemplateEditor);
125
124
  addCustomElement('temba-toast', Toast);
125
+ addCustomElement('temba-chat', Chat);
126
126
  addCustomElement('temba-media-picker', MediaPicker);
package/temba-webchat.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { Chat } from './src/chat/Chat';
1
2
  import { VectorIcon } from './src/vectoricon/VectorIcon';
2
3
  import { WebChat } from './src/webchat/WebChat';
3
4
 
@@ -8,4 +9,5 @@ export function addCustomElement(name: string, comp: any) {
8
9
  }
9
10
 
10
11
  addCustomElement('temba-icon', VectorIcon);
12
+ addCustomElement('temba-chat', Chat);
11
13
  addCustomElement('temba-webchat', WebChat);
@@ -38,6 +38,7 @@ const getContactChat = async (attrs: any = {}) => {
38
38
 
39
39
  // TODO: this should be waiting for an event instead
40
40
  await waitFor(100);
41
+ await clock.tick(0);
41
42
  return chat;
42
43
  };
43
44
 
@@ -16,8 +16,8 @@ describe('temba-lightbox', () => {
16
16
  );
17
17
 
18
18
  await assertScreenshot('lightbox/img', {
19
- x: 28,
20
- y: 28,
19
+ x: 0,
20
+ y: 0,
21
21
  width: 1024,
22
22
  height: 768
23
23
  });
@@ -26,8 +26,8 @@ describe('temba-lightbox', () => {
26
26
  lightbox.showElement(img as HTMLElement);
27
27
 
28
28
  await assertScreenshot('lightbox/img-zoomed', {
29
- x: 28,
30
- y: 28,
29
+ x: 0,
30
+ y: 0,
31
31
  width: 1024,
32
32
  height: 768
33
33
  });
@@ -71,22 +71,6 @@
71
71
  },
72
72
  "status": "C"
73
73
  },
74
- {
75
- "type": "run_result_changed",
76
- "created_on": "2021-03-30T15:20:35.573533-07:00",
77
- "step_uuid": "6b384ebe-5831-4bef-9db9-fef4941c84c5",
78
- "name": "Result",
79
- "value": "0",
80
- "category": "Failure",
81
- "session_uuid": "885a9736-88fd-4676-b124-2577e1eaabd9"
82
- },
83
- {
84
- "type": "error",
85
- "created_on": "2021-03-30T15:20:35.573515-07:00",
86
- "step_uuid": "6b384ebe-5831-4bef-9db9-fef4941c84c5",
87
- "text": "DTOne API request failed: Account not found. Please enter a correct login and password (995)",
88
- "session_uuid": "885a9736-88fd-4676-b124-2577e1eaabd9"
89
- },
90
74
  {
91
75
  "type": "airtime_transferred",
92
76
  "created_on": "2021-03-30T22:20:35.573511+00:00",
@@ -113,16 +97,6 @@
113
97
  "status": "W",
114
98
  "logs_url": "/channels/channellog/read/1478/"
115
99
  },
116
- {
117
- "type": "run_result_changed",
118
- "created_on": "2021-03-30T15:20:33.924827-07:00",
119
- "step_uuid": "9f1a43c1-cbc8-4513-a223-18180f28a95a",
120
- "name": "Name",
121
- "value": "no",
122
- "category": "Other",
123
- "input": "no",
124
- "session_uuid": "885a9736-88fd-4676-b124-2577e1eaabd9"
125
- },
126
100
  {
127
101
  "type": "msg_received",
128
102
  "created_on": "2021-03-30T22:20:33.801814+00:00",
@@ -155,16 +129,6 @@
155
129
  "status": "W",
156
130
  "logs_url": "/channels/channellog/read/1476/"
157
131
  },
158
- {
159
- "type": "run_result_changed",
160
- "created_on": "2021-03-30T15:20:31.933494-07:00",
161
- "step_uuid": "5959d883-93f4-4996-beb9-c153f5605f90",
162
- "name": "Beer",
163
- "value": "primus",
164
- "category": "Primus",
165
- "input": "primus",
166
- "session_uuid": "885a9736-88fd-4676-b124-2577e1eaabd9"
167
- },
168
132
  {
169
133
  "type": "msg_received",
170
134
  "created_on": "2021-03-30T22:20:31.656303+00:00",
@@ -197,16 +161,6 @@
197
161
  "status": "W",
198
162
  "logs_url": "/channels/channellog/read/1474/"
199
163
  },
200
- {
201
- "type": "run_result_changed",
202
- "created_on": "2021-03-30T15:20:29.397464-07:00",
203
- "step_uuid": "5b46790e-fedc-4594-9c02-aa0812ff3488",
204
- "name": "Color",
205
- "value": "blue",
206
- "category": "Blue",
207
- "input": "blue",
208
- "session_uuid": "885a9736-88fd-4676-b124-2577e1eaabd9"
209
- },
210
164
  {
211
165
  "type": "msg_received",
212
166
  "created_on": "2021-03-30T22:20:29.277186+00:00",
@@ -223,15 +177,6 @@
223
177
  "msg_type": "F",
224
178
  "logs_url": "/channels/channellog/read/1473/"
225
179
  },
226
- {
227
- "type": "run_result_changed",
228
- "created_on": "2021-03-30T15:20:26.704509-07:00",
229
- "step_uuid": "83cbe193-29d8-40ce-a820-0b06d719932a",
230
- "name": "A new result",
231
- "value": "Some Value",
232
- "category": "",
233
- "session_uuid": "885a9736-88fd-4676-b124-2577e1eaabd9"
234
- },
235
180
  {
236
181
  "type": "contact_groups_changed",
237
182
  "created_on": "2021-03-30T15:20:26.704497-07:00",
@@ -311,4 +256,4 @@
311
256
  "logs_url": "/channels/channellog/read/1471/"
312
257
  }
313
258
  ]
314
- }
259
+ }