@adatechnology/conversations-ui 0.5.0 → 0.6.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 (50) hide show
  1. package/README.md +82 -20
  2. package/dist/{chunk-JXJCPN34.js → chunk-FAQLC3TX.js} +1 -1
  3. package/dist/{chunk-RJMSM3YA.js → chunk-O6457XHK.js} +17 -11
  4. package/dist/chunk-OVFCLRQQ.js +84 -0
  5. package/dist/index.d.ts +14 -4
  6. package/dist/index.js +3 -3
  7. package/dist/participant/index.d.ts +25 -1
  8. package/dist/participant/index.js +454 -194
  9. package/dist/preview/index.js +2 -2
  10. package/dist/styles.css +98 -0
  11. package/package.json +2 -2
  12. package/src/MessageBubble.test.tsx +2 -2
  13. package/src/MessageText.test.tsx +27 -10
  14. package/src/MessageText.tsx +25 -17
  15. package/src/MessageTextCopiedBadge.tsx +10 -2
  16. package/src/StatusTicks.test.tsx +27 -6
  17. package/src/StatusTicks.tsx +30 -15
  18. package/src/legacyChannels.golden.test.ts +89 -0
  19. package/src/legacyDefaults.golden.test.tsx +127 -0
  20. package/src/legacyStyles.fixture.css +1121 -0
  21. package/src/legacyStyles.golden.test.ts +121 -0
  22. package/src/messageTextCopyInteraction.test.ts +75 -0
  23. package/src/messageTextCopyInteraction.ts +37 -0
  24. package/src/participant/ParticipantChannelBadges.test.tsx +59 -0
  25. package/src/participant/ParticipantChannelBadges.tsx +75 -0
  26. package/src/participant/ParticipantConversations.tsx +13 -6
  27. package/src/participant/ParticipantConversationsScreen.tsx +18 -7
  28. package/src/participant/ParticipantInbox.test.tsx +99 -2
  29. package/src/participant/ParticipantInbox.tsx +27 -46
  30. package/src/participant/ParticipantInboxRow.tsx +75 -0
  31. package/src/participant/ParticipantInboxSearchField.tsx +34 -0
  32. package/src/participant/ParticipantMessageBubble.test.tsx +2 -0
  33. package/src/participant/ParticipantMessageBubble.tsx +3 -3
  34. package/src/participant/ParticipantProtocolBadge.tsx +74 -0
  35. package/src/participant/ParticipantProtocolView.test.tsx +208 -0
  36. package/src/participant/ParticipantThread.test.tsx +19 -2
  37. package/src/participant/ParticipantThread.tsx +25 -15
  38. package/src/participant/index.ts +1 -0
  39. package/src/participant/participant.types.ts +9 -0
  40. package/src/participant/participantChannels.test.ts +42 -0
  41. package/src/participant/participantChannels.ts +33 -0
  42. package/src/participant/participantGrouping.test.ts +101 -3
  43. package/src/participant/participantGrouping.ts +20 -7
  44. package/src/participant/participantLabels.ts +29 -0
  45. package/src/participant/participantProtocol.test.ts +104 -0
  46. package/src/participant/participantProtocol.ts +52 -0
  47. package/src/participant/participantProtocolCopy.test.ts +45 -0
  48. package/src/participant/participantProtocolCopy.ts +32 -0
  49. package/src/styles.css +19 -1
  50. package/dist/chunk-WSFGNR5R.js +0 -55
@@ -0,0 +1,127 @@
1
+ import { describe, expect, it } from 'bun:test'
2
+ import { renderToStaticMarkup } from 'react-dom/server'
3
+
4
+ import { MessageBubble } from './MessageBubble'
5
+ import { MessageText } from './MessageText'
6
+ import { MessageTextCopiedBadge } from './MessageTextCopiedBadge'
7
+ import { StatusTicks } from './StatusTicks'
8
+ import type { MessagePayload } from './types'
9
+
10
+ // Literal markup rendered by @adatechnology/conversations-ui 0.4.2 (b9f1ef6): the default appearance of
11
+ // these shared components must never drift, because hosts upgrade without touching their markup.
12
+ const LEGACY_TEXT_MARKUP =
13
+ '<div class="text-[14.2px] leading-[19px] whitespace-pre-wrap break-words select-all [&amp;_strong]:font-bold [&amp;_em]:italic [&amp;_del]:line-through"><div><strong>oi</strong></div></div>'
14
+
15
+ const LEGACY_TEMPLATE_MARKUP = '<p class="text-sm italic text-[#667781] dark:text-[#8696a0]">Olá modelo</p>'
16
+
17
+ const LEGACY_TICKS_SENT =
18
+ '<span class="cursor-help leading-none flex items-center text-black/40 dark:text-white/40"><svg viewBox="0 0 20 12" width="15" height="9" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M1 6.5L5 10.5L14.5 1" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"></path></svg></span>'
19
+
20
+ const LEGACY_TICKS_DELIVERED =
21
+ '<span class="cursor-help leading-none flex items-center text-black/40 dark:text-white/40"><svg viewBox="0 0 20 12" width="15" height="9" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M1 6.5L4.5 10L11 2" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"></path><path d="M6 6.5L9.5 10L19 1" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"></path></svg></span>'
22
+
23
+ const LEGACY_TICKS_READ =
24
+ '<span class="cursor-help leading-none flex items-center text-sky-500"><svg viewBox="0 0 20 12" width="15" height="9" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M1 6.5L4.5 10L11 2" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"></path><path d="M6 6.5L9.5 10L19 1" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"></path></svg></span>'
25
+
26
+ const LEGACY_TICKS_FAILED =
27
+ '<span class="cursor-help leading-none flex items-center text-red-500"><svg xmlns="http://www.w3.org/2000/svg" width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-triangle-alert lucide-alert-triangle" aria-hidden="true"><path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"></path><path d="M12 9v4"></path><path d="M12 17h.01"></path></svg></span>'
28
+
29
+ const LEGACY_TICKS_READ_WITH_TITLE =
30
+ '<span class="cursor-help leading-none flex items-center text-sky-500" data-cv-tooltip="x"><svg viewBox="0 0 20 12" width="15" height="9" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M1 6.5L4.5 10L11 2" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"></path><path d="M6 6.5L9.5 10L19 1" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"></path></svg></span>'
31
+
32
+ const LEGACY_COPIED_BADGE_MARKUP =
33
+ '<span class="absolute top-0 right-0 -translate-y-full bg-[#3b4a54] text-white text-[11px] px-1.5 py-0.5 rounded shadow-lg">Copiado!</span>'
34
+
35
+ const LEGACY_UNKNOWN_STATUS_MARKUP = LEGACY_TICKS_DELIVERED
36
+
37
+ function buildMessage(type: MessagePayload['type'], content: string): MessagePayload {
38
+ return {
39
+ id: 'msg-1',
40
+ type,
41
+ direction: 'inbound',
42
+ sender: 'customer',
43
+ timestamp: '2026-08-05T12:00:00.000Z',
44
+ content,
45
+ }
46
+ }
47
+
48
+ describe('MessageText mantém o markup da 0.4.2 por padrão', () => {
49
+ it('G1: texto comum é um div clicável sem role, tabindex nem teclado', () => {
50
+ const markup = renderToStaticMarkup(<MessageText message={buildMessage('text', '*oi*')} />)
51
+
52
+ expect(markup).toBe(LEGACY_TEXT_MARKUP)
53
+ expect(markup).not.toContain('role=')
54
+ expect(markup).not.toContain('tabindex')
55
+ })
56
+
57
+ it('G2: template continua sendo o parágrafo em itálico', () => {
58
+ const markup = renderToStaticMarkup(<MessageText message={buildMessage('template', 'Olá modelo')} />)
59
+
60
+ expect(markup).toBe(LEGACY_TEMPLATE_MARKUP)
61
+ })
62
+
63
+ it('G3: o selo de cópia é "Copiado!" com a classe Tailwind exata', () => {
64
+ expect(renderToStaticMarkup(<MessageTextCopiedBadge />)).toBe(LEGACY_COPIED_BADGE_MARKUP)
65
+ })
66
+ })
67
+
68
+ describe('StatusTicks mantém o markup da 0.4.2 por padrão', () => {
69
+ it('G4: sent', () => {
70
+ expect(renderToStaticMarkup(<StatusTicks status="sent" />)).toBe(LEGACY_TICKS_SENT)
71
+ })
72
+
73
+ it('G4: delivered', () => {
74
+ expect(renderToStaticMarkup(<StatusTicks status="delivered" />)).toBe(LEGACY_TICKS_DELIVERED)
75
+ })
76
+
77
+ it('G4: read', () => {
78
+ expect(renderToStaticMarkup(<StatusTicks status="read" />)).toBe(LEGACY_TICKS_READ)
79
+ })
80
+
81
+ it('G4: failed', () => {
82
+ expect(renderToStaticMarkup(<StatusTicks status="failed" />)).toBe(LEGACY_TICKS_FAILED)
83
+ })
84
+
85
+ it('G5: status desconhecido desenha dois tiques cinza', () => {
86
+ expect(renderToStaticMarkup(<StatusTicks status="pending" />)).toBe(LEGACY_UNKNOWN_STATUS_MARKUP)
87
+ expect(renderToStaticMarkup(<StatusTicks status="xyz" />)).toBe(LEGACY_UNKNOWN_STATUS_MARKUP)
88
+ })
89
+
90
+ it('G5: queued e bounced, que a 0.4.2 nunca recebia, também caem nos dois tiques cinza', () => {
91
+ expect(renderToStaticMarkup(<StatusTicks status="queued" />)).toBe(LEGACY_UNKNOWN_STATUS_MARKUP)
92
+ expect(renderToStaticMarkup(<StatusTicks status="bounced" />)).toBe(LEGACY_UNKNOWN_STATUS_MARKUP)
93
+ })
94
+
95
+ it('G6: title vira data-cv-tooltip e nunca aria-label', () => {
96
+ const markup = renderToStaticMarkup(<StatusTicks status="read" title="x" />)
97
+
98
+ expect(markup).toBe(LEGACY_TICKS_READ_WITH_TITLE)
99
+ expect(markup).toContain('data-cv-tooltip="x"')
100
+ expect(markup).not.toContain('aria-label')
101
+ })
102
+ })
103
+
104
+ describe('MessageBubble mantém o selo da 0.4.2', () => {
105
+ it('G7: mensagem enviada e lida contém o StatusTicks idêntico ao da 0.4.2', () => {
106
+ const message: MessagePayload = {
107
+ ...buildMessage('text', 'oi'),
108
+ direction: 'outbound',
109
+ sender: 'agent',
110
+ status: 'read',
111
+ }
112
+
113
+ expect(renderToStaticMarkup(<MessageBubble message={message} isMine />)).toContain(LEGACY_TICKS_READ)
114
+ })
115
+
116
+ it('G7: bounced no balão não vira falha: sem anel de erro e com dois tiques cinza', () => {
117
+ const message: MessagePayload = {
118
+ ...buildMessage('text', 'oi'),
119
+ direction: 'outbound',
120
+ sender: 'agent',
121
+ status: 'bounced',
122
+ }
123
+ const markup = renderToStaticMarkup(<MessageBubble message={message} isMine />)
124
+
125
+ expect(markup).toContain(LEGACY_TICKS_DELIVERED)
126
+ })
127
+ })