corp-chat-library-antd-react-socket 1.2.14 → 1.2.15
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 +44 -20
- package/dist/CHAT/provider/ChatSocketProvider.d.ts +7 -2
- package/dist/CHAT/types/types.d.ts +16 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1719 -1711
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -9,24 +9,32 @@ npm install corp-chat-library-antd-react-socket
|
|
|
9
9
|
```tsx
|
|
10
10
|
import Chat from "corp-chat-library-antd-react-socket";
|
|
11
11
|
|
|
12
|
-
export default () => (
|
|
13
|
-
<Chat userdata={userdata}
|
|
14
|
-
httpParams={httpParams}
|
|
15
|
-
fetchParams={fetchParams}
|
|
16
|
-
socketSubscribe={socketSubscribe}
|
|
17
|
-
socketActions={socketActions}
|
|
18
|
-
|
|
19
|
-
);
|
|
20
|
-
|
|
12
|
+
export default () => (
|
|
13
|
+
<Chat userdata={userdata}
|
|
14
|
+
httpParams={httpParams}
|
|
15
|
+
fetchParams={fetchParams}
|
|
16
|
+
socketSubscribe={socketSubscribe}
|
|
17
|
+
socketActions={socketActions}
|
|
18
|
+
onNewMessage={(payload) => {
|
|
19
|
+
console.log('new chat message', payload);
|
|
20
|
+
}}
|
|
21
|
+
onMessageUpdated={(payload) => {
|
|
22
|
+
console.log('chat message updated', payload);
|
|
23
|
+
}}
|
|
24
|
+
/>
|
|
25
|
+
);
|
|
26
|
+
```
|
|
21
27
|
## Props types
|
|
22
28
|
```ts
|
|
23
|
-
export interface ChatParams {
|
|
24
|
-
userdata: UserData;
|
|
25
|
-
httpParams: HttpParams;
|
|
26
|
-
fetchParams: FetchParams;
|
|
27
|
-
socketSubscribe: SocketSubscribe;
|
|
28
|
-
socketActions: SocketActions;
|
|
29
|
-
|
|
29
|
+
export interface ChatParams {
|
|
30
|
+
userdata: UserData;
|
|
31
|
+
httpParams: HttpParams;
|
|
32
|
+
fetchParams: FetchParams;
|
|
33
|
+
socketSubscribe: SocketSubscribe;
|
|
34
|
+
socketActions: SocketActions;
|
|
35
|
+
onNewMessage?: (payload: NewSmsResponse) => void;
|
|
36
|
+
onMessageUpdated?: (payload: UpdateSmsResponse) => void;
|
|
37
|
+
}
|
|
30
38
|
|
|
31
39
|
export interface HttpParams {
|
|
32
40
|
CSRF_TOKEN: string;
|
|
@@ -46,10 +54,26 @@ export interface SocketSubscribe {
|
|
|
46
54
|
subscribeToChat: string;
|
|
47
55
|
}
|
|
48
56
|
|
|
49
|
-
export interface SocketActions {
|
|
50
|
-
newSms: string;
|
|
51
|
-
updateSms: string;
|
|
52
|
-
}
|
|
57
|
+
export interface SocketActions {
|
|
58
|
+
newSms: string;
|
|
59
|
+
updateSms: string;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface NewSmsResponse {
|
|
63
|
+
left?: ChatToList & {
|
|
64
|
+
total_unread?: number;
|
|
65
|
+
};
|
|
66
|
+
right?: ChatMessage;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface UpdateSmsResponse {
|
|
70
|
+
sms?: ChatMessage & {
|
|
71
|
+
to?: number;
|
|
72
|
+
count_unread?: number;
|
|
73
|
+
total_unread?: number;
|
|
74
|
+
};
|
|
75
|
+
from?: number;
|
|
76
|
+
}
|
|
53
77
|
|
|
54
78
|
export interface UserData {
|
|
55
79
|
acls: number[],
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
-
|
|
2
|
+
import { NewSmsResponse, UpdateSmsResponse } from '../types/types';
|
|
3
|
+
interface ChatSocketProviderProps {
|
|
3
4
|
children: React.ReactNode;
|
|
4
|
-
|
|
5
|
+
onNewMessage?: (payload: NewSmsResponse) => void;
|
|
6
|
+
onMessageUpdated?: (payload: UpdateSmsResponse) => void;
|
|
7
|
+
}
|
|
8
|
+
export declare const ChatSocketProvider: ({ children, onNewMessage, onMessageUpdated }: ChatSocketProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -5,6 +5,8 @@ export interface ChatParams {
|
|
|
5
5
|
fetchParams: FetchParams;
|
|
6
6
|
socketSubscribe: SocketSubscribe;
|
|
7
7
|
socketActions: SocketActions;
|
|
8
|
+
onNewMessage?: (payload: NewSmsResponse) => void;
|
|
9
|
+
onMessageUpdated?: (payload: UpdateSmsResponse) => void;
|
|
8
10
|
}
|
|
9
11
|
export interface HttpParams {
|
|
10
12
|
CSRF_TOKEN: string;
|
|
@@ -25,6 +27,20 @@ export interface SocketActions {
|
|
|
25
27
|
newSms: string;
|
|
26
28
|
updateSms: string;
|
|
27
29
|
}
|
|
30
|
+
export interface NewSmsResponse {
|
|
31
|
+
left?: ChatToList & {
|
|
32
|
+
total_unread?: number;
|
|
33
|
+
};
|
|
34
|
+
right?: ChatMessage;
|
|
35
|
+
}
|
|
36
|
+
export interface UpdateSmsResponse {
|
|
37
|
+
sms?: ChatMessage & {
|
|
38
|
+
to?: number;
|
|
39
|
+
count_unread?: number;
|
|
40
|
+
total_unread?: number;
|
|
41
|
+
};
|
|
42
|
+
from?: number;
|
|
43
|
+
}
|
|
28
44
|
export interface UserData {
|
|
29
45
|
acls: number[];
|
|
30
46
|
companies: Company[];
|
package/dist/index.d.ts
CHANGED
|
@@ -2,5 +2,5 @@ export { default as Chat } from './Chat';
|
|
|
2
2
|
export { default as ChatBtn } from './CHAT/ChatBtn';
|
|
3
3
|
export { useChatSocket } from './CHAT/context/ChatSocketContext';
|
|
4
4
|
export { ChatSocketProvider } from './CHAT/provider/ChatSocketProvider';
|
|
5
|
-
export type { ChatParams } from './CHAT/types/types.ts';
|
|
5
|
+
export type { ChatParams, NewSmsResponse, UpdateSmsResponse } from './CHAT/types/types.ts';
|
|
6
6
|
export { default } from './Chat';
|