@dialtribe/chat-client 0.4.0 → 0.5.1

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/README.md CHANGED
@@ -111,6 +111,7 @@ function MessageButton({ user }: { user: { id: string; name: string } }) {
111
111
  | `panelWidth` | `380` | Desktop panel width in px |
112
112
  | `railDmLimit` | `5` | Recent DMs shown as rail icons |
113
113
  | `mobileBreakpoint` | `768` | Below this width the rail becomes the floating button |
114
+ | `notifications` | `false` | Show the Dialtribe Notifications inbox: a bell above Messages with an unread badge (see below). Pass `{ onOpen(item) }` to route clicks yourself; return `true` when you navigated |
114
115
 
115
116
  ### Your own rail items
116
117
 
@@ -137,6 +138,37 @@ active trigger closes the panel, and `useDialtribeMessages().openItem("account")
137
138
  opens it from anywhere. On mobile the item lives in the drawer like everything
138
139
  else.
139
140
 
141
+ ### Notifications
142
+
143
+ `notifications` adds your users' in-app notifications to the rail. Your backend
144
+ sends them to Dialtribe with your secret key; the rail reads them with the same
145
+ session token as chat, and new ones arrive live on the existing connection.
146
+
147
+ ```ts
148
+ // Your server
149
+ await fetch("https://dialtribe.com/api/public/v1/notifications", {
150
+ method: "POST",
151
+ headers: { Authorization: `Bearer ${DIALTRIBE_SECRET_KEY}`, "Content-Type": "application/json" },
152
+ body: JSON.stringify({
153
+ eventType: "chat.mention",
154
+ recipients: ["123"], // your user ids, up to 1,000 per call
155
+ dedupeKey: "mention:msg_9981", // re-sending never notifies anyone twice
156
+ title: "milkbox mentioned you",
157
+ body: "hey @you, listen to this",
158
+ url: "https://yourapp.com/rooms/42",
159
+ actor: { userId: "1", name: "milkbox", avatarUrl: "https://..." },
160
+ groupKey: "kudos:msg_9981", // optional: repeats show as one row
161
+ }),
162
+ });
163
+ ```
164
+
165
+ ```tsx
166
+ <DialtribeMessages notifications={{ onOpen: (item) => { router.push(item.url); return true; } }} />
167
+ ```
168
+
169
+ The provider's `apiUrl` (default `https://dialtribe.com`) is where notifications
170
+ are read from.
171
+
140
172
  ## Hooks
141
173
 
142
174
  All hooks must be under `<DialtribeChatProvider>`, which owns one connection
@@ -182,7 +214,14 @@ one subscription.
182
214
  ### `useDialtribeMessages()`
183
215
 
184
216
  Drive the rail: `open`, `close`, `toggle`, `openInbox`, `openRoom(roomId)`, `openItem(itemId)`,
185
- `messageUser(userId, hint?)`, `isOpen`, `view`.
217
+ `openNotifications()`, `messageUser(userId, hint?)`, `isOpen`, `view`.
218
+
219
+ ### `useDialtribeNotifications()`
220
+
221
+ `{ items, unreadCount, status, hasMore, loadingMore, error }` plus `refresh`,
222
+ `loadMore`, `markRead(ids)`, `markAllRead`, `markSeen`, `click(ids)`. Use it to
223
+ build your own notifications UI, or render `<NotificationsPanel labels={...} />`
224
+ anywhere under the provider.
186
225
 
187
226
  ### `useChatConnection()`
188
227
 
package/dist/index.d.mts CHANGED
@@ -204,7 +204,40 @@ type UserEvent = {
204
204
  type: "chat-error";
205
205
  code: ChatErrorCode;
206
206
  message?: string;
207
+ }
208
+ /** Dialtribe Notifications: a new item for this user (unread). */
209
+ | {
210
+ type: "notification.created";
211
+ notification: NotificationItem;
212
+ unreadCount?: number;
213
+ }
214
+ /** Items were read elsewhere (another tab or device). `ids` null means all. */
215
+ | {
216
+ type: "notification.read";
217
+ ids: string[] | null;
218
+ unreadCount: number;
207
219
  };
220
+ /** One in-app notification for the signed-in user (Dialtribe Notifications). */
221
+ interface NotificationItem {
222
+ id: string;
223
+ eventType: string;
224
+ title: string;
225
+ body: string | null;
226
+ url: string | null;
227
+ imageUrl: string | null;
228
+ actor: {
229
+ userId: string | null;
230
+ name: string | null;
231
+ avatarUrl: string | null;
232
+ } | null;
233
+ /** Items sharing a groupKey are shown as one row ("and 3 others"). */
234
+ groupKey: string | null;
235
+ data: unknown;
236
+ createdAt: string;
237
+ seenAt: string | null;
238
+ readAt: string | null;
239
+ clickedAt: string | null;
240
+ }
208
241
 
209
242
  /**
210
243
  * A failed chat call: a transport failure, or a chat-ws rejection with the
@@ -332,9 +365,56 @@ declare class InboxStore extends Store<InboxSnapshot> {
332
365
  private setRooms;
333
366
  }
334
367
 
368
+ interface NotificationsSnapshot {
369
+ status: "idle" | "loading" | "ready" | "error";
370
+ /** Newest first. */
371
+ items: NotificationItem[];
372
+ unreadCount: number;
373
+ /** More older items exist (call loadMore). */
374
+ hasMore: boolean;
375
+ loadingMore: boolean;
376
+ error: ChatRequestError | null;
377
+ }
378
+ /**
379
+ * The signed-in user's notifications (Dialtribe Notifications service). Live
380
+ * via the personal channel the chat connection already holds; reconciled from
381
+ * the server on every (re)connect, so a missed event never leaves it wrong.
382
+ * Started on first `acquire()`, so apps that don't show notifications pay nothing.
383
+ */
384
+ declare class NotificationsStore extends Store<NotificationsSnapshot> {
385
+ private readonly client;
386
+ private refs;
387
+ private unlisten;
388
+ private refreshTimer;
389
+ private nextCursor;
390
+ constructor(client: ChatClient);
391
+ acquire(): void;
392
+ release(): void;
393
+ /** Reload the first page and the unread count. */
394
+ refresh(): Promise<void>;
395
+ /** Append the next (older) page. */
396
+ loadMore(): Promise<void>;
397
+ /** Mark items read (optimistic). */
398
+ markRead(ids: string[]): Promise<void>;
399
+ /** Mark everything read (optimistic). */
400
+ markAllRead(): Promise<void>;
401
+ /** Record that the list was shown (for stats; doesn't change unread). */
402
+ markSeen(): Promise<void>;
403
+ /** Record a click (also marks read). Pass every id in a grouped row. */
404
+ click(ids: string[]): Promise<void>;
405
+ private onUserEvent;
406
+ private applyRead;
407
+ private scheduleRefresh;
408
+ }
409
+
335
410
  interface ChatClientOptions {
336
411
  /** chat-ws base URL, e.g. "https://chatws.dialtribe.com". */
337
412
  serverUrl: string;
413
+ /**
414
+ * Dialtribe API base URL for services outside chat-ws (notifications).
415
+ * Defaults to "https://dialtribe.com". Uses the same session token.
416
+ */
417
+ apiUrl?: string;
338
418
  /**
339
419
  * Returns a current `sess_` token minted by the host backend for the signed-in
340
420
  * user. Called on start, and again whenever chat-ws rejects the token, so
@@ -383,6 +463,7 @@ declare class ChatClient {
383
463
  readonly connection: ConnectionStore;
384
464
  private readonly events;
385
465
  private readonly serverUrl;
466
+ private readonly apiUrl;
386
467
  private centrifuge;
387
468
  private userChannel;
388
469
  private sessionToken;
@@ -391,6 +472,7 @@ declare class ChatClient {
391
472
  private generation;
392
473
  private rooms;
393
474
  private inboxStore;
475
+ private notificationsStore;
394
476
  constructor(options: ChatClientOptions);
395
477
  /** Connect. Idempotent; resolves once the connection has been initiated. */
396
478
  start(): Promise<void>;
@@ -401,6 +483,8 @@ declare class ChatClient {
401
483
  room(roomId: string): RoomStore;
402
484
  /** The signed-in user's DM inbox (created on first use). */
403
485
  get inbox(): InboxStore;
486
+ /** The signed-in user's notifications (created on first use). */
487
+ get notifications(): NotificationsStore;
404
488
  get self(): ChatSelf | null;
405
489
  private open;
406
490
  private fetchGrant;
@@ -425,6 +509,14 @@ declare class ChatClient {
425
509
  }[];
426
510
  userCount: number;
427
511
  }>;
512
+ /**
513
+ * Authenticated JSON request to the Dialtribe API (apiUrl), with the same
514
+ * session token and 401 retry as chat-ws requests. `path` is under /api/public/v1.
515
+ */
516
+ api<T>(path: string, init?: {
517
+ method?: "GET" | "POST";
518
+ body?: unknown;
519
+ }): Promise<T>;
428
520
  /** A DM action on POST /dm (see DMS.md). */
429
521
  dm<T = Record<string, unknown>>(action: string, fields?: Record<string, unknown>): Promise<T>;
430
522
  /**
@@ -442,6 +534,10 @@ type MessagesView = {
442
534
  kind: "room";
443
535
  roomId: string;
444
536
  }
537
+ /** The built-in notifications panel (DialtribeMessages `notifications`). */
538
+ | {
539
+ kind: "notifications";
540
+ }
445
541
  /** A host-defined rail item (DialtribeMessages `items`). */
446
542
  | {
447
543
  kind: "item";
@@ -482,7 +578,7 @@ interface DialtribeChatProviderProps extends Omit<ChatClientOptions, "getSession
482
578
  * )}
483
579
  * ```
484
580
  */
485
- declare function DialtribeChatProvider({ children, getSessionToken, serverUrl, websocketUrl, websocket }: DialtribeChatProviderProps): react.JSX.Element;
581
+ declare function DialtribeChatProvider({ children, getSessionToken, serverUrl, apiUrl, websocketUrl, websocket }: DialtribeChatProviderProps): react.JSX.Element;
486
582
  /** The shared ChatClient. Must be under a <DialtribeChatProvider>. */
487
583
  declare function useChatClient(): ChatClient;
488
584
 
@@ -563,6 +659,8 @@ interface UseDialtribeMessagesReturn {
563
659
  openRoom: (roomId: string) => void;
564
660
  /** Show one of the host's own rail items (DialtribeMessages `items`) by id. */
565
661
  openItem: (itemId: string) => void;
662
+ /** Open the notifications panel (when the rail shows notifications). */
663
+ openNotifications: () => void;
566
664
  /**
567
665
  * Start (or reopen) a DM with one of your users and show it. `hint` is only a
568
666
  * display name for someone Dialtribe hasn't seen yet. Rejects with
@@ -585,6 +683,19 @@ interface UseDialtribeMessagesReturn {
585
683
  */
586
684
  declare function useDialtribeMessages(): UseDialtribeMessagesReturn;
587
685
 
686
+ type UseDialtribeNotificationsReturn = NotificationsSnapshot & Pick<NotificationsStore, "refresh" | "loadMore" | "markRead" | "markAllRead" | "markSeen" | "click">;
687
+ /**
688
+ * The signed-in user's in-app notifications (Dialtribe Notifications): newest
689
+ * first, the unread count, and the read/click actions. Live over the existing
690
+ * chat connection. Must be under a <DialtribeChatProvider>.
691
+ *
692
+ * @example
693
+ * ```tsx
694
+ * const { items, unreadCount, markAllRead } = useDialtribeNotifications();
695
+ * ```
696
+ */
697
+ declare function useDialtribeNotifications(): UseDialtribeNotificationsReturn;
698
+
588
699
  /** User-facing strings for <DialtribeMessages>. Override any via the `labels` prop. */
589
700
  interface MessagesLabels {
590
701
  messages: string;
@@ -622,6 +733,15 @@ interface MessagesLabels {
622
733
  cancel: string;
623
734
  messagePlaceholder: string;
624
735
  openMessages: string;
736
+ /** Notifications panel and rail button. */
737
+ notifications: string;
738
+ noNotifications: string;
739
+ markAllRead: string;
740
+ loadMore: string;
741
+ /** Extra line on a grouped row: "and 3 more". */
742
+ groupMore: (count: number) => string;
743
+ /** Relative times: "now", "5m", "3h", "2d". */
744
+ timeAgo: (date: Date) => string;
625
745
  }
626
746
  declare const DEFAULT_LABELS: MessagesLabels;
627
747
 
@@ -705,6 +825,14 @@ interface DialtribeMessagesProps {
705
825
  * proceed. Without it, a built-in dialog inside the panel is used.
706
826
  */
707
827
  confirm?: ConfirmFn;
828
+ /**
829
+ * Show the Dialtribe Notifications inbox: a bell on the rail (above Messages)
830
+ * with an unread badge, opening the notifications panel. Pass an object to
831
+ * handle opening a notification yourself (return true when you navigated).
832
+ */
833
+ notifications?: boolean | {
834
+ onOpen?: (item: NotificationItem) => boolean | void;
835
+ };
708
836
  }
709
837
  /**
710
838
  * Drop-in messages rail: inbox, DM requests, conversations, and any host
@@ -721,7 +849,24 @@ interface DialtribeMessagesProps {
721
849
  * </DialtribeChatProvider>
722
850
  * ```
723
851
  */
724
- declare function DialtribeMessages({ side, placement, openPlacement, items, inboxRowClose, contexts, theme, labels: labelOverrides, panelWidth, railDmLimit, mobileBreakpoint, confirm: hostConfirm, }: DialtribeMessagesProps): react.JSX.Element;
852
+ declare function DialtribeMessages({ side, placement, openPlacement, items, inboxRowClose, contexts, theme, labels: labelOverrides, panelWidth, railDmLimit, mobileBreakpoint, confirm: hostConfirm, notifications, }: DialtribeMessagesProps): react.JSX.Element;
853
+
854
+ interface NotificationsPanelProps {
855
+ labels: MessagesLabels;
856
+ onClose?: () => void;
857
+ /**
858
+ * Called when a notification is opened. Return true if you handled the
859
+ * navigation (e.g. client-side routing); otherwise the browser goes to its url.
860
+ */
861
+ onOpen?: (item: NotificationItem) => boolean | void;
862
+ /** Called after a notification with a link was opened (the rail closes itself on mobile). */
863
+ onOpened?: (item: NotificationItem) => void;
864
+ }
865
+ /**
866
+ * The notifications list shown in the messages rail. Usable on its own too
867
+ * (any host panel) as long as it's under a <DialtribeChatProvider>.
868
+ */
869
+ declare function NotificationsPanel({ labels, onClose, onOpen, onOpened }: NotificationsPanelProps): react.JSX.Element;
725
870
 
726
871
  interface AvatarProps {
727
872
  name: string;
@@ -800,4 +945,4 @@ interface ChatInputProps {
800
945
  */
801
946
  declare function ChatInput({ onSendMessage, onSendTyping, replyTo, onClearReply, disabled, placeholder, maxLength, }: ChatInputProps): react.JSX.Element;
802
947
 
803
- export { Avatar, type AvatarProps, ChatClient, type ChatClientOptions, type ChatErrorCode, ChatInput, type ChatInputProps, type ChatMessage, ChatMessageItem, type ChatMessageItemProps, ChatPanel, type ChatPanelProps, ChatRequestError, type ChatRoomConfig, ChatRoomProvider, type ChatRoomProviderProps, type ChatSelf, type ConfirmFn, type ConfirmOptions, type ConnectionSnapshot, type ConnectionState, DEFAULT_LABELS, DialtribeChatProvider, type DialtribeChatProviderProps, DialtribeMessages, type DialtribeMessagesProps, type DmMemberStatus, type DmParticipant, type DmRequestResult, type DmRoomSummary, type Flair, type InboxSnapshot, type MessagesContext, type MessagesLabels, type MessagesTheme, type MessagesUiSnapshot, type MessagesView, type ParsedReactions, type RailItem, type RichMediaConfig, type RoomEvent, type RoomInit, type RoomSnapshot, type RoomState, type TypingUser, type UseChatRoomsReturn, type UseDialtribeChatOptions, type UseDialtribeChatReturn, type UseDialtribeMessagesReturn, type UserEvent, parseReactions, useChatClient, useChatConnection, useChatRoomContext, useChatRooms, useDialtribeChat, useDialtribeMessages };
948
+ export { Avatar, type AvatarProps, ChatClient, type ChatClientOptions, type ChatErrorCode, ChatInput, type ChatInputProps, type ChatMessage, ChatMessageItem, type ChatMessageItemProps, ChatPanel, type ChatPanelProps, ChatRequestError, type ChatRoomConfig, ChatRoomProvider, type ChatRoomProviderProps, type ChatSelf, type ConfirmFn, type ConfirmOptions, type ConnectionSnapshot, type ConnectionState, DEFAULT_LABELS, DialtribeChatProvider, type DialtribeChatProviderProps, DialtribeMessages, type DialtribeMessagesProps, type DmMemberStatus, type DmParticipant, type DmRequestResult, type DmRoomSummary, type Flair, type InboxSnapshot, type MessagesContext, type MessagesLabels, type MessagesTheme, type MessagesUiSnapshot, type MessagesView, type NotificationItem, NotificationsPanel, type NotificationsPanelProps, type NotificationsSnapshot, type ParsedReactions, type RailItem, type RichMediaConfig, type RoomEvent, type RoomInit, type RoomSnapshot, type RoomState, type TypingUser, type UseChatRoomsReturn, type UseDialtribeChatOptions, type UseDialtribeChatReturn, type UseDialtribeMessagesReturn, type UseDialtribeNotificationsReturn, type UserEvent, parseReactions, useChatClient, useChatConnection, useChatRoomContext, useChatRooms, useDialtribeChat, useDialtribeMessages, useDialtribeNotifications };
package/dist/index.d.ts CHANGED
@@ -204,7 +204,40 @@ type UserEvent = {
204
204
  type: "chat-error";
205
205
  code: ChatErrorCode;
206
206
  message?: string;
207
+ }
208
+ /** Dialtribe Notifications: a new item for this user (unread). */
209
+ | {
210
+ type: "notification.created";
211
+ notification: NotificationItem;
212
+ unreadCount?: number;
213
+ }
214
+ /** Items were read elsewhere (another tab or device). `ids` null means all. */
215
+ | {
216
+ type: "notification.read";
217
+ ids: string[] | null;
218
+ unreadCount: number;
207
219
  };
220
+ /** One in-app notification for the signed-in user (Dialtribe Notifications). */
221
+ interface NotificationItem {
222
+ id: string;
223
+ eventType: string;
224
+ title: string;
225
+ body: string | null;
226
+ url: string | null;
227
+ imageUrl: string | null;
228
+ actor: {
229
+ userId: string | null;
230
+ name: string | null;
231
+ avatarUrl: string | null;
232
+ } | null;
233
+ /** Items sharing a groupKey are shown as one row ("and 3 others"). */
234
+ groupKey: string | null;
235
+ data: unknown;
236
+ createdAt: string;
237
+ seenAt: string | null;
238
+ readAt: string | null;
239
+ clickedAt: string | null;
240
+ }
208
241
 
209
242
  /**
210
243
  * A failed chat call: a transport failure, or a chat-ws rejection with the
@@ -332,9 +365,56 @@ declare class InboxStore extends Store<InboxSnapshot> {
332
365
  private setRooms;
333
366
  }
334
367
 
368
+ interface NotificationsSnapshot {
369
+ status: "idle" | "loading" | "ready" | "error";
370
+ /** Newest first. */
371
+ items: NotificationItem[];
372
+ unreadCount: number;
373
+ /** More older items exist (call loadMore). */
374
+ hasMore: boolean;
375
+ loadingMore: boolean;
376
+ error: ChatRequestError | null;
377
+ }
378
+ /**
379
+ * The signed-in user's notifications (Dialtribe Notifications service). Live
380
+ * via the personal channel the chat connection already holds; reconciled from
381
+ * the server on every (re)connect, so a missed event never leaves it wrong.
382
+ * Started on first `acquire()`, so apps that don't show notifications pay nothing.
383
+ */
384
+ declare class NotificationsStore extends Store<NotificationsSnapshot> {
385
+ private readonly client;
386
+ private refs;
387
+ private unlisten;
388
+ private refreshTimer;
389
+ private nextCursor;
390
+ constructor(client: ChatClient);
391
+ acquire(): void;
392
+ release(): void;
393
+ /** Reload the first page and the unread count. */
394
+ refresh(): Promise<void>;
395
+ /** Append the next (older) page. */
396
+ loadMore(): Promise<void>;
397
+ /** Mark items read (optimistic). */
398
+ markRead(ids: string[]): Promise<void>;
399
+ /** Mark everything read (optimistic). */
400
+ markAllRead(): Promise<void>;
401
+ /** Record that the list was shown (for stats; doesn't change unread). */
402
+ markSeen(): Promise<void>;
403
+ /** Record a click (also marks read). Pass every id in a grouped row. */
404
+ click(ids: string[]): Promise<void>;
405
+ private onUserEvent;
406
+ private applyRead;
407
+ private scheduleRefresh;
408
+ }
409
+
335
410
  interface ChatClientOptions {
336
411
  /** chat-ws base URL, e.g. "https://chatws.dialtribe.com". */
337
412
  serverUrl: string;
413
+ /**
414
+ * Dialtribe API base URL for services outside chat-ws (notifications).
415
+ * Defaults to "https://dialtribe.com". Uses the same session token.
416
+ */
417
+ apiUrl?: string;
338
418
  /**
339
419
  * Returns a current `sess_` token minted by the host backend for the signed-in
340
420
  * user. Called on start, and again whenever chat-ws rejects the token, so
@@ -383,6 +463,7 @@ declare class ChatClient {
383
463
  readonly connection: ConnectionStore;
384
464
  private readonly events;
385
465
  private readonly serverUrl;
466
+ private readonly apiUrl;
386
467
  private centrifuge;
387
468
  private userChannel;
388
469
  private sessionToken;
@@ -391,6 +472,7 @@ declare class ChatClient {
391
472
  private generation;
392
473
  private rooms;
393
474
  private inboxStore;
475
+ private notificationsStore;
394
476
  constructor(options: ChatClientOptions);
395
477
  /** Connect. Idempotent; resolves once the connection has been initiated. */
396
478
  start(): Promise<void>;
@@ -401,6 +483,8 @@ declare class ChatClient {
401
483
  room(roomId: string): RoomStore;
402
484
  /** The signed-in user's DM inbox (created on first use). */
403
485
  get inbox(): InboxStore;
486
+ /** The signed-in user's notifications (created on first use). */
487
+ get notifications(): NotificationsStore;
404
488
  get self(): ChatSelf | null;
405
489
  private open;
406
490
  private fetchGrant;
@@ -425,6 +509,14 @@ declare class ChatClient {
425
509
  }[];
426
510
  userCount: number;
427
511
  }>;
512
+ /**
513
+ * Authenticated JSON request to the Dialtribe API (apiUrl), with the same
514
+ * session token and 401 retry as chat-ws requests. `path` is under /api/public/v1.
515
+ */
516
+ api<T>(path: string, init?: {
517
+ method?: "GET" | "POST";
518
+ body?: unknown;
519
+ }): Promise<T>;
428
520
  /** A DM action on POST /dm (see DMS.md). */
429
521
  dm<T = Record<string, unknown>>(action: string, fields?: Record<string, unknown>): Promise<T>;
430
522
  /**
@@ -442,6 +534,10 @@ type MessagesView = {
442
534
  kind: "room";
443
535
  roomId: string;
444
536
  }
537
+ /** The built-in notifications panel (DialtribeMessages `notifications`). */
538
+ | {
539
+ kind: "notifications";
540
+ }
445
541
  /** A host-defined rail item (DialtribeMessages `items`). */
446
542
  | {
447
543
  kind: "item";
@@ -482,7 +578,7 @@ interface DialtribeChatProviderProps extends Omit<ChatClientOptions, "getSession
482
578
  * )}
483
579
  * ```
484
580
  */
485
- declare function DialtribeChatProvider({ children, getSessionToken, serverUrl, websocketUrl, websocket }: DialtribeChatProviderProps): react.JSX.Element;
581
+ declare function DialtribeChatProvider({ children, getSessionToken, serverUrl, apiUrl, websocketUrl, websocket }: DialtribeChatProviderProps): react.JSX.Element;
486
582
  /** The shared ChatClient. Must be under a <DialtribeChatProvider>. */
487
583
  declare function useChatClient(): ChatClient;
488
584
 
@@ -563,6 +659,8 @@ interface UseDialtribeMessagesReturn {
563
659
  openRoom: (roomId: string) => void;
564
660
  /** Show one of the host's own rail items (DialtribeMessages `items`) by id. */
565
661
  openItem: (itemId: string) => void;
662
+ /** Open the notifications panel (when the rail shows notifications). */
663
+ openNotifications: () => void;
566
664
  /**
567
665
  * Start (or reopen) a DM with one of your users and show it. `hint` is only a
568
666
  * display name for someone Dialtribe hasn't seen yet. Rejects with
@@ -585,6 +683,19 @@ interface UseDialtribeMessagesReturn {
585
683
  */
586
684
  declare function useDialtribeMessages(): UseDialtribeMessagesReturn;
587
685
 
686
+ type UseDialtribeNotificationsReturn = NotificationsSnapshot & Pick<NotificationsStore, "refresh" | "loadMore" | "markRead" | "markAllRead" | "markSeen" | "click">;
687
+ /**
688
+ * The signed-in user's in-app notifications (Dialtribe Notifications): newest
689
+ * first, the unread count, and the read/click actions. Live over the existing
690
+ * chat connection. Must be under a <DialtribeChatProvider>.
691
+ *
692
+ * @example
693
+ * ```tsx
694
+ * const { items, unreadCount, markAllRead } = useDialtribeNotifications();
695
+ * ```
696
+ */
697
+ declare function useDialtribeNotifications(): UseDialtribeNotificationsReturn;
698
+
588
699
  /** User-facing strings for <DialtribeMessages>. Override any via the `labels` prop. */
589
700
  interface MessagesLabels {
590
701
  messages: string;
@@ -622,6 +733,15 @@ interface MessagesLabels {
622
733
  cancel: string;
623
734
  messagePlaceholder: string;
624
735
  openMessages: string;
736
+ /** Notifications panel and rail button. */
737
+ notifications: string;
738
+ noNotifications: string;
739
+ markAllRead: string;
740
+ loadMore: string;
741
+ /** Extra line on a grouped row: "and 3 more". */
742
+ groupMore: (count: number) => string;
743
+ /** Relative times: "now", "5m", "3h", "2d". */
744
+ timeAgo: (date: Date) => string;
625
745
  }
626
746
  declare const DEFAULT_LABELS: MessagesLabels;
627
747
 
@@ -705,6 +825,14 @@ interface DialtribeMessagesProps {
705
825
  * proceed. Without it, a built-in dialog inside the panel is used.
706
826
  */
707
827
  confirm?: ConfirmFn;
828
+ /**
829
+ * Show the Dialtribe Notifications inbox: a bell on the rail (above Messages)
830
+ * with an unread badge, opening the notifications panel. Pass an object to
831
+ * handle opening a notification yourself (return true when you navigated).
832
+ */
833
+ notifications?: boolean | {
834
+ onOpen?: (item: NotificationItem) => boolean | void;
835
+ };
708
836
  }
709
837
  /**
710
838
  * Drop-in messages rail: inbox, DM requests, conversations, and any host
@@ -721,7 +849,24 @@ interface DialtribeMessagesProps {
721
849
  * </DialtribeChatProvider>
722
850
  * ```
723
851
  */
724
- declare function DialtribeMessages({ side, placement, openPlacement, items, inboxRowClose, contexts, theme, labels: labelOverrides, panelWidth, railDmLimit, mobileBreakpoint, confirm: hostConfirm, }: DialtribeMessagesProps): react.JSX.Element;
852
+ declare function DialtribeMessages({ side, placement, openPlacement, items, inboxRowClose, contexts, theme, labels: labelOverrides, panelWidth, railDmLimit, mobileBreakpoint, confirm: hostConfirm, notifications, }: DialtribeMessagesProps): react.JSX.Element;
853
+
854
+ interface NotificationsPanelProps {
855
+ labels: MessagesLabels;
856
+ onClose?: () => void;
857
+ /**
858
+ * Called when a notification is opened. Return true if you handled the
859
+ * navigation (e.g. client-side routing); otherwise the browser goes to its url.
860
+ */
861
+ onOpen?: (item: NotificationItem) => boolean | void;
862
+ /** Called after a notification with a link was opened (the rail closes itself on mobile). */
863
+ onOpened?: (item: NotificationItem) => void;
864
+ }
865
+ /**
866
+ * The notifications list shown in the messages rail. Usable on its own too
867
+ * (any host panel) as long as it's under a <DialtribeChatProvider>.
868
+ */
869
+ declare function NotificationsPanel({ labels, onClose, onOpen, onOpened }: NotificationsPanelProps): react.JSX.Element;
725
870
 
726
871
  interface AvatarProps {
727
872
  name: string;
@@ -800,4 +945,4 @@ interface ChatInputProps {
800
945
  */
801
946
  declare function ChatInput({ onSendMessage, onSendTyping, replyTo, onClearReply, disabled, placeholder, maxLength, }: ChatInputProps): react.JSX.Element;
802
947
 
803
- export { Avatar, type AvatarProps, ChatClient, type ChatClientOptions, type ChatErrorCode, ChatInput, type ChatInputProps, type ChatMessage, ChatMessageItem, type ChatMessageItemProps, ChatPanel, type ChatPanelProps, ChatRequestError, type ChatRoomConfig, ChatRoomProvider, type ChatRoomProviderProps, type ChatSelf, type ConfirmFn, type ConfirmOptions, type ConnectionSnapshot, type ConnectionState, DEFAULT_LABELS, DialtribeChatProvider, type DialtribeChatProviderProps, DialtribeMessages, type DialtribeMessagesProps, type DmMemberStatus, type DmParticipant, type DmRequestResult, type DmRoomSummary, type Flair, type InboxSnapshot, type MessagesContext, type MessagesLabels, type MessagesTheme, type MessagesUiSnapshot, type MessagesView, type ParsedReactions, type RailItem, type RichMediaConfig, type RoomEvent, type RoomInit, type RoomSnapshot, type RoomState, type TypingUser, type UseChatRoomsReturn, type UseDialtribeChatOptions, type UseDialtribeChatReturn, type UseDialtribeMessagesReturn, type UserEvent, parseReactions, useChatClient, useChatConnection, useChatRoomContext, useChatRooms, useDialtribeChat, useDialtribeMessages };
948
+ export { Avatar, type AvatarProps, ChatClient, type ChatClientOptions, type ChatErrorCode, ChatInput, type ChatInputProps, type ChatMessage, ChatMessageItem, type ChatMessageItemProps, ChatPanel, type ChatPanelProps, ChatRequestError, type ChatRoomConfig, ChatRoomProvider, type ChatRoomProviderProps, type ChatSelf, type ConfirmFn, type ConfirmOptions, type ConnectionSnapshot, type ConnectionState, DEFAULT_LABELS, DialtribeChatProvider, type DialtribeChatProviderProps, DialtribeMessages, type DialtribeMessagesProps, type DmMemberStatus, type DmParticipant, type DmRequestResult, type DmRoomSummary, type Flair, type InboxSnapshot, type MessagesContext, type MessagesLabels, type MessagesTheme, type MessagesUiSnapshot, type MessagesView, type NotificationItem, NotificationsPanel, type NotificationsPanelProps, type NotificationsSnapshot, type ParsedReactions, type RailItem, type RichMediaConfig, type RoomEvent, type RoomInit, type RoomSnapshot, type RoomState, type TypingUser, type UseChatRoomsReturn, type UseDialtribeChatOptions, type UseDialtribeChatReturn, type UseDialtribeMessagesReturn, type UseDialtribeNotificationsReturn, type UserEvent, parseReactions, useChatClient, useChatConnection, useChatRoomContext, useChatRooms, useDialtribeChat, useDialtribeMessages, useDialtribeNotifications };