@poolse/react-ui 0.1.2 → 0.2.0-alpha.2

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/dist/index.d.cts CHANGED
@@ -1,49 +1,49 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { Message, Conversation, Uuid, Membership, Attachment, MessageCreateRequest } from '@poolse/sdk';
2
+ import { Uuid, Message, Conversation, Membership, Attachment, MessageCreateRequest } from '@poolse/sdk';
3
3
  import { ReactNode, SVGProps, ReactElement } from 'react';
4
4
  import { ReactionMap } from '@poolse/react';
5
5
 
6
6
  interface ConversationViewProps {
7
- /** Which conversation to mount. Re-mounting with a different id swaps cleanly. */
8
- conversationId: string;
9
- /** Optional placeholder when there are no messages. */
7
+ conversationId: Uuid;
8
+ /** Placeholder when there are no messages. */
10
9
  emptyState?: ReactNode;
11
10
  /**
12
- * Render-prop escape hatch for individual messages. Use this when
13
- * CSS-variable theming + `<MessageBubble>` isn't enough — e.g. you
14
- * want avatars, threading UI, reaction picker.
11
+ * Render-prop escape hatch for individual messages. When set,
12
+ * COMPLETELY overrides the default per-message rendering — you
13
+ * get the raw message + currentUserId and own the bubble shape.
14
+ * Leave unset to use the brand-aligned defaults (with reactions,
15
+ * actions, attachments inline as configured below).
15
16
  */
16
17
  renderMessage?: (msg: Message, currentUserId: string | null) => ReactNode;
17
18
  /** Translate a typing user_id into a display name. */
18
19
  labelFor?: (userId: string) => string;
19
20
  /**
20
- * Auto-load the brand fonts (Bricolage Grotesque / Hanken Grotesk /
21
- * JetBrains Mono) from Google Fonts on mount. Defaults to `true`.
22
- * Set to `false` when the host app already loads them, when CSP
23
- * forbids dynamic <link> injection, or when you're self-hosting.
21
+ * Auto-load the brand fonts on mount. Defaults to `true`. Set to
22
+ * `false` when the host app already loads them, or when CSP
23
+ * forbids dynamic <link> injection.
24
24
  */
25
25
  loadFonts?: boolean;
26
+ /** Show inline reaction strip under each message + emoji picker in hover actions. */
27
+ reactions?: boolean;
28
+ /** Swap the plain composer for one with `@`-autocomplete drawn from members. */
29
+ mentions?: boolean;
30
+ /** Paperclip → file picker → presigned upload → send-with-attachment. */
31
+ attachments?: boolean;
32
+ /** Hover-revealed react / reply / edit / delete popover next to each message. */
33
+ actions?: boolean;
34
+ /** "Reply in thread" opens a right-side ThreadView. */
35
+ threads?: boolean;
36
+ /** Check-double glyph on own messages once another member's read cursor advances past them. */
37
+ readReceipts?: boolean;
38
+ /**
39
+ * Fired once after the caller's auto-mark-read fires for a fresh
40
+ * message. Useful for clearing a sidebar unread badge before the
41
+ * `member:read` realtime echo round-trips. Receives the conv id so
42
+ * a single handler can switch between rooms.
43
+ */
44
+ onMarkedRead?: (conversationId: string) => void;
26
45
  }
27
- /**
28
- * Plug-and-play conversation surface. Composes `useMe`, `useMessages`,
29
- * `useTyping`, and `useRealtimeStatus` from `@poolse/react` with the
30
- * default `<MessageBubble>` / `<MessageComposer>` / `<TypingIndicator>`
31
- * pieces from this package.
32
- *
33
- * Drop in once for instant chat; eject to individual pieces (or the
34
- * raw hooks) when you need more control.
35
- *
36
- * ```tsx
37
- * import '@poolse/react-ui/styles.css';
38
- * import { PoolseProvider } from '@poolse/react';
39
- * import { ConversationView } from '@poolse/react-ui';
40
- *
41
- * <PoolseProvider config={{apiUrl, getToken}}>
42
- * <ConversationView conversationId={id} />
43
- * </PoolseProvider>
44
- * ```
45
- */
46
- declare function ConversationView({ conversationId, emptyState, renderMessage, labelFor, loadFonts, }: ConversationViewProps): react_jsx_runtime.JSX.Element;
46
+ declare function ConversationView({ conversationId, emptyState, renderMessage, labelFor, loadFonts, reactions, mentions, attachments, actions, threads, readReceipts, onMarkedRead, }: ConversationViewProps): react_jsx_runtime.JSX.Element;
47
47
 
48
48
  interface MessageBubbleProps {
49
49
  message: Message;
@@ -68,6 +68,19 @@ interface MessageBubbleProps {
68
68
  */
69
69
  declare function MessageBubble({ message, currentUserId, readState }: MessageBubbleProps): react_jsx_runtime.JSX.Element;
70
70
 
71
+ interface EditableMessageBubbleProps {
72
+ message: Message;
73
+ currentUserId: string | null;
74
+ readState?: 'sent' | 'read';
75
+ /** Controlled — parent owns the editing state. */
76
+ editing: boolean;
77
+ /** Called with the new body when the user saves. Should return the promise from `useMessages.edit`. */
78
+ onSave: (body: string) => Promise<unknown> | void;
79
+ /** Called when the user cancels (Esc or click cancel). */
80
+ onCancel: () => void;
81
+ }
82
+ declare function EditableMessageBubble({ message, currentUserId, readState, editing, onSave, onCancel, }: EditableMessageBubbleProps): react_jsx_runtime.JSX.Element;
83
+
71
84
  interface MessageComposerProps {
72
85
  /** Called when the user submits a message. Return value awaited so the input can disable until send completes. */
73
86
  onSend: (body: string) => Promise<unknown> | void;
@@ -83,6 +96,20 @@ interface MessageComposerProps {
83
96
  */
84
97
  declare function MessageComposer({ onSend, onTyping, placeholder, disabled, }: MessageComposerProps): react_jsx_runtime.JSX.Element;
85
98
 
99
+ interface MessageActionsProps {
100
+ /** Triggered when the user picks an emoji. */
101
+ onReact?: (emoji: string) => void;
102
+ /** Triggered when the user wants to reply in thread. */
103
+ onReply?: () => void;
104
+ /** Triggered when the user wants to edit. Only show on own messages. */
105
+ onEdit?: () => void;
106
+ /** Triggered when the user wants to delete. Only show on own messages. */
107
+ onDelete?: () => void;
108
+ /** Render any extra trailing action buttons (e.g. "Pin"). */
109
+ children?: ReactNode;
110
+ }
111
+ declare function MessageActions({ onReact, onReply, onEdit, onDelete, children, }: MessageActionsProps): react_jsx_runtime.JSX.Element;
112
+
86
113
  interface TypingIndicatorProps {
87
114
  /** Set of user_ids currently typing. */
88
115
  typing: Set<string>;
@@ -99,6 +126,20 @@ interface TypingIndicatorProps {
99
126
  */
100
127
  declare function TypingIndicator({ typing, labelFor }: TypingIndicatorProps): react_jsx_runtime.JSX.Element;
101
128
 
129
+ interface ThreadViewProps {
130
+ conversationId: Uuid;
131
+ /** The root message of the thread. ThreadView shows this at the top + lists replies under it. */
132
+ rootMessage: Message;
133
+ /** Triggered when the user closes the pane (X button). */
134
+ onClose?: () => void;
135
+ /**
136
+ * Optional override for rendering each reply. Defaults to the
137
+ * brand-styled <MessageBubble>.
138
+ */
139
+ renderMessage?: (msg: Message, currentUserId: string | null) => ReactNode;
140
+ }
141
+ declare function ThreadView({ conversationId, rootMessage, onClose, renderMessage, }: ThreadViewProps): react_jsx_runtime.JSX.Element;
142
+
102
143
  interface AvatarProps {
103
144
  /** URL to a profile image. Renders initials fallback when omitted or load fails. */
104
145
  src?: string | null;
@@ -434,4 +475,4 @@ declare function usePoolseFonts(enabled?: boolean): void;
434
475
  */
435
476
  declare function PoolseFonts(): null;
436
477
 
437
- export { AttachmentPreview, type AttachmentPreviewProps, Avatar, type AvatarProps, ConversationList, type ConversationListProps, ConversationView, type ConversationViewProps, type IconName, MemberList, type MemberListProps, MentionInput, type MentionInputProps, MessageBubble, type MessageBubbleProps, MessageComposer, type MessageComposerProps, PoolseFonts, PoolseIcon, type PoolseIconProps, PoolseLogo, type PoolseLogoProps, type PoolseLogoVariant, ReactionPicker, ReactionStrip, type ReactionStripProps, TypingIndicator, type TypingIndicatorProps, usePoolseFonts };
478
+ export { AttachmentPreview, type AttachmentPreviewProps, Avatar, type AvatarProps, ConversationList, type ConversationListProps, ConversationView, type ConversationViewProps, EditableMessageBubble, type EditableMessageBubbleProps, type IconName, MemberList, type MemberListProps, MentionInput, type MentionInputProps, MessageActions, type MessageActionsProps, MessageBubble, type MessageBubbleProps, MessageComposer, type MessageComposerProps, PoolseFonts, PoolseIcon, type PoolseIconProps, PoolseLogo, type PoolseLogoProps, type PoolseLogoVariant, ReactionPicker, ReactionStrip, type ReactionStripProps, ThreadView, type ThreadViewProps, TypingIndicator, type TypingIndicatorProps, usePoolseFonts };
package/dist/index.d.ts CHANGED
@@ -1,49 +1,49 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { Message, Conversation, Uuid, Membership, Attachment, MessageCreateRequest } from '@poolse/sdk';
2
+ import { Uuid, Message, Conversation, Membership, Attachment, MessageCreateRequest } from '@poolse/sdk';
3
3
  import { ReactNode, SVGProps, ReactElement } from 'react';
4
4
  import { ReactionMap } from '@poolse/react';
5
5
 
6
6
  interface ConversationViewProps {
7
- /** Which conversation to mount. Re-mounting with a different id swaps cleanly. */
8
- conversationId: string;
9
- /** Optional placeholder when there are no messages. */
7
+ conversationId: Uuid;
8
+ /** Placeholder when there are no messages. */
10
9
  emptyState?: ReactNode;
11
10
  /**
12
- * Render-prop escape hatch for individual messages. Use this when
13
- * CSS-variable theming + `<MessageBubble>` isn't enough — e.g. you
14
- * want avatars, threading UI, reaction picker.
11
+ * Render-prop escape hatch for individual messages. When set,
12
+ * COMPLETELY overrides the default per-message rendering — you
13
+ * get the raw message + currentUserId and own the bubble shape.
14
+ * Leave unset to use the brand-aligned defaults (with reactions,
15
+ * actions, attachments inline as configured below).
15
16
  */
16
17
  renderMessage?: (msg: Message, currentUserId: string | null) => ReactNode;
17
18
  /** Translate a typing user_id into a display name. */
18
19
  labelFor?: (userId: string) => string;
19
20
  /**
20
- * Auto-load the brand fonts (Bricolage Grotesque / Hanken Grotesk /
21
- * JetBrains Mono) from Google Fonts on mount. Defaults to `true`.
22
- * Set to `false` when the host app already loads them, when CSP
23
- * forbids dynamic <link> injection, or when you're self-hosting.
21
+ * Auto-load the brand fonts on mount. Defaults to `true`. Set to
22
+ * `false` when the host app already loads them, or when CSP
23
+ * forbids dynamic <link> injection.
24
24
  */
25
25
  loadFonts?: boolean;
26
+ /** Show inline reaction strip under each message + emoji picker in hover actions. */
27
+ reactions?: boolean;
28
+ /** Swap the plain composer for one with `@`-autocomplete drawn from members. */
29
+ mentions?: boolean;
30
+ /** Paperclip → file picker → presigned upload → send-with-attachment. */
31
+ attachments?: boolean;
32
+ /** Hover-revealed react / reply / edit / delete popover next to each message. */
33
+ actions?: boolean;
34
+ /** "Reply in thread" opens a right-side ThreadView. */
35
+ threads?: boolean;
36
+ /** Check-double glyph on own messages once another member's read cursor advances past them. */
37
+ readReceipts?: boolean;
38
+ /**
39
+ * Fired once after the caller's auto-mark-read fires for a fresh
40
+ * message. Useful for clearing a sidebar unread badge before the
41
+ * `member:read` realtime echo round-trips. Receives the conv id so
42
+ * a single handler can switch between rooms.
43
+ */
44
+ onMarkedRead?: (conversationId: string) => void;
26
45
  }
27
- /**
28
- * Plug-and-play conversation surface. Composes `useMe`, `useMessages`,
29
- * `useTyping`, and `useRealtimeStatus` from `@poolse/react` with the
30
- * default `<MessageBubble>` / `<MessageComposer>` / `<TypingIndicator>`
31
- * pieces from this package.
32
- *
33
- * Drop in once for instant chat; eject to individual pieces (or the
34
- * raw hooks) when you need more control.
35
- *
36
- * ```tsx
37
- * import '@poolse/react-ui/styles.css';
38
- * import { PoolseProvider } from '@poolse/react';
39
- * import { ConversationView } from '@poolse/react-ui';
40
- *
41
- * <PoolseProvider config={{apiUrl, getToken}}>
42
- * <ConversationView conversationId={id} />
43
- * </PoolseProvider>
44
- * ```
45
- */
46
- declare function ConversationView({ conversationId, emptyState, renderMessage, labelFor, loadFonts, }: ConversationViewProps): react_jsx_runtime.JSX.Element;
46
+ declare function ConversationView({ conversationId, emptyState, renderMessage, labelFor, loadFonts, reactions, mentions, attachments, actions, threads, readReceipts, onMarkedRead, }: ConversationViewProps): react_jsx_runtime.JSX.Element;
47
47
 
48
48
  interface MessageBubbleProps {
49
49
  message: Message;
@@ -68,6 +68,19 @@ interface MessageBubbleProps {
68
68
  */
69
69
  declare function MessageBubble({ message, currentUserId, readState }: MessageBubbleProps): react_jsx_runtime.JSX.Element;
70
70
 
71
+ interface EditableMessageBubbleProps {
72
+ message: Message;
73
+ currentUserId: string | null;
74
+ readState?: 'sent' | 'read';
75
+ /** Controlled — parent owns the editing state. */
76
+ editing: boolean;
77
+ /** Called with the new body when the user saves. Should return the promise from `useMessages.edit`. */
78
+ onSave: (body: string) => Promise<unknown> | void;
79
+ /** Called when the user cancels (Esc or click cancel). */
80
+ onCancel: () => void;
81
+ }
82
+ declare function EditableMessageBubble({ message, currentUserId, readState, editing, onSave, onCancel, }: EditableMessageBubbleProps): react_jsx_runtime.JSX.Element;
83
+
71
84
  interface MessageComposerProps {
72
85
  /** Called when the user submits a message. Return value awaited so the input can disable until send completes. */
73
86
  onSend: (body: string) => Promise<unknown> | void;
@@ -83,6 +96,20 @@ interface MessageComposerProps {
83
96
  */
84
97
  declare function MessageComposer({ onSend, onTyping, placeholder, disabled, }: MessageComposerProps): react_jsx_runtime.JSX.Element;
85
98
 
99
+ interface MessageActionsProps {
100
+ /** Triggered when the user picks an emoji. */
101
+ onReact?: (emoji: string) => void;
102
+ /** Triggered when the user wants to reply in thread. */
103
+ onReply?: () => void;
104
+ /** Triggered when the user wants to edit. Only show on own messages. */
105
+ onEdit?: () => void;
106
+ /** Triggered when the user wants to delete. Only show on own messages. */
107
+ onDelete?: () => void;
108
+ /** Render any extra trailing action buttons (e.g. "Pin"). */
109
+ children?: ReactNode;
110
+ }
111
+ declare function MessageActions({ onReact, onReply, onEdit, onDelete, children, }: MessageActionsProps): react_jsx_runtime.JSX.Element;
112
+
86
113
  interface TypingIndicatorProps {
87
114
  /** Set of user_ids currently typing. */
88
115
  typing: Set<string>;
@@ -99,6 +126,20 @@ interface TypingIndicatorProps {
99
126
  */
100
127
  declare function TypingIndicator({ typing, labelFor }: TypingIndicatorProps): react_jsx_runtime.JSX.Element;
101
128
 
129
+ interface ThreadViewProps {
130
+ conversationId: Uuid;
131
+ /** The root message of the thread. ThreadView shows this at the top + lists replies under it. */
132
+ rootMessage: Message;
133
+ /** Triggered when the user closes the pane (X button). */
134
+ onClose?: () => void;
135
+ /**
136
+ * Optional override for rendering each reply. Defaults to the
137
+ * brand-styled <MessageBubble>.
138
+ */
139
+ renderMessage?: (msg: Message, currentUserId: string | null) => ReactNode;
140
+ }
141
+ declare function ThreadView({ conversationId, rootMessage, onClose, renderMessage, }: ThreadViewProps): react_jsx_runtime.JSX.Element;
142
+
102
143
  interface AvatarProps {
103
144
  /** URL to a profile image. Renders initials fallback when omitted or load fails. */
104
145
  src?: string | null;
@@ -434,4 +475,4 @@ declare function usePoolseFonts(enabled?: boolean): void;
434
475
  */
435
476
  declare function PoolseFonts(): null;
436
477
 
437
- export { AttachmentPreview, type AttachmentPreviewProps, Avatar, type AvatarProps, ConversationList, type ConversationListProps, ConversationView, type ConversationViewProps, type IconName, MemberList, type MemberListProps, MentionInput, type MentionInputProps, MessageBubble, type MessageBubbleProps, MessageComposer, type MessageComposerProps, PoolseFonts, PoolseIcon, type PoolseIconProps, PoolseLogo, type PoolseLogoProps, type PoolseLogoVariant, ReactionPicker, ReactionStrip, type ReactionStripProps, TypingIndicator, type TypingIndicatorProps, usePoolseFonts };
478
+ export { AttachmentPreview, type AttachmentPreviewProps, Avatar, type AvatarProps, ConversationList, type ConversationListProps, ConversationView, type ConversationViewProps, EditableMessageBubble, type EditableMessageBubbleProps, type IconName, MemberList, type MemberListProps, MentionInput, type MentionInputProps, MessageActions, type MessageActionsProps, MessageBubble, type MessageBubbleProps, MessageComposer, type MessageComposerProps, PoolseFonts, PoolseIcon, type PoolseIconProps, PoolseLogo, type PoolseLogoProps, type PoolseLogoVariant, ReactionPicker, ReactionStrip, type ReactionStripProps, ThreadView, type ThreadViewProps, TypingIndicator, type TypingIndicatorProps, usePoolseFonts };