@linktr.ee/messaging-react 1.0.0 → 1.0.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/package.json +3 -2
- package/src/components/ActionButton/ActionButton.stories.tsx +46 -0
- package/src/components/ActionButton/ActionButton.test.tsx +112 -0
- package/src/components/ActionButton/index.tsx +33 -0
- package/src/components/Avatar/Avatar.stories.tsx +144 -0
- package/src/components/Avatar/avatarColors.ts +36 -0
- package/src/components/Avatar/index.tsx +64 -0
- package/src/components/ChannelList/ChannelList.stories.tsx +48 -0
- package/src/components/ChannelList/CustomChannelPreview.stories.tsx +303 -0
- package/src/components/ChannelList/CustomChannelPreview.tsx +114 -0
- package/src/components/ChannelList/index.tsx +129 -0
- package/src/components/ChannelView.tsx +422 -0
- package/src/components/CloseButton/index.tsx +16 -0
- package/src/components/IconButton/IconButton.stories.tsx +40 -0
- package/src/components/IconButton/index.tsx +32 -0
- package/src/components/Loading/Loading.stories.tsx +24 -0
- package/src/components/Loading/index.tsx +50 -0
- package/src/components/MessagingShell/EmptyState.stories.tsx +38 -0
- package/src/components/MessagingShell/EmptyState.tsx +55 -0
- package/src/components/MessagingShell/ErrorState.stories.tsx +42 -0
- package/src/components/MessagingShell/ErrorState.tsx +33 -0
- package/src/components/MessagingShell/LoadingState.stories.tsx +26 -0
- package/src/components/MessagingShell/LoadingState.tsx +15 -0
- package/src/components/MessagingShell/index.tsx +298 -0
- package/src/components/ParticipantPicker/ParticipantItem.stories.tsx +188 -0
- package/src/components/ParticipantPicker/ParticipantItem.tsx +59 -0
- package/src/components/ParticipantPicker/ParticipantPicker.stories.tsx +54 -0
- package/src/components/ParticipantPicker/ParticipantPicker.tsx +196 -0
- package/src/components/ParticipantPicker/index.tsx +234 -0
- package/src/components/SearchInput/SearchInput.stories.tsx +33 -0
- package/src/components/SearchInput/SearchInput.test.tsx +108 -0
- package/src/components/SearchInput/index.tsx +50 -0
- package/src/hooks/useMessaging.ts +9 -0
- package/src/hooks/useParticipants.ts +92 -0
- package/src/index.ts +26 -0
- package/src/providers/MessagingProvider.tsx +282 -0
- package/src/stories/mocks.tsx +157 -0
- package/src/test/setup.ts +30 -0
- package/src/test/utils.tsx +23 -0
- package/src/types.ts +113 -0
package/src/types.ts
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import type { Channel } from 'stream-chat';
|
|
2
|
+
import type { MessagingUser, StreamChatServiceConfig } from '@linktr.ee/messaging-core';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Generic participant interface for different host environments
|
|
6
|
+
*/
|
|
7
|
+
export interface Participant {
|
|
8
|
+
id: string;
|
|
9
|
+
name: string;
|
|
10
|
+
email?: string;
|
|
11
|
+
image?: string;
|
|
12
|
+
username?: string;
|
|
13
|
+
phone?: string;
|
|
14
|
+
metadata?: Record<string, any>;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Source for loading participants (followers, team members, etc.)
|
|
19
|
+
*/
|
|
20
|
+
export interface ParticipantSource {
|
|
21
|
+
loadParticipants: (options?: {
|
|
22
|
+
search?: string;
|
|
23
|
+
limit?: number;
|
|
24
|
+
cursor?: string;
|
|
25
|
+
}) => Promise<{
|
|
26
|
+
participants: Participant[];
|
|
27
|
+
hasMore: boolean;
|
|
28
|
+
nextCursor?: string;
|
|
29
|
+
}>;
|
|
30
|
+
totalCount?: number;
|
|
31
|
+
loading?: boolean;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Messaging capabilities configuration
|
|
36
|
+
*/
|
|
37
|
+
export interface MessagingCapabilities {
|
|
38
|
+
showStartConversation?: boolean;
|
|
39
|
+
participantSource?: ParticipantSource;
|
|
40
|
+
participantLabel?: string; // e.g., "followers", "team members"
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Customization options
|
|
45
|
+
*/
|
|
46
|
+
export interface MessagingCustomization {
|
|
47
|
+
theme?: 'light' | 'dark' | 'auto';
|
|
48
|
+
accentColor?: string;
|
|
49
|
+
showParticipantStatus?: boolean;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Main MessagingShell component props
|
|
54
|
+
*/
|
|
55
|
+
export interface MessagingShellProps {
|
|
56
|
+
capabilities?: MessagingCapabilities;
|
|
57
|
+
customization?: MessagingCustomization;
|
|
58
|
+
className?: string;
|
|
59
|
+
renderMessageInputActions?: (channel: Channel) => React.ReactNode;
|
|
60
|
+
onChannelSelect?: (channel: Channel) => void;
|
|
61
|
+
onParticipantSelect?: (participant: Participant) => void;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* ChannelList component props
|
|
66
|
+
*/
|
|
67
|
+
export interface ChannelListProps {
|
|
68
|
+
onChannelSelect: (channel: Channel) => void;
|
|
69
|
+
selectedChannel?: Channel;
|
|
70
|
+
showStartConversation?: boolean;
|
|
71
|
+
onStartConversation?: () => void;
|
|
72
|
+
participantLabel?: string;
|
|
73
|
+
className?: string;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* ChannelView component props
|
|
78
|
+
*/
|
|
79
|
+
export interface ChannelViewProps {
|
|
80
|
+
channel: Channel;
|
|
81
|
+
onBack?: () => void;
|
|
82
|
+
showBackButton?: boolean;
|
|
83
|
+
renderMessageInputActions?: (channel: Channel) => React.ReactNode;
|
|
84
|
+
onLeaveConversation?: (channel: Channel) => void;
|
|
85
|
+
onBlockParticipant?: (participantId?: string) => void;
|
|
86
|
+
className?: string;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* ParticipantPicker component props
|
|
91
|
+
*/
|
|
92
|
+
export interface ParticipantPickerProps {
|
|
93
|
+
participantSource: ParticipantSource;
|
|
94
|
+
onSelectParticipant: (participant: Participant) => void;
|
|
95
|
+
onClose: () => void;
|
|
96
|
+
existingParticipantIds?: Set<string>;
|
|
97
|
+
participantLabel?: string;
|
|
98
|
+
searchPlaceholder?: string;
|
|
99
|
+
className?: string;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* MessagingProvider component props
|
|
104
|
+
*/
|
|
105
|
+
export interface MessagingProviderProps {
|
|
106
|
+
children: React.ReactNode;
|
|
107
|
+
user: MessagingUser | null;
|
|
108
|
+
serviceConfig: Omit<StreamChatServiceConfig, 'apiKey'>;
|
|
109
|
+
apiKey: string;
|
|
110
|
+
capabilities?: MessagingCapabilities;
|
|
111
|
+
customization?: MessagingCustomization;
|
|
112
|
+
debug?: boolean;
|
|
113
|
+
}
|