react-pro-messenger 1.0.13 → 1.0.15

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,240 @@
1
+ ## React Pro Messenger
2
+
3
+ A feature-rich chat component with Telegram-inspired UI and modern messaging features.
4
+
5
+ ![Chat Interface Preview](https://github.com/user-attachments/assets/1989e6b1-e6c8-4c1b-a78b-10e979b7544c) ![image](https://github.com/user-attachments/assets/43d19d72-03fb-4637-b913-fedbbd2d58a6) ![image](https://github.com/user-attachments/assets/e47668bf-bae8-4a91-acf9-4ac2432fed39)
6
+
7
+ ---
8
+
9
+ ## Features ✨
10
+
11
+ ### Core Functionality
12
+
13
+ - Telegram-style messaging interface
14
+ - Multi-user chat support
15
+ - Message history with scroll
16
+ - Responsive design
17
+
18
+ ### Message Types
19
+
20
+ - **Text messages** with formatting
21
+ - **Voice messages** with audio player
22
+ - **File attachments** (images, documents)
23
+ - **Symbol integration** (@mentions, #tasks)
24
+
25
+ ### Interactive Features
26
+
27
+ - Context menu for message actions
28
+ - Delete/edit message functionality
29
+ - Dynamic symbol recognition:(for example :)
30
+ - `@` for user mentions
31
+ - `#` for task references
32
+ - Animated message transitions
33
+
34
+ ---
35
+
36
+ ## Installation 📦
37
+
38
+ ```bash
39
+ npm install react-pro-messenger
40
+ ```
41
+
42
+ # or
43
+
44
+ ```bash
45
+ yarn add react-pro-messenger
46
+ ```
47
+
48
+ ## Basic Usage 🚀
49
+
50
+ ```tsx
51
+ import { Chat, MessageEntity } from "react-pro-messenger";
52
+
53
+ const App = () => {
54
+ const [messages, setMessages] = useState<MessageEntity[]>(initialMessages);
55
+ const currentUser = { id: "user-1", fullName: "John Doe" };
56
+
57
+ return (
58
+ <Chat
59
+ messages={messages}
60
+ user={currentUser}
61
+ onMessageSent={(newMsg) => setMessages([...messages, newMsg])}
62
+ onDeleteMessage={(id) =>
63
+ setMessages(messages.filter((msg) => msg.id !== id))
64
+ }
65
+ />
66
+ );
67
+ };
68
+ ```
69
+
70
+ ## Component Props ⚙️
71
+
72
+ ### Chat Component Configuration
73
+
74
+ | Prop | Type | Default | Description |
75
+ | -------------------------- | -------------------- | ------------ | ------------------------- |
76
+ | `messages` | `MessageEntity[]` | **Required** | Array of message objects |
77
+ | `user` | `UserInterface` | **Required** | Current user details |
78
+ | `width` | `string` | `"400px"` | Container width |
79
+ | `height` | `string` | `"600px"` | Container height |
80
+ | `dynamicSymbolAssignments` | `SymbolAssignment[]` | `[]` | Symbol-component mappings |
81
+ | `className` | `string` | `""` | Additional CSS classes |
82
+
83
+ **Key**:
84
+ 📌 `Type` = Expected prop type
85
+ 📌 `Default` = Default value if not required
86
+ 📌 **Required** = Must be provided
87
+
88
+ ## Customization 🎨
89
+
90
+ Symbol Integration
91
+
92
+ ```tsx
93
+ const taskComponent = ({ listsProps, onClick }) => (
94
+ <div className="task-item">
95
+ <span>📌</span>
96
+ <p>{listsProps.name}</p>
97
+ </div>
98
+ );
99
+
100
+ <Chat
101
+ dynamicSymbolAssignments={[
102
+ {
103
+ symbol: "#",
104
+ component: taskComponent,
105
+ lists: tasksList,
106
+ },
107
+ ]}
108
+ />;
109
+ ```
110
+
111
+ # Basic Usage 💻
112
+
113
+ ```tsx
114
+ Copy;
115
+ import { Chat, MessageEntity } from "react-pro-messenger";
116
+ import { useState } from "react";
117
+
118
+ function App() {
119
+ const [messages, setMessages] = useState<MessageEntity[]>([]);
120
+ const currentUser = { id: "user-1", fullName: "John Doe" };
121
+
122
+ return (
123
+ <div className="h-[600px] w-[400px]">
124
+ <Chat
125
+ messages={messages}
126
+ user={currentUser}
127
+ onMessageSent={(newMsg) => setMessages([...messages, newMsg])}
128
+ onDeleteMessage={(id) =>
129
+ setMessages(messages.filter((msg) => msg.id !== id))
130
+ }
131
+ />
132
+ </div>
133
+ );
134
+ }
135
+ ```
136
+
137
+ ## Dynamic Symbol Integration (@/#) 🔠
138
+
139
+ ```tsx
140
+ Copy;
141
+ import { Tasks, User } from "react-pro-messenger";
142
+
143
+ // In your main component
144
+ <Chat
145
+ dynamicSymbolAssignments={[
146
+ {
147
+ symbol: "#",
148
+ component: ({ listsProps, onClick }) => (
149
+ <Tasks task={listsProps} onClick={onClick} />
150
+ ),
151
+ lists: yourTasksList,
152
+ },
153
+ {
154
+ symbol: "@",
155
+ component: ({ listsProps, onClick }) => (
156
+ <User user={listsProps} onClick={onClick} />
157
+ ),
158
+ lists: yourUsersList,
159
+ },
160
+ ]}
161
+ />;
162
+ ```
163
+
164
+ ## Sending Messages Example 📩
165
+
166
+ ```tsx
167
+ Copy;
168
+ // Create new message
169
+ const newMessage = new MessageEntity({
170
+ id: Date.now().toString(),
171
+ text: "Hello World!",
172
+ createdDate: new Date().toISOString(),
173
+ user: currentUser,
174
+ isRightSided: true,
175
+ });
176
+
177
+ // Add to messages array
178
+ setMessages((prev) => [...prev, newMessage]);
179
+ ```
180
+
181
+ ## Advanced Features 🚀
182
+
183
+ 1. Custom Styling
184
+
185
+ ```tsx
186
+ <Chat
187
+ className="custom-chat-styles"
188
+ dynamicSymbolAssignments={
189
+ [
190
+ /*...*/
191
+ ]
192
+ }
193
+ // Add Tailwind classes or CSS modules
194
+ style={{
195
+ "--message-bg": "#f0f4ff",
196
+ "--user-color": "#1a237e",
197
+ }}
198
+ />
199
+ ```
200
+
201
+ 2. Context Menu Handling
202
+
203
+ ```tsx
204
+ const handleDelete = (messageId: string) => {
205
+ setMessages(messages.filter((msg) => msg.id !== messageId));
206
+ };
207
+
208
+ const handleEdit = (messageId: string) => {
209
+ // Your edit logic
210
+ };
211
+
212
+ <Chat onDeleteMessage={handleDelete} onEditMessage={handleEdit} />;
213
+ ```
214
+
215
+ ## Contributing 🤝
216
+
217
+ Fork the repository
218
+
219
+ Create feature branch:
220
+
221
+ ```bash
222
+ git checkout -b feature/new-feature
223
+ ```
224
+
225
+ Commit changes:
226
+
227
+ ```bash
228
+ git commit -m 'Add awesome feature'
229
+ ```
230
+
231
+ Push to branch:
232
+
233
+ ```bash
234
+ git push origin feature/new-feature
235
+ ```
236
+
237
+ Open a Pull Request
238
+
239
+ License 📜
240
+ MIT License © 2023 [mahdij98]