@mantine-vue/whatsapp-inbox 3.2.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 (111) hide show
  1. package/README.md +88 -0
  2. package/cjs/index.cjs +11842 -0
  3. package/cjs/index.cjs.map +1 -0
  4. package/esm/index.mjs +11704 -0
  5. package/esm/index.mjs.map +1 -0
  6. package/lib/WhatsAppInbox.context.d.ts +70 -0
  7. package/lib/component-props.d.ts +138 -0
  8. package/lib/components/WhatsAppAttachmentPreview/WhatsAppAttachmentPreview.d.ts +8 -0
  9. package/lib/components/WhatsAppAttachmentPreview/WhatsAppAttachmentPreview.types.d.ts +33 -0
  10. package/lib/components/WhatsAppAttachmentPreview/WhatsAppAttachmentPreview.vue.d.ts +19 -0
  11. package/lib/components/WhatsAppAttachmentPreview/index.d.ts +1 -0
  12. package/lib/components/WhatsAppComposer/WhatsAppComposer.d.ts +10 -0
  13. package/lib/components/WhatsAppComposer/WhatsAppComposer.types.d.ts +173 -0
  14. package/lib/components/WhatsAppComposer/WhatsAppComposer.vue.d.ts +52 -0
  15. package/lib/components/WhatsAppComposer/index.d.ts +1 -0
  16. package/lib/components/WhatsAppContactPanel/WhatsAppContactPanel.d.ts +9 -0
  17. package/lib/components/WhatsAppContactPanel/WhatsAppContactPanel.types.d.ts +40 -0
  18. package/lib/components/WhatsAppContactPanel/WhatsAppContactPanel.vue.d.ts +19 -0
  19. package/lib/components/WhatsAppContactPanel/index.d.ts +1 -0
  20. package/lib/components/WhatsAppConversation/WhatsAppConversation.d.ts +10 -0
  21. package/lib/components/WhatsAppConversation/WhatsAppConversation.types.d.ts +163 -0
  22. package/lib/components/WhatsAppConversation/WhatsAppConversation.vue.d.ts +69 -0
  23. package/lib/components/WhatsAppConversation/index.d.ts +1 -0
  24. package/lib/components/WhatsAppConversationHeader/WhatsAppConversationHeader.d.ts +9 -0
  25. package/lib/components/WhatsAppConversationHeader/WhatsAppConversationHeader.types.d.ts +57 -0
  26. package/lib/components/WhatsAppConversationHeader/WhatsAppConversationHeader.vue.d.ts +23 -0
  27. package/lib/components/WhatsAppConversationHeader/index.d.ts +1 -0
  28. package/lib/components/WhatsAppConversationList/WhatsAppConversationList.d.ts +9 -0
  29. package/lib/components/WhatsAppConversationList/WhatsAppConversationList.types.d.ts +113 -0
  30. package/lib/components/WhatsAppConversationList/WhatsAppConversationList.vue.d.ts +35 -0
  31. package/lib/components/WhatsAppConversationList/index.d.ts +1 -0
  32. package/lib/components/WhatsAppConversationListItem/WhatsAppConversationListItem.d.ts +9 -0
  33. package/lib/components/WhatsAppConversationListItem/WhatsAppConversationListItem.types.d.ts +56 -0
  34. package/lib/components/WhatsAppConversationListItem/WhatsAppConversationListItem.vue.d.ts +21 -0
  35. package/lib/components/WhatsAppConversationListItem/index.d.ts +1 -0
  36. package/lib/components/WhatsAppEmojiPicker/WhatsAppEmojiPicker.d.ts +9 -0
  37. package/lib/components/WhatsAppEmojiPicker/WhatsAppEmojiPicker.types.d.ts +91 -0
  38. package/lib/components/WhatsAppEmojiPicker/WhatsAppEmojiPicker.vue.d.ts +31 -0
  39. package/lib/components/WhatsAppEmojiPicker/index.d.ts +1 -0
  40. package/lib/components/WhatsAppInbox/WhatsAppInbox.d.ts +10 -0
  41. package/lib/components/WhatsAppInbox/WhatsAppInbox.types.d.ts +135 -0
  42. package/lib/components/WhatsAppInbox/WhatsAppInbox.vue.d.ts +84 -0
  43. package/lib/components/WhatsAppInbox/index.d.ts +1 -0
  44. package/lib/components/WhatsAppInboxDrawer/WhatsAppInboxDrawer.d.ts +9 -0
  45. package/lib/components/WhatsAppInboxDrawer/WhatsAppInboxDrawer.types.d.ts +52 -0
  46. package/lib/components/WhatsAppInboxDrawer/WhatsAppInboxDrawer.vue.d.ts +24 -0
  47. package/lib/components/WhatsAppInboxDrawer/index.d.ts +1 -0
  48. package/lib/components/WhatsAppInboxModal/WhatsAppInboxModal.d.ts +9 -0
  49. package/lib/components/WhatsAppInboxModal/WhatsAppInboxModal.types.d.ts +52 -0
  50. package/lib/components/WhatsAppInboxModal/WhatsAppInboxModal.vue.d.ts +28 -0
  51. package/lib/components/WhatsAppInboxModal/index.d.ts +1 -0
  52. package/lib/components/WhatsAppInboxProvider/WhatsAppInboxProvider.d.ts +16 -0
  53. package/lib/components/WhatsAppInboxProvider/WhatsAppInboxProvider.types.d.ts +16 -0
  54. package/lib/components/WhatsAppInboxProvider/WhatsAppInboxProvider.vue.d.ts +11 -0
  55. package/lib/components/WhatsAppInboxProvider/index.d.ts +1 -0
  56. package/lib/components/WhatsAppInteractiveMessageEditor/WhatsAppInteractiveMessageEditor.d.ts +8 -0
  57. package/lib/components/WhatsAppInteractiveMessageEditor/WhatsAppInteractiveMessageEditor.types.d.ts +49 -0
  58. package/lib/components/WhatsAppInteractiveMessageEditor/WhatsAppInteractiveMessageEditor.vue.d.ts +27 -0
  59. package/lib/components/WhatsAppInteractiveMessageEditor/index.d.ts +1 -0
  60. package/lib/components/WhatsAppMediaAttachment/WhatsAppMediaAttachment.d.ts +8 -0
  61. package/lib/components/WhatsAppMediaAttachment/WhatsAppMediaAttachment.types.d.ts +41 -0
  62. package/lib/components/WhatsAppMediaAttachment/WhatsAppMediaAttachment.vue.d.ts +19 -0
  63. package/lib/components/WhatsAppMediaAttachment/index.d.ts +1 -0
  64. package/lib/components/WhatsAppMessage/WhatsAppMessage.d.ts +9 -0
  65. package/lib/components/WhatsAppMessage/WhatsAppMessage.types.d.ts +46 -0
  66. package/lib/components/WhatsAppMessage/WhatsAppMessage.vue.d.ts +25 -0
  67. package/lib/components/WhatsAppMessage/index.d.ts +1 -0
  68. package/lib/components/WhatsAppMessageBubble/WhatsAppMessageBubble.d.ts +9 -0
  69. package/lib/components/WhatsAppMessageBubble/WhatsAppMessageBubble.types.d.ts +77 -0
  70. package/lib/components/WhatsAppMessageBubble/WhatsAppMessageBubble.vue.d.ts +22 -0
  71. package/lib/components/WhatsAppMessageBubble/index.d.ts +1 -0
  72. package/lib/components/WhatsAppMessageList/WhatsAppMessageList.d.ts +10 -0
  73. package/lib/components/WhatsAppMessageList/WhatsAppMessageList.types.d.ts +94 -0
  74. package/lib/components/WhatsAppMessageList/WhatsAppMessageList.vue.d.ts +39 -0
  75. package/lib/components/WhatsAppMessageList/index.d.ts +1 -0
  76. package/lib/components/WhatsAppMessageStatus/WhatsAppMessageStatus.d.ts +7 -0
  77. package/lib/components/WhatsAppMessageStatus/WhatsAppMessageStatus.types.d.ts +30 -0
  78. package/lib/components/WhatsAppMessageStatus/WhatsAppMessageStatus.vue.d.ts +24 -0
  79. package/lib/components/WhatsAppMessageStatus/index.d.ts +1 -0
  80. package/lib/components/WhatsAppMessagingWindowNotice/WhatsAppMessagingWindowNotice.d.ts +9 -0
  81. package/lib/components/WhatsAppMessagingWindowNotice/WhatsAppMessagingWindowNotice.types.d.ts +55 -0
  82. package/lib/components/WhatsAppMessagingWindowNotice/WhatsAppMessagingWindowNotice.vue.d.ts +18 -0
  83. package/lib/components/WhatsAppMessagingWindowNotice/index.d.ts +1 -0
  84. package/lib/components/WhatsAppTemplatePreview/WhatsAppTemplatePreview.d.ts +7 -0
  85. package/lib/components/WhatsAppTemplatePreview/WhatsAppTemplatePreview.types.d.ts +36 -0
  86. package/lib/components/WhatsAppTemplatePreview/WhatsAppTemplatePreview.vue.d.ts +12 -0
  87. package/lib/components/WhatsAppTemplatePreview/index.d.ts +1 -0
  88. package/lib/components/WhatsAppTemplateSelector/WhatsAppTemplateSelector.d.ts +9 -0
  89. package/lib/components/WhatsAppTemplateSelector/WhatsAppTemplateSelector.types.d.ts +106 -0
  90. package/lib/components/WhatsAppTemplateSelector/WhatsAppTemplateSelector.vue.d.ts +33 -0
  91. package/lib/components/WhatsAppTemplateSelector/index.d.ts +1 -0
  92. package/lib/emoji/emoji-data.d.ts +27 -0
  93. package/lib/emoji/emoji-filter.d.ts +49 -0
  94. package/lib/emoji/index.d.ts +4 -0
  95. package/lib/icons/WhatsAppIcon.vue.d.ts +14 -0
  96. package/lib/icons/icon-paths.d.ts +43 -0
  97. package/lib/icons/index.d.ts +3 -0
  98. package/lib/index.d.mts +29 -0
  99. package/lib/index.d.ts +29 -0
  100. package/lib/labels.d.ts +184 -0
  101. package/lib/types.d.ts +777 -0
  102. package/lib/utils/capabilities.d.ts +14 -0
  103. package/lib/utils/format.d.ts +27 -0
  104. package/lib/utils/index.d.ts +9 -0
  105. package/lib/utils/media.d.ts +45 -0
  106. package/lib/utils/messages.d.ts +48 -0
  107. package/lib/utils/phone.d.ts +18 -0
  108. package/lib/utils/templates.d.ts +65 -0
  109. package/package.json +46 -0
  110. package/styles.css +1504 -0
  111. package/styles.layer.css +1506 -0
package/lib/types.d.ts ADDED
@@ -0,0 +1,777 @@
1
+ /**
2
+ * Backend neutral domain model of the WhatsApp inbox.
3
+ *
4
+ * These types are independent of Meta Cloud API response shapes. Applications map backend data
5
+ * to this model.
6
+ *
7
+ * Timestamps are plain values so that any serialization survives the trip: ISO 8601 strings are
8
+ * recommended, but anything `new Date(value)` understands is accepted.
9
+ */
10
+ /** Point in time accepted by every component. Rendered through the inbox formatters. */
11
+ export type WhatsAppTimestamp = string | number | Date;
12
+ /** Who sent the message. */
13
+ export type WhatsAppMessageDirection = 'inbound' | 'outbound';
14
+ /**
15
+ * Delivery state of a message, as reported by the backend.
16
+ *
17
+ * Inbound messages usually leave this unset. The extension never advances the state on its own.
18
+ */
19
+ export type WhatsAppDeliveryStatus = 'pending' | 'sent' | 'delivered' | 'read' | 'failed';
20
+ /** Kind of media carried by an attachment. */
21
+ export type WhatsAppMediaType = 'image' | 'video' | 'audio' | 'document' | 'sticker';
22
+ /**
23
+ * Discriminator of the message union.
24
+ *
25
+ * `unsupported` is the escape hatch for anything the backend received but could not normalize;
26
+ * rendering it keeps the history complete instead of leaving a hole in it.
27
+ */
28
+ export type WhatsAppMessageType = 'text' | 'image' | 'video' | 'audio' | 'document' | 'sticker' | 'location' | 'contacts' | 'template' | 'interactive' | 'system' | 'unsupported';
29
+ /** One labelled value shown in the contact panel, for example a CRM field. */
30
+ export interface WhatsAppContactField {
31
+ /** Stable key, used as the list key. */
32
+ key: string;
33
+ /** Field name shown to the user. */
34
+ label: string;
35
+ /** Field value. Rendered as text unless `href` is set. */
36
+ value: string;
37
+ /** If set, the value is rendered as a link. */
38
+ href?: string;
39
+ }
40
+ /** Person on the other end of a conversation. */
41
+ export interface WhatsAppContact {
42
+ /** Stable identifier in the consumer's system. */
43
+ id: string;
44
+ /** Display name. Falls back to `phoneNumber`. */
45
+ name?: string;
46
+ /** WhatsApp phone number, in whatever format the backend stores it. */
47
+ phoneNumber?: string;
48
+ /** Profile image. */
49
+ avatarUrl?: string;
50
+ /** WhatsApp "about" text. */
51
+ about?: string;
52
+ /** Email address, shown in the contact panel. */
53
+ email?: string;
54
+ /** Free-form labels shown as badges. */
55
+ tags?: string[];
56
+ /** Extra fields shown in the contact panel. */
57
+ fields?: WhatsAppContactField[];
58
+ /** Anything the consumer needs to carry along. Never read by the components. */
59
+ meta?: Record<string, unknown>;
60
+ }
61
+ /** Agent or team a conversation is assigned to. */
62
+ export interface WhatsAppAssignee {
63
+ id: string;
64
+ name: string;
65
+ avatarUrl?: string;
66
+ }
67
+ /** A media file that is already hosted somewhere the browser can reach. */
68
+ export interface WhatsAppAttachment {
69
+ /** Identifier assigned by the consumer's storage or by the WhatsApp provider. */
70
+ id?: string;
71
+ /** Determines which renderer is used. */
72
+ mediaType: WhatsAppMediaType;
73
+ /** Location the file is served from. Required to preview or download it. */
74
+ url?: string;
75
+ /** Poster for videos, thumbnail for images and documents. */
76
+ thumbnailUrl?: string;
77
+ /** Original file name, shown for documents. */
78
+ fileName?: string;
79
+ /** MIME type, used for the document icon and for validation. */
80
+ mimeType?: string;
81
+ /** Size in bytes. */
82
+ size?: number;
83
+ /** Duration in seconds, for audio and video. */
84
+ durationSeconds?: number;
85
+ /** Intrinsic width in pixels, used to reserve space before the media loads. */
86
+ width?: number;
87
+ /** Intrinsic height in pixels, used to reserve space before the media loads. */
88
+ height?: number;
89
+ /** Anything the consumer needs to carry along. */
90
+ meta?: Record<string, unknown>;
91
+ }
92
+ /** Lifecycle of a file picked in the composer. Owned entirely by the consumer. */
93
+ export type WhatsAppUploadStatus = 'pending' | 'uploading' | 'uploaded' | 'failed' | 'canceled';
94
+ /**
95
+ * One file in the composer, with the upload state the consumer reports back.
96
+ *
97
+ * The extension never uploads anything: it emits `attachmentsAdd` with the picked files and
98
+ * renders whatever `uploads` the consumer passes back in.
99
+ */
100
+ export interface WhatsAppUpload {
101
+ /** Identifier generated by the consumer when it accepts the file. */
102
+ id: string;
103
+ /** File name shown in the preview. */
104
+ fileName: string;
105
+ /** Determines the preview renderer. */
106
+ mediaType: WhatsAppMediaType;
107
+ /** Current state of the upload. */
108
+ status: WhatsAppUploadStatus;
109
+ /** Progress in percent, `0` to `100`. Rendered as an indeterminate bar when unset. */
110
+ progress?: number;
111
+ /** MIME type of the picked file. */
112
+ mimeType?: string;
113
+ /** Size in bytes. */
114
+ size?: number;
115
+ /** Local or remote preview, typically an object URL. */
116
+ previewUrl?: string;
117
+ /** Set once the upload finished. This is what ends up in the outgoing payload. */
118
+ attachment?: WhatsAppAttachment;
119
+ /** Human readable failure reason, shown on the preview when `status` is `failed`. */
120
+ error?: string;
121
+ /** Anything the consumer needs to carry along. */
122
+ meta?: Record<string, unknown>;
123
+ }
124
+ /** File constraints enforced by the composer before a file reaches the consumer. */
125
+ export interface WhatsAppMediaConstraints {
126
+ /** Largest accepted file size in bytes. */
127
+ maxFileSize?: number;
128
+ /** Accepted MIME types or extensions, in the format of the `accept` attribute. */
129
+ accept?: string[];
130
+ /** Largest number of files that may be attached to a single message. */
131
+ maxFiles?: number;
132
+ }
133
+ /** Template category. Open ended: providers keep adding new ones. */
134
+ export type WhatsAppTemplateCategory = 'marketing' | 'utility' | 'authentication' | (string & {});
135
+ /** Approval state of a template. Only approved templates can normally be sent. */
136
+ export type WhatsAppTemplateStatus = 'approved' | 'pending' | 'rejected' | 'paused' | 'disabled' | (string & {});
137
+ /** Kind of value a template placeholder expects. */
138
+ export type WhatsAppTemplateParameterType = 'text' | 'currency' | 'date_time' | 'image' | 'video' | 'document' | 'location';
139
+ /** One placeholder inside a template component. */
140
+ export interface WhatsAppTemplateParameter {
141
+ /**
142
+ * Placeholder key. Positional templates use `1`, `2` and so on; named templates use the
143
+ * variable name. Entered values are stored under this key.
144
+ */
145
+ key: string;
146
+ /** Field label. Falls back to the key. */
147
+ label?: string;
148
+ /**
149
+ * Value type the placeholder expects.
150
+ * @default 'text'
151
+ */
152
+ type?: WhatsAppTemplateParameterType;
153
+ /**
154
+ * Whether a value must be provided before the template can be submitted.
155
+ * @default true
156
+ */
157
+ required?: boolean;
158
+ /** Example value from the approved template, shown as a hint. */
159
+ example?: string;
160
+ /** Longer explanation shown under the field. */
161
+ description?: string;
162
+ /** Input placeholder. Falls back to `example`. */
163
+ placeholder?: string;
164
+ /** Largest accepted length, enforced by the parameter form. */
165
+ maxLength?: number;
166
+ }
167
+ /** Header of a template. `format` decides whether it carries text or media. */
168
+ export interface WhatsAppTemplateHeaderComponent {
169
+ type: 'header';
170
+ /**
171
+ * What the header renders.
172
+ * @default 'text'
173
+ */
174
+ format?: 'text' | 'image' | 'video' | 'document' | 'location';
175
+ /** Header text with placeholders, for text headers. */
176
+ text?: string;
177
+ /** Placeholders inside the header. */
178
+ parameters?: WhatsAppTemplateParameter[];
179
+ /** Media used in the approved example, previewed before the user picks their own. */
180
+ example?: WhatsAppAttachment;
181
+ }
182
+ /** Body of a template. Every template has exactly one. */
183
+ export interface WhatsAppTemplateBodyComponent {
184
+ type: 'body';
185
+ /** Body text with placeholders. */
186
+ text: string;
187
+ /** Placeholders inside the body. */
188
+ parameters?: WhatsAppTemplateParameter[];
189
+ }
190
+ /** Static footer of a template. Never carries placeholders. */
191
+ export interface WhatsAppTemplateFooterComponent {
192
+ type: 'footer';
193
+ text: string;
194
+ }
195
+ /** A button attached to a template. */
196
+ export type WhatsAppTemplateButton = {
197
+ type: 'quick_reply';
198
+ text: string;
199
+ /** Payload sent back when the recipient taps the button. */
200
+ payload?: string;
201
+ } | {
202
+ type: 'url';
203
+ text: string;
204
+ /** Target URL, which may end in a placeholder. */
205
+ url: string;
206
+ /** Placeholders inside the URL. */
207
+ parameters?: WhatsAppTemplateParameter[];
208
+ } | {
209
+ type: 'phone_number';
210
+ text: string;
211
+ phoneNumber: string;
212
+ } | {
213
+ type: 'copy_code';
214
+ text: string;
215
+ parameters?: WhatsAppTemplateParameter[];
216
+ };
217
+ /** Buttons section of a template. */
218
+ export interface WhatsAppTemplateButtonsComponent {
219
+ type: 'buttons';
220
+ buttons: WhatsAppTemplateButton[];
221
+ }
222
+ /** One section of a template, discriminated by `type`. */
223
+ export type WhatsAppTemplateComponent = WhatsAppTemplateHeaderComponent | WhatsAppTemplateBodyComponent | WhatsAppTemplateFooterComponent | WhatsAppTemplateButtonsComponent;
224
+ /** An approved WhatsApp message template, normalized by the backend. */
225
+ export interface WhatsAppTemplate {
226
+ /** Stable identifier. */
227
+ id: string;
228
+ /** Template name as registered with the provider. */
229
+ name: string;
230
+ /** Language code, for example `en_US`. */
231
+ language: string;
232
+ /** Human readable language name. Falls back to `language`. */
233
+ languageLabel?: string;
234
+ /** Category badge shown in the selector. */
235
+ category?: WhatsAppTemplateCategory;
236
+ /** Approval state. Templates that are not approved are shown as unavailable. */
237
+ status?: WhatsAppTemplateStatus;
238
+ /** Sections of the template. */
239
+ components: WhatsAppTemplateComponent[];
240
+ /** Free-form description shown in the selector. */
241
+ description?: string;
242
+ /** Anything the consumer needs to carry along. */
243
+ meta?: Record<string, unknown>;
244
+ }
245
+ /**
246
+ * Values entered for a template's placeholders.
247
+ *
248
+ * Records are keyed by `WhatsAppTemplateParameter.key`; `buttons` is keyed by the button index
249
+ * as a string, so the whole object stays JSON serializable.
250
+ */
251
+ export interface WhatsAppTemplateValues {
252
+ header?: Record<string, string>;
253
+ body?: Record<string, string>;
254
+ buttons?: Record<string, Record<string, string>>;
255
+ /** Media chosen for a media header. */
256
+ headerMedia?: WhatsAppAttachment | null;
257
+ }
258
+ /** A template as it appears in the history, with its placeholders already resolved. */
259
+ export interface WhatsAppTemplateInstance {
260
+ /** Template name as sent. */
261
+ name: string;
262
+ /** Language the template was sent in. */
263
+ language?: string;
264
+ /** Identifier of the template, when the backend keeps one. */
265
+ templateId?: string;
266
+ /** Values the placeholders were filled with. */
267
+ values?: WhatsAppTemplateValues;
268
+ /** Full definition, used to render an exact preview of what was sent. */
269
+ template?: WhatsAppTemplate;
270
+ /** Pre-rendered body text, used when the definition is no longer available. */
271
+ text?: string;
272
+ }
273
+ /** Interactive message flavours. Not every provider supports all of them. */
274
+ export type WhatsAppInteractiveType = 'button' | 'cta_url' | 'list';
275
+ /** Header of an interactive message. */
276
+ export interface WhatsAppInteractiveHeader {
277
+ type: 'text' | 'image' | 'video' | 'document';
278
+ text?: string;
279
+ attachment?: WhatsAppAttachment;
280
+ }
281
+ /** One reply button of an interactive message. */
282
+ export interface WhatsAppInteractiveReplyButton {
283
+ id: string;
284
+ title: string;
285
+ }
286
+ /** One row of a list message. */
287
+ export interface WhatsAppInteractiveListRow {
288
+ id: string;
289
+ title: string;
290
+ description?: string;
291
+ }
292
+ /** One section of a list message. */
293
+ export interface WhatsAppInteractiveListSection {
294
+ title?: string;
295
+ rows: WhatsAppInteractiveListRow[];
296
+ }
297
+ /** Reply-button message: up to three tappable buttons under the body. */
298
+ export interface WhatsAppInteractiveButtonContent {
299
+ type: 'button';
300
+ header?: WhatsAppInteractiveHeader;
301
+ body: string;
302
+ footer?: string;
303
+ buttons: WhatsAppInteractiveReplyButton[];
304
+ }
305
+ /** Call-to-action message: a single button that opens a URL. */
306
+ export interface WhatsAppInteractiveCtaUrlContent {
307
+ type: 'cta_url';
308
+ header?: WhatsAppInteractiveHeader;
309
+ body: string;
310
+ footer?: string;
311
+ action: {
312
+ displayText: string;
313
+ url: string;
314
+ };
315
+ }
316
+ /** List message: a control that opens a sectioned list of options. */
317
+ export interface WhatsAppInteractiveListContent {
318
+ type: 'list';
319
+ header?: WhatsAppInteractiveHeader;
320
+ body: string;
321
+ footer?: string;
322
+ /** Label of the control that opens the list. */
323
+ button: string;
324
+ sections: WhatsAppInteractiveListSection[];
325
+ }
326
+ /** Payload of an interactive message, discriminated by `type`. */
327
+ export type WhatsAppInteractiveContent = WhatsAppInteractiveButtonContent | WhatsAppInteractiveCtaUrlContent | WhatsAppInteractiveListContent;
328
+ /** Who produced an outbound message, shown above the bubble in shared inboxes. */
329
+ export interface WhatsAppMessageAuthor {
330
+ id?: string;
331
+ name: string;
332
+ avatarUrl?: string;
333
+ }
334
+ /** Failure details for a message whose status is `failed`. */
335
+ export interface WhatsAppMessageError {
336
+ /** Provider or backend error code, shown next to the message. */
337
+ code?: string;
338
+ /** Human readable failure reason. */
339
+ message?: string;
340
+ /**
341
+ * Whether the consumer can resend the message. Controls the retry action.
342
+ * @default true
343
+ */
344
+ retryable?: boolean;
345
+ }
346
+ /** Reference to the message another message replies to. */
347
+ export interface WhatsAppMessageReference {
348
+ id: string;
349
+ /** Preview text of the quoted message. */
350
+ text?: string;
351
+ /** Direction of the quoted message, used to colour the quote. */
352
+ direction?: WhatsAppMessageDirection;
353
+ /** Author name of the quoted message. */
354
+ author?: string;
355
+ }
356
+ /** An emoji reaction on a message. */
357
+ export interface WhatsAppReaction {
358
+ emoji: string;
359
+ count?: number;
360
+ /** Whether the current user reacted. */
361
+ reacted?: boolean;
362
+ }
363
+ /** Members every message shares, whatever its `type`. */
364
+ export interface WhatsAppMessageBase {
365
+ /** Stable identifier. Used as the list key, so it must not change between renders. */
366
+ id: string;
367
+ /** Conversation the message belongs to. Optional when the list is already scoped. */
368
+ conversationId?: string;
369
+ /** Whether the message was received or sent. */
370
+ direction: WhatsAppMessageDirection;
371
+ /** Delivery state. Rendered as an icon with a screen-reader label. */
372
+ status?: WhatsAppDeliveryStatus;
373
+ /** When the message was created. */
374
+ timestamp: WhatsAppTimestamp;
375
+ /** Agent who sent the message, for shared inboxes. */
376
+ author?: WhatsAppMessageAuthor;
377
+ /** Message this one replies to. */
378
+ replyTo?: WhatsAppMessageReference;
379
+ /** Failure details, meaningful when `status` is `failed`. */
380
+ error?: WhatsAppMessageError;
381
+ /** Reactions on the message. */
382
+ reactions?: WhatsAppReaction[];
383
+ /** Whether the message was forwarded. */
384
+ forwarded?: boolean;
385
+ /** Anything the consumer needs to carry along. Never read by the components. */
386
+ meta?: Record<string, unknown>;
387
+ }
388
+ /** Plain or multiline text message. */
389
+ export interface WhatsAppTextMessage extends WhatsAppMessageBase {
390
+ type: 'text';
391
+ text: string;
392
+ }
393
+ /** Shared shape of the media message types. */
394
+ export interface WhatsAppMediaMessageBase<Type extends WhatsAppMessageType> extends WhatsAppMessageBase {
395
+ type: Type;
396
+ attachment: WhatsAppAttachment;
397
+ /** Text shown under the media. */
398
+ caption?: string;
399
+ }
400
+ export type WhatsAppImageMessage = WhatsAppMediaMessageBase<'image'>;
401
+ export type WhatsAppVideoMessage = WhatsAppMediaMessageBase<'video'>;
402
+ export type WhatsAppAudioMessage = WhatsAppMediaMessageBase<'audio'>;
403
+ export type WhatsAppDocumentMessage = WhatsAppMediaMessageBase<'document'>;
404
+ export type WhatsAppStickerMessage = WhatsAppMediaMessageBase<'sticker'>;
405
+ /** Any message that carries a single attachment. */
406
+ export type WhatsAppMediaMessage = WhatsAppImageMessage | WhatsAppVideoMessage | WhatsAppAudioMessage | WhatsAppDocumentMessage | WhatsAppStickerMessage;
407
+ /** A template message that was sent to the contact. */
408
+ export interface WhatsAppTemplateMessage extends WhatsAppMessageBase {
409
+ type: 'template';
410
+ template: WhatsAppTemplateInstance;
411
+ }
412
+ /** An interactive message, in either direction. */
413
+ export interface WhatsAppInteractiveMessage extends WhatsAppMessageBase {
414
+ type: 'interactive';
415
+ interactive: WhatsAppInteractiveContent;
416
+ /** Option the recipient picked, for an inbound reply to an interactive message. */
417
+ reply?: {
418
+ id: string;
419
+ title?: string;
420
+ };
421
+ }
422
+ /** A shared location. */
423
+ export interface WhatsAppLocationMessage extends WhatsAppMessageBase {
424
+ type: 'location';
425
+ location: {
426
+ latitude: number;
427
+ longitude: number;
428
+ name?: string;
429
+ address?: string;
430
+ /** Map link opened by the message. */
431
+ url?: string;
432
+ };
433
+ }
434
+ /** One shared contact card. */
435
+ export interface WhatsAppContactCard {
436
+ name: string;
437
+ phoneNumbers?: string[];
438
+ emails?: string[];
439
+ organization?: string;
440
+ }
441
+ /** One or more shared contact cards. */
442
+ export interface WhatsAppContactsMessage extends WhatsAppMessageBase {
443
+ type: 'contacts';
444
+ contacts: WhatsAppContactCard[];
445
+ }
446
+ /**
447
+ * A conversation event rather than a message: assignment changes, window notices, notes.
448
+ * Rendered centred, without a bubble.
449
+ */
450
+ export interface WhatsAppSystemMessage extends WhatsAppMessageBase {
451
+ type: 'system';
452
+ text: string;
453
+ }
454
+ /** A message the backend could not normalize. Keeps the history complete. */
455
+ export interface WhatsAppUnsupportedMessage extends WhatsAppMessageBase {
456
+ type: 'unsupported';
457
+ /** Explanation shown in place of the content. */
458
+ text?: string;
459
+ }
460
+ /**
461
+ * Any message in a conversation.
462
+ *
463
+ * A discriminated union on `type`: narrowing a message gives access to exactly the payload that
464
+ * type carries, and adding a member here is a compile error in every renderer that must handle
465
+ * it.
466
+ */
467
+ export type WhatsAppMessageData = WhatsAppTextMessage | WhatsAppImageMessage | WhatsAppVideoMessage | WhatsAppAudioMessage | WhatsAppDocumentMessage | WhatsAppStickerMessage | WhatsAppTemplateMessage | WhatsAppInteractiveMessage | WhatsAppLocationMessage | WhatsAppContactsMessage | WhatsAppSystemMessage | WhatsAppUnsupportedMessage;
468
+ /**
469
+ * State of the WhatsApp customer service window, as reported by the backend.
470
+ *
471
+ * The extension never computes this. WhatsApp's 24-hour rule depends on the provider's own clock
472
+ * and on message events the frontend does not see, so the backend stays authoritative and the
473
+ * components render whatever it says.
474
+ */
475
+ export interface WhatsAppMessagingWindow {
476
+ /**
477
+ * Whether free-form messages are currently accepted. `unknown` leaves the composer in its
478
+ * normal state rather than blocking the user on information the backend did not send.
479
+ * @default 'unknown'
480
+ */
481
+ state: 'open' | 'closed' | 'unknown';
482
+ /** Machine readable reason, for consumers that map their own copy onto it. */
483
+ reasonCode?: string;
484
+ /** Backend-provided explanation shown to the user when the window is closed. */
485
+ reason?: string;
486
+ /** When an open window expires. Shown as a hint in the composer. */
487
+ expiresAt?: WhatsAppTimestamp;
488
+ }
489
+ /**
490
+ * What the consumer allows in a given conversation.
491
+ *
492
+ * Every composer action is driven by these flags. Nothing about WhatsApp's own rules is
493
+ * hard-coded: a provider that does not support list messages simply leaves `interactiveTypes`
494
+ * without `list`, and the editor stops offering it.
495
+ */
496
+ export interface WhatsAppConversationCapabilities {
497
+ /**
498
+ * Whether free-form text may be sent. Treated as `false` while the messaging window is
499
+ * closed.
500
+ * @default true
501
+ */
502
+ canSendFreeForm?: boolean;
503
+ /**
504
+ * Whether approved templates may be sent. Stays available while the window is closed.
505
+ * @default false
506
+ */
507
+ canSendTemplates?: boolean;
508
+ /**
509
+ * Whether media may be attached.
510
+ * @default false
511
+ */
512
+ canSendMedia?: boolean;
513
+ /**
514
+ * Whether interactive messages may be composed.
515
+ * @default false
516
+ */
517
+ canSendInteractive?: boolean;
518
+ /**
519
+ * Whether the built-in emoji picker may be shown. The `emojiPicker` slot can replace it.
520
+ * @default false
521
+ */
522
+ canUseEmoji?: boolean;
523
+ /**
524
+ * Whether a message may be sent as a reply to another one.
525
+ * @default false
526
+ */
527
+ canReplyToMessage?: boolean;
528
+ /**
529
+ * Whether failed messages offer a retry action.
530
+ * @default true
531
+ */
532
+ canRetryFailed?: boolean;
533
+ /** Media types that may be attached. Defaults to all of them when `canSendMedia` is set. */
534
+ allowedMediaTypes?: WhatsAppMediaType[];
535
+ /** Interactive message types the provider supports. */
536
+ interactiveTypes?: WhatsAppInteractiveType[];
537
+ /** Largest accepted length of a free-form message. */
538
+ maxTextLength?: number;
539
+ /** Per media type file constraints, enforced before a file reaches the consumer. */
540
+ mediaConstraints?: Partial<Record<WhatsAppMediaType, WhatsAppMediaConstraints>>;
541
+ /** Messaging window state. Drives the closed-window notice. */
542
+ messagingWindow?: WhatsAppMessagingWindow;
543
+ /**
544
+ * Explanation shown when the composer is disabled for a reason other than the messaging
545
+ * window, for example a conversation the current agent may not write to.
546
+ */
547
+ disabledReason?: string;
548
+ }
549
+ /**
550
+ * `WhatsAppConversationCapabilities` with every optional flag filled in.
551
+ *
552
+ * Produced by `resolveCapabilities` for use by the composer and related components.
553
+ */
554
+ export interface WhatsAppResolvedCapabilities {
555
+ canSendFreeForm: boolean;
556
+ canSendTemplates: boolean;
557
+ canSendMedia: boolean;
558
+ canSendInteractive: boolean;
559
+ canUseEmoji: boolean;
560
+ canReplyToMessage: boolean;
561
+ canRetryFailed: boolean;
562
+ allowedMediaTypes: WhatsAppMediaType[];
563
+ interactiveTypes: WhatsAppInteractiveType[];
564
+ maxTextLength: number | undefined;
565
+ mediaConstraints: Partial<Record<WhatsAppMediaType, WhatsAppMediaConstraints>>;
566
+ messagingWindow: WhatsAppMessagingWindow;
567
+ disabledReason: string | undefined;
568
+ /** Whether the messaging window explicitly reports itself as closed. */
569
+ windowClosed: boolean;
570
+ /** Whether anything at all can be sent right now. */
571
+ canSendAnything: boolean;
572
+ }
573
+ /** Open ended conversation status. Consumers define their own workflow states. */
574
+ export type WhatsAppConversationStatus = 'open' | 'pending' | 'resolved' | 'snoozed' | 'archived' | (string & {});
575
+ /** Colored label attached to a conversation. */
576
+ export interface WhatsAppConversationLabel {
577
+ id: string;
578
+ name: string;
579
+ /** Key of `theme.colors` or any valid CSS color. */
580
+ color?: string;
581
+ }
582
+ /** Last message of a conversation, as shown in the list. */
583
+ export interface WhatsAppConversationPreview {
584
+ /** Identifier of the previewed message. */
585
+ id?: string;
586
+ /** Type of the previewed message, used to pick the icon shown before the text. */
587
+ type?: WhatsAppMessageType;
588
+ /** Direction of the previewed message. Outbound previews show a delivery state. */
589
+ direction?: WhatsAppMessageDirection;
590
+ /** Delivery state of the previewed message. */
591
+ status?: WhatsAppDeliveryStatus;
592
+ /** Preview text. Falls back to a label derived from `type`. */
593
+ text?: string;
594
+ /** When the previewed message was created. */
595
+ timestamp?: WhatsAppTimestamp;
596
+ }
597
+ /** A conversation as it appears in the conversation list. */
598
+ export interface WhatsAppConversationSummary {
599
+ /** Stable identifier. Used as the list key and as the selection value. */
600
+ id: string;
601
+ /** Person the conversation is with. */
602
+ contact: WhatsAppContact;
603
+ /** Last message, shown under the contact name. */
604
+ lastMessage?: WhatsAppConversationPreview;
605
+ /** Number of unread inbound messages. Renders the unread badge when above zero. */
606
+ unreadCount?: number;
607
+ /** Time of the latest activity. Drives the default ordering. */
608
+ updatedAt?: WhatsAppTimestamp;
609
+ /** Workflow status, used by the status filter. */
610
+ status?: WhatsAppConversationStatus;
611
+ /** Agent the conversation is assigned to, used by the assignment filter. */
612
+ assignee?: WhatsAppAssignee;
613
+ /** Pinned conversations sort above the rest. */
614
+ pinned?: boolean;
615
+ /** Muted conversations render a muted icon. */
616
+ muted?: boolean;
617
+ /** Labels shown as badges on the list item. */
618
+ labels?: WhatsAppConversationLabel[];
619
+ /** Anything the consumer needs to carry along. */
620
+ meta?: Record<string, unknown>;
621
+ }
622
+ /** A conversation opened in the conversation view. */
623
+ export interface WhatsAppConversationData extends WhatsAppConversationSummary {
624
+ /** What may be sent in this conversation. */
625
+ capabilities?: WhatsAppConversationCapabilities;
626
+ }
627
+ /**
628
+ * Conversation list filters.
629
+ *
630
+ * The extension never applies these itself: it emits `filtersChange` and renders whatever list
631
+ * the consumer supplies next.
632
+ */
633
+ export interface WhatsAppInboxFilters {
634
+ /** Free-text search query. */
635
+ query?: string;
636
+ /** Restricts the list to conversations with unread messages. */
637
+ unreadOnly?: boolean;
638
+ /** Assignee to filter by. `null` means unassigned, `undefined` means no filter. */
639
+ assigneeId?: string | null;
640
+ /** Status to filter by. `null` or `undefined` means no filter. */
641
+ status?: WhatsAppConversationStatus | null;
642
+ /** Label ids to filter by. */
643
+ labels?: string[];
644
+ }
645
+ /** Which filter controls the conversation list renders. */
646
+ export interface WhatsAppInboxFiltersConfig {
647
+ /**
648
+ * Whether the search field is rendered.
649
+ * @default true
650
+ */
651
+ search?: boolean;
652
+ /**
653
+ * Whether the unread-only toggle is rendered.
654
+ * @default true
655
+ */
656
+ unread?: boolean;
657
+ /**
658
+ * Assignee options. The control is hidden when this is omitted, so a backend without
659
+ * assignment never shows a filter it cannot answer.
660
+ */
661
+ assignees?: WhatsAppAssignee[];
662
+ /** Status options. The control is hidden when this is omitted. */
663
+ statuses?: WhatsAppFilterOption[];
664
+ }
665
+ /** One option of a select-style filter. */
666
+ export interface WhatsAppFilterOption {
667
+ value: string;
668
+ label: string;
669
+ }
670
+ /** Cursor state of a paginated list. Advanced by the consumer. */
671
+ export interface WhatsAppPaginationState {
672
+ /** Whether another page can be requested. Renders the load-more affordance. */
673
+ hasMore?: boolean;
674
+ /** Whether a page request is in flight. */
675
+ loadingMore?: boolean;
676
+ /** Opaque cursor echoed back in the `loadMore` payload. */
677
+ cursor?: string | null;
678
+ /** Total number of records, when the backend reports one. */
679
+ total?: number;
680
+ }
681
+ /** Async state of one data set, for consumers building their own adapters. */
682
+ export interface WhatsAppAsyncState {
683
+ /** Whether the initial load is in flight. */
684
+ loading?: boolean;
685
+ /** Failure of the last load. Renders the error state with a retry action. */
686
+ error?: string | null;
687
+ }
688
+ /** Members every outgoing payload shares. */
689
+ export interface WhatsAppOutgoingMessageBase {
690
+ /** Conversation the message belongs to. */
691
+ conversationId: string;
692
+ /**
693
+ * Identifier generated by the composer. Use it to reconcile the optimistic message with the
694
+ * one the backend echoes back.
695
+ */
696
+ clientId: string;
697
+ /** Identifier of the message being replied to. */
698
+ replyTo?: string;
699
+ }
700
+ /** A free-form text message. */
701
+ export interface WhatsAppOutgoingTextMessage extends WhatsAppOutgoingMessageBase {
702
+ kind: 'text';
703
+ text: string;
704
+ }
705
+ /** One or more uploaded attachments, with an optional shared caption. */
706
+ export interface WhatsAppOutgoingMediaMessage extends WhatsAppOutgoingMessageBase {
707
+ kind: 'media';
708
+ attachments: WhatsAppAttachment[];
709
+ caption?: string;
710
+ }
711
+ /** A template with its placeholders filled in. */
712
+ export interface WhatsAppOutgoingTemplateMessage extends WhatsAppOutgoingMessageBase {
713
+ kind: 'template';
714
+ /** Identifier of the selected template, when it has one. */
715
+ templateId?: string;
716
+ /** Template name as registered with the provider. */
717
+ name: string;
718
+ /** Language the template is sent in. */
719
+ language: string;
720
+ /** Values entered for the placeholders. */
721
+ values: WhatsAppTemplateValues;
722
+ /** The full definition, so the consumer does not have to look it up again. */
723
+ template: WhatsAppTemplate;
724
+ }
725
+ /** An interactive message composed in the editor. */
726
+ export interface WhatsAppOutgoingInteractiveMessage extends WhatsAppOutgoingMessageBase {
727
+ kind: 'interactive';
728
+ interactive: WhatsAppInteractiveContent;
729
+ }
730
+ /**
731
+ * Anything the composer can ask the consumer to send.
732
+ *
733
+ * A discriminated union on `kind`, so a `switch` in the consumer's send handler is exhaustive.
734
+ */
735
+ export type WhatsAppOutgoingMessage = WhatsAppOutgoingTextMessage | WhatsAppOutgoingMediaMessage | WhatsAppOutgoingTemplateMessage | WhatsAppOutgoingInteractiveMessage;
736
+ /** A file the composer refused before it reached the consumer. */
737
+ export interface WhatsAppRejectedFile {
738
+ file: File;
739
+ code: 'file-too-large' | 'file-invalid-type' | 'too-many-files';
740
+ message: string;
741
+ }
742
+ /** Files the user picked, handed to the consumer to upload. */
743
+ export interface WhatsAppAttachmentsAddPayload {
744
+ /** Conversation the files were picked in, when the composer knows it. */
745
+ conversationId?: string;
746
+ /** Files that passed the configured constraints. */
747
+ files: File[];
748
+ /** Files that were rejected, with the reason. */
749
+ rejected: WhatsAppRejectedFile[];
750
+ }
751
+ /**
752
+ * A conversation the user wants to start with a number that is not in the list yet.
753
+ *
754
+ * The extension does not create anything: it validates the input and hands you the number, and
755
+ * your application decides whether that means creating a conversation, looking up an existing
756
+ * one, or refusing because the contact has not opted in.
757
+ */
758
+ export interface WhatsAppNewConversationPayload {
759
+ /** Phone number exactly as the user typed it. */
760
+ phoneNumber: string;
761
+ /** Digits only, with a leading `+` when one was entered. Convenient as a lookup key. */
762
+ normalizedPhoneNumber: string;
763
+ /** Optional display name the user supplied alongside the number. */
764
+ name?: string;
765
+ }
766
+ /**
767
+ * How the composer treats an unsent draft when the conversation changes.
768
+ *
769
+ * `preserve` keeps one draft per conversation and restores it on return; `reset` drops the draft
770
+ * of the conversation being left.
771
+ */
772
+ export type WhatsAppDraftBehavior = 'preserve' | 'reset';
773
+ /** Payload of the `loadMore` event of a paginated list. */
774
+ export interface WhatsAppLoadMorePayload {
775
+ /** Cursor of the current page, echoed from `pagination.cursor`. */
776
+ cursor?: string | null;
777
+ }