@webinex/chatify 1.0.0-alpha06 → 1.0.0-alpha07
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/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/ui/Chatify.d.ts +3 -3
- package/dist/cjs/types/ui/Message.d.ts +10 -10
- package/dist/cjs/types/ui/index.d.ts +2 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/ui/Chatify.d.ts +3 -3
- package/dist/esm/types/ui/Message.d.ts +10 -10
- package/dist/esm/types/ui/index.d.ts +2 -0
- package/dist/index.d.ts +37 -29
- package/package.json +1 -1
- package/src/ui/ChatBody.tsx +2 -2
- package/src/ui/Chatify.tsx +3 -3
- package/src/ui/Message.tsx +13 -12
- package/src/ui/index.ts +2 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import React$1, { PropsWithChildren, FC, Ref, RefObject, CSSProperties } from 'react';
|
|
2
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
4
|
import { AxiosInstance } from 'axios';
|
|
4
5
|
|
|
@@ -8,29 +9,29 @@ interface Localizer {
|
|
|
8
9
|
chatCreated: () => string;
|
|
9
10
|
};
|
|
10
11
|
message: {
|
|
11
|
-
read: () => React.ReactNode;
|
|
12
|
-
reading: () => React.ReactNode;
|
|
13
|
-
sending: () => React.ReactNode;
|
|
12
|
+
read: () => React$1.ReactNode;
|
|
13
|
+
reading: () => React$1.ReactNode;
|
|
14
|
+
sending: () => React$1.ReactNode;
|
|
14
15
|
};
|
|
15
16
|
addChat: {
|
|
16
|
-
title: () => React.ReactNode;
|
|
17
|
+
title: () => React$1.ReactNode;
|
|
17
18
|
name: {
|
|
18
|
-
label: () => React.ReactNode;
|
|
19
|
+
label: () => React$1.ReactNode;
|
|
19
20
|
required: () => string;
|
|
20
21
|
max250: () => string;
|
|
21
22
|
};
|
|
22
23
|
members: {
|
|
23
|
-
label: () => React.ReactNode;
|
|
24
|
+
label: () => React$1.ReactNode;
|
|
24
25
|
required: () => string;
|
|
25
26
|
};
|
|
26
|
-
submitBtn: () => React.ReactNode;
|
|
27
|
+
submitBtn: () => React$1.ReactNode;
|
|
27
28
|
};
|
|
28
29
|
}
|
|
29
|
-
declare const LocalizerContext: React.Context<Localizer>;
|
|
30
|
+
declare const LocalizerContext: React$1.Context<Localizer>;
|
|
30
31
|
declare function useLocalizer(): Localizer;
|
|
31
32
|
declare const defaultLocalizer: Localizer;
|
|
32
33
|
|
|
33
|
-
type Customizable<TComponent extends React.ComponentType<any>, TKey extends string> = TComponent & {
|
|
34
|
+
type Customizable<TComponent extends React$1.ComponentType<any>, TKey extends string> = TComponent & {
|
|
34
35
|
Component: TComponent;
|
|
35
36
|
key: TKey;
|
|
36
37
|
};
|
|
@@ -45,7 +46,7 @@ interface Account {
|
|
|
45
46
|
name: string;
|
|
46
47
|
avatar: string;
|
|
47
48
|
}
|
|
48
|
-
interface Message
|
|
49
|
+
interface Message {
|
|
49
50
|
id: string;
|
|
50
51
|
chatId: string;
|
|
51
52
|
text: string;
|
|
@@ -63,7 +64,7 @@ interface Chat {
|
|
|
63
64
|
interface ChatListItem {
|
|
64
65
|
id: string;
|
|
65
66
|
name: string;
|
|
66
|
-
message: Message
|
|
67
|
+
message: Message;
|
|
67
68
|
unreadCount: number;
|
|
68
69
|
}
|
|
69
70
|
interface SendMessageRequest {
|
|
@@ -127,7 +128,7 @@ declare class ChatifyClient {
|
|
|
127
128
|
chatId: string;
|
|
128
129
|
skip?: number;
|
|
129
130
|
take?: number;
|
|
130
|
-
}) => Promise<Message
|
|
131
|
+
}) => Promise<Message[]>;
|
|
131
132
|
send: (request: SendMessageRequest) => Promise<void>;
|
|
132
133
|
read: (request: ReadRequest) => Promise<void>;
|
|
133
134
|
removeMember: (request: RemoveMemberRequest) => Promise<void>;
|
|
@@ -192,7 +193,7 @@ declare const ACTIONS: {
|
|
|
192
193
|
chatId: string;
|
|
193
194
|
}) => State;
|
|
194
195
|
message_received: (state: State, { message, requestId }: {
|
|
195
|
-
message: Message
|
|
196
|
+
message: Message;
|
|
196
197
|
requestId: string;
|
|
197
198
|
}) => State;
|
|
198
199
|
chat_created: (state: State, { chat }: {
|
|
@@ -233,10 +234,10 @@ type Action = {
|
|
|
233
234
|
|
|
234
235
|
type Reducer = ReturnType<typeof useReducer>;
|
|
235
236
|
type Subscriber = (state: State) => void;
|
|
236
|
-
declare function useReducer(): readonly [React.MutableRefObject<State>, (action: Action) => void, (subscriber: Subscriber) => () => void];
|
|
237
|
+
declare function useReducer(): readonly [React$1.MutableRefObject<State>, (action: Action) => void, (subscriber: Subscriber) => () => void];
|
|
237
238
|
declare function ReducerProvider({ children }: PropsWithChildren<{}>): react_jsx_runtime.JSX.Element;
|
|
238
239
|
declare function useDispatch(): (action: Action) => void;
|
|
239
|
-
declare function useStateRef(): React.MutableRefObject<State>;
|
|
240
|
+
declare function useStateRef(): React$1.MutableRefObject<State>;
|
|
240
241
|
declare function useSelect<TResult>(select: (state: State) => TResult, deps: any[]): TResult;
|
|
241
242
|
|
|
242
243
|
declare function useChat(args: {
|
|
@@ -251,7 +252,7 @@ declare function useLoadMore({ chatId }: {
|
|
|
251
252
|
|
|
252
253
|
type MessageState = ({
|
|
253
254
|
type: 'message';
|
|
254
|
-
} & Message
|
|
255
|
+
} & Message) | {
|
|
255
256
|
type: 'more';
|
|
256
257
|
} | {
|
|
257
258
|
type: 'sending';
|
|
@@ -320,19 +321,19 @@ declare const SendingMessageInfoBox: Customizable<FC<SendingMessageProps>, strin
|
|
|
320
321
|
declare const SendingMessageBody: Customizable<FC<SendingMessageProps>, string>;
|
|
321
322
|
declare const SendingMessage: Customizable<FC<SendingMessageProps>, string>;
|
|
322
323
|
|
|
323
|
-
interface
|
|
324
|
-
message: Message
|
|
324
|
+
interface MessageBoxProps {
|
|
325
|
+
message: Message;
|
|
325
326
|
}
|
|
326
|
-
interface
|
|
327
|
+
interface MessageRowProps extends MessageBoxProps {
|
|
327
328
|
containerRef?: Ref<HTMLDivElement>;
|
|
328
329
|
}
|
|
329
|
-
declare const MessageAuthor: Customizable<FC<
|
|
330
|
-
declare const MessageText: Customizable<FC<
|
|
331
|
-
declare const MessageInfoBox: Customizable<FC<
|
|
332
|
-
declare const MessageBody: Customizable<FC<
|
|
330
|
+
declare const MessageAuthor: Customizable<FC<MessageBoxProps>, string>;
|
|
331
|
+
declare const MessageText: Customizable<FC<MessageBoxProps>, string>;
|
|
332
|
+
declare const MessageInfoBox: Customizable<FC<MessageBoxProps>, string>;
|
|
333
|
+
declare const MessageBody: Customizable<FC<MessageBoxProps>, string>;
|
|
334
|
+
declare const MessageRow: Customizable<FC<MessageRowProps>, string>;
|
|
333
335
|
declare const MessageBox: Customizable<FC<MessageBoxProps>, string>;
|
|
334
|
-
|
|
335
|
-
interface MessageReadObserverProps extends MessageProps {
|
|
336
|
+
interface MessageReadObserverProps extends MessageBoxProps {
|
|
336
337
|
messageRef: RefObject<HTMLDivElement | null>;
|
|
337
338
|
}
|
|
338
339
|
declare const MessageReadObserver: Customizable<FC<MessageReadObserverProps>, string>;
|
|
@@ -355,9 +356,9 @@ interface ChatifyCustomizeValue {
|
|
|
355
356
|
SendingMessageBody?: typeof SendingMessageBody.Component | null;
|
|
356
357
|
SendingMessageInfoBox?: typeof SendingMessageInfoBox.Component | null;
|
|
357
358
|
SendingMessageText?: typeof SendingMessageText.Component | null;
|
|
358
|
-
Message?: typeof Message.Component | null;
|
|
359
|
-
MessageReadObserver?: typeof MessageReadObserver.Component | null;
|
|
360
359
|
MessageBox?: typeof MessageBox.Component | null;
|
|
360
|
+
MessageReadObserver?: typeof MessageReadObserver.Component | null;
|
|
361
|
+
MessageRow?: typeof MessageRow.Component | null;
|
|
361
362
|
MessageBody?: typeof MessageBody.Component | null;
|
|
362
363
|
MessageInfoBox?: typeof MessageInfoBox.Component | null;
|
|
363
364
|
MessageText?: typeof MessageText.Component | null;
|
|
@@ -376,6 +377,13 @@ interface ChatHeaderProps {
|
|
|
376
377
|
}
|
|
377
378
|
declare function ChatHeader(props: ChatHeaderProps): react_jsx_runtime.JSX.Element;
|
|
378
379
|
|
|
380
|
+
interface SystemMessageProps {
|
|
381
|
+
text: string;
|
|
382
|
+
sentAt: string;
|
|
383
|
+
}
|
|
384
|
+
declare function formatSystemMessage(localizer: Localizer, text: string): React.ReactNode;
|
|
385
|
+
declare function SystemMessage(props: SystemMessageProps): react_jsx_runtime.JSX.Element;
|
|
386
|
+
|
|
379
387
|
declare function useClient(): ChatifyClient;
|
|
380
388
|
declare function useMe(): string;
|
|
381
389
|
interface ChatifyContextValue {
|
|
@@ -386,4 +394,4 @@ declare function ChatifyContext({ value, children }: PropsWithChildren<{
|
|
|
386
394
|
value: ChatifyContextValue;
|
|
387
395
|
}>): react_jsx_runtime.JSX.Element;
|
|
388
396
|
|
|
389
|
-
export { ACTIONS, Account, Action, AddChatButton, AddChatRequest, AddMemberRequest, Avatar, AvatarProps, Chat, ChatHeader, ChatHeaderMembers, ChatHeaderMembersProps, ChatHeaderProps, ChatListItem, ChatListItemBox, ChatListItemBoxProps, ChatListItemLastMessage, ChatListItemLastMessageAuthor, ChatListItemLastMessageContent, ChatListItemName, ChatListItemUnreadCount, Chatify, ChatifyClient, ChatifyClientConfig, ChatifyContext, ChatifyContextValue, ChatifyCustomizeValue, ChatifyProps, ChatifySignalRConfig, File, Header, Localizer, LocalizerContext, Message
|
|
397
|
+
export { ACTIONS, Account, Action, AddChatButton, AddChatRequest, AddMemberRequest, Avatar, AvatarProps, Chat, ChatHeader, ChatHeaderMembers, ChatHeaderMembersProps, ChatHeaderProps, ChatListItem, ChatListItemBox, ChatListItemBoxProps, ChatListItemLastMessage, ChatListItemLastMessageAuthor, ChatListItemLastMessageContent, ChatListItemName, ChatListItemUnreadCount, Chatify, ChatifyClient, ChatifyClientConfig, ChatifyContext, ChatifyContextValue, ChatifyCustomizeValue, ChatifyProps, ChatifySignalRConfig, File, Header, Localizer, LocalizerContext, Message, MessageAuthor, MessageBody, MessageBox, MessageBoxProps, MessageContent, MessageInfoBox, MessageReadObserver, MessageReadObserverProps, MessageRow, MessageRowProps, MessageState, MessageText, ReadEvent, ReadRequest, Reducer, ReducerProvider, RemoveMemberRequest, SendMessageRequest, SystemMessage, SystemMessageProps, defaultLocalizer, formatSystemMessage, useAccounts, useAddChat, useAddMember, useChat, useChatList, useClient, useDispatch, useLoadMore, useLocalizer, useMe, useMessages, useReadMonitor, useReducer, useRemoveMember, useSelect, useSignalRMonitor, useStateRef };
|
package/package.json
CHANGED
package/src/ui/ChatBody.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MessageBox } from './Message';
|
|
2
2
|
import { useMessages } from '../core';
|
|
3
3
|
import { LoadMore } from './LoadMore';
|
|
4
4
|
import { SendingMessage } from './SendingMessage';
|
|
@@ -23,7 +23,7 @@ export function ChatBody(props: ChatBodyProps) {
|
|
|
23
23
|
|
|
24
24
|
switch (x.type) {
|
|
25
25
|
case 'message': {
|
|
26
|
-
return <
|
|
26
|
+
return <MessageBox message={x} key={x.id} />;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
case 'sending': {
|
package/src/ui/Chatify.tsx
CHANGED
|
@@ -26,12 +26,12 @@ import {
|
|
|
26
26
|
SendingMessageText,
|
|
27
27
|
} from './SendingMessage';
|
|
28
28
|
import {
|
|
29
|
-
Message,
|
|
30
29
|
MessageAuthor,
|
|
31
30
|
MessageBody,
|
|
32
31
|
MessageBox,
|
|
33
32
|
MessageInfoBox,
|
|
34
33
|
MessageReadObserver,
|
|
34
|
+
MessageRow,
|
|
35
35
|
MessageText,
|
|
36
36
|
} from './Message';
|
|
37
37
|
|
|
@@ -53,9 +53,9 @@ export interface ChatifyCustomizeValue {
|
|
|
53
53
|
SendingMessageBody?: typeof SendingMessageBody.Component | null;
|
|
54
54
|
SendingMessageInfoBox?: typeof SendingMessageInfoBox.Component | null;
|
|
55
55
|
SendingMessageText?: typeof SendingMessageText.Component | null;
|
|
56
|
-
Message?: typeof Message.Component | null;
|
|
57
|
-
MessageReadObserver?: typeof MessageReadObserver.Component | null;
|
|
58
56
|
MessageBox?: typeof MessageBox.Component | null;
|
|
57
|
+
MessageReadObserver?: typeof MessageReadObserver.Component | null;
|
|
58
|
+
MessageRow?: typeof MessageRow.Component | null;
|
|
59
59
|
MessageBody?: typeof MessageBody.Component | null;
|
|
60
60
|
MessageInfoBox?: typeof MessageInfoBox.Component | null;
|
|
61
61
|
MessageText?: typeof MessageText.Component | null;
|
package/src/ui/Message.tsx
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { useMe } from '../ChatifyContext';
|
|
2
2
|
import { FC, Ref, RefObject, useEffect, useMemo, useRef } from 'react';
|
|
3
|
-
import { useDispatch, useSelect
|
|
3
|
+
import { Message, useDispatch, useSelect } from '../core';
|
|
4
4
|
import { customize } from '../util';
|
|
5
5
|
import { useLocalizer } from './localizer';
|
|
6
6
|
import { Avatar } from './Avatar';
|
|
7
7
|
|
|
8
|
-
export interface
|
|
9
|
-
message:
|
|
8
|
+
export interface MessageBoxProps {
|
|
9
|
+
message: Message;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
export interface
|
|
12
|
+
export interface MessageRowProps extends MessageBoxProps {
|
|
13
13
|
containerRef?: Ref<HTMLDivElement>;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
export const MessageAuthor = customize<FC<
|
|
16
|
+
export const MessageAuthor = customize<FC<MessageBoxProps>, string>('MessageAuthor', (props) => {
|
|
17
17
|
const { sentBy } = props.message;
|
|
18
18
|
|
|
19
19
|
return (
|
|
@@ -23,12 +23,12 @@ export const MessageAuthor = customize<FC<MessageProps>, string>('MessageAuthor'
|
|
|
23
23
|
);
|
|
24
24
|
});
|
|
25
25
|
|
|
26
|
-
export const MessageText = customize<FC<
|
|
26
|
+
export const MessageText = customize<FC<MessageBoxProps>, string>('MessageText', (props) => {
|
|
27
27
|
const { text } = props.message;
|
|
28
28
|
return <div className="wxchtf-message-text">{text}</div>;
|
|
29
29
|
});
|
|
30
30
|
|
|
31
|
-
export const MessageInfoBox = customize<FC<
|
|
31
|
+
export const MessageInfoBox = customize<FC<MessageBoxProps>, string>('MessageInfoBox', (props) => {
|
|
32
32
|
const { message } = props;
|
|
33
33
|
const { id, sentBy, sentAt, read } = message;
|
|
34
34
|
const me = useMe();
|
|
@@ -48,7 +48,7 @@ export const MessageInfoBox = customize<FC<MessageProps>, string>('MessageInfoBo
|
|
|
48
48
|
);
|
|
49
49
|
});
|
|
50
50
|
|
|
51
|
-
export const MessageBody = customize<FC<
|
|
51
|
+
export const MessageBody = customize<FC<MessageBoxProps>, string>('MessageBody', (props) => {
|
|
52
52
|
return (
|
|
53
53
|
<div className="wxchtf-message-body">
|
|
54
54
|
<MessageText {...props} />
|
|
@@ -57,7 +57,7 @@ export const MessageBody = customize<FC<MessageProps>, string>('MessageBody', (p
|
|
|
57
57
|
);
|
|
58
58
|
});
|
|
59
59
|
|
|
60
|
-
export const
|
|
60
|
+
export const MessageRow = customize<FC<MessageRowProps>, string>('MessageRow', (props) => {
|
|
61
61
|
const { message, containerRef } = props;
|
|
62
62
|
const { sentBy } = message;
|
|
63
63
|
const me = useMe();
|
|
@@ -71,20 +71,21 @@ export const MessageBox = customize<FC<MessageBoxProps>, string>('MessageBox', (
|
|
|
71
71
|
);
|
|
72
72
|
});
|
|
73
73
|
|
|
74
|
-
export const
|
|
74
|
+
export const MessageBox = customize<FC<MessageBoxProps>, string>('MessageBox', (props) => {
|
|
75
75
|
const ref = useRef<HTMLDivElement | null>(null);
|
|
76
76
|
|
|
77
77
|
return (
|
|
78
78
|
<>
|
|
79
79
|
<MessageReadObserver messageRef={ref} {...props} />
|
|
80
|
-
<
|
|
80
|
+
<MessageRow containerRef={ref} {...props} />
|
|
81
81
|
</>
|
|
82
82
|
);
|
|
83
83
|
});
|
|
84
84
|
|
|
85
|
-
export interface MessageReadObserverProps extends
|
|
85
|
+
export interface MessageReadObserverProps extends MessageBoxProps {
|
|
86
86
|
messageRef: RefObject<HTMLDivElement | null>;
|
|
87
87
|
}
|
|
88
|
+
|
|
88
89
|
export const MessageReadObserver = customize<FC<MessageReadObserverProps>, string>(
|
|
89
90
|
'MessageReadObserver',
|
|
90
91
|
(props) => {
|