mr-chat-bird 1.0.0

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 (49) hide show
  1. package/LICENCE +21 -0
  2. package/README.md +26 -0
  3. package/app/layout.tsx +69 -0
  4. package/app/page.tsx +9 -0
  5. package/dist/AddReaction-DCDVOMZB.svg +1 -0
  6. package/dist/TextFormat-R4ZVDKE2.svg +1 -0
  7. package/dist/index.css +388 -0
  8. package/dist/index.d.mts +5 -0
  9. package/dist/index.d.ts +5 -0
  10. package/dist/index.js +6425 -0
  11. package/dist/index.mjs +6420 -0
  12. package/eslint.config.mjs +11 -0
  13. package/index.ts +1 -0
  14. package/next-env.d.ts +5 -0
  15. package/next.config.mjs +30 -0
  16. package/package.json +69 -0
  17. package/postcss.config.cjs +14 -0
  18. package/public/favicon.svg +1 -0
  19. package/src/components/ChatUserList/ChatUserList.module.css +253 -0
  20. package/src/components/ChatUserList/ChatUserList.tsx +434 -0
  21. package/src/components/ChatUserList/ChatUserList.type.tsx +12 -0
  22. package/src/components/ChatUserList/ChatUserMessage.tsx +362 -0
  23. package/src/components/ChatUserList/users_list.json +648 -0
  24. package/src/components/ColorSchemeToggle/ColorSchemeToggle.tsx +15 -0
  25. package/src/components/EmojiPickerPopover/EmojiPickerPopover.tsx +72 -0
  26. package/src/components/MrChat/index.tsx +34 -0
  27. package/src/components/RichTextEditor/DropzoneMenuItem.tsx +33 -0
  28. package/src/components/RichTextEditor/EmojiNode.tsx +36 -0
  29. package/src/components/RichTextEditor/RichTextEditor.module.css +95 -0
  30. package/src/components/RichTextEditor/RichTextEditor.tsx +248 -0
  31. package/src/components/UserProfile/UserProfileDrawer.module.css +120 -0
  32. package/src/components/UserProfile/UserProfileDrawer.tsx +115 -0
  33. package/src/components/VirtualizedList/ChatScrollContainer.tsx +92 -0
  34. package/src/components/VirtualizedList/index.tsx +31 -0
  35. package/src/lib/axios.ts +12 -0
  36. package/src/lib/socket.ts +29 -0
  37. package/src/store/provider.tsx +8 -0
  38. package/src/store/slices/ChatSlice.ts +249 -0
  39. package/src/store/socket/index.tsx +32 -0
  40. package/src/store/store.ts +11 -0
  41. package/src/theme.ts +84 -0
  42. package/src/utils/environment.ts +5 -0
  43. package/src/utils/helper.ts +36 -0
  44. package/src/utils/icons/richText/Add.svg +1 -0
  45. package/src/utils/icons/richText/AddReaction.svg +1 -0
  46. package/src/utils/icons/richText/Docs.svg +1 -0
  47. package/src/utils/icons/richText/Image.svg +1 -0
  48. package/src/utils/icons/richText/TextFormat.svg +1 -0
  49. package/tsconfig.json +25 -0
package/LICENCE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Vitaly Rtischev
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,26 @@
1
+ ## Features
2
+
3
+ This template comes with the following features:
4
+
5
+ - [PostCSS](https://postcss.org/) with [mantine-postcss-preset](https://mantine.dev/styles/postcss-preset)
6
+ - [TypeScript](https://www.typescriptlang.org/)
7
+ - ESLint setup with [eslint-config-mantine](https://github.com/mantinedev/eslint-config-mantine)
8
+
9
+ ## npm scripts
10
+
11
+ ### Build and dev scripts
12
+
13
+ - `dev` – start dev server
14
+ - `build` – bundle application for production
15
+ - `analyze` – analyzes application bundle with [@next/bundle-analyzer](https://www.npmjs.com/package/@next/bundle-analyzer)
16
+
17
+ ### Testing scripts
18
+
19
+ - `typecheck` – checks TypeScript types
20
+ - `lint` – runs ESLint
21
+ - `prettier:check` – checks files with Prettier
22
+ - `test` – runs `jest`, `prettier:check`, `lint` and `typecheck` scripts
23
+
24
+ ### Other scripts
25
+
26
+ - `prettier:write` – formats all files with Prettier
package/app/layout.tsx ADDED
@@ -0,0 +1,69 @@
1
+ "use client";
2
+
3
+ import "@mantine/core/styles.css";
4
+ import "@mantine/tiptap/styles.css";
5
+ import "@mantine/notifications/styles.css";
6
+
7
+ import { useState } from "react";
8
+ import { ColorSchemeScript, MantineProvider } from "@mantine/core";
9
+ import { Notifications } from "@mantine/notifications";
10
+ import { createAppTheme } from "../src/theme";
11
+ import { ReduxProvider } from "@/src/store/provider";
12
+ import { SocketProvider } from "@/src/store/socket";
13
+
14
+ // export const metadata = {
15
+ // title: 'MrChatBird',
16
+ // description: 'Easy to integrate with your app the way you want.',
17
+ // };
18
+
19
+ export default function RootLayout({
20
+ children,
21
+ }: {
22
+ children: React.ReactNode;
23
+ }) {
24
+ const [primaryColor, setPrimaryColor] = useState<
25
+ "customBrand" | "emerald" | "ruby" | "sunset" | "ocean"
26
+ >("customBrand");
27
+
28
+ const theme = createAppTheme(primaryColor);
29
+
30
+ return (
31
+ <html lang="en" suppressHydrationWarning>
32
+ <head>
33
+ <ColorSchemeScript defaultColorScheme="light" />
34
+ <link rel="shortcut icon" href="/favicon.svg" />
35
+ <link
36
+ href="https://fonts.googleapis.com/icon?family=Material+Icons+Round"
37
+ rel="stylesheet"
38
+ />
39
+ <meta
40
+ name="viewport"
41
+ content="minimum-scale=1, initial-scale=1, width=device-width, user-scalable=no"
42
+ />
43
+ </head>
44
+ <body>
45
+ <ReduxProvider>
46
+ <SocketProvider>
47
+ <MantineProvider defaultColorScheme="light" theme={theme}>
48
+ <Notifications />
49
+ {/* <div style={{ padding: 16 }}>
50
+ <select
51
+ value={primaryColor}
52
+ onChange={(e) => setPrimaryColor(e.target.value as any)}
53
+ >
54
+ <option value="customBrand">Blue (customBrand)</option>
55
+ <option value="emerald">Green (emerald)</option>
56
+ <option value="ruby">Red (ruby)</option>
57
+ <option value="sunset">Orange (sunset)</option>
58
+ <option value="ocean">Cyan (ocean)</option>
59
+ </select>
60
+ <ColorSchemeToggle />
61
+ </div> */}
62
+ {children}
63
+ </MantineProvider>
64
+ </SocketProvider>
65
+ </ReduxProvider>
66
+ </body>
67
+ </html>
68
+ );
69
+ }
package/app/page.tsx ADDED
@@ -0,0 +1,9 @@
1
+ import { ChatUserList } from '../src/components/ChatUserList/ChatUserList';
2
+
3
+ export default function HomePage() {
4
+ return (
5
+ <>
6
+ <ChatUserList />
7
+ </>
8
+ );
9
+ }
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#000"><path d="M480-480Zm0 400q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q33 0 65 5t62 15q23 8 29 23.5t1 30.5q-5 15-18.5 23.5T588-781q-26-9-52.5-14t-55.5-5q-133 0-226.5 93.5T160-480q0 133 93.5 226.5T480-160q133 0 226.5-93.5T800-480q0-18-2-36t-6-35q-5-19 5-31t25-15q15-3 29.5 4.5T871-564q5 20 7 41t2 43q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm320-680h-40q-17 0-28.5-11.5T720-800q0-17 11.5-28.5T760-840h40v-40q0-17 11.5-28.5T840-920q17 0 28.5 11.5T880-880v40h40q17 0 28.5 11.5T960-800q0 17-11.5 28.5T920-760h-40v40q0 17-11.5 28.5T840-680q-17 0-28.5-11.5T800-720v-40ZM620-520q25 0 42.5-17.5T680-580q0-25-17.5-42.5T620-640q-25 0-42.5 17.5T560-580q0 25 17.5 42.5T620-520Zm-280 0q25 0 42.5-17.5T400-580q0-25-17.5-42.5T340-640q-25 0-42.5 17.5T280-580q0 25 17.5 42.5T340-520Zm140 260q58 0 107-28t79-76q6-12-1-24t-21-12H316q-14 0-21 12t-1 24q30 48 79.5 76T480-260Z"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#000"><path d="M240-200q-17 0-28.5-11.5T200-240q0-17 11.5-28.5T240-280h480q17 0 28.5 11.5T760-240q0 17-11.5 28.5T720-200H240Zm54-208 137-368q4-11 13.5-17.5T466-800h28q12 0 21.5 6.5T529-776l137 369q6 17-4 32t-28 15q-11 0-20.5-6.5T600-384l-30-88H392l-32 89q-4 11-13 17t-20 6q-19 0-29.5-15.5T294-408Zm120-128h132l-64-182h-4l-64 182Z"/></svg>
package/dist/index.css ADDED
@@ -0,0 +1,388 @@
1
+ /* src/components/ChatUserList/ChatUserList.module.css */
2
+ .chatWrapper {
3
+ display: flex;
4
+ flex-direction: column;
5
+ align-items: center;
6
+ height: 100vh;
7
+ background: #f1f3f5;
8
+ }
9
+ .chatContainer {
10
+ display: flex;
11
+ width: 100%;
12
+ max-width: 1260px;
13
+ background: white;
14
+ box-shadow: 0 0 10px rgba(0, 0, 0, 0.05);
15
+ border-radius: 8px;
16
+ overflow: hidden;
17
+ }
18
+ .sidebar {
19
+ width: 280px;
20
+ display: flex;
21
+ flex-direction: column;
22
+ height: 100vh;
23
+ border-right: 1px solid #eee;
24
+ background-color: #fff;
25
+ padding-top: 12px;
26
+ }
27
+ @media (max-width: 760px) {
28
+ .sidebar {
29
+ width: 180px;
30
+ }
31
+ }
32
+ .sidebarTop {
33
+ padding: 0 12px;
34
+ }
35
+ .topBar {
36
+ display: flex;
37
+ justify-content: space-between;
38
+ align-items: center;
39
+ }
40
+ .topActions {
41
+ display: flex;
42
+ align-items: center;
43
+ gap: 10px;
44
+ }
45
+ .scrollWrapper {
46
+ flex: 1;
47
+ min-height: 0;
48
+ overflow: hidden;
49
+ }
50
+ .scrollArea {
51
+ flex: 1;
52
+ height: 100%;
53
+ overflow-y: auto;
54
+ }
55
+ .scrollArea :global(.mantine-ScrollArea-content) {
56
+ padding-bottom: 60px;
57
+ }
58
+ .avatar {
59
+ width: 34px;
60
+ height: 34px;
61
+ border-radius: 50%;
62
+ object-fit: cover;
63
+ }
64
+ .mainArea {
65
+ flex: 1;
66
+ display: flex;
67
+ flex-direction: column;
68
+ }
69
+ .messageArea {
70
+ flex: 1;
71
+ padding: 16px;
72
+ overflow-y: auto;
73
+ padding-bottom: 10px;
74
+ }
75
+ .messageBubble {
76
+ max-width: fit-content;
77
+ padding: 8px 45px 8px 16px;
78
+ margin-bottom: 8px;
79
+ position: relative;
80
+ }
81
+ .outgoing {
82
+ color: white;
83
+ background-color: #366ca4;
84
+ margin-left: auto;
85
+ }
86
+ .incoming {
87
+ background-color: #eeeeee;
88
+ margin-right: auto;
89
+ }
90
+ .inputBar {
91
+ display: flex;
92
+ align-items: end;
93
+ gap: 8px;
94
+ padding: 0px 16px 16px;
95
+ }
96
+ .chatItem {
97
+ display: flex;
98
+ align-items: center;
99
+ gap: 6px;
100
+ padding: 8px 12px;
101
+ cursor: pointer;
102
+ transition: background 0.2s;
103
+ margin: 2px 4px;
104
+ border-radius: 6px;
105
+ }
106
+ .chatItem:hover {
107
+ background-color: #f6f6f6;
108
+ }
109
+ .chatLabelItem {
110
+ font-size: 15px;
111
+ }
112
+ .chatHeader {
113
+ display: flex;
114
+ justify-content: space-between;
115
+ align-items: center;
116
+ padding: 12px 16px;
117
+ border-bottom: 1px solid #eee;
118
+ background-color: #f8f9fa;
119
+ position: sticky;
120
+ top: 0;
121
+ z-index: 2;
122
+ min-height: 63px;
123
+ }
124
+ .receiverInfo {
125
+ display: flex;
126
+ align-items: center;
127
+ gap: 12px;
128
+ cursor: pointer;
129
+ }
130
+ .emptyState {
131
+ height: 100%;
132
+ display: flex;
133
+ align-items: center;
134
+ justify-content: center;
135
+ }
136
+ .encryptionMinimal {
137
+ display: flex;
138
+ align-items: center;
139
+ gap: 6px;
140
+ padding: 6px 10px;
141
+ border-radius: 12px;
142
+ background: rgba(0, 0, 0, 0.04);
143
+ color: #666;
144
+ font-size: 12px;
145
+ }
146
+ .encryptionText {
147
+ font-size: 16px;
148
+ color: #666;
149
+ margin-left: 3px;
150
+ }
151
+ .messageContent {
152
+ max-width: 370px;
153
+ word-wrap: break-word;
154
+ font-size: 14px;
155
+ }
156
+ .messagePreviewContent p,
157
+ .messageContent p {
158
+ margin: 0;
159
+ padding: 0;
160
+ }
161
+ .activeChatItem {
162
+ background-color: #eee;
163
+ }
164
+ .chatItem:hover {
165
+ background-color: #eee;
166
+ }
167
+ .messageTime {
168
+ font-size: 11px;
169
+ opacity: 0.6;
170
+ text-align: right;
171
+ margin-top: 4px;
172
+ position: absolute;
173
+ bottom: 4px;
174
+ right: 8px;
175
+ z-index: 1;
176
+ }
177
+ .dateSeparator {
178
+ text-align: center;
179
+ font-size: 13px;
180
+ margin: 12px 0;
181
+ color: #888;
182
+ }
183
+ .chatInfo {
184
+ width: 100%;
185
+ position: relative;
186
+ }
187
+ .messagePreview {
188
+ display: flex;
189
+ justify-content: space-between;
190
+ align-items: end;
191
+ margin-top: 1px;
192
+ }
193
+ .messagePreviewTime {
194
+ position: relative;
195
+ top: 1px;
196
+ right: 0;
197
+ }
198
+ .unreadBadge {
199
+ background: #366ca4;
200
+ color: white;
201
+ font-size: 10px;
202
+ border-radius: 50%;
203
+ padding: 3px 5px;
204
+ min-width: 18px;
205
+ text-align: center;
206
+ position: absolute;
207
+ top: 1px;
208
+ right: 0px;
209
+ }
210
+ .messagePreviewContent {
211
+ font-size: 14px;
212
+ }
213
+
214
+ /* src/components/RichTextEditor/RichTextEditor.module.css */
215
+ .richTextEditorContainer {
216
+ position: relative;
217
+ border-radius: 16px;
218
+ }
219
+ .richTextEditorContainer :global(.mantine-RichTextEditor-toolbar) {
220
+ border: none;
221
+ background-color: transparent;
222
+ padding: 0;
223
+ margin-bottom: 4px;
224
+ margin-left: 3px;
225
+ gap: 0.5rem;
226
+ }
227
+ .richTextEditorContainer :global(.emoji-big) {
228
+ font-size: 18px;
229
+ line-height: 1;
230
+ vertical-align: middle;
231
+ display: inline-block;
232
+ }
233
+ .richTextEditorContainer :global(.mantine-RichTextEditor-Typography) {
234
+ font-size: 15px;
235
+ }
236
+ .richTextEditorContainer :global(.mantine-RichTextEditor-Typography),
237
+ .richTextEditorContainer :global(.mantine-RichTextEditor-content) {
238
+ border-radius: 16px;
239
+ min-height: 41px;
240
+ max-height: 200px;
241
+ overflow: scroll;
242
+ }
243
+ .richTextEditorContainer :global(.ProseMirror) {
244
+ padding: 12px 16px 4px;
245
+ }
246
+ .mainActionContainer {
247
+ height: 24px;
248
+ margin-bottom: 4px;
249
+ }
250
+ .mainActionAddIcon {
251
+ margin-left: 3px;
252
+ }
253
+ .mainActionEmojiIcon {
254
+ margin: 0 4px 0 3px;
255
+ }
256
+ .mainActionEmojiIcon svg {
257
+ padding: 2.3px;
258
+ }
259
+ .mainActionAddIcon svg,
260
+ .mainTextFormatIcon svg,
261
+ .mainActionEmojiIcon svg {
262
+ fill: #495057;
263
+ }
264
+ .mainTextFormatIcon svg {
265
+ position: relative;
266
+ top: 1.2px;
267
+ }
268
+ .mainSendMsgIcon {
269
+ position: absolute;
270
+ right: 6px;
271
+ }
272
+ .customToolActionItem {
273
+ background-color: var(--mantine-color-white);
274
+ border-color: var(--mantine-color-gray-4);
275
+ color: var(--mantine-color-gray-7);
276
+ border-radius: 0px;
277
+ height: 26px;
278
+ min-height: 26px;
279
+ border-right: none;
280
+ }
281
+ .mainAddLabels {
282
+ font-size: 15px;
283
+ }
284
+ .mainAddLabels :global(svg) {
285
+ width: 19px;
286
+ height: 19px;
287
+ }
288
+ @media (max-width: 950px) {
289
+ .secondRichTextEditorToolBar {
290
+ display: none;
291
+ }
292
+ }
293
+
294
+ /* src/components/UserProfile/UserProfileDrawer.module.css */
295
+ .overlay {
296
+ position: absolute;
297
+ inset: 0;
298
+ background: rgba(0, 0, 0, 0.3);
299
+ z-index: 50;
300
+ }
301
+ .drawer {
302
+ position: absolute;
303
+ top: 0;
304
+ right: 0;
305
+ width: 100%;
306
+ max-width: 400px;
307
+ height: 100%;
308
+ background: #fff;
309
+ display: flex;
310
+ flex-direction: column;
311
+ }
312
+ .open {
313
+ animation: slideIn 0.25s ease forwards;
314
+ }
315
+ .close {
316
+ animation: slideOut 0.25s ease forwards;
317
+ }
318
+ @keyframes slideIn {
319
+ from {
320
+ transform: translateX(100%);
321
+ }
322
+ to {
323
+ transform: translateX(0);
324
+ }
325
+ }
326
+ @keyframes slideOut {
327
+ from {
328
+ transform: translateX(0);
329
+ }
330
+ to {
331
+ transform: translateX(100%);
332
+ }
333
+ }
334
+ .header {
335
+ height: 60px;
336
+ display: flex;
337
+ align-items: center;
338
+ gap: 15px;
339
+ padding: 0 16px;
340
+ border-bottom: 1px solid #eee;
341
+ }
342
+ .backBtn {
343
+ cursor: pointer;
344
+ display: flex;
345
+ align-items: center;
346
+ }
347
+ .profileSection {
348
+ padding: 30px 20px;
349
+ border-bottom: 1px solid #f0f0f0;
350
+ display: flex;
351
+ flex-direction: column;
352
+ align-items: center;
353
+ text-align: center;
354
+ }
355
+ .actions {
356
+ padding: 10px;
357
+ }
358
+ .item {
359
+ display: flex;
360
+ align-items: center;
361
+ gap: 12px;
362
+ padding: 14px;
363
+ border-radius: 10px;
364
+ cursor: pointer;
365
+ }
366
+ .item:hover {
367
+ background: #f5f5f5;
368
+ }
369
+ .itemDanger {
370
+ color: #fa5252;
371
+ }
372
+ .itemDanger:hover {
373
+ background: rgba(250, 82, 82, 0.1);
374
+ }
375
+ .imagePreview {
376
+ position: fixed;
377
+ inset: 0;
378
+ background: black;
379
+ z-index: 100;
380
+ display: flex;
381
+ justify-content: center;
382
+ align-items: center;
383
+ }
384
+ .imagePreview img {
385
+ max-width: 90%;
386
+ max-height: 90%;
387
+ border-radius: 12px;
388
+ }
@@ -0,0 +1,5 @@
1
+ import * as react from 'react';
2
+
3
+ declare function MrChat(props: any): react.JSX.Element;
4
+
5
+ export { MrChat };
@@ -0,0 +1,5 @@
1
+ import * as react from 'react';
2
+
3
+ declare function MrChat(props: any): react.JSX.Element;
4
+
5
+ export { MrChat };