react-pro-messenger 1.0.0 → 1.0.2
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 +240 -50
- 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 +8 -6
- package/types/App.d.ts +20 -0
- package/types/components/ConformaitionModal/ConformationModal.d.ts +10 -0
- package/types/components/ContextMenu/ContextMenu.d.ts +19 -0
- package/types/components/Icons/DoubleCheckIcon.d.ts +2 -0
- package/types/components/Icons/FileIcon.d.ts +2 -0
- package/types/components/Icons/MicIcon.d.ts +2 -0
- package/types/components/Icons/PlayIcon.d.ts +3 -0
- package/types/components/Icons/PuaseIcon.d.ts +3 -0
- package/types/components/Icons/SendIcon.d.ts +2 -0
- package/types/components/Icons/SpeechBubbleCornerIcon.d.ts +2 -0
- package/types/components/Input/Input.d.ts +8 -0
- package/types/components/Media/File/File.d.ts +9 -0
- package/types/components/Media/Media.d.ts +7 -0
- package/types/components/Media/Voice/Voice.d.ts +6 -0
- package/types/components/Message/LeftSide/LeftSide.d.ts +9 -0
- package/types/components/Message/RightSide/RightSide.d.ts +8 -0
- package/types/components/Tasks/Tasks.d.ts +11 -0
- package/types/domain/MessageEntity.d.ts +34 -0
- package/types/features/Chat/index.d.ts +18 -0
- package/types/features/Chat/logic.d.ts +29 -0
- package/types/index.d.ts +4 -0
- package/types/main.d.ts +1 -0
- package/types/ts/enum.d.ts +6 -0
- package/types/ts/interfaces.d.ts +18 -0
package/package.json
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-pro-messenger",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Telegram-style chat component for React",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.umd.js",
|
|
7
7
|
"module": "dist/index.es.js",
|
|
8
8
|
"types": "types/index.d.ts",
|
|
9
|
-
"files": [
|
|
9
|
+
"files": [
|
|
10
|
+
"dist",
|
|
11
|
+
"types"
|
|
12
|
+
],
|
|
10
13
|
"scripts": {
|
|
11
14
|
"dev": "vite --open",
|
|
12
15
|
"build": "tsc && vite build",
|
|
13
|
-
"
|
|
14
|
-
"lint": "eslint ."
|
|
15
|
-
"test": "jest"
|
|
16
|
+
"prepack": "npm run build",
|
|
17
|
+
"lint": "eslint ."
|
|
16
18
|
},
|
|
17
19
|
"peerDependencies": {
|
|
18
20
|
"react": "^18.0.0 || ^19.0.0",
|
|
@@ -44,4 +46,4 @@
|
|
|
44
46
|
"type": "git",
|
|
45
47
|
"url": "https://github.com/yourusername/react-pro-messenger.git"
|
|
46
48
|
}
|
|
47
|
-
}
|
|
49
|
+
}
|
package/types/App.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface TaskInterface {
|
|
2
|
+
id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
}
|
|
5
|
+
export interface TasksProps {
|
|
6
|
+
symbol?: string;
|
|
7
|
+
task: TaskInterface;
|
|
8
|
+
onClick: (id: string, text: string) => void;
|
|
9
|
+
}
|
|
10
|
+
export interface UserPropsInterface {
|
|
11
|
+
id: string;
|
|
12
|
+
name: string;
|
|
13
|
+
}
|
|
14
|
+
export interface UserProps {
|
|
15
|
+
symbol?: string;
|
|
16
|
+
user: UserPropsInterface;
|
|
17
|
+
onClick: (id: string, value: string) => void;
|
|
18
|
+
}
|
|
19
|
+
declare function App(): import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
export default App;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
interface ConfirmationModalProps {
|
|
3
|
+
isOpen: boolean;
|
|
4
|
+
onClose: () => void;
|
|
5
|
+
onConfirm: () => void;
|
|
6
|
+
header: string;
|
|
7
|
+
question: string;
|
|
8
|
+
}
|
|
9
|
+
declare const ConfirmationModal: React.FC<ConfirmationModalProps>;
|
|
10
|
+
export default ConfirmationModal;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface ContextMenuItem {
|
|
3
|
+
name: string;
|
|
4
|
+
icon: React.JSX.Element;
|
|
5
|
+
onClick: (id: string) => void;
|
|
6
|
+
onlyCurrentUserMessage?: boolean;
|
|
7
|
+
}
|
|
8
|
+
interface ContextMenuProps {
|
|
9
|
+
items: ContextMenuItem[];
|
|
10
|
+
isVisible: boolean;
|
|
11
|
+
messageId: string;
|
|
12
|
+
position: {
|
|
13
|
+
x: number;
|
|
14
|
+
y: number;
|
|
15
|
+
};
|
|
16
|
+
isCurrentUserMessage: boolean;
|
|
17
|
+
}
|
|
18
|
+
declare const ContextMenu: React.FC<ContextMenuProps>;
|
|
19
|
+
export default ContextMenu;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { SymbolAssignment } from "../../ts/interfaces";
|
|
2
|
+
declare const ChatInput: ({ onSendMessage, onSendVoice, onFileSend, dynamicSymbolAssignments, }: {
|
|
3
|
+
onSendMessage: (newMessage: string) => void;
|
|
4
|
+
onSendVoice: (voiceBlobUrl: string) => void;
|
|
5
|
+
onFileSend: (blob: Blob) => void;
|
|
6
|
+
dynamicSymbolAssignments?: SymbolAssignment<any>[];
|
|
7
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export default ChatInput;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AttachmentTypeEnum } from "../../ts/enum";
|
|
2
|
+
interface MediaProps {
|
|
3
|
+
attachment: string;
|
|
4
|
+
attachmentType?: AttachmentTypeEnum;
|
|
5
|
+
}
|
|
6
|
+
declare const Media: ({ attachment, attachmentType }: MediaProps) => import("react/jsx-runtime").JSX.Element | null | undefined;
|
|
7
|
+
export default Media;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { MessageEntity } from "../../../domain/MessageEntity";
|
|
3
|
+
declare const LeftSide: ({ message, showUserProfile, handleContextMenu, media, }: {
|
|
4
|
+
media: React.JSX.Element | null;
|
|
5
|
+
message: MessageEntity;
|
|
6
|
+
showUserProfile: boolean;
|
|
7
|
+
handleContextMenu: (event: React.MouseEvent, message: MessageEntity) => void;
|
|
8
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export default LeftSide;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { MessageEntity } from "../../../domain/MessageEntity";
|
|
3
|
+
declare const RightSide: ({ handleContextMenu, media, message, }: {
|
|
4
|
+
media: React.JSX.Element | null;
|
|
5
|
+
message: MessageEntity;
|
|
6
|
+
handleContextMenu: (event: React.MouseEvent, message: MessageEntity) => void;
|
|
7
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export default RightSide;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface TaskInterface {
|
|
2
|
+
id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
}
|
|
5
|
+
export interface TasksProps {
|
|
6
|
+
symbol?: string;
|
|
7
|
+
task: TaskInterface;
|
|
8
|
+
onClick: (id: string, text: string) => void;
|
|
9
|
+
}
|
|
10
|
+
declare const Tasks: ({ symbol, onClick, task }: TasksProps) => import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export default Tasks;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { AttachmentTypeEnum } from "../ts/enum";
|
|
2
|
+
import { UserInterface } from "../ts/interfaces";
|
|
3
|
+
export declare class MessageEntity {
|
|
4
|
+
id: string;
|
|
5
|
+
text: string;
|
|
6
|
+
createdDate: string;
|
|
7
|
+
attachment: undefined | string;
|
|
8
|
+
attachmentType: AttachmentTypeEnum | undefined;
|
|
9
|
+
user: UserInterface;
|
|
10
|
+
isRightSided: boolean | undefined;
|
|
11
|
+
symbols: {
|
|
12
|
+
symbol: string;
|
|
13
|
+
value: {
|
|
14
|
+
name: string;
|
|
15
|
+
id: string;
|
|
16
|
+
};
|
|
17
|
+
} | undefined;
|
|
18
|
+
constructor({ id, text, createdDate, attachment, attachmentType, user, isRightSided, symbols, }: {
|
|
19
|
+
id: string;
|
|
20
|
+
text: string;
|
|
21
|
+
createdDate: string;
|
|
22
|
+
attachment?: string;
|
|
23
|
+
attachmentType?: AttachmentTypeEnum;
|
|
24
|
+
user: UserInterface;
|
|
25
|
+
isRightSided?: boolean;
|
|
26
|
+
symbols?: {
|
|
27
|
+
symbol: string;
|
|
28
|
+
value: {
|
|
29
|
+
name: string;
|
|
30
|
+
id: string;
|
|
31
|
+
};
|
|
32
|
+
} | undefined;
|
|
33
|
+
});
|
|
34
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { MessageEntity } from "../../domain/MessageEntity";
|
|
3
|
+
import { SymbolAssignment, UserInterface } from "../../ts/interfaces";
|
|
4
|
+
export interface ChatPropsInterface {
|
|
5
|
+
messages: MessageEntity[];
|
|
6
|
+
user: UserInterface;
|
|
7
|
+
width?: string;
|
|
8
|
+
height?: string;
|
|
9
|
+
className?: string;
|
|
10
|
+
style?: React.CSSProperties;
|
|
11
|
+
updateMessages: (messages: MessageEntity[]) => void;
|
|
12
|
+
onMessageSent: (message: MessageEntity) => void;
|
|
13
|
+
dynamicSymbolAssignments?: SymbolAssignment<any>[];
|
|
14
|
+
onDeleteMessage: (id: string) => void;
|
|
15
|
+
onEditMessage: (id: string) => void;
|
|
16
|
+
}
|
|
17
|
+
declare const Chat: ({ width, height, className, style, messages, user, updateMessages, onMessageSent, onDeleteMessage, onEditMessage, dynamicSymbolAssignments, }: ChatPropsInterface) => import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
export default Chat;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ContextMenuItem } from "../../components/ContextMenu/ContextMenu";
|
|
3
|
+
import { MessageEntity } from "../../domain/MessageEntity";
|
|
4
|
+
import { UserInterface } from "../../ts/interfaces";
|
|
5
|
+
declare const Logic: ({ user, messages, updateMessages, onMessageSent, onEditMessage, onDeleteMessage, }: {
|
|
6
|
+
messages: MessageEntity[];
|
|
7
|
+
user: UserInterface;
|
|
8
|
+
updateMessages: (messages: MessageEntity[]) => void;
|
|
9
|
+
onMessageSent: (message: MessageEntity) => void;
|
|
10
|
+
onDeleteMessage: (id: string) => void;
|
|
11
|
+
onEditMessage: (id: string) => void;
|
|
12
|
+
}) => {
|
|
13
|
+
handleDeleteConfirmation: () => void;
|
|
14
|
+
handleCloseContextMenu: () => void;
|
|
15
|
+
contextMenuItems: ContextMenuItem[];
|
|
16
|
+
handleSendFile: (file: Blob) => void;
|
|
17
|
+
handleSendVoice: (voiceBlobUrl: string) => void;
|
|
18
|
+
handleSendMessage: (text: string) => void;
|
|
19
|
+
handleContextMenu: (event: React.MouseEvent, message: MessageEntity) => void;
|
|
20
|
+
isModalOpen: boolean;
|
|
21
|
+
contextMenu: {
|
|
22
|
+
x: number;
|
|
23
|
+
y: number;
|
|
24
|
+
message: MessageEntity | null;
|
|
25
|
+
} | null;
|
|
26
|
+
chatRef: React.RefObject<HTMLDivElement | null>;
|
|
27
|
+
setIsModalOpen: React.Dispatch<React.SetStateAction<boolean>>;
|
|
28
|
+
};
|
|
29
|
+
export default Logic;
|
package/types/index.d.ts
ADDED
package/types/main.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "./index.css";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface UserInterface {
|
|
3
|
+
id: string;
|
|
4
|
+
profileImageUrl?: string;
|
|
5
|
+
fullName?: string;
|
|
6
|
+
firstName?: string;
|
|
7
|
+
lastName?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface SymbolAssignment<T = any> {
|
|
10
|
+
symbol: string;
|
|
11
|
+
component?: ({ onClick, listsProps, }: {
|
|
12
|
+
onClick: (id: string, value: string) => void;
|
|
13
|
+
listsProps: T;
|
|
14
|
+
}) => React.JSX.Element;
|
|
15
|
+
lists?: T[];
|
|
16
|
+
pagNumber: number;
|
|
17
|
+
updatePageNumber: (newPage: number) => void;
|
|
18
|
+
}
|