@adatechnology/conversations-ui 0.4.2 → 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 (110) hide show
  1. package/README.md +231 -0
  2. package/dist/{ConversationSimulatorPanel-DnXElfY8.d.ts → ConversationSimulatorPanel-CrfFjiWh.d.ts} +2 -268
  3. package/dist/{chunk-PJNR6UMN.js → chunk-CBYEHPX6.js} +1 -63
  4. package/dist/{chunk-4P5KMWOI.js → chunk-FAQLC3TX.js} +327 -522
  5. package/dist/{chunk-HMCOTZAX.js → chunk-HOKNKXIT.js} +1 -1
  6. package/dist/chunk-MRVFFJEH.js +64 -0
  7. package/dist/chunk-O6457XHK.js +255 -0
  8. package/dist/chunk-OVFCLRQQ.js +84 -0
  9. package/dist/flows/index.js +5 -3
  10. package/dist/index.d.ts +21 -5
  11. package/dist/index.js +783 -807
  12. package/dist/participant/index.d.ts +186 -0
  13. package/dist/participant/index.js +1708 -0
  14. package/dist/preview/index.d.ts +4 -2
  15. package/dist/preview/index.js +4 -2
  16. package/dist/quickReply.types-B4gmZsSr.d.ts +274 -0
  17. package/dist/styles.css +689 -0
  18. package/package.json +8 -4
  19. package/src/ChannelIcon.tsx +2 -0
  20. package/src/MessageText.test.tsx +76 -0
  21. package/src/MessageText.tsx +28 -12
  22. package/src/MessageTextCopiedBadge.tsx +15 -0
  23. package/src/StatusTicks.test.tsx +51 -0
  24. package/src/StatusTicks.tsx +36 -6
  25. package/src/buildOutput.test.ts +41 -0
  26. package/src/channelCapability.test.ts +17 -0
  27. package/src/conversationChannel.test.ts +30 -1
  28. package/src/conversationChannel.ts +19 -1
  29. package/src/legacyChannels.golden.test.ts +89 -0
  30. package/src/legacyDefaults.golden.test.tsx +127 -0
  31. package/src/legacyStyles.fixture.css +1121 -0
  32. package/src/legacyStyles.golden.test.ts +121 -0
  33. package/src/messageTextCopyInteraction.test.ts +75 -0
  34. package/src/messageTextCopyInteraction.ts +37 -0
  35. package/src/participant/ParticipantAttachmentItem.tsx +77 -0
  36. package/src/participant/ParticipantChannelBadges.test.tsx +59 -0
  37. package/src/participant/ParticipantChannelBadges.tsx +75 -0
  38. package/src/participant/ParticipantComposer.test.tsx +97 -0
  39. package/src/participant/ParticipantComposer.tsx +167 -0
  40. package/src/participant/ParticipantConversations.test.tsx +90 -0
  41. package/src/participant/ParticipantConversations.tsx +49 -0
  42. package/src/participant/ParticipantConversationsScreen.tsx +78 -0
  43. package/src/participant/ParticipantInbox.test.tsx +244 -0
  44. package/src/participant/ParticipantInbox.tsx +149 -0
  45. package/src/participant/ParticipantInboxRow.tsx +75 -0
  46. package/src/participant/ParticipantInboxSearchField.tsx +34 -0
  47. package/src/participant/ParticipantLoadState.tsx +27 -0
  48. package/src/participant/ParticipantMessageBubble.test.tsx +167 -0
  49. package/src/participant/ParticipantMessageBubble.tsx +185 -0
  50. package/src/participant/ParticipantProtocolBadge.tsx +74 -0
  51. package/src/participant/ParticipantProtocolView.test.tsx +208 -0
  52. package/src/participant/ParticipantThread.test.tsx +149 -0
  53. package/src/participant/ParticipantThread.tsx +184 -0
  54. package/src/participant/ParticipantThreadScreen.tsx +135 -0
  55. package/src/participant/bindAttachmentUrlResolver.test.ts +25 -0
  56. package/src/participant/bindAttachmentUrlResolver.ts +7 -0
  57. package/src/participant/index.ts +26 -0
  58. package/src/participant/participant.types.ts +52 -0
  59. package/src/participant/participantApi.types.ts +59 -0
  60. package/src/participant/participantAttachmentUrl.test.ts +32 -0
  61. package/src/participant/participantAttachmentUrl.ts +10 -0
  62. package/src/participant/participantBubbleActions.test.ts +44 -0
  63. package/src/participant/participantBubbleActions.ts +40 -0
  64. package/src/participant/participantChannels.test.ts +42 -0
  65. package/src/participant/participantChannels.ts +33 -0
  66. package/src/participant/participantDrafts.test.ts +65 -0
  67. package/src/participant/participantDrafts.ts +50 -0
  68. package/src/participant/participantFileValidation.test.ts +86 -0
  69. package/src/participant/participantFileValidation.ts +72 -0
  70. package/src/participant/participantFixtures.test-helper.ts +41 -0
  71. package/src/participant/participantGrouping.test.ts +236 -0
  72. package/src/participant/participantGrouping.ts +90 -0
  73. package/src/participant/participantInboxState.test.ts +69 -0
  74. package/src/participant/participantInboxState.ts +74 -0
  75. package/src/participant/participantLabels.ts +115 -0
  76. package/src/participant/participantLoadView.test.ts +23 -0
  77. package/src/participant/participantLoadView.ts +21 -0
  78. package/src/participant/participantMessages.test.ts +128 -0
  79. package/src/participant/participantMessages.ts +73 -0
  80. package/src/participant/participantNewMessages.test.ts +54 -0
  81. package/src/participant/participantNewMessages.ts +29 -0
  82. package/src/participant/participantProtocol.test.ts +104 -0
  83. package/src/participant/participantProtocol.ts +52 -0
  84. package/src/participant/participantProtocolCopy.test.ts +45 -0
  85. package/src/participant/participantProtocolCopy.ts +32 -0
  86. package/src/participant/participantQuickReply.test.ts +23 -0
  87. package/src/participant/participantQuickReply.ts +6 -0
  88. package/src/participant/participantScroll.test.ts +69 -0
  89. package/src/participant/participantScroll.ts +43 -0
  90. package/src/participant/participantSendController.test.ts +201 -0
  91. package/src/participant/participantSendController.ts +134 -0
  92. package/src/participant/participantSendStates.ts +31 -0
  93. package/src/participant/participantTheme.ts +20 -0
  94. package/src/participant/participantThreadState.test.ts +75 -0
  95. package/src/participant/participantThreadState.ts +59 -0
  96. package/src/participant/shouldMarkRead.test.ts +24 -0
  97. package/src/participant/shouldMarkRead.ts +16 -0
  98. package/src/participant/useDocumentVisibility.ts +18 -0
  99. package/src/participant/useParticipantConversationView.ts +60 -0
  100. package/src/participant/useParticipantDraft.ts +45 -0
  101. package/src/participant/useParticipantInbox.ts +57 -0
  102. package/src/participant/useParticipantMarkRead.ts +26 -0
  103. package/src/participant/useParticipantRevalidation.ts +36 -0
  104. package/src/participant/useParticipantSend.ts +84 -0
  105. package/src/participant/useParticipantThread.ts +116 -0
  106. package/src/participant/useParticipantThreadScroll.ts +26 -0
  107. package/src/participant/useStickToBottom.ts +77 -0
  108. package/src/preview/ConversationSimulatorPanel.tsx +8 -0
  109. package/src/styles.css +178 -0
  110. package/src/types.ts +3 -1
@@ -0,0 +1,186 @@
1
+ import * as react from 'react';
2
+ import { ReactNode } from 'react';
3
+ import { ParticipantConversationSummary, ParticipantSubjectRef, ParticipantConversationPage, ParticipantMessage, ParticipantAttachment } from '@adatechnology/conversation-contracts';
4
+ export { ParticipantAttachment, ParticipantConversationPage, ParticipantConversationSummary, ParticipantMessage, ParticipantSubjectRef } from '@adatechnology/conversation-contracts';
5
+ import { C as ConversationChannel, a as ConversationsTheme, Q as QuickReply } from '../quickReply.types-B4gmZsSr.js';
6
+
7
+ type ParticipantSubjectGroup = {
8
+ readonly subjectType: string;
9
+ readonly label: string;
10
+ readonly icon?: ReactNode;
11
+ };
12
+ /** Host-drawn icon for a list row; null/undefined falls back to the subject group icon. */
13
+ type ParticipantSubjectIconRenderer = (conversation: ParticipantConversationSummary) => ReactNode;
14
+ type ParticipantInboxSection = {
15
+ /** 'awaiting' | 'closed' | 'other' or the subjectType of a group. */
16
+ readonly key: string;
17
+ /** Absent for groups: the host resolves it from subjectGroups. */
18
+ readonly label?: string;
19
+ readonly conversations: readonly ParticipantConversationSummary[];
20
+ readonly unreadCount: number;
21
+ };
22
+ type ParticipantInboxFilter = {
23
+ readonly subjectType: string;
24
+ readonly label: string;
25
+ readonly unreadCount: number;
26
+ };
27
+ type ParticipantInboxView = {
28
+ readonly sections: readonly ParticipantInboxSection[];
29
+ readonly filters: readonly ParticipantInboxFilter[];
30
+ readonly showFilters: boolean;
31
+ /** The filter actually applied: 'all' when the requested one has no conversations left. */
32
+ readonly activeFilter: string;
33
+ /** The search finds conversations, but none under the active subject filter. */
34
+ readonly hasMatchesOutsideFilter: boolean;
35
+ };
36
+ type GroupParticipantConversationsParams = {
37
+ readonly conversations: readonly ParticipantConversationSummary[];
38
+ readonly subjectGroups: readonly ParticipantSubjectGroup[];
39
+ /** subjectType, or 'all'/undefined for everything. */
40
+ readonly filter?: string;
41
+ /** Narrows the rows only: chips and their counts always describe the whole list. */
42
+ readonly searchQuery?: string;
43
+ };
44
+ type ParticipantConversationsClassNames = {
45
+ readonly root: string;
46
+ readonly inbox: string;
47
+ readonly thread: string;
48
+ };
49
+
50
+ type ParticipantSendInput = {
51
+ readonly subject: ParticipantSubjectRef;
52
+ /** Generated by the package (crypto.randomUUID). The host uses it as Idempotency-Key; a resend repeats it. */
53
+ readonly clientMessageId: string;
54
+ readonly text?: string;
55
+ readonly files?: readonly File[];
56
+ };
57
+ type ParticipantSendResult = {
58
+ readonly outcome: 'sent';
59
+ readonly message: ParticipantMessage;
60
+ } | {
61
+ readonly outcome: 'queued';
62
+ };
63
+ type ParticipantConversationEvent = {
64
+ readonly type: 'inbox-changed';
65
+ } | {
66
+ readonly type: 'conversation-changed';
67
+ readonly subject: ParticipantSubjectRef;
68
+ };
69
+ interface ParticipantConversationsApi {
70
+ listConversations(params?: {
71
+ readonly cursor?: string;
72
+ }): Promise<ParticipantConversationPage>;
73
+ fetchMessages(subject: ParticipantSubjectRef, params?: {
74
+ readonly before?: string;
75
+ readonly limit?: number;
76
+ }): Promise<readonly ParticipantMessage[]>;
77
+ /** Throwing means failed; the package shows a retry affordance and repeats the SAME clientMessageId. */
78
+ sendMessage(input: ParticipantSendInput): Promise<ParticipantSendResult>;
79
+ /** Marks the other side's messages of THAT subject as read, never "all". */
80
+ markRead(subject: ParticipantSubjectRef): Promise<void>;
81
+ resolveAttachmentUrl(attachment: ParticipantAttachment, disposition?: 'inline' | 'attachment'): Promise<string>;
82
+ openConversation?(subject: ParticipantSubjectRef): Promise<ParticipantConversationSummary>;
83
+ subscribe?(listener: (event: ParticipantConversationEvent) => void): () => void;
84
+ }
85
+ type ParticipantPendingAttachment = {
86
+ readonly filename: string;
87
+ readonly mimeType: string;
88
+ readonly sizeBytes: number;
89
+ };
90
+ /** Message the host keeps in its durable queue and hands back to the package. */
91
+ type ParticipantPendingMessage = {
92
+ readonly clientMessageId: string;
93
+ readonly subject: ParticipantSubjectRef;
94
+ readonly text?: string;
95
+ readonly attachments?: readonly ParticipantPendingAttachment[];
96
+ readonly createdAt: string;
97
+ readonly state: 'queued' | 'failed';
98
+ };
99
+ /** Message still living only in the memory of the screen: being sent, queued by the host and not yet reflected, sent but not yet echoed, or failed. */
100
+ type ParticipantLocalPendingMessage = Omit<ParticipantPendingMessage, 'state'> & {
101
+ readonly state: 'sending' | 'queued' | 'failed' | 'sent';
102
+ };
103
+
104
+ type ParticipantConversationsLabels = {
105
+ readonly inboxTitle: string;
106
+ readonly sectionAwaiting: string;
107
+ readonly sectionClosed: string;
108
+ readonly sectionOther: string;
109
+ readonly filterAll: string;
110
+ readonly filtersGroup: string;
111
+ readonly emptyInbox: string;
112
+ /** Uses the `{count}` placeholder. */
113
+ readonly unreadCount: string;
114
+ readonly back: string;
115
+ readonly openSubject: string;
116
+ readonly me: string;
117
+ readonly newMessages: string;
118
+ readonly loadOlder: string;
119
+ readonly closedNotice: string;
120
+ readonly messageInputLabel: string;
121
+ readonly messageInputPlaceholder: string;
122
+ readonly send: string;
123
+ readonly attach: string;
124
+ readonly attachmentsList: string;
125
+ readonly removeAttachment: string;
126
+ readonly attachmentTooLarge: string;
127
+ readonly attachmentTypeNotAccepted: string;
128
+ readonly quickRepliesGroup: string;
129
+ readonly downloadAttachment: string;
130
+ readonly statusSending: string;
131
+ readonly statusQueued: string;
132
+ readonly statusSent: string;
133
+ readonly statusDelivered: string;
134
+ readonly statusRead: string;
135
+ readonly statusFailed: string;
136
+ readonly statusFailedShort: string;
137
+ readonly retry: string;
138
+ readonly discard: string;
139
+ readonly edit: string;
140
+ readonly notFound: string;
141
+ readonly loading: string;
142
+ readonly loadError: string;
143
+ readonly loadMore: string;
144
+ readonly searchLabel: string;
145
+ readonly searchPlaceholder: string;
146
+ readonly noResults: string;
147
+ readonly noResultsInFilter: string;
148
+ readonly noResultsLoadedOnly: string;
149
+ /** Spoken before the protocol code, e.g. "Protocol 261009-K7M2". */
150
+ readonly protocolPrefix: string;
151
+ readonly copyProtocol: string;
152
+ readonly protocolCopied: string;
153
+ readonly channelsGroup: string;
154
+ readonly channelApp: string;
155
+ readonly channelWhatsapp: string;
156
+ readonly channelEmail: string;
157
+ readonly channelPortal: string;
158
+ readonly channelWebchat: string;
159
+ };
160
+ declare const DEFAULT_PARTICIPANT_CONVERSATIONS_LABELS: ParticipantConversationsLabels;
161
+
162
+ type ParticipantConversationsProps = {
163
+ api: ParticipantConversationsApi;
164
+ subjectGroups: readonly ParticipantSubjectGroup[];
165
+ /** undefined renders the list; defined renders that conversation. */
166
+ selected: ParticipantSubjectRef | undefined;
167
+ onSelect: (subject: ParticipantSubjectRef) => void;
168
+ onBack?: () => void;
169
+ channel?: ConversationChannel;
170
+ labels?: Partial<ParticipantConversationsLabels>;
171
+ locale?: string;
172
+ theme?: ConversationsTheme;
173
+ className?: string;
174
+ classNames?: Partial<ParticipantConversationsClassNames>;
175
+ pendingMessages?: readonly ParticipantPendingMessage[];
176
+ onRetryPending?: (clientMessageId: string) => void;
177
+ quickReplies?: readonly QuickReply[];
178
+ renderSubjectIcon?: ParticipantSubjectIconRenderer;
179
+ renderSubjectCard?: (conversation: ParticipantConversationSummary) => ReactNode;
180
+ onOpenSubject?: (subject: ParticipantSubjectRef) => void;
181
+ };
182
+ declare function ParticipantConversations(props: ParticipantConversationsProps): react.JSX.Element;
183
+
184
+ declare function groupParticipantConversations(params: GroupParticipantConversationsParams): ParticipantInboxView;
185
+
186
+ export { DEFAULT_PARTICIPANT_CONVERSATIONS_LABELS, type GroupParticipantConversationsParams, type ParticipantConversationEvent, ParticipantConversations, type ParticipantConversationsApi, type ParticipantConversationsClassNames, type ParticipantConversationsLabels, type ParticipantConversationsProps, type ParticipantInboxSection, type ParticipantInboxView, type ParticipantLocalPendingMessage, type ParticipantPendingMessage, type ParticipantSendInput, type ParticipantSendResult, type ParticipantSubjectGroup, type ParticipantSubjectIconRenderer, groupParticipantConversations };