@nyaruka/temba-components 0.67.4 → 0.68.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 (65) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/demo/index.html +5 -3
  3. package/dist/{a386634d.js → dd629ee4.js} +801 -121
  4. package/dist/index.js +801 -121
  5. package/dist/static/svg/index.svg +1 -1
  6. package/dist/sw.js +1 -1
  7. package/dist/sw.js.map +1 -1
  8. package/dist/templates/components-body.html +1 -1
  9. package/dist/templates/components-head.html +1 -1
  10. package/out-tsc/src/contacts/ContactTickets.js +4 -6
  11. package/out-tsc/src/contacts/ContactTickets.js.map +1 -1
  12. package/out-tsc/src/contacts/events.js +3 -8
  13. package/out-tsc/src/contacts/events.js.map +1 -1
  14. package/out-tsc/src/imagepicker/CroppieCSS.js +254 -0
  15. package/out-tsc/src/imagepicker/CroppieCSS.js.map +1 -0
  16. package/out-tsc/src/imagepicker/ImagePicker.js +248 -0
  17. package/out-tsc/src/imagepicker/ImagePicker.js.map +1 -0
  18. package/out-tsc/src/interfaces.js.map +1 -1
  19. package/out-tsc/src/list/TembaMenu.js +1 -1
  20. package/out-tsc/src/list/TembaMenu.js.map +1 -1
  21. package/out-tsc/src/list/TicketList.js +16 -12
  22. package/out-tsc/src/list/TicketList.js.map +1 -1
  23. package/out-tsc/src/mask/Mask.js +36 -0
  24. package/out-tsc/src/mask/Mask.js.map +1 -0
  25. package/out-tsc/src/utils/index.js +24 -16
  26. package/out-tsc/src/utils/index.js.map +1 -1
  27. package/out-tsc/src/vectoricon/index.js +4 -1
  28. package/out-tsc/src/vectoricon/index.js.map +1 -1
  29. package/out-tsc/src/webchat/WebChat.js +515 -0
  30. package/out-tsc/src/webchat/WebChat.js.map +1 -0
  31. package/out-tsc/src/webchat/index.js +7 -0
  32. package/out-tsc/src/webchat/index.js.map +1 -0
  33. package/out-tsc/temba-modules.js +6 -0
  34. package/out-tsc/temba-modules.js.map +1 -1
  35. package/package.json +4 -2
  36. package/screenshots/truth/contacts/tickets-assignment.png +0 -0
  37. package/screenshots/truth/contacts/tickets.png +0 -0
  38. package/screenshots/truth/menu/menu-focused-with items.png +0 -0
  39. package/screenshots/truth/menu/menu-refresh-1.png +0 -0
  40. package/screenshots/truth/menu/menu-refresh-2.png +0 -0
  41. package/screenshots/truth/menu/menu-root.png +0 -0
  42. package/screenshots/truth/menu/menu-submenu.png +0 -0
  43. package/screenshots/truth/menu/menu-tasks-nextup.png +0 -0
  44. package/screenshots/truth/menu/menu-tasks.png +0 -0
  45. package/src/contacts/ContactTickets.ts +4 -6
  46. package/src/contacts/events.ts +3 -9
  47. package/src/imagepicker/CroppieCSS.ts +254 -0
  48. package/src/imagepicker/ImagePicker.ts +272 -0
  49. package/src/interfaces.ts +2 -1
  50. package/src/list/TembaMenu.ts +1 -1
  51. package/src/list/TicketList.ts +16 -12
  52. package/src/mask/Mask.ts +32 -0
  53. package/src/untyped.d.ts +1 -0
  54. package/src/utils/index.ts +26 -18
  55. package/src/vectoricon/index.ts +4 -1
  56. package/src/webchat/WebChat.ts +559 -0
  57. package/src/webchat/index.ts +6 -0
  58. package/static/svg/index.svg +1 -1
  59. package/static/svg/webchat.svg +1 -0
  60. package/static/svg/work/traced/camera-01.svg +1 -0
  61. package/static/svg/work/traced/send-03.svg +1 -0
  62. package/static/svg/work/used/camera-01.svg +4 -0
  63. package/static/svg/work/used/send-03.svg +3 -0
  64. package/svg.js +12 -8
  65. package/temba-modules.ts +6 -0
@@ -2,8 +2,8 @@ import { html, TemplateResult } from 'lit';
2
2
  import { property } from 'lit/decorators.js';
3
3
  import { TembaList } from './TembaList';
4
4
  import { Contact } from '../interfaces';
5
- import { renderUserAvatar } from '../contacts/events';
6
5
  import { Icon } from '../vectoricon';
6
+ import { renderAvatar } from '../utils';
7
7
 
8
8
  export class TicketList extends TembaList {
9
9
  @property({ type: String })
@@ -33,7 +33,7 @@ export class TicketList extends TembaList {
33
33
  >
34
34
  <div style="flex: 1; color:#333;">
35
35
  <div
36
- style="font-weight:400;line-height:1.6;display:-webkit-box;-webkit-box-orient: vertical; -webkit-line-clamp: 1;overflow: hidden;"
36
+ style="font-weight:400;line-height:1.6;padding-right:0.5em;display:-webkit-box;-webkit-box-orient: vertical; -webkit-line-clamp: 1;overflow: hidden;"
37
37
  >
38
38
  ${contact.name}
39
39
  </div>
@@ -72,22 +72,26 @@ export class TicketList extends TembaList {
72
72
  : null}
73
73
  </div>
74
74
  <div
75
- style="font-size:0.8em;display:flex;flex-direction:column;align-items:flex-end;max-width:60px;min-width:30px;border:0px solid green;text-align:right"
75
+ style="margin-right: -5px; margin-top: 0px;display:flex;flex-direction:column;align-items:flex-end;max-width:60px;min-width:30px;border:0px solid green;text-align:right"
76
76
  >
77
- <div style="padding:4px;padding-bottom:2px">
78
- <temba-date
79
- value=${contact.ticket.closed_on ||
80
- contact.ticket.last_activity_on}
81
- display="duration"
82
- ></temba-date>
83
- </div>
84
- <div style="font-size:0.7em;">
77
+ <div>
85
78
  ${!contact.ticket.closed_on && contact.ticket.assignee
86
- ? html`${renderUserAvatar(contact.ticket.assignee)}`
79
+ ? html`${renderAvatar({
80
+ user: contact.ticket.assignee,
81
+ scale: 0.8,
82
+ })}`
87
83
  : null}
88
84
  </div>
89
85
  </div>
90
86
  </div>
87
+
88
+ <div style="font-size:0.8em;text-align:right;border:0px solid red;">
89
+ <temba-date
90
+ value=${contact.ticket.closed_on ||
91
+ contact.ticket.last_activity_on}
92
+ display="duration"
93
+ ></temba-date>
94
+ </div>
91
95
  </div>
92
96
  `;
93
97
  };
@@ -0,0 +1,32 @@
1
+ import { LitElement, css, html } from 'lit';
2
+ import { property } from 'lit/decorators.js';
3
+
4
+ export class Mask extends LitElement {
5
+ static styles = css`
6
+ .mask {
7
+ position: fixed;
8
+ top: 0;
9
+ left: 0;
10
+ z-index: 100;
11
+ width: 100vw;
12
+ height: 100vh;
13
+ background: rgba(0, 0, 0, 0.6);
14
+ display: none;
15
+ align-items: center;
16
+ justify-content: center;
17
+ }
18
+
19
+ .show {
20
+ display: flex;
21
+ }
22
+ `;
23
+
24
+ @property({ type: Boolean })
25
+ show = false;
26
+
27
+ render() {
28
+ return html` <div class="mask ${this.show ? 'show' : ''}">
29
+ <slot></slot>
30
+ </div>`;
31
+ }
32
+ }
package/src/untyped.d.ts CHANGED
@@ -18,3 +18,4 @@ declare function mouseUp();
18
18
  declare function mouseClick(x: number, y: number);
19
19
  declare function setViewport({}: any);
20
20
  declare function waitForNetworkIdle();
21
+ declare module 'croppie';
@@ -4,6 +4,7 @@ import { Button } from '../button/Button';
4
4
  import { Dialog } from '../dialog/Dialog';
5
5
  import { Attachment, ContactField, Ticket, User } from '../interfaces';
6
6
  import ColorHash from 'color-hash';
7
+ import { userInfo } from 'os';
7
8
 
8
9
  export const DEFAULT_MEDIA_ENDPOINT = '/api/v2/media.json';
9
10
 
@@ -718,21 +719,16 @@ export const renderAvatar = (input: {
718
719
  name?: string;
719
720
  user?: User;
720
721
  icon?: string;
721
- image?: string;
722
722
  position?: string;
723
723
  tip?: boolean;
724
+ scale?: number;
724
725
  }) => {
725
726
  if (!input.position) {
726
727
  input.position = 'right';
727
728
  }
728
729
 
729
- // just a url
730
- if (input.image) {
731
- return html`<img src="${input.image}" />`;
732
- }
733
-
734
730
  let text = input.name;
735
- if (input.user) {
731
+ if (input.user && input.user.first_name && input.user.last_name) {
736
732
  text = `${input.user.first_name} ${input.user.last_name}`;
737
733
  }
738
734
 
@@ -740,31 +736,43 @@ export const renderAvatar = (input: {
740
736
  return null;
741
737
  }
742
738
 
743
- const color = colorHash.hex(text);
744
- const initials = extractInitials(text);
739
+ let initials = '';
740
+ let color = colorHash.hex(text);
741
+ // just a url
742
+ if (input.user && input.user.avatar) {
743
+ color = `url('${input.user.avatar}') center / contain no-repeat`;
744
+ } else if (text) {
745
+ initials = extractInitials(text);
746
+ }
747
+
745
748
  const avatar = html`
746
749
  <div
747
- style="border: 0px solid red; display:flex; flex-direction: column; align-items:center;"
750
+ style="display:flex; flex-direction: column; align-items:center;transform:scale(${input.scale ||
751
+ 1});"
748
752
  >
749
753
  <div
750
754
  class="avatar-circle"
751
755
  style="
752
756
  display: flex;
753
- height: 2em;
754
- width: 2em;
757
+ height: 30px;
758
+ width: 30px;
755
759
  flex-direction: row;
756
760
  align-items: center;
757
761
  color: #fff;
758
762
  border-radius: 100%;
759
763
  font-weight: 400;
760
- border: 0.3em solid rgba(0,0,0,.05);
764
+ overflow: hidden;
765
+ font-size: 12px;
766
+ box-shadow: inset 0 0 0 3px rgba(0, 0, 0, 0.1);
761
767
  background:${color}"
762
768
  >
763
- <div
764
- style="border: 0px solid red; display:flex; flex-direction: column; align-items:center;flex-grow:1"
765
- >
766
- <div style="border:0px solid blue;">${initials}</div>
767
- </div>
769
+ ${initials
770
+ ? html` <div
771
+ style="border: 0px solid red; display:flex; flex-direction: column; align-items:center;flex-grow:1"
772
+ >
773
+ <div style="border:0px solid blue;">${initials}</div>
774
+ </div>`
775
+ : null}
768
776
  </div>
769
777
  </div>
770
778
  `;
@@ -1,5 +1,5 @@
1
1
  // for cache busting we dynamically generate a fingerprint, use yarn svg to update
2
- export const SVG_FINGERPRINT = '963a11882da2ee8b18c878e911d8eaf1';
2
+ export const SVG_FINGERPRINT = '819ccb7b7ad3480361d5afba355b4e6f';
3
3
 
4
4
  // only icons below are included in the sprite sheet
5
5
  export enum Icon {
@@ -162,6 +162,7 @@ export enum Icon {
162
162
  search = 'search-refraction',
163
163
  select_open = 'chevron-down',
164
164
  select_clear = 'x',
165
+ send = 'send-03',
165
166
  service = 'magic-wand-01',
166
167
  service_end = 'log-out-04',
167
168
  settings = 'settings-02',
@@ -171,6 +172,7 @@ export enum Icon {
171
172
  sort_down = 'sort-arrow-down',
172
173
  sort_up = 'sort-arrow-up',
173
174
  staff = 'hard-drive',
175
+ submit = 'check',
174
176
  tickets = 'agent',
175
177
  tickets_all = 'archive',
176
178
  tickets_closed = 'check',
@@ -199,6 +201,7 @@ export enum Icon {
199
201
  updated = 'edit-02',
200
202
  up = 'chevron-up',
201
203
  upload = 'upload-cloud-01',
204
+ upload_image = 'camera-01',
202
205
  usages = 'link-04',
203
206
  user = 'users-01',
204
207
  users = 'users-01',