@linktr.ee/messaging-react 1.0.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 ADDED
@@ -0,0 +1,127 @@
1
+ # @linktr.ee/messaging-react
2
+
3
+ React messaging components built on `@linktr.ee/messaging-core` for web applications.
4
+
5
+ ## Features
6
+
7
+ - **Web-optimized**: Uses Tailwind CSS and web APIs for responsive design
8
+ - **Component-based**: Modular components that can be used individually or together
9
+ - **Capability-driven**: Inject different data sources and capabilities per host
10
+ - **Stream Chat integration**: Built on Stream Chat React for reliable messaging
11
+ - **TypeScript**: Full type safety throughout
12
+
13
+ ## Components
14
+
15
+ ### MessagingShell
16
+ Main container component that provides complete messaging interface.
17
+
18
+ ```tsx
19
+ import { MessagingShell, MessagingProvider } from '@linktr.ee/messaging-react';
20
+
21
+ <MessagingProvider user={user} serviceConfig={config} apiKey={apiKey}>
22
+ <MessagingShell
23
+ capabilities={{
24
+ showStartConversation: true,
25
+ participantSource: followersSource,
26
+ participantLabel: 'followers'
27
+ }}
28
+ />
29
+ </MessagingProvider>
30
+ ```
31
+
32
+ ### Individual Components
33
+ - **ChannelList**: Sidebar with conversations and start conversation button
34
+ - **ChannelView**: Message interface with customizable actions via render props
35
+ - **ParticipantPicker**: Generic dialog for selecting conversation participants
36
+ - **MessagingProvider**: Context provider for messaging state
37
+
38
+ ## Integration Patterns
39
+
40
+ ### MFE Pattern (Current)
41
+ ```tsx
42
+ // Uses existing adapters and data sources
43
+ import { createFollowersParticipantSource } from '../adapters/followersAdapter';
44
+
45
+ const capabilities = {
46
+ showStartConversation: true,
47
+ participantSource: createFollowersParticipantSource(),
48
+ participantLabel: 'followers'
49
+ };
50
+ ```
51
+
52
+ ### Next.js Pattern (Future)
53
+ ```tsx
54
+ // Custom data sources for Next.js environment
55
+ const capabilities = {
56
+ showStartConversation: true,
57
+ participantSource: createCustomParticipantSource(),
58
+ attachmentSource: createLinksAttachmentSource()
59
+ };
60
+ ```
61
+
62
+ ### Embedded Pattern (Future)
63
+ ```tsx
64
+ // Use individual components in existing layouts
65
+ <div className="sidebar">
66
+ <ChannelList onChannelSelect={handleSelect} />
67
+ </div>
68
+ <div className="main">
69
+ <ChannelView channel={selectedChannel} />
70
+ </div>
71
+ ```
72
+
73
+ ## Capability System
74
+
75
+ The package uses a capability-based architecture to customize functionality:
76
+
77
+ ```typescript
78
+ interface MessagingCapabilities {
79
+ showStartConversation?: boolean;
80
+ showAttachments?: boolean;
81
+ participantSource?: ParticipantSource;
82
+ attachmentSource?: AttachmentSource;
83
+ participantLabel?: string; // e.g., "followers", "team members"
84
+ attachmentLabel?: string; // e.g., "links", "files"
85
+ }
86
+ ```
87
+
88
+ ## Data Source Interfaces
89
+
90
+ ### ParticipantSource
91
+ Interface for loading conversation participants:
92
+
93
+ ```typescript
94
+ interface ParticipantSource {
95
+ loadParticipants: (options?: {
96
+ search?: string;
97
+ limit?: number;
98
+ cursor?: string;
99
+ }) => Promise<{
100
+ participants: Participant[];
101
+ hasMore: boolean;
102
+ nextCursor?: string;
103
+ }>;
104
+ totalCount?: number;
105
+ loading?: boolean;
106
+ }
107
+ ```
108
+
109
+ ### AttachmentSource (Future)
110
+ Interface for loading attachments like links or files.
111
+
112
+ ## Architecture Benefits
113
+
114
+ - **Portability**: Works across different host environments
115
+ - **Customization**: Inject different data sources per host
116
+ - **Consistency**: Maintains Linktree design system
117
+ - **Performance**: Web-optimized with lazy loading and pagination
118
+ - **Maintainability**: Clean separation between UI and business logic
119
+
120
+ ## Development Status
121
+
122
+ ✅ Core messaging functionality
123
+ ✅ Follower participant selection
124
+ ✅ Responsive design
125
+ ✅ TypeScript safety
126
+ ⏳ Attachment system (planned)
127
+ ⏳ Advanced customization options (planned)
@@ -0,0 +1,194 @@
1
+ import { Channel } from 'stream-chat';
2
+ import { default as default_2 } from 'react';
3
+ import { MessagingUser } from '@linktr.ee/messaging-core';
4
+ import { StreamChatService } from '@linktr.ee/messaging-core';
5
+ import { StreamChatServiceConfig } from '@linktr.ee/messaging-core';
6
+
7
+ /**
8
+ * Avatar component that displays a user image or colored initial fallback
9
+ */
10
+ export declare const Avatar: default_2.FC<AvatarProps>;
11
+
12
+ export declare interface AvatarProps {
13
+ id: string;
14
+ name: string;
15
+ image?: string;
16
+ size?: number;
17
+ className?: string;
18
+ }
19
+
20
+ /**
21
+ * Channel list component with customizable header and actions
22
+ */
23
+ export declare const ChannelList: default_2.FC<ChannelListProps>;
24
+
25
+ /**
26
+ * ChannelList component props
27
+ */
28
+ export declare interface ChannelListProps {
29
+ onChannelSelect: (channel: Channel) => void;
30
+ selectedChannel?: Channel;
31
+ showStartConversation?: boolean;
32
+ onStartConversation?: () => void;
33
+ participantLabel?: string;
34
+ className?: string;
35
+ }
36
+
37
+ /**
38
+ * Channel view component with message list and input
39
+ */
40
+ export declare const ChannelView: default_2.FC<ChannelViewProps>;
41
+
42
+ /**
43
+ * ChannelView component props
44
+ */
45
+ export declare interface ChannelViewProps {
46
+ channel: Channel;
47
+ onBack?: () => void;
48
+ showBackButton?: boolean;
49
+ renderMessageInputActions?: (channel: Channel) => React.ReactNode;
50
+ onLeaveConversation?: (channel: Channel) => void;
51
+ onBlockParticipant?: (participantId?: string) => void;
52
+ className?: string;
53
+ }
54
+
55
+ /**
56
+ * Messaging capabilities configuration
57
+ */
58
+ export declare interface MessagingCapabilities {
59
+ showStartConversation?: boolean;
60
+ participantSource?: ParticipantSource;
61
+ participantLabel?: string;
62
+ }
63
+
64
+ /**
65
+ * Context value for messaging state and service
66
+ */
67
+ declare interface MessagingContextValue {
68
+ service: StreamChatService | null;
69
+ client: any;
70
+ isConnected: boolean;
71
+ isLoading: boolean;
72
+ error: string | null;
73
+ capabilities: MessagingCapabilities;
74
+ customization: MessagingCustomization;
75
+ refreshConnection: () => Promise<void>;
76
+ debug: boolean;
77
+ }
78
+
79
+ /**
80
+ * Customization options
81
+ */
82
+ declare interface MessagingCustomization {
83
+ theme?: 'light' | 'dark' | 'auto';
84
+ accentColor?: string;
85
+ showParticipantStatus?: boolean;
86
+ }
87
+
88
+ /**
89
+ * Provider component that wraps messaging-core with React state management
90
+ */
91
+ export declare const MessagingProvider: default_2.FC<MessagingProviderProps>;
92
+
93
+ /**
94
+ * MessagingProvider component props
95
+ */
96
+ export declare interface MessagingProviderProps {
97
+ children: React.ReactNode;
98
+ user: MessagingUser | null;
99
+ serviceConfig: Omit<StreamChatServiceConfig, 'apiKey'>;
100
+ apiKey: string;
101
+ capabilities?: MessagingCapabilities;
102
+ customization?: MessagingCustomization;
103
+ debug?: boolean;
104
+ }
105
+
106
+ /**
107
+ * Main messaging interface component that combines channel list and channel view
108
+ */
109
+ export declare const MessagingShell: default_2.FC<MessagingShellProps>;
110
+
111
+ /**
112
+ * Main MessagingShell component props
113
+ */
114
+ export declare interface MessagingShellProps {
115
+ capabilities?: MessagingCapabilities;
116
+ customization?: MessagingCustomization;
117
+ className?: string;
118
+ renderMessageInputActions?: (channel: Channel) => React.ReactNode;
119
+ onChannelSelect?: (channel: Channel) => void;
120
+ onParticipantSelect?: (participant: Participant) => void;
121
+ }
122
+
123
+ /**
124
+ * Generic participant interface for different host environments
125
+ */
126
+ export declare interface Participant {
127
+ id: string;
128
+ name: string;
129
+ email?: string;
130
+ image?: string;
131
+ username?: string;
132
+ phone?: string;
133
+ metadata?: Record<string, any>;
134
+ }
135
+
136
+ /**
137
+ * Generic participant picker component for starting conversations
138
+ */
139
+ export declare const ParticipantPicker: default_2.FC<ParticipantPickerProps>;
140
+
141
+ /**
142
+ * ParticipantPicker component props
143
+ */
144
+ export declare interface ParticipantPickerProps {
145
+ participantSource: ParticipantSource;
146
+ onSelectParticipant: (participant: Participant) => void;
147
+ onClose: () => void;
148
+ existingParticipantIds?: Set<string>;
149
+ participantLabel?: string;
150
+ searchPlaceholder?: string;
151
+ className?: string;
152
+ }
153
+
154
+ /**
155
+ * Source for loading participants (followers, team members, etc.)
156
+ */
157
+ export declare interface ParticipantSource {
158
+ loadParticipants: (options?: {
159
+ search?: string;
160
+ limit?: number;
161
+ cursor?: string;
162
+ }) => Promise<{
163
+ participants: Participant[];
164
+ hasMore: boolean;
165
+ nextCursor?: string;
166
+ }>;
167
+ totalCount?: number;
168
+ loading?: boolean;
169
+ }
170
+
171
+ /**
172
+ * Hook to access messaging service and state
173
+ */
174
+ export declare const useMessaging: () => MessagingContextValue;
175
+
176
+ /**
177
+ * Hook for managing participant loading with search and pagination
178
+ */
179
+ export declare const useParticipants: (participantSource: ParticipantSource, options?: {
180
+ initialSearch?: string;
181
+ pageSize?: number;
182
+ }) => {
183
+ participants: Participant[];
184
+ loading: boolean;
185
+ error: string | null;
186
+ searchQuery: string;
187
+ hasMore: boolean;
188
+ totalCount: number | undefined;
189
+ loadMore: () => void;
190
+ search: (query: string) => void;
191
+ refresh: () => void;
192
+ };
193
+
194
+ export { }