react-pro-messenger 1.0.1 → 1.0.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.
package/README.md CHANGED
@@ -1,28 +1,29 @@
1
- ## React Pro Messenger
1
+ ## React Pro Messenger
2
2
 
3
3
  A feature-rich chat component with Telegram-inspired UI and modern messaging features.
4
4
 
5
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
6
 
7
-
8
-
9
7
  ---
10
8
 
11
9
  ## Features ✨
12
10
 
13
11
  ### Core Functionality
12
+
14
13
  - Telegram-style messaging interface
15
14
  - Multi-user chat support
16
15
  - Message history with scroll
17
16
  - Responsive design
18
17
 
19
18
  ### Message Types
19
+
20
20
  - **Text messages** with formatting
21
21
  - **Voice messages** with audio player
22
22
  - **File attachments** (images, documents)
23
23
  - **Symbol integration** (@mentions, #tasks)
24
24
 
25
25
  ### Interactive Features
26
+
26
27
  - Context menu for message actions
27
28
  - Delete/edit message functionality
28
29
  - Dynamic symbol recognition:(for example :)
@@ -37,7 +38,9 @@ A feature-rich chat component with Telegram-inspired UI and modern messaging fea
37
38
  ```bash
38
39
  npm install react-pro-messenger
39
40
  ```
41
+
40
42
  # or
43
+
41
44
  ```bash
42
45
  yarn add react-pro-messenger
43
46
  ```
@@ -45,7 +48,7 @@ yarn add react-pro-messenger
45
48
  ## Basic Usage 🚀
46
49
 
47
50
  ```tsx
48
- import { Chat, MessageEntity } from 'react-pro-messenger';
51
+ import { Chat, MessageEntity } from "react-pro-messenger";
49
52
 
50
53
  const App = () => {
51
54
  const [messages, setMessages] = useState<MessageEntity[]>(initialMessages);
@@ -56,23 +59,26 @@ const App = () => {
56
59
  messages={messages}
57
60
  user={currentUser}
58
61
  onMessageSent={(newMsg) => setMessages([...messages, newMsg])}
59
- onDeleteMessage={(id) => setMessages(messages.filter(msg => msg.id !== id))}
62
+ onDeleteMessage={(id) =>
63
+ setMessages(messages.filter((msg) => msg.id !== id))
64
+ }
60
65
  />
61
66
  );
62
67
  };
63
68
  ```
69
+
64
70
  ## Component Props ⚙️
65
71
 
66
72
  ### Chat Component Configuration
67
73
 
68
- | Prop | Type | Default | Description |
69
- |---------------------------|-------------------------------|---------------|------------------------------------------|
70
- | `messages` | `MessageEntity[]` | **Required** | Array of message objects |
71
- | `user` | `UserInterface` | **Required** | Current user details |
72
- | `width` | `string` | `"400px"` | Container width |
73
- | `height` | `string` | `"600px"` | Container height |
74
- | `dynamicSymbolAssignments`| `SymbolAssignment[]` | `[]` | Symbol-component mappings |
75
- | `className` | `string` | `""` | Additional CSS classes |
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 |
76
82
 
77
83
  **Key**:
78
84
  📌 `Type` = Expected prop type
@@ -92,15 +98,122 @@ const taskComponent = ({ listsProps, onClick }) => (
92
98
  );
93
99
 
94
100
  <Chat
95
- dynamicSymbolAssignments={[{
96
- symbol: '#',
97
- component: taskComponent,
98
- lists: tasksList
99
- }]}
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
+ }}
100
198
  />
199
+ ```
101
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} />;
102
213
  ```
214
+
103
215
  ## Contributing 🤝
216
+
104
217
  Fork the repository
105
218
 
106
219
  Create feature branch:
@@ -108,16 +221,19 @@ Create feature branch:
108
221
  ```bash
109
222
  git checkout -b feature/new-feature
110
223
  ```
224
+
111
225
  Commit changes:
112
226
 
113
227
  ```bash
114
228
  git commit -m 'Add awesome feature'
115
229
  ```
230
+
116
231
  Push to branch:
117
232
 
118
233
  ```bash
119
234
  git push origin feature/new-feature
120
235
  ```
236
+
121
237
  Open a Pull Request
122
238
 
123
239
  License 📜
Binary file