@linktr.ee/messaging-react 1.6.1 → 1.6.3

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.
Files changed (66) hide show
  1. package/dist/assets/index.css +1 -1
  2. package/dist/index.d.ts +253 -16
  3. package/dist/index.js +311 -305
  4. package/dist/index.js.map +1 -1
  5. package/package.json +1 -1
  6. package/src/components/Avatar/avatarColors.ts +3 -28
  7. package/src/components/Avatar/getAvatarEmoji.ts +44 -0
  8. package/src/components/Avatar/index.tsx +8 -9
  9. package/dist/.tsbuildinfo +0 -1
  10. package/dist/components/ActionButton/ActionButton.test.d.ts +0 -2
  11. package/dist/components/ActionButton/ActionButton.test.d.ts.map +0 -1
  12. package/dist/components/ActionButton/index.d.ts +0 -7
  13. package/dist/components/ActionButton/index.d.ts.map +0 -1
  14. package/dist/components/Avatar/avatarColors.d.ts +0 -8
  15. package/dist/components/Avatar/avatarColors.d.ts.map +0 -1
  16. package/dist/components/Avatar/index.d.ts +0 -13
  17. package/dist/components/Avatar/index.d.ts.map +0 -1
  18. package/dist/components/ChannelList/CustomChannelPreview.d.ts +0 -13
  19. package/dist/components/ChannelList/CustomChannelPreview.d.ts.map +0 -1
  20. package/dist/components/ChannelList/index.d.ts +0 -7
  21. package/dist/components/ChannelList/index.d.ts.map +0 -1
  22. package/dist/components/ChannelView.d.ts +0 -7
  23. package/dist/components/ChannelView.d.ts.map +0 -1
  24. package/dist/components/CloseButton/index.d.ts +0 -6
  25. package/dist/components/CloseButton/index.d.ts.map +0 -1
  26. package/dist/components/FaqList/FaqListItem.d.ts +0 -9
  27. package/dist/components/FaqList/FaqListItem.d.ts.map +0 -1
  28. package/dist/components/FaqList/index.d.ts +0 -19
  29. package/dist/components/FaqList/index.d.ts.map +0 -1
  30. package/dist/components/IconButton/index.d.ts +0 -9
  31. package/dist/components/IconButton/index.d.ts.map +0 -1
  32. package/dist/components/Loading/index.d.ts +0 -7
  33. package/dist/components/Loading/index.d.ts.map +0 -1
  34. package/dist/components/MessagingShell/EmptyState.d.ts +0 -10
  35. package/dist/components/MessagingShell/EmptyState.d.ts.map +0 -1
  36. package/dist/components/MessagingShell/ErrorState.d.ts +0 -9
  37. package/dist/components/MessagingShell/ErrorState.d.ts.map +0 -1
  38. package/dist/components/MessagingShell/LoadingState.d.ts +0 -5
  39. package/dist/components/MessagingShell/LoadingState.d.ts.map +0 -1
  40. package/dist/components/MessagingShell/index.d.ts +0 -7
  41. package/dist/components/MessagingShell/index.d.ts.map +0 -1
  42. package/dist/components/ParticipantPicker/ParticipantItem.d.ts +0 -13
  43. package/dist/components/ParticipantPicker/ParticipantItem.d.ts.map +0 -1
  44. package/dist/components/ParticipantPicker/ParticipantPicker.d.ts +0 -7
  45. package/dist/components/ParticipantPicker/ParticipantPicker.d.ts.map +0 -1
  46. package/dist/components/ParticipantPicker/index.d.ts +0 -7
  47. package/dist/components/ParticipantPicker/index.d.ts.map +0 -1
  48. package/dist/components/SearchInput/SearchInput.test.d.ts +0 -2
  49. package/dist/components/SearchInput/SearchInput.test.d.ts.map +0 -1
  50. package/dist/components/SearchInput/index.d.ts +0 -8
  51. package/dist/components/SearchInput/index.d.ts.map +0 -1
  52. package/dist/hooks/useMessaging.d.ts +0 -6
  53. package/dist/hooks/useMessaging.d.ts.map +0 -1
  54. package/dist/hooks/useParticipants.d.ts +0 -19
  55. package/dist/hooks/useParticipants.d.ts.map +0 -1
  56. package/dist/index.d.ts.map +0 -1
  57. package/dist/providers/MessagingProvider.d.ts +0 -27
  58. package/dist/providers/MessagingProvider.d.ts.map +0 -1
  59. package/dist/stories/mocks.d.ts +0 -29
  60. package/dist/stories/mocks.d.ts.map +0 -1
  61. package/dist/test/setup.d.ts +0 -2
  62. package/dist/test/setup.d.ts.map +0 -1
  63. package/dist/test/utils.d.ts +0 -12
  64. package/dist/test/utils.d.ts.map +0 -1
  65. package/dist/types.d.ts +0 -134
  66. package/dist/types.d.ts.map +0 -1
package/dist/index.d.ts CHANGED
@@ -1,16 +1,253 @@
1
- import './styles.css';
2
- export { MessagingShell } from './components/MessagingShell';
3
- export { ChannelList } from './components/ChannelList';
4
- export { ChannelView } from './components/ChannelView';
5
- export { ParticipantPicker } from './components/ParticipantPicker';
6
- export { Avatar } from './components/Avatar';
7
- export { FaqList } from './components/FaqList';
8
- export { FaqListItem } from './components/FaqList/FaqListItem';
9
- export { MessagingProvider } from './providers/MessagingProvider';
10
- export { useMessaging } from './hooks/useMessaging';
11
- export { useParticipants } from './hooks/useParticipants';
12
- export type { MessagingShellProps, ChannelListProps, ChannelViewProps, ParticipantPickerProps, MessagingProviderProps, MessagingCapabilities, ParticipantSource, Participant, } from './types';
13
- export type { AvatarProps } from './components/Avatar';
14
- export type { Faq, FaqListProps } from './components/FaqList';
15
- export type { FaqListItemProps } from './components/FaqList/FaqListItem';
16
- //# sourceMappingURL=index.d.ts.map
1
+ import { Channel } from 'stream-chat';
2
+ import { default as default_2 } from 'react';
3
+ import { MessagingUser } from '@linktr.ee/messaging-core';
4
+ import { StreamChat } from 'stream-chat';
5
+ import { StreamChatService } from '@linktr.ee/messaging-core';
6
+ import { StreamChatServiceConfig } from '@linktr.ee/messaging-core';
7
+
8
+ /**
9
+ * Avatar component that displays a user image or colored initial fallback
10
+ */
11
+ export declare const Avatar: default_2.FC<AvatarProps>;
12
+
13
+ export declare interface AvatarProps {
14
+ id: string;
15
+ name: string;
16
+ image?: string;
17
+ size?: number;
18
+ className?: string;
19
+ }
20
+
21
+ /**
22
+ * Channel list component with customizable header and actions
23
+ */
24
+ export declare const ChannelList: default_2.FC<ChannelListProps>;
25
+
26
+ /**
27
+ * ChannelList component props
28
+ */
29
+ export declare interface ChannelListProps {
30
+ onChannelSelect: (channel: Channel) => void;
31
+ selectedChannel?: Channel;
32
+ showStartConversation?: boolean;
33
+ onStartConversation?: () => void;
34
+ participantLabel?: string;
35
+ className?: string;
36
+ }
37
+
38
+ /**
39
+ * Channel view component with message list and input
40
+ */
41
+ export declare const ChannelView: default_2.FC<ChannelViewProps>;
42
+
43
+ /**
44
+ * ChannelView component props
45
+ */
46
+ export declare interface ChannelViewProps {
47
+ channel: Channel;
48
+ onBack?: () => void;
49
+ showBackButton?: boolean;
50
+ renderMessageInputActions?: (channel: Channel) => React.ReactNode;
51
+ onLeaveConversation?: (channel: Channel) => void;
52
+ onBlockParticipant?: (participantId?: string) => void;
53
+ className?: string;
54
+ CustomChannelEmptyState?: React.ComponentType;
55
+ }
56
+
57
+ export declare interface Faq {
58
+ id: string;
59
+ question: string;
60
+ answer: string;
61
+ enabled: boolean;
62
+ order?: number | null;
63
+ }
64
+
65
+ export declare const FaqList: default_2.FC<FaqListProps>;
66
+
67
+ export declare const FaqListItem: default_2.FC<FaqListItemProps>;
68
+
69
+ export declare interface FaqListItemProps {
70
+ question: string;
71
+ onClick: () => void;
72
+ loading?: boolean;
73
+ className?: string;
74
+ }
75
+
76
+ export declare interface FaqListProps {
77
+ faqs: Faq[];
78
+ onFaqClick: (faqId: string) => void;
79
+ loadingFaqId?: string | null;
80
+ headerText?: string;
81
+ className?: string;
82
+ avatarImage?: string;
83
+ avatarName?: string;
84
+ }
85
+
86
+ /**
87
+ * Messaging capabilities configuration
88
+ */
89
+ export declare interface MessagingCapabilities {
90
+ showStartConversation?: boolean;
91
+ participantSource?: ParticipantSource;
92
+ participantLabel?: string;
93
+ }
94
+
95
+ /**
96
+ * Context value for messaging state and service
97
+ */
98
+ declare interface MessagingContextValue {
99
+ service: StreamChatService | null;
100
+ client: StreamChat | null;
101
+ isConnected: boolean;
102
+ isLoading: boolean;
103
+ error: string | null;
104
+ capabilities: MessagingCapabilities;
105
+ customization: MessagingCustomization;
106
+ refreshConnection: () => Promise<void>;
107
+ debug: boolean;
108
+ }
109
+
110
+ /**
111
+ * Customization options
112
+ */
113
+ declare interface MessagingCustomization {
114
+ theme?: 'light' | 'dark' | 'auto';
115
+ accentColor?: string;
116
+ showParticipantStatus?: boolean;
117
+ }
118
+
119
+ /**
120
+ * Provider component that wraps messaging-core with React state management
121
+ */
122
+ export declare const MessagingProvider: default_2.FC<MessagingProviderProps>;
123
+
124
+ /**
125
+ * MessagingProvider component props
126
+ */
127
+ export declare interface MessagingProviderProps {
128
+ children: React.ReactNode;
129
+ user: MessagingUser | null;
130
+ serviceConfig: Omit<StreamChatServiceConfig, 'apiKey'>;
131
+ apiKey: string;
132
+ capabilities?: MessagingCapabilities;
133
+ customization?: MessagingCustomization;
134
+ debug?: boolean;
135
+ }
136
+
137
+ /**
138
+ * Main messaging interface component that combines channel list and channel view
139
+ */
140
+ export declare const MessagingShell: default_2.FC<MessagingShellProps>;
141
+
142
+ /**
143
+ * Main MessagingShell component props
144
+ */
145
+ export declare interface MessagingShellProps {
146
+ capabilities?: MessagingCapabilities;
147
+ customization?: MessagingCustomization;
148
+ className?: string;
149
+ renderMessageInputActions?: (channel: Channel) => React.ReactNode;
150
+ onChannelSelect?: (channel: Channel) => void;
151
+ onParticipantSelect?: (participant: Participant) => void;
152
+ /**
153
+ * Auto-select a conversation with this participant on mount.
154
+ * Useful for deep-linking to a specific conversation (e.g., /messages/[accountUuid])
155
+ *
156
+ * If a channel with this participant exists, it will be auto-selected.
157
+ * If no channel exists, you can provide initialParticipantData to automatically
158
+ * create the channel using the existing ChannelCreator.
159
+ */
160
+ initialParticipantFilter?: string;
161
+ /**
162
+ * Participant data for auto-creating a channel when initialParticipantFilter
163
+ * is provided but no channel exists. If this is provided, MessagingShell will
164
+ * automatically call service.startChannelWithParticipant() to create the channel.
165
+ *
166
+ * This reuses the existing ChannelCreator from StreamChatServiceConfig.
167
+ */
168
+ initialParticipantData?: Participant;
169
+ /**
170
+ * Custom empty state component to render when a channel has no messages.
171
+ * Useful for showing FAQs or other contextual information in empty channels.
172
+ */
173
+ CustomChannelEmptyState?: React.ComponentType;
174
+ /**
175
+ * Controls whether the channel list is shown. When false, the channel list
176
+ * is immediately hidden. Useful for direct conversation mode where you want
177
+ * to show only the channel view without the list.
178
+ */
179
+ showChannelList?: boolean;
180
+ }
181
+
182
+ /**
183
+ * Generic participant interface for different host environments
184
+ */
185
+ export declare interface Participant {
186
+ id: string;
187
+ name: string;
188
+ email?: string;
189
+ image?: string;
190
+ username?: string;
191
+ phone?: string;
192
+ metadata?: Record<string, unknown>;
193
+ }
194
+
195
+ /**
196
+ * Generic participant picker component for starting conversations
197
+ */
198
+ export declare const ParticipantPicker: default_2.FC<ParticipantPickerProps>;
199
+
200
+ /**
201
+ * ParticipantPicker component props
202
+ */
203
+ export declare interface ParticipantPickerProps {
204
+ participantSource: ParticipantSource;
205
+ onSelectParticipant: (participant: Participant) => void;
206
+ onClose: () => void;
207
+ existingParticipantIds?: Set<string>;
208
+ participantLabel?: string;
209
+ searchPlaceholder?: string;
210
+ className?: string;
211
+ }
212
+
213
+ /**
214
+ * Source for loading participants (followers, team members, etc.)
215
+ */
216
+ export declare interface ParticipantSource {
217
+ loadParticipants: (options?: {
218
+ search?: string;
219
+ limit?: number;
220
+ cursor?: string;
221
+ }) => Promise<{
222
+ participants: Participant[];
223
+ hasMore: boolean;
224
+ nextCursor?: string;
225
+ }>;
226
+ totalCount?: number;
227
+ loading?: boolean;
228
+ }
229
+
230
+ /**
231
+ * Hook to access messaging service and state
232
+ */
233
+ export declare const useMessaging: () => MessagingContextValue;
234
+
235
+ /**
236
+ * Hook for managing participant loading with search and pagination
237
+ */
238
+ export declare const useParticipants: (participantSource: ParticipantSource, options?: {
239
+ initialSearch?: string;
240
+ pageSize?: number;
241
+ }) => {
242
+ participants: Participant[];
243
+ loading: boolean;
244
+ error: string | null;
245
+ searchQuery: string;
246
+ hasMore: boolean;
247
+ totalCount: number | undefined;
248
+ loadMore: () => void;
249
+ search: (query: string) => void;
250
+ refresh: () => void;
251
+ };
252
+
253
+ export { }