corp-chat-library-antd-react-socket 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.
- package/LICENSE +20 -0
- package/README.md +73 -0
- package/dist/CHAT/ChatBtn.d.ts +5 -0
- package/dist/CHAT/components/ChatContent.d.ts +3 -0
- package/dist/CHAT/components/ChatDivider.d.ts +3 -0
- package/dist/CHAT/components/ChatFooter.d.ts +9 -0
- package/dist/CHAT/components/ChatHeader.d.ts +5 -0
- package/dist/CHAT/components/ChatIncomingMsg.d.ts +4 -0
- package/dist/CHAT/components/ChatInput.d.ts +4 -0
- package/dist/CHAT/components/ChatLayout.d.ts +1 -0
- package/dist/CHAT/components/ChatList.d.ts +7 -0
- package/dist/CHAT/components/ChatModal.d.ts +8 -0
- package/dist/CHAT/components/ChatSelfMsg.d.ts +4 -0
- package/dist/CHAT/components/ChatSidebar.d.ts +6 -0
- package/dist/CHAT/context/ChatSocketContext.d.ts +53 -0
- package/dist/CHAT/hooks/useInfiniteScrollUp.d.ts +19 -0
- package/dist/CHAT/hooks/useMarkMessagesRead.d.ts +22 -0
- package/dist/CHAT/hooks/useScrollDown.d.ts +18 -0
- package/dist/CHAT/mock/chatParams.d.ts +64 -0
- package/dist/CHAT/mock/mockSms.d.ts +97 -0
- package/dist/CHAT/types/types.d.ts +147 -0
- package/dist/Chat.d.ts +3 -0
- package/dist/index.css +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +10598 -0
- package/dist/vite.svg +1 -0
- package/package.json +73 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
Copyright (c) 2025 azzimandias
|
|
3
|
+
|
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
in the Software without restriction, including without limitation the rights
|
|
7
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
furnished to do so, subject to the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be included in all
|
|
12
|
+
copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# React + TypeScript + Vite
|
|
2
|
+
|
|
3
|
+
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
|
|
4
|
+
|
|
5
|
+
Currently, two official plugins are available:
|
|
6
|
+
|
|
7
|
+
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) (or [oxc](https://oxc.rs) when used in [rolldown-vite](https://vite.dev/guide/rolldown)) for Fast Refresh
|
|
8
|
+
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
|
|
9
|
+
|
|
10
|
+
## React Compiler
|
|
11
|
+
|
|
12
|
+
The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation).
|
|
13
|
+
|
|
14
|
+
## Expanding the ESLint configuration
|
|
15
|
+
|
|
16
|
+
If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
|
|
17
|
+
|
|
18
|
+
```js
|
|
19
|
+
export default defineConfig([
|
|
20
|
+
globalIgnores(['dist']),
|
|
21
|
+
{
|
|
22
|
+
files: ['**/*.{ts,tsx}'],
|
|
23
|
+
extends: [
|
|
24
|
+
// Other configs...
|
|
25
|
+
|
|
26
|
+
// Remove tseslint.configs.recommended and replace with this
|
|
27
|
+
tseslint.configs.recommendedTypeChecked,
|
|
28
|
+
// Alternatively, use this for stricter rules
|
|
29
|
+
tseslint.configs.strictTypeChecked,
|
|
30
|
+
// Optionally, add this for stylistic rules
|
|
31
|
+
tseslint.configs.stylisticTypeChecked,
|
|
32
|
+
|
|
33
|
+
// Other configs...
|
|
34
|
+
],
|
|
35
|
+
languageOptions: {
|
|
36
|
+
parserOptions: {
|
|
37
|
+
project: ['./tsconfig.node.json', './tsconfig.app.json'],
|
|
38
|
+
tsconfigRootDir: import.meta.dirname,
|
|
39
|
+
},
|
|
40
|
+
// other options...
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
])
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:
|
|
47
|
+
|
|
48
|
+
```js
|
|
49
|
+
// eslint.config.js
|
|
50
|
+
import reactX from 'eslint-plugin-react-x'
|
|
51
|
+
import reactDom from 'eslint-plugin-react-dom'
|
|
52
|
+
|
|
53
|
+
export default defineConfig([
|
|
54
|
+
globalIgnores(['dist']),
|
|
55
|
+
{
|
|
56
|
+
files: ['**/*.{ts,tsx}'],
|
|
57
|
+
extends: [
|
|
58
|
+
// Other configs...
|
|
59
|
+
// Enable lint rules for React
|
|
60
|
+
reactX.configs['recommended-typescript'],
|
|
61
|
+
// Enable lint rules for React DOM
|
|
62
|
+
reactDom.configs.recommended,
|
|
63
|
+
],
|
|
64
|
+
languageOptions: {
|
|
65
|
+
parserOptions: {
|
|
66
|
+
project: ['./tsconfig.node.json', './tsconfig.app.json'],
|
|
67
|
+
tsconfigRootDir: import.meta.dirname,
|
|
68
|
+
},
|
|
69
|
+
// other options...
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
])
|
|
73
|
+
```
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
type Position = "topLeft" | "topRight" | "bottomLeft" | "bottomRight";
|
|
2
|
+
interface ChatFooterParams {
|
|
3
|
+
draggable: boolean;
|
|
4
|
+
setDraggable: (draggable: boolean) => void;
|
|
5
|
+
position: Position | null;
|
|
6
|
+
setPosition: (position: Position | null) => void;
|
|
7
|
+
}
|
|
8
|
+
export default function ChatFooter({ draggable, setDraggable, position, setPosition }: ChatFooterParams): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function ChatLayout(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
interface ChatListParams {
|
|
2
|
+
search: string;
|
|
3
|
+
onSelectChat: (chatId: number | null) => void;
|
|
4
|
+
selectedChatId: number | null;
|
|
5
|
+
}
|
|
6
|
+
export default function ChatList({ search, onSelectChat, selectedChatId }: ChatListParams): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
interface ChatModalParams {
|
|
2
|
+
open: boolean;
|
|
3
|
+
onOk: () => void;
|
|
4
|
+
onCancel: () => void;
|
|
5
|
+
positionCorner: 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight' | null;
|
|
6
|
+
}
|
|
7
|
+
export declare const ChatModal: ({ open, onOk, onCancel, positionCorner }: ChatModalParams) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
import { AlertInfo, Chat, ChatToList, UserData } from '../types/types.ts';
|
|
3
|
+
import { UploadFile } from 'antd';
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
interface ChatSocketContextType {
|
|
6
|
+
connected: boolean;
|
|
7
|
+
connectionStatus: string;
|
|
8
|
+
isAlertVisibleKey: number;
|
|
9
|
+
alertInfo: AlertInfo;
|
|
10
|
+
totalUnread: number;
|
|
11
|
+
chatsList: ChatToList[];
|
|
12
|
+
chats: Chat[];
|
|
13
|
+
currentChatId: number;
|
|
14
|
+
loadingChatList: boolean;
|
|
15
|
+
loadingChat: boolean;
|
|
16
|
+
loadingSendSms: boolean;
|
|
17
|
+
fetchChatsList: (search: string | null) => void;
|
|
18
|
+
fetchChatMessages: (chatId: number, lastMsg: number | null) => void;
|
|
19
|
+
sendSms: ({ to, text, files, answer, timestamp, from_id }: toSendSms) => void;
|
|
20
|
+
markMessagesAsRead: (messageIds: (number | undefined)[]) => void;
|
|
21
|
+
setSubscribeToChat: (search: string | null) => void;
|
|
22
|
+
setNewSms: (search: string | null) => void;
|
|
23
|
+
setUpdateSms: (search: string | null) => void;
|
|
24
|
+
userdata: UserData | null;
|
|
25
|
+
setUserData: (data: UserData) => void;
|
|
26
|
+
HTTP_HOST: string | null;
|
|
27
|
+
SET_HTTP_HOST: (host: string) => void;
|
|
28
|
+
CSRF_TOKEN: string | null;
|
|
29
|
+
SET_CSRF_TOKEN: (token: string) => void;
|
|
30
|
+
PRODMODE: boolean | null;
|
|
31
|
+
SET_PRODMODE: (mode: boolean) => void;
|
|
32
|
+
PROD_AXIOS_INSTANCE: AxiosInstance | null;
|
|
33
|
+
SET_PROD_AXIOS_INSTANCE: (instance: AxiosInstance) => void;
|
|
34
|
+
setFetchChatsListPath: (path: string | null) => void;
|
|
35
|
+
setFetchChatMessagesPath: (path: string | null) => void;
|
|
36
|
+
setSendSmsPath: (path: string | null) => void;
|
|
37
|
+
setMarkMessagesAsReadPath: (path: string | null) => void;
|
|
38
|
+
}
|
|
39
|
+
interface toSendSms {
|
|
40
|
+
to: number;
|
|
41
|
+
text: string;
|
|
42
|
+
files?: UploadFile[];
|
|
43
|
+
answer: number | null;
|
|
44
|
+
timestamp: number;
|
|
45
|
+
from_id: number;
|
|
46
|
+
}
|
|
47
|
+
export declare const ChatSocketContext: React.Context<ChatSocketContextType | undefined>;
|
|
48
|
+
export declare const ChatSocketProvider: ({ children, url }: {
|
|
49
|
+
children: React.ReactNode;
|
|
50
|
+
url: string;
|
|
51
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
52
|
+
export declare const useChatSocket: () => ChatSocketContextType;
|
|
53
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Хук для подгрузки сообщений при скролле вверх.
|
|
4
|
+
* Работает даже если DOM-элементы пересоздаются при обновлении.
|
|
5
|
+
*
|
|
6
|
+
* @param {object} params - объект конфигурации
|
|
7
|
+
* @param {React.RefObject} params.containerRef - контейнер с сообщениями, за которым следим
|
|
8
|
+
* @param {function} params.fetchMoreMessages - метод выполняемый в точке офсета
|
|
9
|
+
* @param {boolean} params.hasMore - флаг надо ли еще реагировать на офсет
|
|
10
|
+
* @param {number} [params.offset=100] - офсет, расстояние до топа контейнера, в котором срабатывает метод
|
|
11
|
+
*/
|
|
12
|
+
interface hookParams {
|
|
13
|
+
containerRef: RefObject<HTMLDivElement | null>;
|
|
14
|
+
fetchMoreMessages: () => void;
|
|
15
|
+
hasMore: boolean;
|
|
16
|
+
offset: number;
|
|
17
|
+
}
|
|
18
|
+
export declare const useInfiniteScrollUp: ({ containerRef, fetchMoreMessages, hasMore, offset, }: hookParams) => void;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
import { messagesWithDividersInterface } from '../types/types.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Хук, который вызывает колбэк метод когда во вьюпорт попадает конкретный объект
|
|
5
|
+
* (например в чате со скроллом появляется непрочитанное сообщение)
|
|
6
|
+
*
|
|
7
|
+
* @param {object} params - объект конфигурации
|
|
8
|
+
* @param {Array} params.messagesWithDividers - сообщения, их количество изменится - сработает хук
|
|
9
|
+
* @param {number} params.currentUserId - id пользователя
|
|
10
|
+
* @param {number} [params.chatId] - id чата
|
|
11
|
+
* @param {React.RefObject} params.containerRef - контейнер с сообщениями, за которым следим
|
|
12
|
+
* @param {function} [params.markMessagesAsRead] - функция срабатываемая при попадании сообщения в observer
|
|
13
|
+
*/
|
|
14
|
+
interface hookParams {
|
|
15
|
+
messagesWithDividers: messagesWithDividersInterface[];
|
|
16
|
+
currentUserId: number | null;
|
|
17
|
+
chatId: number;
|
|
18
|
+
containerRef: RefObject<HTMLDivElement | null>;
|
|
19
|
+
markMessagesAsRead: (messageIds: (number | undefined)[]) => void;
|
|
20
|
+
}
|
|
21
|
+
export declare const useMarkMessagesRead: ({ messagesWithDividers, currentUserId, chatId, containerRef, markMessagesAsRead }: hookParams) => void;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
import { messagesWithDividersInterface } from '../types/types.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Хук для притягивания скролла к низу контейнера, когда отправлено новое сообщение
|
|
5
|
+
* или пришло новое сообщение, если скролл находится в офсете (близко к низу контейнера)
|
|
6
|
+
*
|
|
7
|
+
* @param {object} params - объект конфигурации
|
|
8
|
+
* @param {Array} params.messagesWithDividers - сообщения, их количество изменится - сработает хук
|
|
9
|
+
* @param {React.RefObject} params.containerRef - контейнер с сообщениями, за которым следим
|
|
10
|
+
* @param {number} [params.offset=100] - офсет, расстояние до низа контейнера
|
|
11
|
+
*/
|
|
12
|
+
interface hookParams {
|
|
13
|
+
messagesWithDividers: messagesWithDividersInterface[];
|
|
14
|
+
containerRef: RefObject<HTMLDivElement | null>;
|
|
15
|
+
offset: number;
|
|
16
|
+
}
|
|
17
|
+
export declare const useScrollDown: ({ messagesWithDividers, containerRef, offset, }: hookParams) => void;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
export declare const MS_USER: {
|
|
2
|
+
acls: number[];
|
|
3
|
+
companies: {
|
|
4
|
+
id: number;
|
|
5
|
+
name: string;
|
|
6
|
+
description: string;
|
|
7
|
+
is_active: number;
|
|
8
|
+
template_prefix: string;
|
|
9
|
+
folder: string;
|
|
10
|
+
color: string;
|
|
11
|
+
ext_address_offers: string;
|
|
12
|
+
path_logo: string;
|
|
13
|
+
created_at: null;
|
|
14
|
+
updated_at: null;
|
|
15
|
+
places: {
|
|
16
|
+
id: number;
|
|
17
|
+
name: string;
|
|
18
|
+
label: string;
|
|
19
|
+
accessgroup: number;
|
|
20
|
+
accessname: string;
|
|
21
|
+
position: number;
|
|
22
|
+
place: number;
|
|
23
|
+
}[];
|
|
24
|
+
}[];
|
|
25
|
+
user: {
|
|
26
|
+
id: number;
|
|
27
|
+
name: string;
|
|
28
|
+
surname: string;
|
|
29
|
+
secondname: string;
|
|
30
|
+
occupy: string;
|
|
31
|
+
passcard: null;
|
|
32
|
+
id_role: number;
|
|
33
|
+
email: null;
|
|
34
|
+
sales_role: number;
|
|
35
|
+
password2: string;
|
|
36
|
+
active_company: number;
|
|
37
|
+
id_departament: number;
|
|
38
|
+
id_company: number;
|
|
39
|
+
};
|
|
40
|
+
mode: number;
|
|
41
|
+
duration: number;
|
|
42
|
+
state: never[];
|
|
43
|
+
status: number;
|
|
44
|
+
};
|
|
45
|
+
export declare const HTTP_PARAMS: {
|
|
46
|
+
CSRF_TOKEN: string;
|
|
47
|
+
PRODMODE: boolean;
|
|
48
|
+
PROD_AXIOS_INSTANCE: null;
|
|
49
|
+
HTTP_HOST: string;
|
|
50
|
+
BFF_PORT: number;
|
|
51
|
+
};
|
|
52
|
+
export declare const FETCH_PARAMS: {
|
|
53
|
+
fetchChatsListPath: string;
|
|
54
|
+
fetchChatMessagesPath: string;
|
|
55
|
+
sendSmsPath: string;
|
|
56
|
+
markMessagesAsReadPath: string;
|
|
57
|
+
};
|
|
58
|
+
export declare const SOCKET_SUBSCRIBE: {
|
|
59
|
+
subscribeToChat: string;
|
|
60
|
+
};
|
|
61
|
+
export declare const SOCKET_ACTIONS: {
|
|
62
|
+
newSms: string;
|
|
63
|
+
updateSms: string;
|
|
64
|
+
};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
export declare const CHAT_LIST_MOCK: {
|
|
2
|
+
content: {
|
|
3
|
+
sms: {
|
|
4
|
+
id: number;
|
|
5
|
+
chat_id: number;
|
|
6
|
+
from: {
|
|
7
|
+
surname: string;
|
|
8
|
+
name: string;
|
|
9
|
+
id: number;
|
|
10
|
+
};
|
|
11
|
+
to: {
|
|
12
|
+
surname: string;
|
|
13
|
+
name: string;
|
|
14
|
+
id: number;
|
|
15
|
+
};
|
|
16
|
+
text: string;
|
|
17
|
+
files: string[];
|
|
18
|
+
status: boolean;
|
|
19
|
+
created_at: number;
|
|
20
|
+
updated_at: number;
|
|
21
|
+
count_unread: number;
|
|
22
|
+
}[];
|
|
23
|
+
total_unread: number;
|
|
24
|
+
};
|
|
25
|
+
message: string;
|
|
26
|
+
};
|
|
27
|
+
export declare const CHAT_MOCK: {
|
|
28
|
+
content: {
|
|
29
|
+
messages: {
|
|
30
|
+
id: number;
|
|
31
|
+
from_id: number;
|
|
32
|
+
answer: null;
|
|
33
|
+
text: string;
|
|
34
|
+
files: {
|
|
35
|
+
id: number;
|
|
36
|
+
route: string;
|
|
37
|
+
extension: string;
|
|
38
|
+
name: string;
|
|
39
|
+
}[];
|
|
40
|
+
status: boolean;
|
|
41
|
+
created_at: number;
|
|
42
|
+
updated_at: number;
|
|
43
|
+
}[];
|
|
44
|
+
who: string;
|
|
45
|
+
total: number;
|
|
46
|
+
};
|
|
47
|
+
message: string;
|
|
48
|
+
};
|
|
49
|
+
export declare const CHAT_MOCK_NEW: {
|
|
50
|
+
content: {
|
|
51
|
+
messages: {
|
|
52
|
+
id: number;
|
|
53
|
+
from_id: number;
|
|
54
|
+
answer: null;
|
|
55
|
+
text: string;
|
|
56
|
+
files: {
|
|
57
|
+
id: number;
|
|
58
|
+
route: string;
|
|
59
|
+
extension: string;
|
|
60
|
+
name: string;
|
|
61
|
+
}[];
|
|
62
|
+
status: boolean;
|
|
63
|
+
created_at: number;
|
|
64
|
+
updated_at: number;
|
|
65
|
+
}[];
|
|
66
|
+
who: string;
|
|
67
|
+
total: number;
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
export declare const WS_NEW_MESSAGE: {
|
|
71
|
+
left: {
|
|
72
|
+
id: number;
|
|
73
|
+
chat_id: number;
|
|
74
|
+
from: {
|
|
75
|
+
surname: string;
|
|
76
|
+
name: string;
|
|
77
|
+
id: number;
|
|
78
|
+
};
|
|
79
|
+
to: {
|
|
80
|
+
surname: string;
|
|
81
|
+
name: string;
|
|
82
|
+
id: number;
|
|
83
|
+
};
|
|
84
|
+
text: string;
|
|
85
|
+
status: boolean;
|
|
86
|
+
created_at: number;
|
|
87
|
+
updated_at: number;
|
|
88
|
+
};
|
|
89
|
+
right: {
|
|
90
|
+
id: number;
|
|
91
|
+
from_id: number;
|
|
92
|
+
answer: null;
|
|
93
|
+
text: string;
|
|
94
|
+
created_at: number;
|
|
95
|
+
updated_at: number;
|
|
96
|
+
};
|
|
97
|
+
};
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
export interface ChatParams {
|
|
3
|
+
userdata: UserData;
|
|
4
|
+
httpParams: HttpParams;
|
|
5
|
+
fetchParams: FetchParams;
|
|
6
|
+
socketSubscribe: SocketSubscribe;
|
|
7
|
+
socketActions: SocketActions;
|
|
8
|
+
}
|
|
9
|
+
export interface HttpParams {
|
|
10
|
+
CSRF_TOKEN: string;
|
|
11
|
+
PRODMODE: boolean;
|
|
12
|
+
PROD_AXIOS_INSTANCE: AxiosInstance | null;
|
|
13
|
+
HTTP_HOST: string;
|
|
14
|
+
BFF_PORT: number;
|
|
15
|
+
}
|
|
16
|
+
export interface FetchParams {
|
|
17
|
+
fetchChatsListPath: string;
|
|
18
|
+
fetchChatMessagesPath: string;
|
|
19
|
+
sendSmsPath: string;
|
|
20
|
+
markMessagesAsReadPath: string;
|
|
21
|
+
}
|
|
22
|
+
export interface SocketSubscribe {
|
|
23
|
+
subscribeToChat: string;
|
|
24
|
+
}
|
|
25
|
+
export interface SocketActions {
|
|
26
|
+
newSms: string;
|
|
27
|
+
updateSms: string;
|
|
28
|
+
}
|
|
29
|
+
export interface UserData {
|
|
30
|
+
acls: number[];
|
|
31
|
+
companies: Company[];
|
|
32
|
+
user: User;
|
|
33
|
+
mode: number;
|
|
34
|
+
duration: number;
|
|
35
|
+
status: number;
|
|
36
|
+
}
|
|
37
|
+
export interface Company {
|
|
38
|
+
id: number;
|
|
39
|
+
name: string;
|
|
40
|
+
description: string;
|
|
41
|
+
is_active: number;
|
|
42
|
+
template_prefix: string;
|
|
43
|
+
folder: string;
|
|
44
|
+
color: string;
|
|
45
|
+
ext_address_offers: string;
|
|
46
|
+
path_logo: string;
|
|
47
|
+
places: Place[];
|
|
48
|
+
}
|
|
49
|
+
export interface Place {
|
|
50
|
+
id: number;
|
|
51
|
+
name: string;
|
|
52
|
+
label: string;
|
|
53
|
+
accessgroup: number;
|
|
54
|
+
accessname: string;
|
|
55
|
+
position: number;
|
|
56
|
+
place: number;
|
|
57
|
+
}
|
|
58
|
+
export interface User {
|
|
59
|
+
id: number;
|
|
60
|
+
name: string;
|
|
61
|
+
surname: string;
|
|
62
|
+
secondname: string;
|
|
63
|
+
occupy: string;
|
|
64
|
+
passcard: string | null | undefined;
|
|
65
|
+
id_role: number;
|
|
66
|
+
email: string | null | undefined;
|
|
67
|
+
sales_role: number;
|
|
68
|
+
password2: string;
|
|
69
|
+
active_company: number;
|
|
70
|
+
id_departament: number;
|
|
71
|
+
id_company: number;
|
|
72
|
+
super?: number | null;
|
|
73
|
+
}
|
|
74
|
+
export interface AlertInfo {
|
|
75
|
+
message: string;
|
|
76
|
+
description: string;
|
|
77
|
+
type: "success" | "info" | "warning" | "error";
|
|
78
|
+
}
|
|
79
|
+
export interface ChatToList {
|
|
80
|
+
id: number | undefined;
|
|
81
|
+
chat_id: number | undefined;
|
|
82
|
+
text: string;
|
|
83
|
+
files: string[];
|
|
84
|
+
status: boolean;
|
|
85
|
+
created_at: number;
|
|
86
|
+
updated_at: number;
|
|
87
|
+
count_unread: number;
|
|
88
|
+
from: From;
|
|
89
|
+
to: To;
|
|
90
|
+
to_id?: number;
|
|
91
|
+
from_id?: number;
|
|
92
|
+
last_message?: number;
|
|
93
|
+
}
|
|
94
|
+
export interface From {
|
|
95
|
+
id: number | undefined;
|
|
96
|
+
name: string;
|
|
97
|
+
surname: string;
|
|
98
|
+
}
|
|
99
|
+
export interface To {
|
|
100
|
+
id: number | undefined;
|
|
101
|
+
name: string;
|
|
102
|
+
surname: string;
|
|
103
|
+
}
|
|
104
|
+
export interface Chat {
|
|
105
|
+
chat_id: number;
|
|
106
|
+
who: string;
|
|
107
|
+
messages: ChatMessage[];
|
|
108
|
+
total: number;
|
|
109
|
+
}
|
|
110
|
+
export interface ChatMessage {
|
|
111
|
+
id: number;
|
|
112
|
+
from_id: number;
|
|
113
|
+
answer: number | null;
|
|
114
|
+
text: string;
|
|
115
|
+
files: File[];
|
|
116
|
+
status: boolean;
|
|
117
|
+
created_at: number;
|
|
118
|
+
updated_at: number;
|
|
119
|
+
from?: number;
|
|
120
|
+
isLocal?: boolean;
|
|
121
|
+
isSending?: boolean;
|
|
122
|
+
}
|
|
123
|
+
export interface File {
|
|
124
|
+
id: number;
|
|
125
|
+
route: string;
|
|
126
|
+
extension: string;
|
|
127
|
+
name: string;
|
|
128
|
+
}
|
|
129
|
+
export interface Normalized {
|
|
130
|
+
fromId: number;
|
|
131
|
+
id: number;
|
|
132
|
+
text: string;
|
|
133
|
+
files: File[];
|
|
134
|
+
timestamp: number;
|
|
135
|
+
isSelf: boolean;
|
|
136
|
+
senderName: string;
|
|
137
|
+
isLocal: boolean;
|
|
138
|
+
isSending: boolean;
|
|
139
|
+
status: boolean;
|
|
140
|
+
_raw: ChatMessage;
|
|
141
|
+
}
|
|
142
|
+
export interface messagesWithDividersInterface {
|
|
143
|
+
type: string;
|
|
144
|
+
id: string;
|
|
145
|
+
timestamp?: number;
|
|
146
|
+
message?: Normalized;
|
|
147
|
+
}
|
package/dist/Chat.d.ts
ADDED
package/dist/index.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
:root{--app-top-menu: linear-gradient(178deg, rgba(79, 143, 207, 1) 0%, rgba(41, 92, 143, 1) 100%);--sa-primary-color: #2178fa}.ant-layout-sider-children{margin:0!important;padding:0!important}ol,ul{list-style:none;padding-left:0;margin:0}._draggableWrapper_1bp6r_17 .ant-modal-content{padding:0;background-color:#fff;border:1px solid #787878a2;border-radius:15px;overflow:hidden}._chat-modal__title_1bp6r_33{cursor:grab;padding:20px 10px 10px 20px;background:var(--app-top-menu);color:#fff!important;font-weight:400!important}._chat-modal__title_1bp6r_33:active{cursor:grabbing}._chat-input__footer_1bp6r_57{border-top:1px solid #c1c1c1;background:#fff;padding:5px 0;display:flex;gap:5px;justify-content:space-around}._chat-input__footer_1bp6r_57>*{margin:0 auto!important}._sidebar-layout_1bp6r_83{display:flex;flex-direction:column;height:100%;border-right:1px solid #c1c1c1;padding:2px 0}._sidebar-layout_1bp6r_83>*:not(:last-child){border-bottom:1px solid #e6e6e6}._sidebar-layout_1bp6r_83:nth-child(1){border-bottom:none}._chat-list_1bp6r_113::-webkit-scrollbar{display:none}._chat-list_1bp6r_113>*{margin:0;border-bottom:1px solid #e6e6e6;height:77px}._chat-item_1bp6r_145{margin-bottom:12px}._last-message_1bp6r_153{height:44px;display:-webkit-box;-webkit-line-clamp:2;line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;text-overflow:ellipsis;white-space:normal;font-size:.9em;color:#555}._activeChatItem_1bp6r_177 ._last-message_1bp6r_153{color:#f3f1f1}._message_1bp6r_187{display:flex;margin-bottom:8px}._myMessage_1bp6r_197{justify-content:flex-end}._otherMessage_1bp6r_205{justify-content:flex-start}._bubble_1bp6r_215{max-width:70%;padding:8px 12px;position:relative}._myMessageBubble_1bp6r_229{border-radius:25px 25px 0;margin:0 7px 0 auto;background:#dcf8c6;color:#000;align-self:flex-end;border:1px solid #e6e6e6;-webkit-box-shadow:9px 10px 15px -5px rgba(34,60,80,.2);-moz-box-shadow:9px 10px 15px -5px rgba(34,60,80,.2);box-shadow:9px 10px 15px -5px #223c5033}._otherMessageBubble_1bp6r_255{border-radius:25px 25px 25px 0;margin-left:7px;background:#e1f8f2;color:#000;border:1px solid #e6e6e6;align-self:flex-start;-webkit-box-shadow:-13px 10px 15px -5px rgba(34,60,80,.2);-moz-box-shadow:-13px 10px 15px -5px rgba(34,60,80,.2);box-shadow:-13px 10px 15px -5px #223c5033}._senderName_1bp6r_281{display:block;font-size:12px;font-weight:700;color:#333;margin-bottom:4px}._time_1bp6r_299{font-size:11px;color:#666;text-align:right;margin-top:2px}._chat_header_1bp6r_315{height:40px;display:flex;justify-content:space-between;align-items:center;padding:8px 16px;border-bottom:1px solid #f0f0f0;background:#fafafa;flex-shrink:0}._lastUpdate_1bp6r_339{font-size:12px;color:#888}._localMessage_1bp6r_349{opacity:.7}._sending_1bp6r_357{color:#1890ff;font-size:11px;font-style:italic}._notification-badge_1bp6r_369{cursor:pointer;transition:background-color .2s}._notification-badge_1bp6r_369:hover{background-color:#1890ff}._chat-layout_1bp6r_389{height:700px;display:flex;overflow:hidden}._chat-content_1bp6r_401{flex:1;overflow:hidden}._chatcontentLayout_1bp6r_411{height:100%;display:flex;flex-direction:column}._chat_content_1bp6r_423{display:grid;grid-template-columns:1fr;grid-template-rows:auto 1fr auto}._messagesList_1bp6r_445{flex:1;overflow-y:auto;padding:8px;min-height:0;display:flex;flex-direction:column}._messagesList_1bp6r_445::-webkit-scrollbar,._textArea_1bp6r_467::-webkit-scrollbar{display:none}._textArea_1bp6r_467{min-height:40px;max-height:120px;resize:none;padding:0 2px;width:200px;line-height:40px}._textArea_1bp6r_467::placeholder{color:#999;opacity:.5}._chatItem_1bp6r_503{height:77px;padding:5px;display:flex;align-items:center;justify-content:space-between}._activeChatItem_1bp6r_177{background:var(--app-top-menu);color:#fff;opacity:.8}._chat_body_1bp6r_533{flex:1;display:flex;flex-direction:column;overflow-y:scroll;scrollbar-color:#f5f5f5 #f5f5f5;scrollbar-width:thin;transition:.3s}._chat_body_1bp6r_533:hover{scrollbar-color:var(--sa-primary-color) #f5f5f5}._antd_empty_1bp6r_561{height:100%;display:flex;flex-direction:column;justify-content:center;align-items:center}._chat_inputs_1bp6r_577{width:100%;display:grid;grid-template-columns:auto 1fr auto auto;align-items:center;grid-gap:10px;padding:0 10px}._chat-list__container_1bp6r_595{height:100%;overflow-y:scroll;scrollbar-color:#f5f5f5 #f5f5f5;scrollbar-width:thin;transition:.3s}._chat-list__container_1bp6r_595:hover{scrollbar-color:var(--sa-primary-color) #f5f5f5}._files_container_1bp6r_615{display:flex;flex-direction:column;align-items:center;gap:10px}._file_1bp6r_615{width:100%;padding:0 5px;border-radius:5px;color:#333;display:flex;align-items:center;gap:10px}._file_circle_1bp6r_645{background-color:#99bad3;border-radius:50%;padding:10px;display:flex;align-items:center;justify-content:center}._file_circle_1bp6r_645._self_1bp6r_661{background-color:#9ed399}._href_label_1bp6r_667{margin:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { default as Chat } from './Chat';
|
|
2
|
+
export { default as ChatBtn } from './CHAT/ChatBtn';
|
|
3
|
+
export { ChatSocketProvider, useChatSocket } from './CHAT/context/ChatSocketContext';
|
|
4
|
+
export type { ChatParams } from './CHAT/types/types.ts';
|
|
5
|
+
export { default } from './Chat';
|