@nyaruka/temba-components 0.91.6 → 0.92.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 +9 -0
  2. package/demo/index.html +1 -1
  3. package/dist/temba-components.js +760 -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 +518 -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 +609 -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,107 +0,0 @@
1
- import { fixture, assert, expect } from '@open-wc/testing';
2
- import { useFakeTimers } from 'sinon';
3
- import { ContactHistory } from '../src/contacts/ContactHistory';
4
- import {
5
- assertScreenshot,
6
- getClip,
7
- getHTML,
8
- loadStore,
9
- mockGET,
10
- mockNow
11
- } from '../test/utils.test';
12
- import './utils.test';
13
-
14
- export const createHistory = async (def: string) => {
15
- const parentNode = document.createElement('div');
16
- parentNode.setAttribute(
17
- 'style',
18
- 'width: 500px;height:750px;display:flex;flex-direction:column;flex-grow:1;min-height:0;'
19
- );
20
- const history = (await fixture(def, { parentNode })) as ContactHistory;
21
-
22
- // make sure our initial fetch is made
23
- await history.httpComplete;
24
-
25
- return history;
26
- };
27
-
28
- const getHistoryHTML = (attrs: any = {} as any) =>
29
- // attrs = "min-height:0;display:flex;flex-grow:1;flex-direction:column";
30
- getHTML('temba-contact-history', attrs);
31
-
32
- const getHistoryClip = (ele: ContactHistory) => {
33
- const clip = getClip(ele);
34
- clip.height = Math.min(clip.height, 750);
35
- clip.bottom = clip.top + clip.height;
36
- return clip;
37
- };
38
-
39
- // stub our current date for consistent screenshots
40
- mockNow('2021-03-31T00:31:00.000-00:00');
41
- let clock: any;
42
-
43
- describe('temba-contact-history', () => {
44
- beforeEach(async () => {
45
- clock = useFakeTimers();
46
-
47
- mockGET(
48
- /\/contact\/history\/contact-dave-active\/.*/,
49
- '/test-assets/contacts/history.json'
50
- );
51
-
52
- mockGET(
53
- /\/api\/v2\/tickets\.json\?contact=contact-dave-active/,
54
- '/test-assets/api/tickets.json'
55
- );
56
-
57
- await loadStore();
58
- });
59
-
60
- afterEach(function () {
61
- clock.restore();
62
- });
63
-
64
- it('can be created', async () => {
65
- const history = await createHistory(getHistoryHTML());
66
- assert.instanceOf(history, ContactHistory);
67
- });
68
-
69
- it('renders history', async () => {
70
- const history = await createHistory(
71
- getHistoryHTML({
72
- uuid: 'contact-dave-active'
73
- })
74
- );
75
-
76
- // we should have scrolled to the bottom, but the scroll
77
- // happens in a window timeout
78
- await clock.runAllAsync();
79
- await history.updateComplete;
80
-
81
- const events = history.shadowRoot.querySelector('.events');
82
- const top = events.scrollHeight - events.getBoundingClientRect().height;
83
- expect(top).to.equal(571);
84
- // make sure we actually scrolled to there
85
- expect(events.scrollTop).to.equal(top);
86
- await assertScreenshot('contacts/history', getHistoryClip(history));
87
- });
88
-
89
- it('expands event groups', async () => {
90
- const history = await createHistory(
91
- getHistoryHTML({
92
- uuid: 'contact-dave-active'
93
- })
94
- );
95
-
96
- // our groups with collapsed events
97
- const groups = [3, 5, 7];
98
- for (const idx of groups) {
99
- const group = history.shadowRoot.querySelector(
100
- `.event-count[data-group-index='${idx}']`
101
- ) as HTMLDivElement;
102
- group.click();
103
- await clock.runAllAsync();
104
- expect(group.parentElement.classList.contains('expanded')).equal(true);
105
- }
106
- });
107
- });