@rpg-engine/long-bow 0.7.23 → 0.7.25
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/ChatRevamp/RecentChats.d.ts +1 -0
- package/dist/hooks/useChat.d.ts +10 -3
- package/dist/long-bow.cjs.development.js +70 -57
- 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 +70 -57
- package/dist/long-bow.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/ChatRevamp/ChatContent.tsx +15 -13
- package/src/components/ChatRevamp/ChatRevamp.tsx +38 -35
- package/src/components/ChatRevamp/ExpandButton.tsx +1 -1
- package/src/components/ChatRevamp/PrivateChat.tsx +0 -0
- package/src/components/ChatRevamp/RecentChats.tsx +55 -44
- package/src/hooks/useChat.ts +17 -17
- package/src/stories/ChatRevamp.stories.tsx +38 -10
package/package.json
CHANGED
|
@@ -43,6 +43,20 @@ export const ChatContent: React.FC<ChatContentProps> = ({
|
|
|
43
43
|
hideSearchCharacterUI,
|
|
44
44
|
onCharacterClick,
|
|
45
45
|
}) => {
|
|
46
|
+
const handleSendMessage = (message: string) => {
|
|
47
|
+
if (autoCloseOnSend) {
|
|
48
|
+
onCloseButton();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (isPrivate) {
|
|
52
|
+
onSendPrivateChatMessage(message);
|
|
53
|
+
} else if (isTrade) {
|
|
54
|
+
onSendTradeMessage(message);
|
|
55
|
+
} else {
|
|
56
|
+
onSendGlobalChatMessage(message);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
|
|
46
60
|
if (isPrivate && searchCharacterUI) {
|
|
47
61
|
return (
|
|
48
62
|
<SearchCharacter
|
|
@@ -61,19 +75,7 @@ export const ChatContent: React.FC<ChatContentProps> = ({
|
|
|
61
75
|
<ChatWrapper>
|
|
62
76
|
<Chat
|
|
63
77
|
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
|
-
}}
|
|
78
|
+
onSendChatMessage={handleSendMessage}
|
|
77
79
|
sendMessage={true}
|
|
78
80
|
onCloseButton={onCloseButton}
|
|
79
81
|
styles={styles}
|
|
@@ -8,44 +8,40 @@ import { ExpandButton } from './ExpandButton';
|
|
|
8
8
|
import { RecentChats } from './RecentChats';
|
|
9
9
|
import { IChatRevampProps } from './types';
|
|
10
10
|
|
|
11
|
-
export const ChatRevamp: React.FC<IChatRevampProps> =
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
} = props;
|
|
38
|
-
|
|
11
|
+
export const ChatRevamp: React.FC<IChatRevampProps> = ({
|
|
12
|
+
chatMessages,
|
|
13
|
+
onSendGlobalChatMessage,
|
|
14
|
+
onChangeCharacterName,
|
|
15
|
+
onFocus,
|
|
16
|
+
onBlur,
|
|
17
|
+
onCloseButton,
|
|
18
|
+
styles,
|
|
19
|
+
tabs,
|
|
20
|
+
onChangeTab,
|
|
21
|
+
activeTab = 'global',
|
|
22
|
+
privateChatCharacters,
|
|
23
|
+
onCharacterClick,
|
|
24
|
+
onSendPrivateChatMessage,
|
|
25
|
+
recentChatCharacters,
|
|
26
|
+
recentSelectedChatCharacterId,
|
|
27
|
+
onPreviousChatCharacterClick,
|
|
28
|
+
onRemoveRecentChatCharacter,
|
|
29
|
+
unseenMessageCharacterIds,
|
|
30
|
+
onSendTradeMessage,
|
|
31
|
+
searchCharacterUI,
|
|
32
|
+
hideSearchCharacterUI,
|
|
33
|
+
showSearchCharacterUI,
|
|
34
|
+
minimizedByDefault = false,
|
|
35
|
+
autoCloseOnSend,
|
|
36
|
+
}) => {
|
|
39
37
|
const isPrivate = activeTab === 'private';
|
|
40
38
|
const isTrade = activeTab === 'trade';
|
|
41
39
|
|
|
42
40
|
const chatHook = useChat({
|
|
43
|
-
activeTab,
|
|
44
41
|
minimizedByDefault,
|
|
45
42
|
isPrivate,
|
|
46
43
|
onChangeTab,
|
|
47
44
|
onPreviousChatCharacterClick,
|
|
48
|
-
hideSearchCharacterUI,
|
|
49
45
|
unseenMessageCharacterIds,
|
|
50
46
|
});
|
|
51
47
|
|
|
@@ -70,7 +66,7 @@ export const ChatRevamp: React.FC<IChatRevampProps> = props => {
|
|
|
70
66
|
isExpanded={chatHook.isExpanded}
|
|
71
67
|
>
|
|
72
68
|
{chatHook.isExpanded ? (
|
|
73
|
-
|
|
69
|
+
<ExpandedChatContent>
|
|
74
70
|
{isPrivate && (
|
|
75
71
|
<RecentChats
|
|
76
72
|
showRecentChats={chatHook.showRecentChats}
|
|
@@ -80,11 +76,12 @@ export const ChatRevamp: React.FC<IChatRevampProps> = props => {
|
|
|
80
76
|
recentChatCharacters={recentChatCharacters}
|
|
81
77
|
recentSelectedChatCharacterId={recentSelectedChatCharacterId}
|
|
82
78
|
unseenMessageCharacterIds={unseenMessageCharacterIds}
|
|
83
|
-
onPreviousChatCharacterClick={
|
|
84
|
-
chatHook.handlePreviousChatCharacterClick
|
|
79
|
+
onPreviousChatCharacterClick={
|
|
80
|
+
chatHook.handlePreviousChatCharacterClick
|
|
85
81
|
}
|
|
86
82
|
onRemoveRecentChatCharacter={onRemoveRecentChatCharacter}
|
|
87
83
|
isPrivate={isPrivate}
|
|
84
|
+
hideSearchCharacterUI={hideSearchCharacterUI}
|
|
88
85
|
/>
|
|
89
86
|
)}
|
|
90
87
|
<ChatContentWrapper isPrivate={isPrivate}>
|
|
@@ -108,7 +105,7 @@ export const ChatRevamp: React.FC<IChatRevampProps> = props => {
|
|
|
108
105
|
onCharacterClick={onCharacterClick}
|
|
109
106
|
/>
|
|
110
107
|
</ChatContentWrapper>
|
|
111
|
-
|
|
108
|
+
</ExpandedChatContent>
|
|
112
109
|
) : (
|
|
113
110
|
<CollapsedChatInput>
|
|
114
111
|
<Chat
|
|
@@ -162,7 +159,7 @@ const ChatContentWrapper = styled.div<{ isPrivate: boolean }>`
|
|
|
162
159
|
display: flex;
|
|
163
160
|
flex-direction: column;
|
|
164
161
|
position: relative;
|
|
165
|
-
width: ${props => (props.isPrivate ? '
|
|
162
|
+
width: ${props => (props.isPrivate ? '75%' : '100%')};
|
|
166
163
|
`;
|
|
167
164
|
|
|
168
165
|
const CollapsedChatInput = styled.div`
|
|
@@ -171,3 +168,9 @@ const CollapsedChatInput = styled.div`
|
|
|
171
168
|
display: flex;
|
|
172
169
|
align-items: center;
|
|
173
170
|
`;
|
|
171
|
+
|
|
172
|
+
const ExpandedChatContent = styled.div`
|
|
173
|
+
display: flex;
|
|
174
|
+
width: 100%;
|
|
175
|
+
height: 100%;
|
|
176
|
+
`;
|
|
@@ -20,7 +20,7 @@ export const ExpandButton: React.FC<ExpandButtonProps> = ({
|
|
|
20
20
|
const StyledExpandButton = styled.button<{ isExpanded: boolean }>`
|
|
21
21
|
position: absolute;
|
|
22
22
|
top: 0;
|
|
23
|
-
${({ isExpanded }) => (isExpanded ? 'right: 0' : 'left: 0')};
|
|
23
|
+
${({ isExpanded }) => (isExpanded ? 'right: 0' : 'left: 0.5rem')};
|
|
24
24
|
width: 30px;
|
|
25
25
|
height: 30px;
|
|
26
26
|
background-color: ${uiColors.orange};
|
|
File without changes
|
|
@@ -17,6 +17,7 @@ interface IRecentChatsProps {
|
|
|
17
17
|
onPreviousChatCharacterClick: (character: PrivateChatCharacter) => void;
|
|
18
18
|
onRemoveRecentChatCharacter?: (character: PrivateChatCharacter) => void;
|
|
19
19
|
isPrivate: boolean;
|
|
20
|
+
hideSearchCharacterUI: () => void; // Add this line
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
export const RecentChats: React.FC<IRecentChatsProps> = ({
|
|
@@ -30,50 +31,60 @@ export const RecentChats: React.FC<IRecentChatsProps> = ({
|
|
|
30
31
|
onPreviousChatCharacterClick,
|
|
31
32
|
onRemoveRecentChatCharacter,
|
|
32
33
|
isPrivate,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
<
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
>
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
<
|
|
63
|
-
{character.
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
34
|
+
hideSearchCharacterUI, // Add this line
|
|
35
|
+
}) => {
|
|
36
|
+
const handlePreviousChatCharacterClick = (
|
|
37
|
+
character: PrivateChatCharacter
|
|
38
|
+
) => {
|
|
39
|
+
onPreviousChatCharacterClick(character);
|
|
40
|
+
hideSearchCharacterUI(); // Call hideSearchCharacterUI here
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<RecentChatTabContainer isOpen={showRecentChats} isPrivate={isPrivate}>
|
|
45
|
+
<RecentChatTopBar>
|
|
46
|
+
<BurgerIconContainer
|
|
47
|
+
onPointerDown={toggleRecentChats}
|
|
48
|
+
hasUnseenMessages={hasUnseenMessages}
|
|
49
|
+
>
|
|
50
|
+
<BurgerLineIcon />
|
|
51
|
+
<BurgerLineIcon />
|
|
52
|
+
<BurgerLineIcon />
|
|
53
|
+
</BurgerIconContainer>
|
|
54
|
+
{showRecentChats && (
|
|
55
|
+
<SearchButton onPointerDown={showSearchCharacterUI}>
|
|
56
|
+
<RxMagnifyingGlass size={16} color={uiColors.white} />
|
|
57
|
+
</SearchButton>
|
|
58
|
+
)}
|
|
59
|
+
</RecentChatTopBar>
|
|
60
|
+
<RecentChatLogContainer isOpen={showRecentChats}>
|
|
61
|
+
{recentChatCharacters?.map(character => (
|
|
62
|
+
<ListElementContainer key={character._id}>
|
|
63
|
+
<ListElement
|
|
64
|
+
active={character._id === recentSelectedChatCharacterId}
|
|
65
|
+
onPointerDown={() => handlePreviousChatCharacterClick(character)}
|
|
66
|
+
>
|
|
67
|
+
<StatusDot
|
|
68
|
+
isUnseen={
|
|
69
|
+
unseenMessageCharacterIds?.includes(character._id) ?? false
|
|
70
|
+
}
|
|
71
|
+
/>
|
|
72
|
+
<Ellipsis maxWidth="140px" maxLines={1}>
|
|
73
|
+
{character.name}
|
|
74
|
+
</Ellipsis>
|
|
75
|
+
</ListElement>
|
|
76
|
+
<CloseButton
|
|
77
|
+
className="close-button"
|
|
78
|
+
onPointerDown={() => onRemoveRecentChatCharacter?.(character)}
|
|
79
|
+
>
|
|
80
|
+
<RxCross2 size={16} />
|
|
81
|
+
</CloseButton>
|
|
82
|
+
</ListElementContainer>
|
|
83
|
+
))}
|
|
84
|
+
</RecentChatLogContainer>
|
|
85
|
+
</RecentChatTabContainer>
|
|
86
|
+
);
|
|
87
|
+
};
|
|
77
88
|
|
|
78
89
|
const RecentChatTabContainer = styled.div<{
|
|
79
90
|
isPrivate: boolean;
|
package/src/hooks/useChat.ts
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import { useEffect, useState } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
import { PrivateChatCharacter } from '../components/ChatRevamp/types';
|
|
3
|
+
|
|
4
|
+
interface IUseChat {
|
|
5
|
+
minimizedByDefault: boolean;
|
|
6
|
+
isPrivate: boolean;
|
|
7
|
+
onChangeTab: (tabId: string) => void;
|
|
8
|
+
onPreviousChatCharacterClick?: (character: PrivateChatCharacter) => void;
|
|
9
|
+
hideSearchCharacterUI?: () => void;
|
|
10
|
+
unseenMessageCharacterIds?: string[];
|
|
11
|
+
}
|
|
6
12
|
|
|
7
13
|
export const useChat = ({
|
|
8
14
|
minimizedByDefault,
|
|
@@ -11,17 +17,7 @@ export const useChat = ({
|
|
|
11
17
|
onPreviousChatCharacterClick,
|
|
12
18
|
hideSearchCharacterUI,
|
|
13
19
|
unseenMessageCharacterIds,
|
|
14
|
-
}:
|
|
15
|
-
IChatRevampProps,
|
|
16
|
-
| 'activeTab'
|
|
17
|
-
| 'minimizedByDefault'
|
|
18
|
-
| 'onChangeTab'
|
|
19
|
-
| 'onPreviousChatCharacterClick'
|
|
20
|
-
| 'hideSearchCharacterUI'
|
|
21
|
-
| 'unseenMessageCharacterIds'
|
|
22
|
-
> & {
|
|
23
|
-
isPrivate: boolean;
|
|
24
|
-
}) => {
|
|
20
|
+
}: IUseChat) => {
|
|
25
21
|
const [showRecentChats, setShowRecentChats] = useState(false);
|
|
26
22
|
const [isExpanded, setIsExpanded] = useState(!minimizedByDefault);
|
|
27
23
|
|
|
@@ -45,8 +41,12 @@ export const useChat = ({
|
|
|
45
41
|
const handlePreviousChatCharacterClick = (
|
|
46
42
|
character: PrivateChatCharacter
|
|
47
43
|
) => {
|
|
48
|
-
onPreviousChatCharacterClick
|
|
49
|
-
|
|
44
|
+
if (onPreviousChatCharacterClick) {
|
|
45
|
+
onPreviousChatCharacterClick(character);
|
|
46
|
+
}
|
|
47
|
+
if (hideSearchCharacterUI) {
|
|
48
|
+
hideSearchCharacterUI();
|
|
49
|
+
}
|
|
50
50
|
};
|
|
51
51
|
|
|
52
52
|
return {
|
|
@@ -156,23 +156,43 @@ const Template: Story<IChatRevampProps> = args => (
|
|
|
156
156
|
export const Default = Template.bind({});
|
|
157
157
|
|
|
158
158
|
Default.args = {
|
|
159
|
-
onSendGlobalChatMessage:
|
|
160
|
-
|
|
159
|
+
onSendGlobalChatMessage: value => {
|
|
160
|
+
console.log('Sending global chat message:', value);
|
|
161
|
+
},
|
|
162
|
+
onChangeCharacterName: value => {
|
|
163
|
+
console.log('Changing character name to:', value);
|
|
164
|
+
},
|
|
161
165
|
chatMessages: chatMessagesMock,
|
|
162
166
|
styles: { width: `calc(100% - 0.5rem * 2)`, height: '200px' },
|
|
163
|
-
onCloseButton: () =>
|
|
167
|
+
onCloseButton: () => {
|
|
168
|
+
console.log('Closing chat...');
|
|
169
|
+
},
|
|
164
170
|
tabs: tabsMock,
|
|
165
171
|
privateChatCharacters: recentPrivateChatCharactersMock,
|
|
166
172
|
activeTab: 'global',
|
|
167
|
-
onChangeTab:
|
|
168
|
-
|
|
169
|
-
|
|
173
|
+
onChangeTab: tab => {
|
|
174
|
+
console.log('Changing tab to:', tab);
|
|
175
|
+
},
|
|
176
|
+
onSendPrivateChatMessage: value => {
|
|
177
|
+
console.log('Sending private chat message:', value);
|
|
178
|
+
},
|
|
179
|
+
onSendTradeMessage: value => {
|
|
180
|
+
console.log('Sending trade message:', value);
|
|
181
|
+
},
|
|
182
|
+
hideSearchCharacterUI: () => {
|
|
183
|
+
console.log('Hiding search character UI...');
|
|
184
|
+
},
|
|
170
185
|
};
|
|
171
186
|
|
|
172
187
|
export const Private = Template.bind({});
|
|
173
188
|
|
|
174
189
|
Private.args = {
|
|
175
|
-
onSendGlobalChatMessage: () => {
|
|
190
|
+
onSendGlobalChatMessage: () => {
|
|
191
|
+
console.log('Sending private chat message...');
|
|
192
|
+
},
|
|
193
|
+
onSendPrivateChatMessage: () => {
|
|
194
|
+
console.log('Sending private message...');
|
|
195
|
+
},
|
|
176
196
|
onChangeCharacterName: () => {},
|
|
177
197
|
chatMessages: chatMessagesMock,
|
|
178
198
|
styles: { width: `calc(100% - 0.5rem * 2)`, height: '200px' },
|
|
@@ -180,18 +200,26 @@ Private.args = {
|
|
|
180
200
|
tabs: tabsMock,
|
|
181
201
|
privateChatCharacters: recentPrivateChatCharactersMock,
|
|
182
202
|
activeTab: 'private',
|
|
183
|
-
onChangeTab: () => {
|
|
184
|
-
|
|
203
|
+
onChangeTab: () => {
|
|
204
|
+
console.log('Changing tab...');
|
|
205
|
+
},
|
|
185
206
|
recentChatCharacters: recentPrivateChatCharactersMock,
|
|
186
207
|
recentSelectedChatCharacterId: recentPrivateChatCharactersMock[0]._id,
|
|
187
208
|
unseenMessageCharacterIds: [recentPrivateChatCharactersMock[0]._id],
|
|
188
209
|
onSendTradeMessage: () => {},
|
|
210
|
+
searchCharacterUI: false,
|
|
211
|
+
hideSearchCharacterUI: () => {},
|
|
189
212
|
};
|
|
190
213
|
|
|
191
214
|
export const Trade = Template.bind({});
|
|
192
215
|
|
|
193
216
|
Trade.args = {
|
|
194
|
-
onSendGlobalChatMessage: () => {
|
|
217
|
+
onSendGlobalChatMessage: () => {
|
|
218
|
+
console.log('Sending global message...');
|
|
219
|
+
},
|
|
220
|
+
onSendPrivateChatMessage: () => {
|
|
221
|
+
console.log('Sending private message...');
|
|
222
|
+
},
|
|
195
223
|
onChangeCharacterName: () => {},
|
|
196
224
|
chatMessages: chatMessagesMock,
|
|
197
225
|
styles: { width: `calc(100% - 0.5rem * 2)`, height: '200px' },
|