@poolse/react-ui 2.12.1 → 2.13.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/CHANGELOG.md +287 -260
- package/LICENSE +21 -21
- package/README.md +335 -335
- package/dist/index.cjs +217 -133
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +44 -0
- package/dist/index.d.ts +44 -0
- package/dist/index.js +217 -133
- package/dist/index.js.map +1 -1
- package/dist/styles.css +2818 -2818
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,335 +1,335 @@
|
|
|
1
|
-
# `@poolse/react-ui`
|
|
2
|
-
|
|
3
|
-
Drop-in React chat components — `<ConversationView>` mounts the whole chat surface in one component, or compose the building blocks (`<MessageBubble>`, `<MessageComposer>`, `<ConversationList>`, `<MemberList>`, `<ThreadView>`, `<MentionInput>`, `<TypingIndicator>`, `<ReactionPicker>`) for custom layouts. CSS-variable theming — re-skin without a rebuild. Built for Next.js + React 18+.
|
|
4
|
-
|
|
5
|
-
> **MIT-licensed alternative to Sendbird UIKit, Stream Chat React UI, TalkJS, and CometChat React UI Kit.** Same component names + prop shapes as [`@poolse/react-native`](https://www.npmjs.com/package/@poolse/react-native) so cross-platform code stays mechanical to port.
|
|
6
|
-
|
|
7
|
-
Sits on top of [`@poolse/react`](https://www.npmjs.com/package/@poolse/react) (hooks) and [`@poolse/sdk`](https://www.npmjs.com/package/@poolse/sdk) (client).
|
|
8
|
-
|
|
9
|
-
> **⚠️ Upgrading from 1.x?** See [MIGRATING.md](https://github.com/poolse-hq/js-sdk/blob/main/MIGRATING.md). Every `labelFor` / `avatarFor` / `onlineUserIds` prop is now keyed by `external_id`. `<UserName>` and `useDisplayName` switched from `userId` to `externalId`.
|
|
10
|
-
|
|
11
|
-
## Install
|
|
12
|
-
|
|
13
|
-
```bash
|
|
14
|
-
npm install @poolse/react-ui @poolse/react @poolse/sdk
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
```tsx
|
|
18
|
-
import '@poolse/react-ui/styles.css';
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
Import the stylesheet **once** at your app root. It defines the `--poolse-*` design tokens and the component styles.
|
|
22
|
-
|
|
23
|
-
## Quick start
|
|
24
|
-
|
|
25
|
-
```tsx
|
|
26
|
-
import { PoolseProvider } from '@poolse/react';
|
|
27
|
-
import { ConversationView } from '@poolse/react-ui';
|
|
28
|
-
import '@poolse/react-ui/styles.css';
|
|
29
|
-
|
|
30
|
-
export function App() {
|
|
31
|
-
return (
|
|
32
|
-
<PoolseProvider
|
|
33
|
-
config={{
|
|
34
|
-
getToken: async () => {
|
|
35
|
-
const res = await fetch('/api/chat-token', { method: 'POST' });
|
|
36
|
-
const { token } = await res.json();
|
|
37
|
-
return token;
|
|
38
|
-
},
|
|
39
|
-
}}
|
|
40
|
-
>
|
|
41
|
-
<ConversationView conversationId="00000000-0000-0000-0000-000000000000" />
|
|
42
|
-
</PoolseProvider>
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
That's a complete chat surface. On mount it injects the brand fonts (Bricolage Grotesque, Hanken Grotesk, JetBrains Mono) via a Google Fonts `<link>`. Pass `loadFonts={false}` if your host app already loads them or your CSP forbids dynamic injection.
|
|
48
|
-
|
|
49
|
-
## `<ConversationView>`
|
|
50
|
-
|
|
51
|
-
The default composed surface. Every feature is on a flag you can turn off.
|
|
52
|
-
|
|
53
|
-
```tsx
|
|
54
|
-
<ConversationView
|
|
55
|
-
conversationId={id}
|
|
56
|
-
|
|
57
|
-
// Feature toggles (all default true unless noted)
|
|
58
|
-
reactions
|
|
59
|
-
mentions
|
|
60
|
-
attachments
|
|
61
|
-
actions
|
|
62
|
-
threads
|
|
63
|
-
quotations
|
|
64
|
-
readReceipts
|
|
65
|
-
markdown
|
|
66
|
-
grouping
|
|
67
|
-
daySeparators
|
|
68
|
-
|
|
69
|
-
// Behavioral knobs
|
|
70
|
-
maxBodyLength={200} // 0 disables the "Read more" trim
|
|
71
|
-
groupingWindowMs={300000} // 5 min — same-sender messages within this window cluster
|
|
72
|
-
senderLabels="auto" // 'auto' (on for 3+ members) | 'always' | 'never'
|
|
73
|
-
avatars="auto" // same
|
|
74
|
-
|
|
75
|
-
// Customer wiring
|
|
76
|
-
labelFor={(userId) => /* … */}
|
|
77
|
-
onMarkedRead={(convId) => /* clear sidebar badge */}
|
|
78
|
-
renderMessage={(msg, currentUserId) => /* fully custom row */}
|
|
79
|
-
emptyState={<div>Say hi.</div>}
|
|
80
|
-
loadFonts // default true
|
|
81
|
-
/>
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
### What it gives you
|
|
85
|
-
|
|
86
|
-
- **Message list with infinite-scroll-up.** Top-sentinel `IntersectionObserver` fires `loadMore()` when the user gets within ~400px of the top.
|
|
87
|
-
- **Smart auto-scroll.** Stays pinned to the bottom while the user is at the bottom; otherwise increments a "N new messages" badge.
|
|
88
|
-
- **Auto mark-read.** When the latest message is in view, fires `markReadUpTo` once per fresh tail. Drives both your own progress (`onMarkedRead` callback) and the server-broadcast read receipt that flips other users' double-check glyph.
|
|
89
|
-
- **Drag-and-drop attachments.** The whole conversation pane accepts a file drop and forwards it to the composer's upload queue.
|
|
90
|
-
- **Quote-reply chip** above the composer when `quotations` is on. The chip carries the quoted sender + a snippet, and Esc dismisses it.
|
|
91
|
-
- **Realtime status banner.** Renders "Connecting…" / "Reconnecting…" / "Disconnected" pills when the socket isn't connected.
|
|
92
|
-
- **Thread side-pane** opens on the right when the user clicks "Reply in thread"; below 760px it goes full-screen.
|
|
93
|
-
- **Day separators.** "Today" / "Yesterday" / weekday name / `26 May 2024` between calendar days.
|
|
94
|
-
- **Message clustering.** Same sender, same day, within `groupingWindowMs` (default 5 min) — clustered with a single asymmetric tail on the last bubble (iMessage / WhatsApp convention).
|
|
95
|
-
- **Markdown bodies.** GitHub-flavored, sanitized: bold/italic/lists/code/blockquotes/strikethrough/autolinks. URLs render with `target="_blank" rel="noopener noreferrer nofollow"`.
|
|
96
|
-
- **Long-message trim.** Bodies past `maxBodyLength` collapse to a `Read more` toggle.
|
|
97
|
-
|
|
98
|
-
### `renderMessage` escape hatch
|
|
99
|
-
|
|
100
|
-
`renderMessage` completely replaces the default `<MessageRow>` for each message — you own the layout from the bubble outward. Group position, avatars, sender labels, hover actions: none of that is wired automatically when you take the slot.
|
|
101
|
-
|
|
102
|
-
```tsx
|
|
103
|
-
<ConversationView
|
|
104
|
-
conversationId={id}
|
|
105
|
-
renderMessage={(msg, currentUserId) => (
|
|
106
|
-
<MyCustomBubble message={msg} isSelf={msg.sender_id === currentUserId} />
|
|
107
|
-
)}
|
|
108
|
-
/>
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
If you want to keep most of the default behavior, render `<MessageRow>` yourself with the props you'd like to flip.
|
|
112
|
-
|
|
113
|
-
## Components
|
|
114
|
-
|
|
115
|
-
### Composed surfaces
|
|
116
|
-
|
|
117
|
-
| Component | What |
|
|
118
|
-
| -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
119
|
-
| `<PoolseInbox>` | Full inbox shell — two-column side-by-side list + detail on wide viewports, push-pane on ≤720px. Imperative ref API for `open`, `openDirect`, `openGroup`, `promptNewChat`, `promptNewGroup`, `close`. Built-in user picker + group-details sheet when a `users` directory is provided. |
|
|
120
|
-
| `<ConversationView>` | Full chat (above) — `useMessages` + `useMembers` + `useTyping` + composer + thread pane wired together. |
|
|
121
|
-
| `<ChatHeader>` | Standalone title bar — direct chats resolve the OTHER member's name + avatar via `labelFor` / `avatarFor`, groups show member count, presence-driven green dot. Optional `onBack`, `onPress`, `onMembersPress`, plus a free-form `rightSlot` for custom actions (e.g. an "Invite" button). |
|
|
122
|
-
| `<ThreadView>` | The right-side reply pane. `useThread`-driven; close button + Esc + drag-drop. Used internally by `<ConversationView>`; export it for custom layouts. |
|
|
123
|
-
|
|
124
|
-
### Sheets / modals
|
|
125
|
-
|
|
126
|
-
| Component | What |
|
|
127
|
-
| --------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
128
|
-
| `<UserPickerSheet>` | Modal for picking a direct-chat target or a group's members. `mode: 'single'` is one-tap-to-start, `mode: 'group'` adds a name input + multi-select. Accepts an `InboxUser` directory. |
|
|
129
|
-
| `<GroupDetailsSheet>` | Modal showing a group's name, avatar, and the existing `<MemberList>` roster with presence dots. Optional `footer` slot for "Leave group" / "Invite" actions. |
|
|
130
|
-
|
|
131
|
-
### Message surface
|
|
132
|
-
|
|
133
|
-
| Component | What |
|
|
134
|
-
| ------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
135
|
-
| `<MessageRow>` | One fully-wired row: bubble + (optional) avatar + reaction strip + thread pill + hover actions. Owns a single `useReactions` instance shared by the inline strip and the picker. |
|
|
136
|
-
| `<MessageBubble>` | Just the bubble — sender label, quoted card, attachments, body, meta. Pure presentational; takes `Message` + `currentUserId`. |
|
|
137
|
-
| `<EditableMessageBubble>` | `<MessageBubble>` plus an in-place edit mode (textarea, Enter to save, Esc to cancel). Controlled via the `editing` prop. |
|
|
138
|
-
| `<MessageActions>` | Hover popover with the react / reply / quote / copy / edit / delete affordances. |
|
|
139
|
-
| `<TypingIndicator>` | Three bouncing dots + a `role="status"` live region announcing "Alice is typing" / "Alice and Bob are typing" / "3 people are typing". |
|
|
140
|
-
|
|
141
|
-
### Composer
|
|
142
|
-
|
|
143
|
-
| Component | What |
|
|
144
|
-
| -------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
145
|
-
| `<MessageComposer>` | Pill input + send button + paperclip → upload queue. Smart list continuation (Enter on `- item` repeats the bullet). Exposes an imperative `addFiles(files)` via `ref` for drag-drop callers. |
|
|
146
|
-
| `<MentionInput>` | Same as `<MessageComposer>` but with `@`-autocomplete from the conversation's member list. `combobox` ARIA, keyboard-navigable dropdown. Sends `MessageCreateRequest` shape (including `mentions[]`) on submit. |
|
|
147
|
-
| `<UploadQueueStrip>` | Renders one chip per item in the composer's upload queue — pending/uploading/ready/error — with cancel + dismiss. Live progress bar driven by the SDK's XHR-based upload. |
|
|
148
|
-
|
|
149
|
-
### Attachments
|
|
150
|
-
|
|
151
|
-
| Component | What |
|
|
152
|
-
| --------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
153
|
-
| `<AttachmentPreview>` | Inline image (lazy thumbnail → fullscreen lightbox on click) or a file card with download. Resolves the presigned URL via `useAttachmentUrl`. |
|
|
154
|
-
|
|
155
|
-
### Conversation roster
|
|
156
|
-
|
|
157
|
-
| Component | What |
|
|
158
|
-
| -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
159
|
-
| `<ConversationList>` | Sidebar list of the user's conversations. Avatar + name + `last_message_preview` + timestamp + unread pill. Direct rows resolve the other member's name/avatar via `labelFor` / `avatarFor` (the same resolvers `<ChatHeader>` and `<PoolseInbox>` take), so a customer can wire one mapping everywhere. Controlled mode: pass `conversations`/`loading`/`error` to render from external state instead of `useConversations()`. |
|
|
160
|
-
| `<MemberList>` | Roster for one conversation. Role badges, online dot, optional remove button gated by a `canRemove(membership)` predicate. |
|
|
161
|
-
|
|
162
|
-
### Reactions
|
|
163
|
-
|
|
164
|
-
| Component | What |
|
|
165
|
-
| ------------------ | ------------------------------------------------------------------------------------------------ |
|
|
166
|
-
| `<ReactionStrip>` | Inline emoji pills with counts + "your reaction" highlight; optional picker button on the right. |
|
|
167
|
-
| `<ReactionPicker>` | Standalone emoji popover. Six common emojis, arrow-key navigation, Esc closes. |
|
|
168
|
-
|
|
169
|
-
### Identity
|
|
170
|
-
|
|
171
|
-
| Component | What |
|
|
172
|
-
| ------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
173
|
-
| `<Avatar>` | Circular image with initials fallback + green presence dot. `size: 'sm' \| 'md' \| 'lg'`. |
|
|
174
|
-
| `<UserName>` / `useDisplayName` | Resolve a `user_id` to a display string via the configured `userResolver`, with a `labelFor` sync override and a stable fallback (`User abc123`) when nothing is available. |
|
|
175
|
-
|
|
176
|
-
### Brand chrome
|
|
177
|
-
|
|
178
|
-
| Component | What |
|
|
179
|
-
| -------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
180
|
-
| `<PoolseIcon name="…">` | One SVG icon from a built-in set (41 names: `attachment`, `bell`, `check`, `chevron-down`, `close`, `download`, `edit`, `emoji`, `heart`, `image`, `message`, `messages`, `pin`, `plus`, `presence`, `pulse`, `reply`, `search`, `send`, `send-fill`, `settings`, `thumbs-up`, `trash`, `typing`, `user`, `users`, `webhook`, …). Pass `label={null}` for purely decorative. |
|
|
181
|
-
| `<PoolseLogo>` | Brand mark / lockup / wordmark / mono (single-color) variants. |
|
|
182
|
-
| `<PoolseFonts />` / `usePoolseFonts()` | Inject the Google Fonts link into `<head>` (idempotent). `<ConversationView>` calls this automatically unless you pass `loadFonts={false}`. |
|
|
183
|
-
|
|
184
|
-
## Attachments inside the bubble (1.1.0+)
|
|
185
|
-
|
|
186
|
-
As of 1.1.0, `<MessageBubble>` renders attachments **inside** the bubble (WhatsApp / iMessage convention) rather than as a separate block under it.
|
|
187
|
-
|
|
188
|
-
The layout chooses a grid template by image count:
|
|
189
|
-
|
|
190
|
-
| Count | Layout |
|
|
191
|
-
| --------- | ----------------------------------------------------------------------------- |
|
|
192
|
-
| 1 image | Single full-bleed tile, natural aspect, capped at 360px tall. |
|
|
193
|
-
| 2 images | Two equal squares, side-by-side. |
|
|
194
|
-
| 3 images | One 16:9 hero on top + two squares beneath. |
|
|
195
|
-
| 4+ images | 2×2 grid. The 4th tile shows a `+N more` overlay when the total exceeds four. |
|
|
196
|
-
|
|
197
|
-
Non-image attachments (PDFs, etc.) render as stacked file cards inside the bubble's padded area, below the image mosaic. On self-bubbles the cards tint white-on-coral to read against the brand color.
|
|
198
|
-
|
|
199
|
-
When a message has **only** images (no body text and no file cards), the meta row (time + read tick) becomes a small dark pill overlaid on the bottom-right of the mosaic — same convention as WhatsApp.
|
|
200
|
-
|
|
201
|
-
The bubble has `overflow: hidden` so the mosaic is clipped to the bubble's rounded corners and the asymmetric tail.
|
|
202
|
-
|
|
203
|
-
### Opting out
|
|
204
|
-
|
|
205
|
-
```tsx
|
|
206
|
-
<MessageBubble message={msg} currentUserId={meId} showAttachments={false} />
|
|
207
|
-
```
|
|
208
|
-
|
|
209
|
-
Pass `showAttachments={false}` to suppress in-bubble attachments — useful if you want to render them yourself outside the bubble. `<MessageRow>` forwards its `attachments` flag to this prop, and `<ConversationView>`'s `attachments` flag forwards to `<MessageRow>`.
|
|
210
|
-
|
|
211
|
-
### Migration from 1.0.x
|
|
212
|
-
|
|
213
|
-
Anything customizing `.poolse-message-row__attachments` in your stylesheet won't match anymore — that class is no longer rendered. The new class names are:
|
|
214
|
-
|
|
215
|
-
- `.poolse-message__media` — image mosaic container
|
|
216
|
-
- `.poolse-message__media--n1` / `--n2` / `--n3` / `--n4` — count-specific grid templates
|
|
217
|
-
- `.poolse-message__media-tile` — one image cell
|
|
218
|
-
- `.poolse-message__media-overflow` — the `+N more` overlay
|
|
219
|
-
- `.poolse-message__files` — file-card stack
|
|
220
|
-
- `.poolse-message__meta--overlay` — modifier applied to `.poolse-message__meta` in image-only mode
|
|
221
|
-
- `.poolse-message--has-media` / `--media-only` — parent state modifiers
|
|
222
|
-
|
|
223
|
-
If you weren't styling the old class, you don't need to do anything — the new layout is on by default.
|
|
224
|
-
|
|
225
|
-
## Theming
|
|
226
|
-
|
|
227
|
-
Every color, radius, shadow, and font in the kit is a CSS variable. Override them in your own stylesheet — no JS, no rebuild:
|
|
228
|
-
|
|
229
|
-
```css
|
|
230
|
-
:root {
|
|
231
|
-
--poolse-brand: #0070f3; /* primary action */
|
|
232
|
-
--poolse-brand-soft: #e0eaff; /* tinted fills, hover, badges */
|
|
233
|
-
--poolse-brand-strong: #0050b3; /* AA text on light surfaces */
|
|
234
|
-
--poolse-on-brand: #ffffff; /* foreground on brand */
|
|
235
|
-
}
|
|
236
|
-
```
|
|
237
|
-
|
|
238
|
-
The full token set:
|
|
239
|
-
|
|
240
|
-
```css
|
|
241
|
-
/* Brand & surfaces */
|
|
242
|
-
--poolse-brand /* primary action (default Pulse Coral #ff5436) */
|
|
243
|
-
--poolse-brand-strong /* AA text on light */
|
|
244
|
-
--poolse-brand-soft /* tinted fills, badges, hover */
|
|
245
|
-
--poolse-on-brand /* foreground on brand */
|
|
246
|
-
--poolse-paper /* page background */
|
|
247
|
-
--poolse-surface /* cards, panels */
|
|
248
|
-
--poolse-surface-2 /* insets, fields */
|
|
249
|
-
--poolse-ink /* primary text */
|
|
250
|
-
--poolse-ink-2 /* secondary text */
|
|
251
|
-
--poolse-ink-3 /* tertiary, hints */
|
|
252
|
-
--poolse-border /* hairline borders */
|
|
253
|
-
|
|
254
|
-
/* Semantic */
|
|
255
|
-
--poolse-presence /* online dot */
|
|
256
|
-
--poolse-success
|
|
257
|
-
--poolse-warning
|
|
258
|
-
--poolse-error /* distinct from coral */
|
|
259
|
-
--poolse-info
|
|
260
|
-
|
|
261
|
-
/* Typography */
|
|
262
|
-
--poolse-font-display /* Bricolage Grotesque */
|
|
263
|
-
--poolse-font-body /* Hanken Grotesk */
|
|
264
|
-
--poolse-font-mono /* JetBrains Mono */
|
|
265
|
-
--poolse-font-size /* default 15px */
|
|
266
|
-
--poolse-line-height /* default 1.5 */
|
|
267
|
-
|
|
268
|
-
/* Radii */
|
|
269
|
-
--poolse-radius-sm /* 8px */
|
|
270
|
-
--poolse-radius-md /* 12px */
|
|
271
|
-
--poolse-radius-lg /* 16px */
|
|
272
|
-
--poolse-radius-xl /* 24px */
|
|
273
|
-
--poolse-radius-pill /* 999px */
|
|
274
|
-
|
|
275
|
-
/* Shadows (warm-tinted) */
|
|
276
|
-
--poolse-shadow-sm
|
|
277
|
-
--poolse-shadow-md
|
|
278
|
-
--poolse-shadow-lg
|
|
279
|
-
```
|
|
280
|
-
|
|
281
|
-
### Dark mode
|
|
282
|
-
|
|
283
|
-
The stylesheet ships with a dark theme keyed off the user's `prefers-color-scheme`. To force a mode, set `data-theme="dark"` or `data-theme="light"` on any ancestor of the chat surface:
|
|
284
|
-
|
|
285
|
-
```html
|
|
286
|
-
<div data-theme="dark">
|
|
287
|
-
<ConversationView ... />
|
|
288
|
-
</div>
|
|
289
|
-
```
|
|
290
|
-
|
|
291
|
-
## Accessibility
|
|
292
|
-
|
|
293
|
-
- `<div role="log" aria-live="polite" aria-relevant="additions">` on the message list — screen readers announce new messages but not the initial load.
|
|
294
|
-
- `<aside role="complementary" aria-label="Message thread">` on the thread pane. Esc closes; close button auto-focuses on mount.
|
|
295
|
-
- `<MentionInput>` is a proper combobox: `role="combobox"`, `aria-expanded`, `aria-controls`, `aria-autocomplete="list"`, `aria-activedescendant` on the input; the dropdown is `role="listbox"` with `role="option"` items.
|
|
296
|
-
- `<ReactionPicker>` is `role="menu"` / `role="menuitem"` with arrow-key navigation and Esc to close.
|
|
297
|
-
- `<TypingIndicator>` is `role="status" aria-live="polite" aria-atomic="true"`; the dots themselves are `aria-hidden`.
|
|
298
|
-
- `<Avatar>` is `role="img" aria-label="{name}"` even when rendering initials.
|
|
299
|
-
- Touch reveal: the hover action menu on `<MessageRow>` is hidden on `(hover: none)` and switches to tap-toggle on the bubble itself, so you don't lose actions on mobile.
|
|
300
|
-
- The image lightbox locks body scroll while open, closes on Esc and on backdrop click, and keeps the image itself non-dismissable (so a click on the image doesn't accidentally close).
|
|
301
|
-
- The whole kit honors `prefers-reduced-motion` for the typing indicator, the message-row hover transitions, and the thread pane slide-in.
|
|
302
|
-
|
|
303
|
-
Touch targets in the composer are 44px; the textarea uses 16px so iOS doesn't auto-zoom on focus; the lightbox + composer apply `safe-area-inset` padding for notched devices.
|
|
304
|
-
|
|
305
|
-
## Customization layers
|
|
306
|
-
|
|
307
|
-
In order of escalating control:
|
|
308
|
-
|
|
309
|
-
1. **CSS variables.** Re-skin without touching JS.
|
|
310
|
-
2. **Feature flags on `<ConversationView>`.** Turn whole features off (`reactions={false}`, `threads={false}`, etc.).
|
|
311
|
-
3. **Render-prop slots.** Replace individual rows: `<ConversationView renderMessage={...}>`, `<ConversationList renderItem={...}>`, `<MemberList renderItem={...}>`, `<ThreadView renderMessage={...}>`.
|
|
312
|
-
4. **Component composition.** Drop `<ConversationView>` and assemble `<MessageRow>` (or `<MessageBubble>` if you want to skip the row's wiring) + `<MessageComposer>` + `<TypingIndicator>` + `<ThreadView>` yourself.
|
|
313
|
-
5. **Drop down to `@poolse/react`.** Build your own components on the same hooks that this package uses internally.
|
|
314
|
-
|
|
315
|
-
You can mix and match — there's no all-or-nothing boundary.
|
|
316
|
-
|
|
317
|
-
## Re-exports
|
|
318
|
-
|
|
319
|
-
The package also re-exports a few helpers that are useful when you're composing your own UI:
|
|
320
|
-
|
|
321
|
-
- `userColor(userId)` — deterministic per-user color for sender labels and avatars (8-hue palette, hashed from the id).
|
|
322
|
-
- `computeGroupPosition(msg, prev, next, windowMs)` / `sameDay(a, b)` / `formatDayLabel(iso)` — the same grouping primitives `<ConversationView>` uses to cluster messages.
|
|
323
|
-
- `useAutogrow(ref, value)` — textarea auto-grow hook used by the composers.
|
|
324
|
-
- `handleListEnter(value, caret)` — the smart-list-continuation primitive (handles `- item` / `1. item` continuation on Enter).
|
|
325
|
-
|
|
326
|
-
## Links
|
|
327
|
-
|
|
328
|
-
- Full docs — <https://poolse.dev/docs/react-ui>
|
|
329
|
-
- Hooks reference — [`@poolse/react`](https://www.npmjs.com/package/@poolse/react)
|
|
330
|
-
- SDK reference — [`@poolse/sdk`](https://www.npmjs.com/package/@poolse/sdk)
|
|
331
|
-
- Source — <https://github.com/poolse-hq/js-sdk>
|
|
332
|
-
|
|
333
|
-
## License
|
|
334
|
-
|
|
335
|
-
MIT
|
|
1
|
+
# `@poolse/react-ui`
|
|
2
|
+
|
|
3
|
+
Drop-in React chat components — `<ConversationView>` mounts the whole chat surface in one component, or compose the building blocks (`<MessageBubble>`, `<MessageComposer>`, `<ConversationList>`, `<MemberList>`, `<ThreadView>`, `<MentionInput>`, `<TypingIndicator>`, `<ReactionPicker>`) for custom layouts. CSS-variable theming — re-skin without a rebuild. Built for Next.js + React 18+.
|
|
4
|
+
|
|
5
|
+
> **MIT-licensed alternative to Sendbird UIKit, Stream Chat React UI, TalkJS, and CometChat React UI Kit.** Same component names + prop shapes as [`@poolse/react-native`](https://www.npmjs.com/package/@poolse/react-native) so cross-platform code stays mechanical to port.
|
|
6
|
+
|
|
7
|
+
Sits on top of [`@poolse/react`](https://www.npmjs.com/package/@poolse/react) (hooks) and [`@poolse/sdk`](https://www.npmjs.com/package/@poolse/sdk) (client).
|
|
8
|
+
|
|
9
|
+
> **⚠️ Upgrading from 1.x?** See [MIGRATING.md](https://github.com/poolse-hq/js-sdk/blob/main/MIGRATING.md). Every `labelFor` / `avatarFor` / `onlineUserIds` prop is now keyed by `external_id`. `<UserName>` and `useDisplayName` switched from `userId` to `externalId`.
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install @poolse/react-ui @poolse/react @poolse/sdk
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
import '@poolse/react-ui/styles.css';
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Import the stylesheet **once** at your app root. It defines the `--poolse-*` design tokens and the component styles.
|
|
22
|
+
|
|
23
|
+
## Quick start
|
|
24
|
+
|
|
25
|
+
```tsx
|
|
26
|
+
import { PoolseProvider } from '@poolse/react';
|
|
27
|
+
import { ConversationView } from '@poolse/react-ui';
|
|
28
|
+
import '@poolse/react-ui/styles.css';
|
|
29
|
+
|
|
30
|
+
export function App() {
|
|
31
|
+
return (
|
|
32
|
+
<PoolseProvider
|
|
33
|
+
config={{
|
|
34
|
+
getToken: async () => {
|
|
35
|
+
const res = await fetch('/api/chat-token', { method: 'POST' });
|
|
36
|
+
const { token } = await res.json();
|
|
37
|
+
return token;
|
|
38
|
+
},
|
|
39
|
+
}}
|
|
40
|
+
>
|
|
41
|
+
<ConversationView conversationId="00000000-0000-0000-0000-000000000000" />
|
|
42
|
+
</PoolseProvider>
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
That's a complete chat surface. On mount it injects the brand fonts (Bricolage Grotesque, Hanken Grotesk, JetBrains Mono) via a Google Fonts `<link>`. Pass `loadFonts={false}` if your host app already loads them or your CSP forbids dynamic injection.
|
|
48
|
+
|
|
49
|
+
## `<ConversationView>`
|
|
50
|
+
|
|
51
|
+
The default composed surface. Every feature is on a flag you can turn off.
|
|
52
|
+
|
|
53
|
+
```tsx
|
|
54
|
+
<ConversationView
|
|
55
|
+
conversationId={id}
|
|
56
|
+
|
|
57
|
+
// Feature toggles (all default true unless noted)
|
|
58
|
+
reactions
|
|
59
|
+
mentions
|
|
60
|
+
attachments
|
|
61
|
+
actions
|
|
62
|
+
threads
|
|
63
|
+
quotations
|
|
64
|
+
readReceipts
|
|
65
|
+
markdown
|
|
66
|
+
grouping
|
|
67
|
+
daySeparators
|
|
68
|
+
|
|
69
|
+
// Behavioral knobs
|
|
70
|
+
maxBodyLength={200} // 0 disables the "Read more" trim
|
|
71
|
+
groupingWindowMs={300000} // 5 min — same-sender messages within this window cluster
|
|
72
|
+
senderLabels="auto" // 'auto' (on for 3+ members) | 'always' | 'never'
|
|
73
|
+
avatars="auto" // same
|
|
74
|
+
|
|
75
|
+
// Customer wiring
|
|
76
|
+
labelFor={(userId) => /* … */}
|
|
77
|
+
onMarkedRead={(convId) => /* clear sidebar badge */}
|
|
78
|
+
renderMessage={(msg, currentUserId) => /* fully custom row */}
|
|
79
|
+
emptyState={<div>Say hi.</div>}
|
|
80
|
+
loadFonts // default true
|
|
81
|
+
/>
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### What it gives you
|
|
85
|
+
|
|
86
|
+
- **Message list with infinite-scroll-up.** Top-sentinel `IntersectionObserver` fires `loadMore()` when the user gets within ~400px of the top.
|
|
87
|
+
- **Smart auto-scroll.** Stays pinned to the bottom while the user is at the bottom; otherwise increments a "N new messages" badge.
|
|
88
|
+
- **Auto mark-read.** When the latest message is in view, fires `markReadUpTo` once per fresh tail. Drives both your own progress (`onMarkedRead` callback) and the server-broadcast read receipt that flips other users' double-check glyph.
|
|
89
|
+
- **Drag-and-drop attachments.** The whole conversation pane accepts a file drop and forwards it to the composer's upload queue.
|
|
90
|
+
- **Quote-reply chip** above the composer when `quotations` is on. The chip carries the quoted sender + a snippet, and Esc dismisses it.
|
|
91
|
+
- **Realtime status banner.** Renders "Connecting…" / "Reconnecting…" / "Disconnected" pills when the socket isn't connected.
|
|
92
|
+
- **Thread side-pane** opens on the right when the user clicks "Reply in thread"; below 760px it goes full-screen.
|
|
93
|
+
- **Day separators.** "Today" / "Yesterday" / weekday name / `26 May 2024` between calendar days.
|
|
94
|
+
- **Message clustering.** Same sender, same day, within `groupingWindowMs` (default 5 min) — clustered with a single asymmetric tail on the last bubble (iMessage / WhatsApp convention).
|
|
95
|
+
- **Markdown bodies.** GitHub-flavored, sanitized: bold/italic/lists/code/blockquotes/strikethrough/autolinks. URLs render with `target="_blank" rel="noopener noreferrer nofollow"`.
|
|
96
|
+
- **Long-message trim.** Bodies past `maxBodyLength` collapse to a `Read more` toggle.
|
|
97
|
+
|
|
98
|
+
### `renderMessage` escape hatch
|
|
99
|
+
|
|
100
|
+
`renderMessage` completely replaces the default `<MessageRow>` for each message — you own the layout from the bubble outward. Group position, avatars, sender labels, hover actions: none of that is wired automatically when you take the slot.
|
|
101
|
+
|
|
102
|
+
```tsx
|
|
103
|
+
<ConversationView
|
|
104
|
+
conversationId={id}
|
|
105
|
+
renderMessage={(msg, currentUserId) => (
|
|
106
|
+
<MyCustomBubble message={msg} isSelf={msg.sender_id === currentUserId} />
|
|
107
|
+
)}
|
|
108
|
+
/>
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
If you want to keep most of the default behavior, render `<MessageRow>` yourself with the props you'd like to flip.
|
|
112
|
+
|
|
113
|
+
## Components
|
|
114
|
+
|
|
115
|
+
### Composed surfaces
|
|
116
|
+
|
|
117
|
+
| Component | What |
|
|
118
|
+
| -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
119
|
+
| `<PoolseInbox>` | Full inbox shell — two-column side-by-side list + detail on wide viewports, push-pane on ≤720px. Imperative ref API for `open`, `openDirect`, `openGroup`, `promptNewChat`, `promptNewGroup`, `close`. Built-in user picker + group-details sheet when a `users` directory is provided. |
|
|
120
|
+
| `<ConversationView>` | Full chat (above) — `useMessages` + `useMembers` + `useTyping` + composer + thread pane wired together. |
|
|
121
|
+
| `<ChatHeader>` | Standalone title bar — direct chats resolve the OTHER member's name + avatar via `labelFor` / `avatarFor`, groups show member count, presence-driven green dot. Optional `onBack`, `onPress`, `onMembersPress`, plus a free-form `rightSlot` for custom actions (e.g. an "Invite" button). |
|
|
122
|
+
| `<ThreadView>` | The right-side reply pane. `useThread`-driven; close button + Esc + drag-drop. Used internally by `<ConversationView>`; export it for custom layouts. |
|
|
123
|
+
|
|
124
|
+
### Sheets / modals
|
|
125
|
+
|
|
126
|
+
| Component | What |
|
|
127
|
+
| --------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
128
|
+
| `<UserPickerSheet>` | Modal for picking a direct-chat target or a group's members. `mode: 'single'` is one-tap-to-start, `mode: 'group'` adds a name input + multi-select. Accepts an `InboxUser` directory. |
|
|
129
|
+
| `<GroupDetailsSheet>` | Modal showing a group's name, avatar, and the existing `<MemberList>` roster with presence dots. Optional `footer` slot for "Leave group" / "Invite" actions. |
|
|
130
|
+
|
|
131
|
+
### Message surface
|
|
132
|
+
|
|
133
|
+
| Component | What |
|
|
134
|
+
| ------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
135
|
+
| `<MessageRow>` | One fully-wired row: bubble + (optional) avatar + reaction strip + thread pill + hover actions. Owns a single `useReactions` instance shared by the inline strip and the picker. |
|
|
136
|
+
| `<MessageBubble>` | Just the bubble — sender label, quoted card, attachments, body, meta. Pure presentational; takes `Message` + `currentUserId`. |
|
|
137
|
+
| `<EditableMessageBubble>` | `<MessageBubble>` plus an in-place edit mode (textarea, Enter to save, Esc to cancel). Controlled via the `editing` prop. |
|
|
138
|
+
| `<MessageActions>` | Hover popover with the react / reply / quote / copy / edit / delete affordances. |
|
|
139
|
+
| `<TypingIndicator>` | Three bouncing dots + a `role="status"` live region announcing "Alice is typing" / "Alice and Bob are typing" / "3 people are typing". |
|
|
140
|
+
|
|
141
|
+
### Composer
|
|
142
|
+
|
|
143
|
+
| Component | What |
|
|
144
|
+
| -------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
145
|
+
| `<MessageComposer>` | Pill input + send button + paperclip → upload queue. Smart list continuation (Enter on `- item` repeats the bullet). Exposes an imperative `addFiles(files)` via `ref` for drag-drop callers. |
|
|
146
|
+
| `<MentionInput>` | Same as `<MessageComposer>` but with `@`-autocomplete from the conversation's member list. `combobox` ARIA, keyboard-navigable dropdown. Sends `MessageCreateRequest` shape (including `mentions[]`) on submit. |
|
|
147
|
+
| `<UploadQueueStrip>` | Renders one chip per item in the composer's upload queue — pending/uploading/ready/error — with cancel + dismiss. Live progress bar driven by the SDK's XHR-based upload. |
|
|
148
|
+
|
|
149
|
+
### Attachments
|
|
150
|
+
|
|
151
|
+
| Component | What |
|
|
152
|
+
| --------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
153
|
+
| `<AttachmentPreview>` | Inline image (lazy thumbnail → fullscreen lightbox on click) or a file card with download. Resolves the presigned URL via `useAttachmentUrl`. |
|
|
154
|
+
|
|
155
|
+
### Conversation roster
|
|
156
|
+
|
|
157
|
+
| Component | What |
|
|
158
|
+
| -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
159
|
+
| `<ConversationList>` | Sidebar list of the user's conversations. Avatar + name + `last_message_preview` + timestamp + unread pill. Direct rows resolve the other member's name/avatar via `labelFor` / `avatarFor` (the same resolvers `<ChatHeader>` and `<PoolseInbox>` take), so a customer can wire one mapping everywhere. Controlled mode: pass `conversations`/`loading`/`error` to render from external state instead of `useConversations()`. |
|
|
160
|
+
| `<MemberList>` | Roster for one conversation. Role badges, online dot, optional remove button gated by a `canRemove(membership)` predicate. |
|
|
161
|
+
|
|
162
|
+
### Reactions
|
|
163
|
+
|
|
164
|
+
| Component | What |
|
|
165
|
+
| ------------------ | ------------------------------------------------------------------------------------------------ |
|
|
166
|
+
| `<ReactionStrip>` | Inline emoji pills with counts + "your reaction" highlight; optional picker button on the right. |
|
|
167
|
+
| `<ReactionPicker>` | Standalone emoji popover. Six common emojis, arrow-key navigation, Esc closes. |
|
|
168
|
+
|
|
169
|
+
### Identity
|
|
170
|
+
|
|
171
|
+
| Component | What |
|
|
172
|
+
| ------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
173
|
+
| `<Avatar>` | Circular image with initials fallback + green presence dot. `size: 'sm' \| 'md' \| 'lg'`. |
|
|
174
|
+
| `<UserName>` / `useDisplayName` | Resolve a `user_id` to a display string via the configured `userResolver`, with a `labelFor` sync override and a stable fallback (`User abc123`) when nothing is available. |
|
|
175
|
+
|
|
176
|
+
### Brand chrome
|
|
177
|
+
|
|
178
|
+
| Component | What |
|
|
179
|
+
| -------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
180
|
+
| `<PoolseIcon name="…">` | One SVG icon from a built-in set (41 names: `attachment`, `bell`, `check`, `chevron-down`, `close`, `download`, `edit`, `emoji`, `heart`, `image`, `message`, `messages`, `pin`, `plus`, `presence`, `pulse`, `reply`, `search`, `send`, `send-fill`, `settings`, `thumbs-up`, `trash`, `typing`, `user`, `users`, `webhook`, …). Pass `label={null}` for purely decorative. |
|
|
181
|
+
| `<PoolseLogo>` | Brand mark / lockup / wordmark / mono (single-color) variants. |
|
|
182
|
+
| `<PoolseFonts />` / `usePoolseFonts()` | Inject the Google Fonts link into `<head>` (idempotent). `<ConversationView>` calls this automatically unless you pass `loadFonts={false}`. |
|
|
183
|
+
|
|
184
|
+
## Attachments inside the bubble (1.1.0+)
|
|
185
|
+
|
|
186
|
+
As of 1.1.0, `<MessageBubble>` renders attachments **inside** the bubble (WhatsApp / iMessage convention) rather than as a separate block under it.
|
|
187
|
+
|
|
188
|
+
The layout chooses a grid template by image count:
|
|
189
|
+
|
|
190
|
+
| Count | Layout |
|
|
191
|
+
| --------- | ----------------------------------------------------------------------------- |
|
|
192
|
+
| 1 image | Single full-bleed tile, natural aspect, capped at 360px tall. |
|
|
193
|
+
| 2 images | Two equal squares, side-by-side. |
|
|
194
|
+
| 3 images | One 16:9 hero on top + two squares beneath. |
|
|
195
|
+
| 4+ images | 2×2 grid. The 4th tile shows a `+N more` overlay when the total exceeds four. |
|
|
196
|
+
|
|
197
|
+
Non-image attachments (PDFs, etc.) render as stacked file cards inside the bubble's padded area, below the image mosaic. On self-bubbles the cards tint white-on-coral to read against the brand color.
|
|
198
|
+
|
|
199
|
+
When a message has **only** images (no body text and no file cards), the meta row (time + read tick) becomes a small dark pill overlaid on the bottom-right of the mosaic — same convention as WhatsApp.
|
|
200
|
+
|
|
201
|
+
The bubble has `overflow: hidden` so the mosaic is clipped to the bubble's rounded corners and the asymmetric tail.
|
|
202
|
+
|
|
203
|
+
### Opting out
|
|
204
|
+
|
|
205
|
+
```tsx
|
|
206
|
+
<MessageBubble message={msg} currentUserId={meId} showAttachments={false} />
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
Pass `showAttachments={false}` to suppress in-bubble attachments — useful if you want to render them yourself outside the bubble. `<MessageRow>` forwards its `attachments` flag to this prop, and `<ConversationView>`'s `attachments` flag forwards to `<MessageRow>`.
|
|
210
|
+
|
|
211
|
+
### Migration from 1.0.x
|
|
212
|
+
|
|
213
|
+
Anything customizing `.poolse-message-row__attachments` in your stylesheet won't match anymore — that class is no longer rendered. The new class names are:
|
|
214
|
+
|
|
215
|
+
- `.poolse-message__media` — image mosaic container
|
|
216
|
+
- `.poolse-message__media--n1` / `--n2` / `--n3` / `--n4` — count-specific grid templates
|
|
217
|
+
- `.poolse-message__media-tile` — one image cell
|
|
218
|
+
- `.poolse-message__media-overflow` — the `+N more` overlay
|
|
219
|
+
- `.poolse-message__files` — file-card stack
|
|
220
|
+
- `.poolse-message__meta--overlay` — modifier applied to `.poolse-message__meta` in image-only mode
|
|
221
|
+
- `.poolse-message--has-media` / `--media-only` — parent state modifiers
|
|
222
|
+
|
|
223
|
+
If you weren't styling the old class, you don't need to do anything — the new layout is on by default.
|
|
224
|
+
|
|
225
|
+
## Theming
|
|
226
|
+
|
|
227
|
+
Every color, radius, shadow, and font in the kit is a CSS variable. Override them in your own stylesheet — no JS, no rebuild:
|
|
228
|
+
|
|
229
|
+
```css
|
|
230
|
+
:root {
|
|
231
|
+
--poolse-brand: #0070f3; /* primary action */
|
|
232
|
+
--poolse-brand-soft: #e0eaff; /* tinted fills, hover, badges */
|
|
233
|
+
--poolse-brand-strong: #0050b3; /* AA text on light surfaces */
|
|
234
|
+
--poolse-on-brand: #ffffff; /* foreground on brand */
|
|
235
|
+
}
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
The full token set:
|
|
239
|
+
|
|
240
|
+
```css
|
|
241
|
+
/* Brand & surfaces */
|
|
242
|
+
--poolse-brand /* primary action (default Pulse Coral #ff5436) */
|
|
243
|
+
--poolse-brand-strong /* AA text on light */
|
|
244
|
+
--poolse-brand-soft /* tinted fills, badges, hover */
|
|
245
|
+
--poolse-on-brand /* foreground on brand */
|
|
246
|
+
--poolse-paper /* page background */
|
|
247
|
+
--poolse-surface /* cards, panels */
|
|
248
|
+
--poolse-surface-2 /* insets, fields */
|
|
249
|
+
--poolse-ink /* primary text */
|
|
250
|
+
--poolse-ink-2 /* secondary text */
|
|
251
|
+
--poolse-ink-3 /* tertiary, hints */
|
|
252
|
+
--poolse-border /* hairline borders */
|
|
253
|
+
|
|
254
|
+
/* Semantic */
|
|
255
|
+
--poolse-presence /* online dot */
|
|
256
|
+
--poolse-success
|
|
257
|
+
--poolse-warning
|
|
258
|
+
--poolse-error /* distinct from coral */
|
|
259
|
+
--poolse-info
|
|
260
|
+
|
|
261
|
+
/* Typography */
|
|
262
|
+
--poolse-font-display /* Bricolage Grotesque */
|
|
263
|
+
--poolse-font-body /* Hanken Grotesk */
|
|
264
|
+
--poolse-font-mono /* JetBrains Mono */
|
|
265
|
+
--poolse-font-size /* default 15px */
|
|
266
|
+
--poolse-line-height /* default 1.5 */
|
|
267
|
+
|
|
268
|
+
/* Radii */
|
|
269
|
+
--poolse-radius-sm /* 8px */
|
|
270
|
+
--poolse-radius-md /* 12px */
|
|
271
|
+
--poolse-radius-lg /* 16px */
|
|
272
|
+
--poolse-radius-xl /* 24px */
|
|
273
|
+
--poolse-radius-pill /* 999px */
|
|
274
|
+
|
|
275
|
+
/* Shadows (warm-tinted) */
|
|
276
|
+
--poolse-shadow-sm
|
|
277
|
+
--poolse-shadow-md
|
|
278
|
+
--poolse-shadow-lg
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
### Dark mode
|
|
282
|
+
|
|
283
|
+
The stylesheet ships with a dark theme keyed off the user's `prefers-color-scheme`. To force a mode, set `data-theme="dark"` or `data-theme="light"` on any ancestor of the chat surface:
|
|
284
|
+
|
|
285
|
+
```html
|
|
286
|
+
<div data-theme="dark">
|
|
287
|
+
<ConversationView ... />
|
|
288
|
+
</div>
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
## Accessibility
|
|
292
|
+
|
|
293
|
+
- `<div role="log" aria-live="polite" aria-relevant="additions">` on the message list — screen readers announce new messages but not the initial load.
|
|
294
|
+
- `<aside role="complementary" aria-label="Message thread">` on the thread pane. Esc closes; close button auto-focuses on mount.
|
|
295
|
+
- `<MentionInput>` is a proper combobox: `role="combobox"`, `aria-expanded`, `aria-controls`, `aria-autocomplete="list"`, `aria-activedescendant` on the input; the dropdown is `role="listbox"` with `role="option"` items.
|
|
296
|
+
- `<ReactionPicker>` is `role="menu"` / `role="menuitem"` with arrow-key navigation and Esc to close.
|
|
297
|
+
- `<TypingIndicator>` is `role="status" aria-live="polite" aria-atomic="true"`; the dots themselves are `aria-hidden`.
|
|
298
|
+
- `<Avatar>` is `role="img" aria-label="{name}"` even when rendering initials.
|
|
299
|
+
- Touch reveal: the hover action menu on `<MessageRow>` is hidden on `(hover: none)` and switches to tap-toggle on the bubble itself, so you don't lose actions on mobile.
|
|
300
|
+
- The image lightbox locks body scroll while open, closes on Esc and on backdrop click, and keeps the image itself non-dismissable (so a click on the image doesn't accidentally close).
|
|
301
|
+
- The whole kit honors `prefers-reduced-motion` for the typing indicator, the message-row hover transitions, and the thread pane slide-in.
|
|
302
|
+
|
|
303
|
+
Touch targets in the composer are 44px; the textarea uses 16px so iOS doesn't auto-zoom on focus; the lightbox + composer apply `safe-area-inset` padding for notched devices.
|
|
304
|
+
|
|
305
|
+
## Customization layers
|
|
306
|
+
|
|
307
|
+
In order of escalating control:
|
|
308
|
+
|
|
309
|
+
1. **CSS variables.** Re-skin without touching JS.
|
|
310
|
+
2. **Feature flags on `<ConversationView>`.** Turn whole features off (`reactions={false}`, `threads={false}`, etc.).
|
|
311
|
+
3. **Render-prop slots.** Replace individual rows: `<ConversationView renderMessage={...}>`, `<ConversationList renderItem={...}>`, `<MemberList renderItem={...}>`, `<ThreadView renderMessage={...}>`.
|
|
312
|
+
4. **Component composition.** Drop `<ConversationView>` and assemble `<MessageRow>` (or `<MessageBubble>` if you want to skip the row's wiring) + `<MessageComposer>` + `<TypingIndicator>` + `<ThreadView>` yourself.
|
|
313
|
+
5. **Drop down to `@poolse/react`.** Build your own components on the same hooks that this package uses internally.
|
|
314
|
+
|
|
315
|
+
You can mix and match — there's no all-or-nothing boundary.
|
|
316
|
+
|
|
317
|
+
## Re-exports
|
|
318
|
+
|
|
319
|
+
The package also re-exports a few helpers that are useful when you're composing your own UI:
|
|
320
|
+
|
|
321
|
+
- `userColor(userId)` — deterministic per-user color for sender labels and avatars (8-hue palette, hashed from the id).
|
|
322
|
+
- `computeGroupPosition(msg, prev, next, windowMs)` / `sameDay(a, b)` / `formatDayLabel(iso)` — the same grouping primitives `<ConversationView>` uses to cluster messages.
|
|
323
|
+
- `useAutogrow(ref, value)` — textarea auto-grow hook used by the composers.
|
|
324
|
+
- `handleListEnter(value, caret)` — the smart-list-continuation primitive (handles `- item` / `1. item` continuation on Enter).
|
|
325
|
+
|
|
326
|
+
## Links
|
|
327
|
+
|
|
328
|
+
- Full docs — <https://poolse.dev/docs/react-ui>
|
|
329
|
+
- Hooks reference — [`@poolse/react`](https://www.npmjs.com/package/@poolse/react)
|
|
330
|
+
- SDK reference — [`@poolse/sdk`](https://www.npmjs.com/package/@poolse/sdk)
|
|
331
|
+
- Source — <https://github.com/poolse-hq/js-sdk>
|
|
332
|
+
|
|
333
|
+
## License
|
|
334
|
+
|
|
335
|
+
MIT
|