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 +134 -18
- package/dist/chat-bg-1.jpg +0 -0
- package/dist/index.es.js +1026 -1026
- package/dist/index.umd.js +15 -15
- package/package.json +1 -1
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
|
  
|
|
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
|
|
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) =>
|
|
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
|
|
69
|
-
|
|
70
|
-
| `messages`
|
|
71
|
-
| `user`
|
|
72
|
-
| `width`
|
|
73
|
-
| `height`
|
|
74
|
-
| `dynamicSymbolAssignments
|
|
75
|
-
| `className`
|
|
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
|
-
|
|
97
|
-
|
|
98
|
-
|
|
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
|