@rpg-engine/long-bow 0.5.43 → 0.5.44
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 +6 -2
- package/dist/components/ChatRevamp/ChatRevamp.d.ts +5 -3
- package/dist/long-bow.cjs.development.js +18 -5
- 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 +18 -5
- package/dist/long-bow.esm.js.map +1 -1
- package/dist/stories/ChatRevamp.stories.d.ts +2 -1
- package/package.json +2 -2
- package/src/components/Chat/Chat.tsx +8 -10
- package/src/components/ChatRevamp/ChatRevamp.tsx +15 -5
- package/src/components/ChatRevamp/SearchCharacter.tsx +14 -3
- package/src/stories/ChatRevamp.stories.tsx +20 -2
|
@@ -3,4 +3,5 @@ import { IChatRevampProps } from '../components/ChatRevamp/ChatRevamp';
|
|
|
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>;
|
|
6
|
-
export declare const
|
|
6
|
+
export declare const Private: import("@storybook/csf").AnnotatedStoryFn<import("@storybook/react").ReactFramework, IChatRevampProps>;
|
|
7
|
+
export declare const Trade: import("@storybook/csf").AnnotatedStoryFn<import("@storybook/react").ReactFramework, IChatRevampProps>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rpg-engine/long-bow",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.44",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
},
|
|
84
84
|
"dependencies": {
|
|
85
85
|
"@rollup/plugin-image": "^2.1.1",
|
|
86
|
-
"@rpg-engine/shared": "^0.9.
|
|
86
|
+
"@rpg-engine/shared": "^0.9.7",
|
|
87
87
|
"dayjs": "^1.11.2",
|
|
88
88
|
"font-awesome": "^4.7.0",
|
|
89
89
|
"fs-extra": "^10.1.0",
|
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
import { IChatMessage, IPrivateChatMessage } from '@rpg-engine/shared';
|
|
2
1
|
import dayjs from 'dayjs';
|
|
3
2
|
import React, { useEffect, useState } from 'react';
|
|
4
3
|
import { ErrorBoundary } from 'react-error-boundary';
|
|
5
4
|
import { RxPaperPlane } from 'react-icons/rx';
|
|
6
5
|
import styled from 'styled-components';
|
|
6
|
+
import { ChatMessage } from '../ChatRevamp/ChatRevamp';
|
|
7
7
|
import { Column } from '../shared/Column';
|
|
8
8
|
|
|
9
|
-
interface IEmitter {
|
|
10
|
-
_id: string;
|
|
11
|
-
name: string;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
9
|
export interface IStyles {
|
|
15
10
|
textColor?: string;
|
|
16
11
|
buttonColor?: string;
|
|
@@ -19,8 +14,13 @@ export interface IStyles {
|
|
|
19
14
|
height?: string;
|
|
20
15
|
}
|
|
21
16
|
|
|
17
|
+
export interface IEmitter {
|
|
18
|
+
_id: string;
|
|
19
|
+
name: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
22
|
export interface IChatProps {
|
|
23
|
-
chatMessages:
|
|
23
|
+
chatMessages: ChatMessage[];
|
|
24
24
|
onSendChatMessage: (message: string) => void;
|
|
25
25
|
onCloseButton: () => void;
|
|
26
26
|
onFocus?: () => void;
|
|
@@ -80,9 +80,7 @@ export const Chat: React.FC<IChatProps> = ({
|
|
|
80
80
|
} ${message}`;
|
|
81
81
|
};
|
|
82
82
|
|
|
83
|
-
const onRenderChatMessages = (
|
|
84
|
-
chatMessages: (IChatMessage | IPrivateChatMessage)[]
|
|
85
|
-
) => {
|
|
83
|
+
const onRenderChatMessages = (chatMessages: ChatMessage[]) => {
|
|
86
84
|
return chatMessages?.length ? (
|
|
87
85
|
chatMessages?.map((chatMessage, index) => (
|
|
88
86
|
<Message
|
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
ICharacter,
|
|
3
3
|
IChatMessage,
|
|
4
4
|
IPrivateChatMessage,
|
|
5
|
+
ITradeChatMessage,
|
|
5
6
|
} from '@rpg-engine/shared';
|
|
6
7
|
import React, { useEffect, useState } from 'react';
|
|
7
8
|
import { RxCross2, RxMagnifyingGlass } from 'react-icons/rx';
|
|
@@ -13,8 +14,12 @@ import { SearchCharacter } from './SearchCharacter';
|
|
|
13
14
|
|
|
14
15
|
export type PrivateChatCharacter = Pick<ICharacter, '_id' | 'name'>;
|
|
15
16
|
|
|
17
|
+
export type ChatMessage =
|
|
18
|
+
| IChatMessage
|
|
19
|
+
| IPrivateChatMessage
|
|
20
|
+
| ITradeChatMessage;
|
|
16
21
|
export interface IChatRevampProps {
|
|
17
|
-
chatMessages:
|
|
22
|
+
chatMessages: ChatMessage[];
|
|
18
23
|
onSendGlobalChatMessage: (message: string) => void;
|
|
19
24
|
onCloseButton: () => void;
|
|
20
25
|
onFocus?: () => void;
|
|
@@ -32,6 +37,7 @@ export interface IChatRevampProps {
|
|
|
32
37
|
onPreviousChatCharacterClick?: (character: PrivateChatCharacter) => void;
|
|
33
38
|
onRemoveRecentChatCharacter?: (character: PrivateChatCharacter) => void;
|
|
34
39
|
unseenMessageCharacterIds?: string[];
|
|
40
|
+
onSendTradeMessage: (message: string) => void;
|
|
35
41
|
}
|
|
36
42
|
|
|
37
43
|
export const ChatRevamp = ({
|
|
@@ -53,6 +59,7 @@ export const ChatRevamp = ({
|
|
|
53
59
|
onPreviousChatCharacterClick,
|
|
54
60
|
onRemoveRecentChatCharacter,
|
|
55
61
|
unseenMessageCharacterIds = [],
|
|
62
|
+
onSendTradeMessage,
|
|
56
63
|
}: IChatRevampProps) => {
|
|
57
64
|
const [showSearchCharacterUI, setShowSearchCharacterUI] = useState(true);
|
|
58
65
|
const [showRecentChats, setShowRecentChats] = useState(false);
|
|
@@ -62,6 +69,7 @@ export const ChatRevamp = ({
|
|
|
62
69
|
}, [activeTab]);
|
|
63
70
|
|
|
64
71
|
const isPrivate = activeTab === 'private';
|
|
72
|
+
const isTrade = activeTab === 'trade';
|
|
65
73
|
|
|
66
74
|
const handlePreviousChatCharacterClick = (
|
|
67
75
|
character: PrivateChatCharacter
|
|
@@ -92,9 +100,7 @@ export const ChatRevamp = ({
|
|
|
92
100
|
<RecentChatTopBar isOpen={showRecentChats}>
|
|
93
101
|
<BurgerIconContainer
|
|
94
102
|
onPointerDown={() => setShowRecentChats(t => !t)}
|
|
95
|
-
hasUnseenMessages={
|
|
96
|
-
unseenMessageCharacterIds?.length > 0 ? true : false
|
|
97
|
-
}
|
|
103
|
+
hasUnseenMessages={unseenMessageCharacterIds?.length > 0 || false}
|
|
98
104
|
>
|
|
99
105
|
<BurgerLineIcon></BurgerLineIcon>
|
|
100
106
|
<BurgerLineIcon></BurgerLineIcon>
|
|
@@ -149,7 +155,11 @@ export const ChatRevamp = ({
|
|
|
149
155
|
<Chat
|
|
150
156
|
chatMessages={chatMessages}
|
|
151
157
|
onSendChatMessage={
|
|
152
|
-
isPrivate
|
|
158
|
+
isPrivate
|
|
159
|
+
? onSendPrivateChatMessage
|
|
160
|
+
: isTrade
|
|
161
|
+
? onSendTradeMessage
|
|
162
|
+
: onSendGlobalChatMessage
|
|
153
163
|
}
|
|
154
164
|
sendMessage={true}
|
|
155
165
|
onCloseButton={onCloseButton}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
1
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
2
2
|
import { RxMagnifyingGlass } from 'react-icons/rx';
|
|
3
3
|
import styled from 'styled-components';
|
|
4
4
|
import { uiColors } from '../../constants/uiColors';
|
|
@@ -33,6 +33,17 @@ export const SearchCharacter = ({
|
|
|
33
33
|
},
|
|
34
34
|
}: ISearchCharacterProps) => {
|
|
35
35
|
const [characterName, setCharacterName] = useState('');
|
|
36
|
+
const searchCharacterRef = useRef<HTMLInputElement>(null);
|
|
37
|
+
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
const timer = setTimeout(() => {
|
|
40
|
+
if (searchCharacterRef.current) {
|
|
41
|
+
searchCharacterRef.current.focus();
|
|
42
|
+
}
|
|
43
|
+
}, 100);
|
|
44
|
+
|
|
45
|
+
return () => clearTimeout(timer);
|
|
46
|
+
}, []);
|
|
36
47
|
|
|
37
48
|
const handleSubmit = (event: React.SyntheticEvent<HTMLFormElement>) => {
|
|
38
49
|
event.preventDefault();
|
|
@@ -47,7 +58,7 @@ export const SearchCharacter = ({
|
|
|
47
58
|
setCharacterName('');
|
|
48
59
|
onCharacterClick(character);
|
|
49
60
|
setShowSearchCharacter(false);
|
|
50
|
-
};
|
|
61
|
+
};
|
|
51
62
|
|
|
52
63
|
return (
|
|
53
64
|
<SearchContainer>
|
|
@@ -55,6 +66,7 @@ export const SearchCharacter = ({
|
|
|
55
66
|
<Column flex={70}>
|
|
56
67
|
<TextField
|
|
57
68
|
value={characterName}
|
|
69
|
+
ref={searchCharacterRef}
|
|
58
70
|
id="characterName"
|
|
59
71
|
name='characterName'
|
|
60
72
|
onChange={e => {
|
|
@@ -68,7 +80,6 @@ export const SearchCharacter = ({
|
|
|
68
80
|
onFocus={onFocus}
|
|
69
81
|
onBlur={onBlur}
|
|
70
82
|
onPointerDown={onFocus}
|
|
71
|
-
autoFocus
|
|
72
83
|
/>
|
|
73
84
|
</Column>
|
|
74
85
|
<Column justifyContent="flex-end">
|
|
@@ -202,6 +202,7 @@ const chatMessagesMock = [
|
|
|
202
202
|
const tabsMock = [
|
|
203
203
|
{ label: 'Global', id: 'global' },
|
|
204
204
|
{ label: 'Private', id: 'private' },
|
|
205
|
+
{ label: 'Trade', id: 'trade' },
|
|
205
206
|
];
|
|
206
207
|
|
|
207
208
|
const recentPrivateChatCharactersMock = [
|
|
@@ -228,11 +229,12 @@ Default.args = {
|
|
|
228
229
|
activeTab: 'global',
|
|
229
230
|
onChangeTab: () => {},
|
|
230
231
|
onSendPrivateChatMessage: () => {},
|
|
232
|
+
onSendTradeMessage: () => {},
|
|
231
233
|
};
|
|
232
234
|
|
|
233
|
-
export const
|
|
235
|
+
export const Private = Template.bind({});
|
|
234
236
|
|
|
235
|
-
|
|
237
|
+
Private.args = {
|
|
236
238
|
onSendGlobalChatMessage: () => {},
|
|
237
239
|
onChangeCharacterName: () => {},
|
|
238
240
|
chatMessages: chatMessagesMock,
|
|
@@ -246,4 +248,20 @@ PrivateCharacters.args = {
|
|
|
246
248
|
recentChatCharacters: recentPrivateChatCharactersMock,
|
|
247
249
|
recentSelectedChatCharacterId: recentPrivateChatCharactersMock[0]._id,
|
|
248
250
|
unseenMessageCharacterIds: [recentPrivateChatCharactersMock[0]._id],
|
|
251
|
+
onSendTradeMessage: () => {},
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
export const Trade = Template.bind({});
|
|
255
|
+
|
|
256
|
+
Trade.args = {
|
|
257
|
+
onSendGlobalChatMessage: () => {},
|
|
258
|
+
onChangeCharacterName: () => {},
|
|
259
|
+
chatMessages: chatMessagesMock,
|
|
260
|
+
styles: { width: `calc(100% - 0.5rem * 2)`, height: '200px' },
|
|
261
|
+
onCloseButton: () => {},
|
|
262
|
+
tabs: tabsMock,
|
|
263
|
+
privateChatCharacters: recentPrivateChatCharactersMock,
|
|
264
|
+
activeTab: 'trade',
|
|
265
|
+
onChangeTab: () => {},
|
|
266
|
+
onSendTradeMessage: () => {},
|
|
249
267
|
};
|