@dialtribe/chat-client 0.1.0 → 0.3.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.
- package/README.md +43 -7
- package/dist/index.d.mts +63 -6
- package/dist/index.d.ts +63 -6
- package/dist/index.js +179 -83
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +179 -83
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -58,7 +58,7 @@ export function App({ user }: { user: { id: string } | null }) {
|
|
|
58
58
|
return (
|
|
59
59
|
<DialtribeChatProvider
|
|
60
60
|
key={user.id}
|
|
61
|
-
serverUrl="https://
|
|
61
|
+
serverUrl="https://chatws.dialtribe.com"
|
|
62
62
|
getSessionToken={() => fetch("/api/chat-token").then((r) => r.text())}
|
|
63
63
|
>
|
|
64
64
|
<YourApp />
|
|
@@ -72,10 +72,12 @@ Mount the provider only while someone is signed in, keyed by their user id.
|
|
|
72
72
|
Signing out or switching accounts then drops the old connection, inbox and
|
|
73
73
|
token rather than showing one user's messages to the next.
|
|
74
74
|
|
|
75
|
-
- **Desktop:** a rail pinned to the right edge (
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
75
|
+
- **Desktop:** a rail pinned to the right edge (or the left, with `side="left"`)
|
|
76
|
+
holding the inbox, your contexts, recent DMs and unread badges, with a panel
|
|
77
|
+
that opens beside it. `placement="push"` pads the page so nothing is covered;
|
|
78
|
+
`"overlay"` floats over it. For your own fixed-position elements the root
|
|
79
|
+
element exposes `--dtc-messages-inset` (the width), plus
|
|
80
|
+
`--dtc-messages-side` and `data-dtc-messages-side` (`left` or `right`).
|
|
79
81
|
- **Mobile:** a floating button with a total badge. Tap it, or swipe in from the
|
|
80
82
|
right edge, to open; swipe right or press Escape to close.
|
|
81
83
|
|
|
@@ -97,7 +99,11 @@ function MessageButton({ user }: { user: { id: string; name: string } }) {
|
|
|
97
99
|
|
|
98
100
|
| Prop | Default | |
|
|
99
101
|
|------|---------|--|
|
|
102
|
+
| `side` | `"right"` | Which screen edge the rail docks to: `"left"` or `"right"` |
|
|
100
103
|
| `placement` | `"push"` | `"push"` or `"overlay"` (desktop) |
|
|
104
|
+
| `openPlacement` | `"push"` | With `placement="push"`: whether the open panel also pushes (`"push"`) or overlays (`"overlay"`). The collapsed rail always pushes |
|
|
105
|
+
| `items` | `[]` | Your own rail entries with your own panels (`RailItem[]`, see below) |
|
|
106
|
+
| `inboxRowClose` | `true` | An X on inbox conversations that removes them from the user's inbox (see `hideDM`) |
|
|
101
107
|
| `contexts` | `[]` | Extra rail entries, e.g. live shows: `{ roomId, label, avatarUrl?, badge? }` |
|
|
102
108
|
| `theme` | | `{ accent, background, surface, text, textMuted, border }` |
|
|
103
109
|
| `labels` | English | Override any string (`MessagesLabels`) to localize |
|
|
@@ -105,6 +111,31 @@ function MessageButton({ user }: { user: { id: string; name: string } }) {
|
|
|
105
111
|
| `railDmLimit` | `5` | Recent DMs shown as rail icons |
|
|
106
112
|
| `mobileBreakpoint` | `768` | Below this width the rail becomes the floating button |
|
|
107
113
|
|
|
114
|
+
### Your own rail items
|
|
115
|
+
|
|
116
|
+
Use the rail as your app's general-purpose rail: each item is your trigger
|
|
117
|
+
(shown with the rail-button chrome, active ring and badge) plus your panel
|
|
118
|
+
(any React, no header imposed).
|
|
119
|
+
|
|
120
|
+
```tsx
|
|
121
|
+
<DialtribeMessages
|
|
122
|
+
items={[{
|
|
123
|
+
id: "account",
|
|
124
|
+
placement: "footer", // "top" (default) above the inbox, "bottom" below the DMs,
|
|
125
|
+
// "footer" pinned to the bottom edge (doesn't scroll)
|
|
126
|
+
label: "Account",
|
|
127
|
+
trigger: ({ active }) => <ProfileAvatar active={active} />,
|
|
128
|
+
panel: ({ close }) => <AccountMenu onDone={close} />,
|
|
129
|
+
badge: 0,
|
|
130
|
+
}]}
|
|
131
|
+
/>
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Don't put a `<button>` inside `trigger`: the rail wraps it in one. Clicking an
|
|
135
|
+
active trigger closes the panel, and `useDialtribeMessages().openItem("account")`
|
|
136
|
+
opens it from anywhere. On mobile the item lives in the drawer like everything
|
|
137
|
+
else.
|
|
138
|
+
|
|
108
139
|
## Hooks
|
|
109
140
|
|
|
110
141
|
All hooks must be under `<DialtribeChatProvider>`, which owns one connection
|
|
@@ -119,7 +150,7 @@ const {
|
|
|
119
150
|
rooms, // every DM, newest first (DmRoomSummary[])
|
|
120
151
|
requests, // incoming requests not yet answered
|
|
121
152
|
totalUnread, // across unmuted, accepted DMs
|
|
122
|
-
requestDM, acceptDM, ignoreDM, closeDM, reopenDM,
|
|
153
|
+
requestDM, acceptDM, ignoreDM, closeDM, reopenDM, hideDM,
|
|
123
154
|
addParticipant, setMuted, markRead, setVisible, refresh,
|
|
124
155
|
} = useChatRooms();
|
|
125
156
|
```
|
|
@@ -127,6 +158,11 @@ const {
|
|
|
127
158
|
A request id is the DM's room id. Ignoring is silent: the requester keeps
|
|
128
159
|
seeing "Request sent". Adding someone to a 1:1 starts a new group conversation.
|
|
129
160
|
|
|
161
|
+
`hideDM(roomId)` removes a conversation from this user's inbox only. Nothing is
|
|
162
|
+
deleted and the other person sees no change; it comes back when a newer message
|
|
163
|
+
arrives or when the user messages or reopens it. `closeDM` is different: it
|
|
164
|
+
closes the conversation for everyone and makes it read-only.
|
|
165
|
+
|
|
130
166
|
### `useDialtribeChat({ roomId })`
|
|
131
167
|
|
|
132
168
|
One room (a DM or a show room): `messages`, `config`, `typingUsers`, `status`,
|
|
@@ -137,7 +173,7 @@ one subscription.
|
|
|
137
173
|
|
|
138
174
|
### `useDialtribeMessages()`
|
|
139
175
|
|
|
140
|
-
Drive the rail: `open`, `close`, `toggle`, `openInbox`, `openRoom(roomId)`,
|
|
176
|
+
Drive the rail: `open`, `close`, `toggle`, `openInbox`, `openRoom(roomId)`, `openItem(itemId)`,
|
|
141
177
|
`messageUser(userId, hint?)`, `isOpen`, `view`.
|
|
142
178
|
|
|
143
179
|
### `useChatConnection()`
|
package/dist/index.d.mts
CHANGED
|
@@ -275,6 +275,12 @@ declare class InboxStore extends Store<InboxSnapshot> {
|
|
|
275
275
|
private readTimers;
|
|
276
276
|
/** Rooms currently on screen: activity there is read, not unread. */
|
|
277
277
|
private visible;
|
|
278
|
+
/**
|
|
279
|
+
* Rooms the user removed (hide/ignore) and when. Filtered out of every list,
|
|
280
|
+
* so a refresh already in flight can't put them back, until a newer message
|
|
281
|
+
* arrives or the user messages/reopens/accepts them.
|
|
282
|
+
*/
|
|
283
|
+
private removed;
|
|
278
284
|
constructor(client: ChatClient);
|
|
279
285
|
acquire(): void;
|
|
280
286
|
release(): void;
|
|
@@ -292,6 +298,12 @@ declare class InboxStore extends Store<InboxSnapshot> {
|
|
|
292
298
|
name?: string;
|
|
293
299
|
avatarUrl?: string;
|
|
294
300
|
}): Promise<string>;
|
|
301
|
+
/**
|
|
302
|
+
* Remove a conversation from the user's own inbox (optimistic). Not deleted
|
|
303
|
+
* and nobody else is affected: it comes back when a newer message arrives or
|
|
304
|
+
* when the user messages/reopens it.
|
|
305
|
+
*/
|
|
306
|
+
hideDM(roomId: string): Promise<void>;
|
|
295
307
|
setMuted(roomId: string, muted: boolean): Promise<void>;
|
|
296
308
|
/** Mark a room read now (optimistic). */
|
|
297
309
|
markRead(roomId: string): Promise<void>;
|
|
@@ -311,7 +323,7 @@ declare class InboxStore extends Store<InboxSnapshot> {
|
|
|
311
323
|
}
|
|
312
324
|
|
|
313
325
|
interface ChatClientOptions {
|
|
314
|
-
/** chat-ws base URL, e.g. "https://
|
|
326
|
+
/** chat-ws base URL, e.g. "https://chatws.dialtribe.com". */
|
|
315
327
|
serverUrl: string;
|
|
316
328
|
/**
|
|
317
329
|
* Returns a current `sess_` token minted by the host backend for the signed-in
|
|
@@ -419,6 +431,11 @@ type MessagesView = {
|
|
|
419
431
|
} | {
|
|
420
432
|
kind: "room";
|
|
421
433
|
roomId: string;
|
|
434
|
+
}
|
|
435
|
+
/** A host-defined rail item (DialtribeMessages `items`). */
|
|
436
|
+
| {
|
|
437
|
+
kind: "item";
|
|
438
|
+
itemId: string;
|
|
422
439
|
};
|
|
423
440
|
interface MessagesUiSnapshot {
|
|
424
441
|
open: boolean;
|
|
@@ -447,7 +464,7 @@ interface DialtribeChatProviderProps extends Omit<ChatClientOptions, "getSession
|
|
|
447
464
|
* {user && (
|
|
448
465
|
* <DialtribeChatProvider
|
|
449
466
|
* key={user.id}
|
|
450
|
-
* serverUrl="https://
|
|
467
|
+
* serverUrl="https://chatws.dialtribe.com"
|
|
451
468
|
* getSessionToken={() => fetch("/api/chat-token").then((r) => r.text())}
|
|
452
469
|
* >
|
|
453
470
|
* <App />
|
|
@@ -508,7 +525,7 @@ declare function ChatRoomProvider({ roomId, children }: ChatRoomProviderProps):
|
|
|
508
525
|
/** The room from the nearest <ChatRoomProvider>. */
|
|
509
526
|
declare function useChatRoomContext(): UseDialtribeChatReturn;
|
|
510
527
|
|
|
511
|
-
type UseChatRoomsReturn = InboxSnapshot & Pick<InboxStore, "requestDM" | "acceptDM" | "ignoreDM" | "closeDM" | "reopenDM" | "addParticipant" | "setMuted" | "markRead" | "setVisible" | "refresh">;
|
|
528
|
+
type UseChatRoomsReturn = InboxSnapshot & Pick<InboxStore, "requestDM" | "acceptDM" | "ignoreDM" | "closeDM" | "reopenDM" | "hideDM" | "addParticipant" | "setMuted" | "markRead" | "setVisible" | "refresh">;
|
|
512
529
|
/**
|
|
513
530
|
* The signed-in user's DMs: inbox (newest first), incoming requests, unread
|
|
514
531
|
* totals, and every DM action. Live via the personal channel; reconciled with
|
|
@@ -534,6 +551,8 @@ interface UseDialtribeMessagesReturn {
|
|
|
534
551
|
openInbox: () => void;
|
|
535
552
|
/** Show a room (a DM or a host context) in the rail. */
|
|
536
553
|
openRoom: (roomId: string) => void;
|
|
554
|
+
/** Show one of the host's own rail items (DialtribeMessages `items`) by id. */
|
|
555
|
+
openItem: (itemId: string) => void;
|
|
537
556
|
/**
|
|
538
557
|
* Start (or reopen) a DM with one of your users and show it. `hint` is only a
|
|
539
558
|
* display name for someone Dialtribe hasn't seen yet. Rejects with
|
|
@@ -571,6 +590,8 @@ interface MessagesLabels {
|
|
|
571
590
|
conversationClosed: string;
|
|
572
591
|
reopen: string;
|
|
573
592
|
closeConversation: string;
|
|
593
|
+
/** Inbox row X: remove from the inbox (comes back on a new message). */
|
|
594
|
+
removeConversation: string;
|
|
574
595
|
mute: string;
|
|
575
596
|
unmute: string;
|
|
576
597
|
messagePlaceholder: string;
|
|
@@ -586,6 +607,31 @@ interface MessagesContext {
|
|
|
586
607
|
/** Optional host-computed badge (e.g. new messages in that show's chat). */
|
|
587
608
|
badge?: number;
|
|
588
609
|
}
|
|
610
|
+
/**
|
|
611
|
+
* A host-defined rail entry: your own trigger (rendered inside the rail-button
|
|
612
|
+
* chrome, so don't put a <button> in it) and your own panel (any React).
|
|
613
|
+
*/
|
|
614
|
+
interface RailItem {
|
|
615
|
+
/** Stable unique id (also what useDialtribeMessages().openItem takes). */
|
|
616
|
+
id: string;
|
|
617
|
+
trigger: React.ReactNode | ((state: {
|
|
618
|
+
active: boolean;
|
|
619
|
+
}) => React.ReactNode);
|
|
620
|
+
/** Rendered in the panel area with no imposed header; `close` closes the rail. */
|
|
621
|
+
panel: React.ReactNode | ((state: {
|
|
622
|
+
close: () => void;
|
|
623
|
+
}) => React.ReactNode);
|
|
624
|
+
/**
|
|
625
|
+
* "top" (default) sits above the inbox button; "bottom" below the DMs (both
|
|
626
|
+
* scroll with the rail); "footer" is pinned to the bottom edge and never
|
|
627
|
+
* scrolls, e.g. the signed-in user's avatar opening a profile menu.
|
|
628
|
+
*/
|
|
629
|
+
placement?: "top" | "bottom" | "footer";
|
|
630
|
+
/** Count bubble on the trigger. */
|
|
631
|
+
badge?: number;
|
|
632
|
+
/** aria-label and tooltip. */
|
|
633
|
+
label?: string;
|
|
634
|
+
}
|
|
589
635
|
interface MessagesTheme {
|
|
590
636
|
accent?: string;
|
|
591
637
|
background?: string;
|
|
@@ -595,8 +641,19 @@ interface MessagesTheme {
|
|
|
595
641
|
border?: string;
|
|
596
642
|
}
|
|
597
643
|
interface DialtribeMessagesProps {
|
|
598
|
-
/**
|
|
644
|
+
/** Which screen edge the rail docks to. */
|
|
645
|
+
side?: "left" | "right";
|
|
646
|
+
/** Desktop: "push" reserves room for the rail on the page; "overlay" floats over it. */
|
|
599
647
|
placement?: "push" | "overlay";
|
|
648
|
+
/**
|
|
649
|
+
* With placement="push": whether the open panel also pushes the page ("push",
|
|
650
|
+
* default) or overlays it ("overlay"). The collapsed rail always pushes.
|
|
651
|
+
*/
|
|
652
|
+
openPlacement?: "push" | "overlay";
|
|
653
|
+
/** Your own rail entries (e.g. an account menu), above or below the DMs. */
|
|
654
|
+
items?: RailItem[];
|
|
655
|
+
/** Show a close (X) on inbox conversations that removes them from the inbox. */
|
|
656
|
+
inboxRowClose?: boolean;
|
|
600
657
|
/** Extra rail entries above the DMs, e.g. live shows (room chats). */
|
|
601
658
|
contexts?: MessagesContext[];
|
|
602
659
|
theme?: MessagesTheme;
|
|
@@ -623,7 +680,7 @@ interface DialtribeMessagesProps {
|
|
|
623
680
|
* </DialtribeChatProvider>
|
|
624
681
|
* ```
|
|
625
682
|
*/
|
|
626
|
-
declare function DialtribeMessages({ placement, contexts, theme, labels: labelOverrides, panelWidth, railDmLimit, mobileBreakpoint, }: DialtribeMessagesProps): react.JSX.Element;
|
|
683
|
+
declare function DialtribeMessages({ side, placement, openPlacement, items, inboxRowClose, contexts, theme, labels: labelOverrides, panelWidth, railDmLimit, mobileBreakpoint, }: DialtribeMessagesProps): react.JSX.Element;
|
|
627
684
|
|
|
628
685
|
interface AvatarProps {
|
|
629
686
|
name: string;
|
|
@@ -702,4 +759,4 @@ interface ChatInputProps {
|
|
|
702
759
|
*/
|
|
703
760
|
declare function ChatInput({ onSendMessage, onSendTyping, replyTo, onClearReply, disabled, placeholder, maxLength, }: ChatInputProps): react.JSX.Element;
|
|
704
761
|
|
|
705
|
-
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 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 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 };
|
|
762
|
+
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 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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -275,6 +275,12 @@ declare class InboxStore extends Store<InboxSnapshot> {
|
|
|
275
275
|
private readTimers;
|
|
276
276
|
/** Rooms currently on screen: activity there is read, not unread. */
|
|
277
277
|
private visible;
|
|
278
|
+
/**
|
|
279
|
+
* Rooms the user removed (hide/ignore) and when. Filtered out of every list,
|
|
280
|
+
* so a refresh already in flight can't put them back, until a newer message
|
|
281
|
+
* arrives or the user messages/reopens/accepts them.
|
|
282
|
+
*/
|
|
283
|
+
private removed;
|
|
278
284
|
constructor(client: ChatClient);
|
|
279
285
|
acquire(): void;
|
|
280
286
|
release(): void;
|
|
@@ -292,6 +298,12 @@ declare class InboxStore extends Store<InboxSnapshot> {
|
|
|
292
298
|
name?: string;
|
|
293
299
|
avatarUrl?: string;
|
|
294
300
|
}): Promise<string>;
|
|
301
|
+
/**
|
|
302
|
+
* Remove a conversation from the user's own inbox (optimistic). Not deleted
|
|
303
|
+
* and nobody else is affected: it comes back when a newer message arrives or
|
|
304
|
+
* when the user messages/reopens it.
|
|
305
|
+
*/
|
|
306
|
+
hideDM(roomId: string): Promise<void>;
|
|
295
307
|
setMuted(roomId: string, muted: boolean): Promise<void>;
|
|
296
308
|
/** Mark a room read now (optimistic). */
|
|
297
309
|
markRead(roomId: string): Promise<void>;
|
|
@@ -311,7 +323,7 @@ declare class InboxStore extends Store<InboxSnapshot> {
|
|
|
311
323
|
}
|
|
312
324
|
|
|
313
325
|
interface ChatClientOptions {
|
|
314
|
-
/** chat-ws base URL, e.g. "https://
|
|
326
|
+
/** chat-ws base URL, e.g. "https://chatws.dialtribe.com". */
|
|
315
327
|
serverUrl: string;
|
|
316
328
|
/**
|
|
317
329
|
* Returns a current `sess_` token minted by the host backend for the signed-in
|
|
@@ -419,6 +431,11 @@ type MessagesView = {
|
|
|
419
431
|
} | {
|
|
420
432
|
kind: "room";
|
|
421
433
|
roomId: string;
|
|
434
|
+
}
|
|
435
|
+
/** A host-defined rail item (DialtribeMessages `items`). */
|
|
436
|
+
| {
|
|
437
|
+
kind: "item";
|
|
438
|
+
itemId: string;
|
|
422
439
|
};
|
|
423
440
|
interface MessagesUiSnapshot {
|
|
424
441
|
open: boolean;
|
|
@@ -447,7 +464,7 @@ interface DialtribeChatProviderProps extends Omit<ChatClientOptions, "getSession
|
|
|
447
464
|
* {user && (
|
|
448
465
|
* <DialtribeChatProvider
|
|
449
466
|
* key={user.id}
|
|
450
|
-
* serverUrl="https://
|
|
467
|
+
* serverUrl="https://chatws.dialtribe.com"
|
|
451
468
|
* getSessionToken={() => fetch("/api/chat-token").then((r) => r.text())}
|
|
452
469
|
* >
|
|
453
470
|
* <App />
|
|
@@ -508,7 +525,7 @@ declare function ChatRoomProvider({ roomId, children }: ChatRoomProviderProps):
|
|
|
508
525
|
/** The room from the nearest <ChatRoomProvider>. */
|
|
509
526
|
declare function useChatRoomContext(): UseDialtribeChatReturn;
|
|
510
527
|
|
|
511
|
-
type UseChatRoomsReturn = InboxSnapshot & Pick<InboxStore, "requestDM" | "acceptDM" | "ignoreDM" | "closeDM" | "reopenDM" | "addParticipant" | "setMuted" | "markRead" | "setVisible" | "refresh">;
|
|
528
|
+
type UseChatRoomsReturn = InboxSnapshot & Pick<InboxStore, "requestDM" | "acceptDM" | "ignoreDM" | "closeDM" | "reopenDM" | "hideDM" | "addParticipant" | "setMuted" | "markRead" | "setVisible" | "refresh">;
|
|
512
529
|
/**
|
|
513
530
|
* The signed-in user's DMs: inbox (newest first), incoming requests, unread
|
|
514
531
|
* totals, and every DM action. Live via the personal channel; reconciled with
|
|
@@ -534,6 +551,8 @@ interface UseDialtribeMessagesReturn {
|
|
|
534
551
|
openInbox: () => void;
|
|
535
552
|
/** Show a room (a DM or a host context) in the rail. */
|
|
536
553
|
openRoom: (roomId: string) => void;
|
|
554
|
+
/** Show one of the host's own rail items (DialtribeMessages `items`) by id. */
|
|
555
|
+
openItem: (itemId: string) => void;
|
|
537
556
|
/**
|
|
538
557
|
* Start (or reopen) a DM with one of your users and show it. `hint` is only a
|
|
539
558
|
* display name for someone Dialtribe hasn't seen yet. Rejects with
|
|
@@ -571,6 +590,8 @@ interface MessagesLabels {
|
|
|
571
590
|
conversationClosed: string;
|
|
572
591
|
reopen: string;
|
|
573
592
|
closeConversation: string;
|
|
593
|
+
/** Inbox row X: remove from the inbox (comes back on a new message). */
|
|
594
|
+
removeConversation: string;
|
|
574
595
|
mute: string;
|
|
575
596
|
unmute: string;
|
|
576
597
|
messagePlaceholder: string;
|
|
@@ -586,6 +607,31 @@ interface MessagesContext {
|
|
|
586
607
|
/** Optional host-computed badge (e.g. new messages in that show's chat). */
|
|
587
608
|
badge?: number;
|
|
588
609
|
}
|
|
610
|
+
/**
|
|
611
|
+
* A host-defined rail entry: your own trigger (rendered inside the rail-button
|
|
612
|
+
* chrome, so don't put a <button> in it) and your own panel (any React).
|
|
613
|
+
*/
|
|
614
|
+
interface RailItem {
|
|
615
|
+
/** Stable unique id (also what useDialtribeMessages().openItem takes). */
|
|
616
|
+
id: string;
|
|
617
|
+
trigger: React.ReactNode | ((state: {
|
|
618
|
+
active: boolean;
|
|
619
|
+
}) => React.ReactNode);
|
|
620
|
+
/** Rendered in the panel area with no imposed header; `close` closes the rail. */
|
|
621
|
+
panel: React.ReactNode | ((state: {
|
|
622
|
+
close: () => void;
|
|
623
|
+
}) => React.ReactNode);
|
|
624
|
+
/**
|
|
625
|
+
* "top" (default) sits above the inbox button; "bottom" below the DMs (both
|
|
626
|
+
* scroll with the rail); "footer" is pinned to the bottom edge and never
|
|
627
|
+
* scrolls, e.g. the signed-in user's avatar opening a profile menu.
|
|
628
|
+
*/
|
|
629
|
+
placement?: "top" | "bottom" | "footer";
|
|
630
|
+
/** Count bubble on the trigger. */
|
|
631
|
+
badge?: number;
|
|
632
|
+
/** aria-label and tooltip. */
|
|
633
|
+
label?: string;
|
|
634
|
+
}
|
|
589
635
|
interface MessagesTheme {
|
|
590
636
|
accent?: string;
|
|
591
637
|
background?: string;
|
|
@@ -595,8 +641,19 @@ interface MessagesTheme {
|
|
|
595
641
|
border?: string;
|
|
596
642
|
}
|
|
597
643
|
interface DialtribeMessagesProps {
|
|
598
|
-
/**
|
|
644
|
+
/** Which screen edge the rail docks to. */
|
|
645
|
+
side?: "left" | "right";
|
|
646
|
+
/** Desktop: "push" reserves room for the rail on the page; "overlay" floats over it. */
|
|
599
647
|
placement?: "push" | "overlay";
|
|
648
|
+
/**
|
|
649
|
+
* With placement="push": whether the open panel also pushes the page ("push",
|
|
650
|
+
* default) or overlays it ("overlay"). The collapsed rail always pushes.
|
|
651
|
+
*/
|
|
652
|
+
openPlacement?: "push" | "overlay";
|
|
653
|
+
/** Your own rail entries (e.g. an account menu), above or below the DMs. */
|
|
654
|
+
items?: RailItem[];
|
|
655
|
+
/** Show a close (X) on inbox conversations that removes them from the inbox. */
|
|
656
|
+
inboxRowClose?: boolean;
|
|
600
657
|
/** Extra rail entries above the DMs, e.g. live shows (room chats). */
|
|
601
658
|
contexts?: MessagesContext[];
|
|
602
659
|
theme?: MessagesTheme;
|
|
@@ -623,7 +680,7 @@ interface DialtribeMessagesProps {
|
|
|
623
680
|
* </DialtribeChatProvider>
|
|
624
681
|
* ```
|
|
625
682
|
*/
|
|
626
|
-
declare function DialtribeMessages({ placement, contexts, theme, labels: labelOverrides, panelWidth, railDmLimit, mobileBreakpoint, }: DialtribeMessagesProps): react.JSX.Element;
|
|
683
|
+
declare function DialtribeMessages({ side, placement, openPlacement, items, inboxRowClose, contexts, theme, labels: labelOverrides, panelWidth, railDmLimit, mobileBreakpoint, }: DialtribeMessagesProps): react.JSX.Element;
|
|
627
684
|
|
|
628
685
|
interface AvatarProps {
|
|
629
686
|
name: string;
|
|
@@ -702,4 +759,4 @@ interface ChatInputProps {
|
|
|
702
759
|
*/
|
|
703
760
|
declare function ChatInput({ onSendMessage, onSendTyping, replyTo, onClearReply, disabled, placeholder, maxLength, }: ChatInputProps): react.JSX.Element;
|
|
704
761
|
|
|
705
|
-
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 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 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 };
|
|
762
|
+
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 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 };
|