@talkjs/web-components 0.1.4 → 0.1.6

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.
package/default.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { AudioBlock } from '@talkjs/core';
2
+ import { ContentBlock } from '@talkjs/core';
2
3
  import { ConversationSnapshot } from '@talkjs/core';
3
4
  import { EditMessageParams } from '@talkjs/core';
4
5
  import { EditTextMessageParams } from '@talkjs/core';
@@ -109,6 +110,8 @@ export declare interface AudioBlockProps {
109
110
  * Also, it has some additional settings that let us turn the sound wave display
110
111
  * into a series of nice rounded bars. Less signal, but also less distraction. I
111
112
  * kinda like it!
113
+ *
114
+ * @public
112
115
  */
113
116
  export declare function AudioPlayer({ src, onError, filename, className, }: AudioPlayerProps): JSX_2.Element;
114
117
 
@@ -117,13 +120,13 @@ export declare function AudioPlayer({ src, onError, filename, className, }: Audi
117
120
  */
118
121
  export declare interface AudioPlayerProps {
119
122
  /**
120
- * Source of the audio that's being played.
123
+ * Source URL of the audio file to play.
121
124
  */
122
125
  src: string;
123
126
  /**
124
127
  * Name of the audio file that's being played.
125
128
  */
126
- filename: string;
129
+ filename?: string;
127
130
  /**
128
131
  * Callback that runs when an error is encountered during playback.
129
132
  */
@@ -153,6 +156,218 @@ export declare interface AvatarProps {
153
156
  photoUrl: string;
154
157
  }
155
158
 
159
+ /**
160
+ * An event object dispatched by the
161
+ * {@link ChatboxProps.onBackButtonClick} event.
162
+ *
163
+ * @public
164
+ */
165
+ export declare interface BackButtonClickEvent {
166
+ currentUser: UserSnapshot;
167
+ }
168
+
169
+ /**
170
+ * @public
171
+ */
172
+ export declare interface BaseChatboxProps {
173
+ /**
174
+ * @hidden
175
+ */
176
+ className?: string;
177
+ /**
178
+ * @hidden
179
+ */
180
+ style?: React_2.CSSProperties;
181
+ /**
182
+ * Your app's unique TalkJS ID. You can find it on the Settings page of the
183
+ * {@link https://talkjs.com/dashboard | TalkJS dashboard.}
184
+ */
185
+ appId: string;
186
+ /**
187
+ * The ID of the current user.
188
+ *
189
+ * @remarks
190
+ * If the given user ID doesn't exist, a "Something went wrong" message will
191
+ * be displayed.
192
+ */
193
+ userId: string;
194
+ /**
195
+ * Lets you override theme components with your own implementations to
196
+ * customize them.
197
+ *
198
+ * @remarks
199
+ * See
200
+ * {@link https://talkjs.com/docs/UI_Components/React/Customization/#custom-theme-components | Custom theme components }
201
+ * for more info.
202
+ */
203
+ theme?: Partial<Theme>;
204
+ /**
205
+ * When true, pressing Enter will send a message.
206
+ *
207
+ * @remarks
208
+ * Defaults to `true`.
209
+ */
210
+ enterSendsMessage?: boolean;
211
+ /**
212
+ * Sets whether the chat header is visible.
213
+ *
214
+ * @remarks
215
+ * Defaults to `true`.
216
+ */
217
+ chatHeaderVisible?: boolean;
218
+ /**
219
+ * Sets whether the message input field is visible.
220
+ *
221
+ * @remarks
222
+ * Defaults to `true`.
223
+ */
224
+ messageFieldVisible?: boolean;
225
+ /**
226
+ * Sets whether spellcheck is enabled in the message field.
227
+ *
228
+ * @remarks
229
+ * Defaults to `false`.
230
+ */
231
+ messageFieldSpellcheck?: boolean;
232
+ /**
233
+ * Adds custom placeholder text for the message input field.
234
+ *
235
+ * @remarks
236
+ * The default placeholder text is `"Say something..."`
237
+ */
238
+ messageFieldPlaceholder?: string;
239
+ /**
240
+ * Callback that triggers when the user deletes a message with the TalkJS UI.
241
+ *
242
+ * @param event - Event object describing the message deletion
243
+ */
244
+ onDeleteMessage?: (event: DeleteMessageEvent) => void;
245
+ /**
246
+ * Callback that triggers when the user sends a message with the TalkJS UI.
247
+ *
248
+ * @param event - Event object describing the message sending action
249
+ */
250
+ onSendMessage?: (event: SendMessageEvent) => void;
251
+ /**
252
+ * Callback that triggers when the user initiates an action that will require
253
+ * a permissions request from the browser, but right before actually
254
+ * requesting the permission from the browser.
255
+ *
256
+ * @remarks
257
+ * You can use this callback to inform the user that they will need to grant a
258
+ * browser permission in order to perform an action.
259
+ *
260
+ * @param request - Object describing the permission request
261
+ */
262
+ beforeBrowserPermissionPrompt?: (request: BrowserPermissionRequest) => void;
263
+ /**
264
+ * Callback that triggers when the user attempts to initiate an action that
265
+ * requires a specific browser permission, but that permission was not
266
+ * granted.
267
+ *
268
+ * @param event - Event object describing the missing permission
269
+ */
270
+ onMissingBrowserPermission?: (event: MissingBrowserPermissionEvent) => void;
271
+ /**
272
+ * This event fires when the user clicks an action button or an action Link
273
+ * inside a message.
274
+ *
275
+ * @remarks
276
+ * The event's `action` and `params` fields specify the name of action and its
277
+ * parameters, if any.
278
+ *
279
+ * See
280
+ * {@link https://talkjs.com/docs/Guides/Web_Components/Action_Buttons_Links/ | Action Buttons and Links }
281
+ * for more info.
282
+ */
283
+ onMessageAction?: (event: MessageActionEvent) => void;
284
+ /**
285
+ * Arbitrary custom data passed down to the theme.
286
+ *
287
+ * @remarks
288
+ * Whatever data you pass here will be made available for use in theme
289
+ * components through {@link CommonChatboxProps.themeCustom} for Chatbox
290
+ * theme components and through
291
+ * {@link CommonConversationListProps.themeCustom} for ConversationList
292
+ * theme components.
293
+ */
294
+ themeCustom?: any;
295
+ }
296
+
297
+ /**
298
+ * @public
299
+ */
300
+ export declare interface BaseConversationListProps {
301
+ /**
302
+ * @hidden
303
+ */
304
+ className?: string;
305
+ /**
306
+ * @hidden
307
+ */
308
+ style?: React_2.CSSProperties;
309
+ /**
310
+ * Your app's unique TalkJS ID. You can find it on the Settings page of the
311
+ * {@link https://talkjs.com/dashboard | TalkJS dashboard.}
312
+ */
313
+ appId: string;
314
+ /**
315
+ * The ID of the current user.
316
+ *
317
+ * @remarks
318
+ * If the given user ID doesn't exist, a "Something went wrong" message will
319
+ * be displayed.
320
+ */
321
+ userId: string;
322
+ /**
323
+ * The ID of the conversation currently selected in the list.
324
+ *
325
+ * @remarks
326
+ *
327
+ * Changing the value of this prop will cause the ConversationList UI to
328
+ * update.
329
+ *
330
+ * Note that updating the selected conversation through this prop **will not**
331
+ * trigger the {@link onSelectConversation} callback.
332
+ */
333
+ selectedConversationId?: string;
334
+ /**
335
+ * Lets you override theme components with your own implementations to
336
+ * customize them.
337
+ *
338
+ * @remarks
339
+ * See
340
+ * {@link https://talkjs.com/docs/UI_Components/React/Customization/#custom-theme-components | Custom theme components }
341
+ * for more info.
342
+ */
343
+ theme?: Partial<Theme>;
344
+ /**
345
+ * Callback that triggers when the user selects a conversation from the list.
346
+ *
347
+ * @param event - Event object containing the selected conversation
348
+ *
349
+ * @remarks
350
+ * Note that updating the selected conversation through the
351
+ * {@link selectedConversationId} prop **will not** trigger this callback.
352
+ *
353
+ * Use this callback to have an adjacent chatbox show the correct
354
+ * conversation. See
355
+ * {@link https://talkjs.com/docs/UI_Components/React/ConversationList/#respond-to-a-select-conversation-event | Respond to a select conversation event.}
356
+ */
357
+ onSelectConversation?: (event: SelectConversationEvent) => void;
358
+ /**
359
+ * Arbitrary custom data passed down to the theme.
360
+ *
361
+ * @remarks
362
+ * Whatever data you pass here will be made available for use in theme
363
+ * components through {@link CommonChatboxProps.themeCustom} for Chatbox
364
+ * theme components and through
365
+ * {@link CommonConversationListProps.themeCustom} for ConversationList
366
+ * theme components.
367
+ */
368
+ themeCustom?: any;
369
+ }
370
+
156
371
  /**
157
372
  * @public
158
373
  */
@@ -229,33 +444,24 @@ export declare class ChatboxController {
229
444
  #private;
230
445
  /**
231
446
  * Deletes the message with the given ID.
232
- *
233
- * @param messageId
234
447
  */
235
448
  deleteMessage(messageId: string): Promise<void>;
236
449
  /**
237
450
  * Enable/disable editing of a given message.
238
451
  *
239
- * @param messageId When `null` is provided, editing mode will be disabled
452
+ * @param messageId - When `null` is provided, editing mode will be disabled
240
453
  */
241
454
  setEditing(messageId: string | null): void;
242
455
  /**
243
456
  * Edit the message with the given ID.
244
- *
245
- * @param messageId
246
- * @param params
247
457
  */
248
458
  editMessage(messageId: string, params: EditTextMessageParams | EditMessageParams): Promise<void>;
249
459
  /**
250
460
  * Send a text message to the current conversation.
251
- *
252
- * @param params
253
461
  */
254
462
  sendMessage(params: SendTextMessageParams | SendMessageParams): Promise<void>;
255
463
  /**
256
464
  * Send a file message to the current conversation.
257
- *
258
- * @param message
259
465
  */
260
466
  sendFileMessage(params: {
261
467
  fileToken: FileToken;
@@ -263,8 +469,6 @@ export declare class ChatboxController {
263
469
  }): Promise<void>;
264
470
  /**
265
471
  * Send a location message to the current conversation.
266
- *
267
- * @param message
268
472
  */
269
473
  sendLocationMessage(message: {
270
474
  location: Coordinates;
@@ -295,13 +499,21 @@ export declare class ChatboxController {
295
499
  getMessageFieldText(): string;
296
500
  /**
297
501
  * Set the plaintext in the message field
298
- * @param text
299
502
  */
300
503
  setMessageFieldText(text: string): void;
301
504
  /**
302
505
  * Focus the message field
303
506
  */
304
507
  focusMessageField(): void;
508
+ /**
509
+ * Emits a {@link ChatboxController.onBackButtonClick} event.
510
+ *
511
+ * @remarks
512
+ * Called from the default ChatHeader theme component for the "back" button
513
+ * which is shown when the chatbox is part of an inbox that's being rendered
514
+ * in mobile mode.
515
+ */
516
+ clickBackButton(): void;
305
517
  }
306
518
 
307
519
  /**
@@ -316,37 +528,38 @@ export declare const ChatboxElement: new () => TalkJS.ChatboxElement;
316
528
  /**
317
529
  * @public
318
530
  */
319
- export declare interface ChatboxProps {
320
- /**
321
- * @hidden
322
- */
323
- className?: string;
531
+ export declare interface ChatboxProps extends BaseChatboxProps {
324
532
  /**
325
- * @hidden
326
- */
327
- style?: React_2.CSSProperties;
328
- /**
329
- * Your app's unique TalkJS ID. You can find it on the Settings page of the
330
- * {@link https://talkjs.com/dashboard | TalkJS dashboard.}
331
- */
332
- appId: string;
333
- /**
334
- * The ID of the current user.
533
+ * The ID of the conversation to display.
335
534
  *
336
535
  * @remarks
337
- * If the given user ID doesn't exist, a "Something went wrong" message will
338
- * be displayed.
536
+ * If the conversation doesn't exist or if the current user isn't a
537
+ * participant of the current conversation, a "Chat not found" message will be
538
+ * displayed (after a timeout). If you create the conversation in parallel (eg
539
+ * via the REST API or via the Data API), it will show in the chatbox
540
+ * automatically. This means that you can safely point a chatbox at a
541
+ * conversation that might not yet exist. This way the chatbox UI and the
542
+ * conversation can load in parallel, which results in snappier UX.
543
+ *
544
+ * Passing `null` deselects the current conversation and shows an empty panel.
545
+ * This may be useful for Inbox-like scenarios where you want to keep the
546
+ * chatbox loaded, without showing a conversation.
547
+ *
548
+ * In the background, the Chatbox keeps active subscriptions to recent
549
+ * conversations, so that switching back and forth between conversations has
550
+ * snappy UX.
339
551
  */
340
- userId: string;
552
+ conversationId: string | null;
341
553
  /**
342
- * The ID of the conversation to display.
554
+ * Fired when the back button in the chat header is clicked.
343
555
  *
344
556
  * @remarks
345
- * If the conversation doesn't exist or if the current user isn't a
346
- * participant of the current conversation, a "Chat not found" message will be
347
- * displayed.
557
+ * By default this back button is only shown inside an inbox on small screens.
558
+ * You can change this behavior in the ChatHeader theme.
559
+ *
560
+ * @public
348
561
  */
349
- conversationId: string;
562
+ onBackButtonClick?: (event: BackButtonClickEvent) => void;
350
563
  /**
351
564
  * A token to authenticate the session with.
352
565
  *
@@ -370,108 +583,7 @@ export declare interface ChatboxProps {
370
583
  * {@link https://talkjs.com/docs/Features/Security/Advanced_Authentication/#refreshable-tokens | Refreshable tokens }
371
584
  * for details and examples.
372
585
  */
373
- tokenFetcher?: () => string | Promise<string>;
374
- /**
375
- * Lets you override theme components with your own implementations to
376
- * customize them.
377
- *
378
- * @remarks
379
- * See
380
- * {@link https://talkjs.com/docs/UI_Components/React/Customization/#custom-theme-components | Custom theme components }
381
- * for more info.
382
- */
383
- theme?: Partial<Theme>;
384
- /**
385
- * When true, pressing Enter will send a message.
386
- *
387
- * @remarks
388
- * Defaults to `true`.
389
- */
390
- enterSendsMessage?: boolean;
391
- /**
392
- * Sets whether the chat header is visible.
393
- *
394
- * @remarks
395
- * Defaults to `true`.
396
- */
397
- chatHeaderVisible?: boolean;
398
- /**
399
- * Sets whether the message input field is visible.
400
- *
401
- * @remarks
402
- * Defaults to `true`.
403
- */
404
- messageFieldVisible?: boolean;
405
- /**
406
- * Sets whether spellcheck is enabled in the message field.
407
- *
408
- * @remarks
409
- * Defaults to `false`.
410
- */
411
- messageFieldSpellcheck?: boolean;
412
- /**
413
- * Adds custom placeholder text for the message input field.
414
- *
415
- * @remarks
416
- * The default placeholder text is `"Say something..."`
417
- */
418
- messageFieldPlaceholder?: string;
419
- /**
420
- * Callback that triggers when the user deletes a message with the TalkJS UI.
421
- *
422
- * @param event Event object describing the message deletion
423
- */
424
- onDeleteMessage?: (event: DeleteMessageEvent) => void;
425
- /**
426
- * Callback that triggers when the user sends a message with the TalkJS UI.
427
- *
428
- * @param event Event object describing the message sending action
429
- */
430
- onSendMessage?: (event: SendMessageEvent) => void;
431
- /**
432
- * Callback that triggers when the user initiates an action that will require
433
- * a permissions request from the browser, but right before actually
434
- * requesting the permission from the browser.
435
- *
436
- * @remarks
437
- * You can use this callback to inform the user that they will need to grant a
438
- * browser permission in order to perform an action.
439
- *
440
- * @param request Object describing the permission request
441
- */
442
- beforeBrowserPermissionPrompt?: (request: BrowserPermissionRequest) => void;
443
- /**
444
- * Callback that triggers when the user attempts to initiate an action that
445
- * requires a specific browser permission, but that permission was not
446
- * granted.
447
- *
448
- * @param event Event object describing the missing permission
449
- */
450
- onMissingBrowserPermission?: (event: MissingBrowserPermissionEvent) => void;
451
- /**
452
- * This event fires when the user clicks an action button or an action Link
453
- * inside a message.
454
- *
455
- * @remarks
456
- * The event's `action` and `params` fields specify the name of action and its
457
- * parameters, if any.
458
- *
459
- * See
460
- * {@link https://talkjs.com/docs/Guides/Web_Components/Action_Buttons_Links/ | Action Buttons and Links }
461
- * for more info.
462
- */
463
- onMessageAction?: (event: MessageActionEvent) => void;
464
- /**
465
- * Arbitrary custom data passed down to the theme.
466
- *
467
- * @remarks
468
- * Whatever data you pass here will be made available for use in theme
469
- * components through {@link CommonChatboxProps.themeCustom} for Chatbox
470
- * theme components and through
471
- * {@link CommonConversationListProps.themeCustom} for ConversationList
472
- * theme components.
473
- */
474
- themeCustom?: any;
586
+ tokenFetcher?: () => string | Promise<string>;
475
587
  }
476
588
 
477
589
  /**
@@ -533,6 +645,15 @@ export declare interface CommonChatboxProps {
533
645
  * The theme object that the chatbox's is currently using.
534
646
  */
535
647
  theme: Theme;
648
+ /**
649
+ * The ID of the conversation displayed in the chatbox.
650
+ *
651
+ * @remarks
652
+ * Prefer this field instead of `common.conversation.id` (which always has the
653
+ * same value), as this enables an optimization that prevents needless
654
+ * re-renders.
655
+ */
656
+ conversationId: string;
536
657
  /**
537
658
  * The conversation displayed in the chatbox.
538
659
  */
@@ -657,7 +778,7 @@ export declare class ConversationListController {
657
778
  * instead, as that lets you keep your local state in sync with the props
658
779
  * passed to the conversation list.
659
780
  */
660
- selectConversation(conversationId: string): void;
781
+ selectConversation(conversationId: string | null): void;
661
782
  }
662
783
 
663
784
  /**
@@ -671,6 +792,9 @@ export declare class ConversationListController {
671
792
  */
672
793
  export declare const ConversationListElement: new () => TalkJS.ConversationListElement;
673
794
 
795
+ /**
796
+ * @public
797
+ */
674
798
  export declare interface ConversationListItemProps {
675
799
  /**
676
800
  * A collection of objects which are passed to all ConversationList theme components.
@@ -690,40 +814,7 @@ export declare interface ConversationListItemProps {
690
814
  /**
691
815
  * @public
692
816
  */
693
- export declare interface ConversationListProps {
694
- /**
695
- * @hidden
696
- */
697
- className?: string;
698
- /**
699
- * @hidden
700
- */
701
- style?: React_2.CSSProperties;
702
- /**
703
- * Your app's unique TalkJS ID. You can find it on the Settings page of the
704
- * {@link https://talkjs.com/dashboard | TalkJS dashboard.}
705
- */
706
- appId: string;
707
- /**
708
- * The ID of the current user.
709
- *
710
- * @remarks
711
- * If the given user ID doesn't exist, a "Something went wrong" message will
712
- * be displayed.
713
- */
714
- userId: string;
715
- /**
716
- * The ID of the conversation currently selected in the list.
717
- *
718
- * @remarks
719
- *
720
- * Changing the value of this prop will cause the ConversationList UI to
721
- * update.
722
- *
723
- * Note that updating the selected conversation through this prop **will not**
724
- * trigger the {@link onSelectConversation} callback.
725
- */
726
- selectedConversationId?: string;
817
+ export declare interface ConversationListProps extends BaseConversationListProps {
727
818
  /**
728
819
  * A token to authenticate the session with.
729
820
  *
@@ -748,41 +839,6 @@ export declare interface ConversationListProps {
748
839
  * for details and examples.
749
840
  */
750
841
  tokenFetcher?: () => string | Promise<string>;
751
- /**
752
- * Lets you override theme components with your own implementations to
753
- * customize them.
754
- *
755
- * @remarks
756
- * See
757
- * {@link https://talkjs.com/docs/UI_Components/React/Customization/#custom-theme-components | Custom theme components }
758
- * for more info.
759
- */
760
- theme?: Partial<Theme>;
761
- /**
762
- * Callback that triggers when the user selects a conversation from the list.
763
- *
764
- * @param event Event object containing the selected conversation
765
- *
766
- * @remarks
767
- * Note that updating the selected conversation through the
768
- * {@link selectedConversationId} prop **will not** trigger this callback.
769
- *
770
- * Use this callback to have an adjacent chatbox show the correct
771
- * conversation. See
772
- * {@link https://talkjs.com/docs/UI_Components/React/ConversationList/#respond-to-a-select-conversation-event | Respond to a select conversation event.}
773
- */
774
- onSelectConversation?: (event: SelectConversationEvent) => void;
775
- /**
776
- * Arbitrary custom data passed down to the theme.
777
- *
778
- * @remarks
779
- * Whatever data you pass here will be made available for use in theme
780
- * components through {@link CommonChatboxProps.themeCustom} for Chatbox
781
- * theme components and through
782
- * {@link CommonConversationListProps.themeCustom} for ConversationList
783
- * theme components.
784
- */
785
- themeCustom?: any;
786
842
  }
787
843
 
788
844
  export { ConversationSnapshot }
@@ -838,8 +894,14 @@ export declare interface DeviceFeatures {
838
894
  isMobile: boolean;
839
895
  }
840
896
 
897
+ /**
898
+ * @public
899
+ */
841
900
  export declare function Editor({ placeholder, disabled, className, characterLimit, spellcheck, }: EditorProps): JSX_2.Element;
842
901
 
902
+ /**
903
+ * @public
904
+ */
843
905
  export declare interface EditorController {
844
906
  isTyping: boolean;
845
907
  atTextLimit: boolean;
@@ -850,6 +912,7 @@ export declare interface EditorController {
850
912
  shareLocation(): void;
851
913
  attachFile(): void;
852
914
  toggleEmojiPicker(): void;
915
+ recordVoiceMessage(): void;
853
916
  }
854
917
 
855
918
  /**
@@ -887,6 +950,9 @@ export declare interface EditorProps {
887
950
  className?: string;
888
951
  }
889
952
 
953
+ /**
954
+ * @public
955
+ */
890
956
  export declare function EmojiPicker(props: EmojiPickerProps): JSX_2.Element;
891
957
 
892
958
  /**
@@ -900,9 +966,7 @@ export declare interface EmojiPickerProps {
900
966
  }
901
967
 
902
968
  /**
903
- * Shows a bar with emoji suggestions when the user types eg `:bla`. Shown if `query` is non-empty.
904
- *
905
- * Uses the IndexedDB-backed emoji database from "emoji-picker-element".
969
+ * @public
906
970
  */
907
971
  export declare function EmojiSuggestBar(props: EmojiSuggestBarProps): JSX_2.Element;
908
972
 
@@ -1083,6 +1147,62 @@ export declare interface ImageBlockProps {
1083
1147
  downloadUrl?: string;
1084
1148
  }
1085
1149
 
1150
+ /**
1151
+ * A collection of actions available on the Inbox UI
1152
+ *
1153
+ * @remarks
1154
+ * Exposes a `chatbox` field which, if a conversation is currently selected,
1155
+ * lets you control the chatbox encapsulated by this inbox.
1156
+ *
1157
+ * @public
1158
+ */
1159
+ export declare class InboxController {
1160
+ #private;
1161
+ /**
1162
+ * The {@link ChatboxController} object of the underlying chatbox
1163
+ *
1164
+ * @remarks
1165
+ * This lets you programmatically control the chatbox side of this inbox, ie
1166
+ * the right panel. For example, to control the message field text:
1167
+ *
1168
+ * ```js
1169
+ * // Obtain a reference to the inbox object, eg:
1170
+ * // const inbox = inboxRef.current; // react
1171
+ * // const inbox = document.querySelector("t-inbox") // web
1172
+ * // const inbox = inboxRef.value // vue
1173
+ * // etc
1174
+ *
1175
+ * inbox.chatbox.setMessageFieldText("Hey there");
1176
+ * ```
1177
+ */
1178
+ get chatbox(): ChatboxController;
1179
+ /**
1180
+ * Select a conversation.
1181
+ *
1182
+ * @remarks
1183
+ * This method is called from the theme's ConversationListItem component when
1184
+ * the user clicks on the given conversation. You can also call it
1185
+ * programmatically from elsewhere to simulate a user click.
1186
+ *
1187
+ * This method will trigger the {@link InboxProps.onSelectConversation} event.
1188
+ * In most cases, if you want to change the selected conversation
1189
+ * programmatically from outside the conversation list, it's better to pass a
1190
+ * different value to the {@link InboxProps.selectedConversationId} prop
1191
+ * instead, as that lets you keep your local state in sync with the props
1192
+ * passed to the conversation list.
1193
+ */
1194
+ selectConversation(conversationId: string): void;
1195
+ }
1196
+
1197
+ /**
1198
+ * The {@link https://talkjs.com/docs/Features/Chat_UIs/#inbox | Inbox UI. }
1199
+ * Combines a Conversation List with a Chatbox, responsively scaling down on
1200
+ * smaller screens.
1201
+ *
1202
+ * @public
1203
+ */
1204
+ export declare const InboxElement: new () => TalkJS.InboxElement;
1205
+
1086
1206
  export { LocationBlock }
1087
1207
 
1088
1208
  /**
@@ -1103,18 +1223,20 @@ export declare interface LocationBlockProps {
1103
1223
  block: LocationBlock;
1104
1224
  }
1105
1225
 
1226
+ /**
1227
+ * @public
1228
+ */
1106
1229
  export declare function MentionSuggestList(props: MentionSuggestListProps): JSX_2.Element | null;
1107
1230
 
1108
- export declare interface MentionSuggestList {
1109
- keydown(key: string): boolean;
1110
- }
1111
-
1112
1231
  /**
1113
1232
  * @public
1114
1233
  */
1115
1234
  export declare interface MentionSuggestListProps {
1116
1235
  }
1117
1236
 
1237
+ /**
1238
+ * @public
1239
+ */
1118
1240
  export declare function MenuItem(props: MenuItemProps): JSX_2.Element;
1119
1241
 
1120
1242
  /**
@@ -1169,6 +1291,9 @@ export declare interface MessageActionMenuProps {
1169
1291
  permissions: MessagePermissions;
1170
1292
  }
1171
1293
 
1294
+ /**
1295
+ * @public
1296
+ */
1172
1297
  export declare function MessageContent(props: MessageContentProps): JSX_2.Element;
1173
1298
 
1174
1299
  /**
@@ -1236,6 +1361,12 @@ export declare interface MessageFieldProps {
1236
1361
  * An object holding the state of the message field.
1237
1362
  */
1238
1363
  editor: EditorController;
1364
+ /**
1365
+ * Controls and holds state related to voice recording. Undefined when nothing
1366
+ * is being recorded. Use editor.recordVoiceMessage() to begin recording a
1367
+ * message.
1368
+ */
1369
+ voiceRecorder?: VoiceRecorderController;
1239
1370
  /**
1240
1371
  * When a message is being edited its ID will be stored here.
1241
1372
  */
@@ -1325,9 +1456,10 @@ export { MessageSnapshot }
1325
1456
  *
1326
1457
  * - `"everyoneRead"` - Everyone in the conversation has read this message. Typically represented using two checkmarks in chat UIs.
1327
1458
  *
1459
+ * - `"virtual"` - a virtual message made with the <VirtualMessage> system component
1328
1460
  * @public
1329
1461
  */
1330
- export declare type MessageStatus = "sending" | "sent" | "everyoneRead";
1462
+ export declare type MessageStatus = "sending" | "sent" | "everyoneRead" | "virtual";
1331
1463
 
1332
1464
  /**
1333
1465
  * Sent by {@link ChatboxProps.onMissingBrowserPermission} when the user
@@ -1361,6 +1493,16 @@ export declare interface MissingBrowserPermissionEvent {
1361
1493
  type: BrowserPermission;
1362
1494
  }
1363
1495
 
1496
+ /**
1497
+ * @public
1498
+ */
1499
+ export declare interface NoConversationSelectedProps {
1500
+ /**
1501
+ * A collection of objects which are passed to all Chatbox theme components.
1502
+ */
1503
+ common: CommonChatboxProps;
1504
+ }
1505
+
1364
1506
  export { ParticipantSnapshot }
1365
1507
 
1366
1508
  /**
@@ -1411,10 +1553,18 @@ export declare interface PopoverButtonProps<T extends object> extends React_2.HT
1411
1553
  * The element to focus when the popover is opened. Can be an element or a selector. Ignored if type is "menu".
1412
1554
  */
1413
1555
  initialFocus?: string | HTMLElement;
1556
+ /**
1557
+ * Whether to render the popover menu outside the parent element (useful if
1558
+ * the menu won't fit inside its container otherwise)
1559
+ */
1560
+ portal?: boolean;
1414
1561
  }
1415
1562
 
1416
1563
  export { Preact }
1417
1564
 
1565
+ /**
1566
+ * @public
1567
+ */
1418
1568
  export declare function ReactionPicker({ messageId, colorScheme, }: ReactionPickerProps): JSX_2.Element;
1419
1569
 
1420
1570
  /**
@@ -1431,6 +1581,20 @@ export declare interface ReactionPickerProps {
1431
1581
  colorScheme: "light" | "dark";
1432
1582
  }
1433
1583
 
1584
+ /**
1585
+ * @public
1586
+ */
1587
+ export declare interface RecordingPreviewProps {
1588
+ /**
1589
+ * A collection of objects which are passed to all Chatbox theme components.
1590
+ */
1591
+ common: CommonChatboxProps;
1592
+ /**
1593
+ * Controls and holds state related to voice recording.
1594
+ */
1595
+ voiceRecorder: VoiceRecorderController;
1596
+ }
1597
+
1434
1598
  /**
1435
1599
  * @public
1436
1600
  */
@@ -1464,13 +1628,15 @@ export declare interface ReplyBarProps {
1464
1628
  /**
1465
1629
  * An event object dispatched by the
1466
1630
  * {@link ConversationListProps.onSelectConversation} event.
1631
+ *
1632
+ * @public
1467
1633
  */
1468
1634
  export declare interface SelectConversationEvent {
1469
1635
  currentUser: UserSnapshot;
1470
1636
  /**
1471
1637
  * The newly-selected conversation.
1472
1638
  */
1473
- conversation: ConversationSnapshot;
1639
+ conversation: ConversationSnapshot | null;
1474
1640
  }
1475
1641
 
1476
1642
  /**
@@ -1573,6 +1739,7 @@ export declare interface Theme {
1573
1739
  MessageListFooter: React_2.ComponentType<MessageListFooterProps>;
1574
1740
  BeforeMessages: React_2.ComponentType<BeforeMessagesProps>;
1575
1741
  AfterMessages: React_2.ComponentType<AfterMessagesProps>;
1742
+ NoConversationSelected: React_2.ComponentType<NoConversationSelectedProps>;
1576
1743
  TextBlock: React_2.ComponentType<TextBlockProps>;
1577
1744
  FileBlock: React_2.ComponentType<FileBlockProps>;
1578
1745
  LocationBlock: React_2.ComponentType<LocationBlockProps>;
@@ -1580,6 +1747,8 @@ export declare interface Theme {
1580
1747
  AudioBlock: React_2.ComponentType<AudioBlockProps>;
1581
1748
  VoiceBlock: React_2.ComponentType<VoiceBlockProps>;
1582
1749
  VideoBlock: React_2.ComponentType<VideoBlockProps>;
1750
+ VoiceRecorder: React_2.ComponentType<VoiceRecorderProps>;
1751
+ RecordingPreview: React_2.ComponentType<RecordingPreviewProps>;
1583
1752
  ConversationListItem: React_2.ComponentType<ConversationListItemProps>;
1584
1753
  }
1585
1754
 
@@ -1627,7 +1796,10 @@ export declare interface Translation extends TranslationStrings {
1627
1796
  locale: string;
1628
1797
  }
1629
1798
 
1630
- declare interface TranslationStrings {
1799
+ /**
1800
+ * @public
1801
+ */
1802
+ export declare interface TranslationStrings {
1631
1803
  YESTERDAY: string;
1632
1804
  TODAY: string;
1633
1805
  DAYS: string;
@@ -1705,13 +1877,16 @@ declare interface TranslationStrings {
1705
1877
 
1706
1878
  export { TypingSnapshot }
1707
1879
 
1880
+ /** @public */
1881
+ export declare type UploadState = "pending" | "done" | "error";
1882
+
1708
1883
  /**
1709
1884
  * Returns a list of participants in the conversation with the given ID.
1710
1885
  * It'll initially return an empty list, and re-render the calling component as data participants are loaded.
1711
1886
  * It'll also cause a re-render when any of those participants change, such as when a user's name or photoUrl changes.
1712
1887
  *
1713
- * @param conversationId ID of the conversation
1714
- * @param limit Maximum number of participants to subscribe to. Defaults to 10. The maximum is 100.
1888
+ * @param conversationId - ID of the conversation
1889
+ * @param limit - Maximum number of participants to subscribe to. Defaults to 10. The maximum is 100.
1715
1890
  * @returns List of participant snapshots.
1716
1891
  *
1717
1892
  * @public
@@ -1722,8 +1897,8 @@ export declare function useParticipants(conversationId: string, limit?: number):
1722
1897
  * Returns "Yesterday", "Last Monday", "Tuesday, March 31" or "Monday, March 31
1723
1898
  * 2014", depending on which is most appropriate.
1724
1899
  *
1725
- * @param timestamp The timestamp of the event in milliseconds since Unix epoch.
1726
- * @param t Relevant translation object to get localized output
1900
+ * @param timestamp - The timestamp of the event in milliseconds since Unix epoch.
1901
+ * @param t - Relevant translation object to get localized output
1727
1902
  *
1728
1903
  * @public
1729
1904
  */
@@ -1821,6 +1996,87 @@ export declare interface VideoBlockProps {
1821
1996
  downloadUrl?: string;
1822
1997
  }
1823
1998
 
1999
+ /**
2000
+ * Lets you render a fake message with content and sender of your choice,
2001
+ * without having to compose a complete MessageSnapshot object.
2002
+ *
2003
+ * @remarks
2004
+ * This system component renders a fake message that looks and behaves like a
2005
+ * real chat message, but is never stored or sent through TalkJS. It is useful
2006
+ * for showing contextual prompts such as welcome messages at the top of a
2007
+ * conversation.
2008
+ *
2009
+ * Uses the provided props to compose a complete {@link MessageSnapshot} object,
2010
+ * which is then passed to the
2011
+ * {@link /UI_Components/Theme/Theme_components/Message | Message} component
2012
+ * from your theme.
2013
+ *
2014
+ * Because the message isn't a real, stored message, the message is rendered as
2015
+ * if the user has no permissions to perform any actions on this message (such
2016
+ * as reply, edit, etc). This means the built-in action menu will not be
2017
+ * accessible.
2018
+ *
2019
+ * @public
2020
+ */
2021
+ export declare function VirtualMessage(props: VirtualMessageProps): JSX_2.Element | null;
2022
+
2023
+ /**
2024
+ * @public
2025
+ */
2026
+ export declare interface VirtualMessageProps {
2027
+ /**
2028
+ * The text of the message. Accepts formatting markup like the chatbox message field does, eg `*this*` would become bold.
2029
+ *
2030
+ * @remarks
2031
+ * Specify either `text` or `content`, but not both.
2032
+ */
2033
+ text?: string;
2034
+ /**
2035
+ * The content of the message as a content block.
2036
+ *
2037
+ * @remarks
2038
+ * Lets you precisely control the formatting of the message, see
2039
+ * {@link https://talkjs.com/docs/Concepts/Message_Content/#sending-message-content | Message content}.
2040
+ * Specify either `text` or `content`, but not both.
2041
+ */
2042
+ content?: ContentBlock[];
2043
+ /**
2044
+ * The ID of the sender of this message, or a complete UserSnapshot with the
2045
+ * sender's details.
2046
+ *
2047
+ * @remarks
2048
+ * When omitted, the message is rendered as a system message.
2049
+ *
2050
+ * When passing a UserSnapshot, this object is used in full and the user is
2051
+ * not loaded from the database, which means that you can also pass a fake
2052
+ * user that does not really exist.
2053
+ */
2054
+ sender?: string | UserSnapshot;
2055
+ /**
2056
+ * Override the message's timestamp
2057
+ *
2058
+ * @remarks
2059
+ * Defaults to `-1`, which our preset themes interpret as "do not show a timestamp at all"
2060
+ */
2061
+ createdAt?: number;
2062
+ /**
2063
+ * Control the message's delivery status
2064
+ *
2065
+ * @remarks
2066
+ * Defaults to "virtual", which make our preset themes not render status ticks
2067
+ * at all. Set it to eg `"sent"` to show a tickmark, or to `"everyoneRead"` to
2068
+ * show a double tickmark.
2069
+ */
2070
+ status?: MessageStatus;
2071
+ /**
2072
+ * Custom data for the `message` object.
2073
+ *
2074
+ * @remarks
2075
+ * You can read this out in `message.custom` inside the Message theme component.
2076
+ */
2077
+ custom?: Record<string, string>;
2078
+ }
2079
+
1824
2080
  export { VoiceBlock }
1825
2081
 
1826
2082
  /**
@@ -1856,6 +2112,92 @@ export declare interface VoiceBlockProps {
1856
2112
  downloadUrl?: string;
1857
2113
  }
1858
2114
 
2115
+ /**
2116
+ * Controller for voice recording. Contains methods and fields related to the
2117
+ * voice message currently being recorded.
2118
+ *
2119
+ * @remarks
2120
+ * Use {@link EditorController.recordVoiceMessage} to begin recording a voice
2121
+ * message.
2122
+ *
2123
+ * @public
2124
+ */
2125
+ export declare interface VoiceRecorderController {
2126
+ /** Whether `"recording"` or `"previewing"`.
2127
+ *
2128
+ * @remarks When not recording at all, the voiceController field is undefined.
2129
+ * */
2130
+ state: VoiceRecorderState;
2131
+ /**
2132
+ * The amount of seconds since the user began recording.
2133
+ */
2134
+ duration: number;
2135
+ /** Defined after stop() has been called. Pass to the `src` prop of
2136
+ * {@link AudioPlayer} to preview the recording. */
2137
+ recordingUrl?: string;
2138
+ /**
2139
+ * TalkJS will immediately upload the voice message while it's being
2140
+ * previewed. This field lets you know how that's coming along.
2141
+ */
2142
+ uploadState: UploadState;
2143
+ /**
2144
+ * Stops the voice recording and changes the state to "previewing".
2145
+ * This also starts the process of uploading the audio file.
2146
+ */
2147
+ stop(): void;
2148
+ /**
2149
+ * Cancels the recording or preview process.
2150
+ */
2151
+ cancel(): void;
2152
+ /**
2153
+ * Sends a message containing the just uploaded voice recording.
2154
+ */
2155
+ send(): void;
2156
+ }
2157
+
2158
+ /**
2159
+ * @public
2160
+ */
2161
+ export declare interface VoiceRecorderProps {
2162
+ /**
2163
+ * A collection of objects which are passed to all Chatbox theme components.
2164
+ */
2165
+ common: CommonChatboxProps;
2166
+ /**
2167
+ * Controls and holds state related to voice recording.
2168
+ */
2169
+ voiceRecorder: VoiceRecorderController;
2170
+ }
2171
+
2172
+ /** @public */
2173
+ export declare type VoiceRecorderState = "recording" | "previewing";
2174
+
2175
+ /**
2176
+ * Renders an audio waveform visualization for voice recording.
2177
+ *
2178
+ * @remarks
2179
+ * Use this component inside your {@link VoiceRecorder} theme component to
2180
+ * display the audio waveform. The waveform automatically visualizes the audio
2181
+ * being recorded
2182
+ *
2183
+ * @public
2184
+ */
2185
+ export declare function Waveform({ className, voiceRecorder }: WaveformProps): JSX_2.Element | null;
2186
+
2187
+ /**
2188
+ * @public
2189
+ */
2190
+ export declare interface WaveformProps {
2191
+ /**
2192
+ * Additional CSS class name to apply to the waveform container.
2193
+ */
2194
+ className?: string;
2195
+ /**
2196
+ * The active voice recorder controller, as passed to MessageField props.
2197
+ */
2198
+ voiceRecorder: VoiceRecorderController;
2199
+ }
2200
+
1859
2201
  export { }
1860
2202
 
1861
2203
 
@@ -1867,14 +2209,20 @@ declare global {
1867
2209
  type NullishConversationListProps = {
1868
2210
  [K in keyof Omit<ConversationListProps, "className" | "style">]: ConversationListProps[K] | null | undefined;
1869
2211
  };
2212
+ type NullishInboxProps = {
2213
+ [K in keyof Omit<InboxProps, "className" | "style">]: InboxProps[K] | null | undefined;
2214
+ };
1870
2215
  interface ChatboxElement extends HTMLElement, NullishChatboxProps, ChatboxController {
1871
2216
  }
1872
2217
  interface ConversationListElement extends HTMLElement, NullishConversationListProps, ConversationListController {
1873
2218
  }
2219
+ interface InboxElement extends HTMLElement, NullishInboxProps, InboxController {
2220
+ }
1874
2221
  }
1875
2222
  interface HTMLElementTagNameMap {
1876
2223
  "t-chatbox": TalkJS.ChatboxElement;
1877
2224
  "t-conversation-list": TalkJS.ConversationListElement;
2225
+ "t-inbox": TalkJS.InboxElement;
1878
2226
  }
1879
2227
  }
1880
2228