@rpg-engine/long-bow 0.7.22 → 0.7.23
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/components/Chat/Chat.d.ts +1 -1
- package/dist/components/ChatRevamp/ChatContent.d.ts +24 -0
- package/dist/components/ChatRevamp/ChatRevamp.d.ts +1 -33
- package/dist/components/ChatRevamp/ChatTabs.d.ts +11 -0
- package/dist/components/ChatRevamp/ExpandButton.d.ts +7 -0
- package/dist/components/ChatRevamp/RecentChats.d.ts +16 -0
- package/dist/components/ChatRevamp/SearchCharacter.d.ts +1 -1
- package/dist/components/ChatRevamp/types.d.ts +33 -0
- package/dist/hooks/useChat.d.ts +12 -0
- package/dist/long-bow.cjs.development.js +331 -212
- package/dist/long-bow.cjs.development.js.map +1 -1
- package/dist/long-bow.cjs.production.min.js +1 -1
- package/dist/long-bow.cjs.production.min.js.map +1 -1
- package/dist/long-bow.esm.js +331 -212
- package/dist/long-bow.esm.js.map +1 -1
- package/dist/stories/ChatRevamp.stories.d.ts +1 -1
- package/package.json +1 -1
- package/src/components/Chat/Chat.tsx +1 -1
- package/src/components/ChatRevamp/ChatContent.tsx +94 -0
- package/src/components/ChatRevamp/ChatRevamp.tsx +119 -433
- package/src/components/ChatRevamp/ChatTabs.tsx +51 -0
- package/src/components/ChatRevamp/ExpandButton.tsx +40 -0
- package/src/components/ChatRevamp/RecentChats.tsx +239 -0
- package/src/components/ChatRevamp/SearchCharacter.tsx +17 -20
- package/src/components/ChatRevamp/types.ts +41 -0
- package/src/hooks/useChat.ts +62 -0
- package/src/stories/Chat.stories.tsx +1 -0
- package/src/stories/ChatRevamp.stories.tsx +18 -89
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Meta } from '@storybook/react';
|
|
2
|
-
import { IChatRevampProps } from '../components/ChatRevamp/
|
|
2
|
+
import { IChatRevampProps } from '../components/ChatRevamp/types';
|
|
3
3
|
declare const meta: Meta;
|
|
4
4
|
export default meta;
|
|
5
5
|
export declare const Default: import("@storybook/csf").AnnotatedStoryFn<import("@storybook/react").ReactFramework, IChatRevampProps>;
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@ import { ErrorBoundary } from 'react-error-boundary';
|
|
|
4
4
|
import { FaTimes } from 'react-icons/fa';
|
|
5
5
|
import styled from 'styled-components';
|
|
6
6
|
import { uiColors } from '../../constants/uiColors';
|
|
7
|
-
import { ChatMessage } from '../ChatRevamp/
|
|
7
|
+
import { ChatMessage } from '../ChatRevamp/types';
|
|
8
8
|
|
|
9
9
|
export interface IStyles {
|
|
10
10
|
textColor?: string;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
import { Chat, IStyles } from '../Chat/Chat';
|
|
4
|
+
import { SearchCharacter } from './SearchCharacter';
|
|
5
|
+
import { ChatMessage, PrivateChatCharacter } from './types';
|
|
6
|
+
|
|
7
|
+
interface ChatContentProps {
|
|
8
|
+
isPrivate: boolean;
|
|
9
|
+
isTrade: boolean;
|
|
10
|
+
searchCharacterUI: boolean;
|
|
11
|
+
chatMessages: ChatMessage[];
|
|
12
|
+
onSendGlobalChatMessage: (message: string) => void;
|
|
13
|
+
onSendPrivateChatMessage: (message: string) => void;
|
|
14
|
+
onSendTradeMessage: (message: string) => void;
|
|
15
|
+
onCloseButton: () => void;
|
|
16
|
+
styles?: IStyles;
|
|
17
|
+
onFocus?: () => void;
|
|
18
|
+
onBlur?: () => void;
|
|
19
|
+
isExpanded: boolean;
|
|
20
|
+
autoCloseOnSend: boolean;
|
|
21
|
+
onChangeCharacterName: (characterName: string) => void;
|
|
22
|
+
privateChatCharacters?: PrivateChatCharacter[];
|
|
23
|
+
hideSearchCharacterUI: () => void;
|
|
24
|
+
onCharacterClick?: (character: PrivateChatCharacter) => void;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const ChatContent: React.FC<ChatContentProps> = ({
|
|
28
|
+
isPrivate,
|
|
29
|
+
isTrade,
|
|
30
|
+
searchCharacterUI,
|
|
31
|
+
chatMessages,
|
|
32
|
+
onSendGlobalChatMessage,
|
|
33
|
+
onSendPrivateChatMessage,
|
|
34
|
+
onSendTradeMessage,
|
|
35
|
+
onCloseButton,
|
|
36
|
+
styles,
|
|
37
|
+
onFocus,
|
|
38
|
+
onBlur,
|
|
39
|
+
isExpanded,
|
|
40
|
+
autoCloseOnSend,
|
|
41
|
+
onChangeCharacterName,
|
|
42
|
+
privateChatCharacters,
|
|
43
|
+
hideSearchCharacterUI,
|
|
44
|
+
onCharacterClick,
|
|
45
|
+
}) => {
|
|
46
|
+
if (isPrivate && searchCharacterUI) {
|
|
47
|
+
return (
|
|
48
|
+
<SearchCharacter
|
|
49
|
+
onFocus={onFocus}
|
|
50
|
+
onBlur={onBlur}
|
|
51
|
+
onChangeCharacterName={onChangeCharacterName}
|
|
52
|
+
styles={styles}
|
|
53
|
+
recentCharacters={privateChatCharacters}
|
|
54
|
+
hideSearchCharacterUI={hideSearchCharacterUI}
|
|
55
|
+
onCharacterClick={onCharacterClick}
|
|
56
|
+
/>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<ChatWrapper>
|
|
62
|
+
<Chat
|
|
63
|
+
chatMessages={chatMessages}
|
|
64
|
+
onSendChatMessage={() => {
|
|
65
|
+
if (autoCloseOnSend) {
|
|
66
|
+
onCloseButton();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (isPrivate) {
|
|
70
|
+
return onSendPrivateChatMessage;
|
|
71
|
+
} else if (isTrade) {
|
|
72
|
+
return onSendTradeMessage;
|
|
73
|
+
} else {
|
|
74
|
+
return onSendGlobalChatMessage;
|
|
75
|
+
}
|
|
76
|
+
}}
|
|
77
|
+
sendMessage={true}
|
|
78
|
+
onCloseButton={onCloseButton}
|
|
79
|
+
styles={styles}
|
|
80
|
+
onFocus={onFocus}
|
|
81
|
+
onBlur={onBlur}
|
|
82
|
+
isExpanded={isExpanded}
|
|
83
|
+
/>
|
|
84
|
+
</ChatWrapper>
|
|
85
|
+
);
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const ChatWrapper = styled.div`
|
|
89
|
+
flex-grow: 1;
|
|
90
|
+
overflow: hidden;
|
|
91
|
+
display: flex;
|
|
92
|
+
flex-direction: column;
|
|
93
|
+
position: relative;
|
|
94
|
+
`;
|