@rpg-engine/long-bow 0.6.88 → 0.6.90
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/SearchCharacter.d.ts +5 -5
- package/dist/long-bow.cjs.development.js +83 -132
- 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 +83 -132
- package/dist/long-bow.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/ChatRevamp/SearchCharacter.tsx +89 -183
package/package.json
CHANGED
|
@@ -1,23 +1,24 @@
|
|
|
1
|
-
import { ICharacter } from '@rpg-engine/shared/dist/types/character.types';
|
|
2
1
|
import React, { useEffect, useRef, useState } from 'react';
|
|
3
|
-
import {
|
|
2
|
+
import { RxMagnifyingGlass } from 'react-icons/rx';
|
|
4
3
|
import styled from 'styled-components';
|
|
5
4
|
import { uiColors } from '../../constants/uiColors';
|
|
6
5
|
import { uiFonts } from '../../constants/uiFonts';
|
|
7
6
|
import { IStyles } from '../Chat/Chat';
|
|
7
|
+
import { Column } from '../shared/Column';
|
|
8
8
|
import { Ellipsis } from '../shared/Ellipsis';
|
|
9
|
+
import type { PrivateChatCharacter } from './ChatRevamp';
|
|
9
10
|
|
|
10
11
|
interface ISearchCharacterProps {
|
|
11
12
|
onFocus?: () => void;
|
|
12
13
|
onBlur?: () => void;
|
|
13
14
|
onChangeCharacterName: (characterName: string) => void;
|
|
14
15
|
styles?: IStyles;
|
|
15
|
-
recentCharacters?:
|
|
16
|
-
onCharacterClick?: (character:
|
|
16
|
+
recentCharacters?: PrivateChatCharacter[];
|
|
17
|
+
onCharacterClick?: (character: PrivateChatCharacter) => void;
|
|
17
18
|
hideSearchCharacterUI: () => void;
|
|
18
19
|
}
|
|
19
20
|
|
|
20
|
-
export const SearchCharacter
|
|
21
|
+
export const SearchCharacter = ({
|
|
21
22
|
onChangeCharacterName,
|
|
22
23
|
onBlur,
|
|
23
24
|
onFocus,
|
|
@@ -25,241 +26,146 @@ export const SearchCharacter: React.FC<ISearchCharacterProps> = ({
|
|
|
25
26
|
hideSearchCharacterUI,
|
|
26
27
|
onCharacterClick,
|
|
27
28
|
styles = {
|
|
28
|
-
textColor:
|
|
29
|
-
buttonColor:
|
|
30
|
-
buttonBackgroundColor:
|
|
31
|
-
width: '
|
|
29
|
+
textColor: '#c65102',
|
|
30
|
+
buttonColor: '#005b96',
|
|
31
|
+
buttonBackgroundColor: 'rgba(0,0,0,.2)',
|
|
32
|
+
width: '80%',
|
|
32
33
|
height: 'auto',
|
|
33
34
|
},
|
|
34
|
-
}) => {
|
|
35
|
+
}: ISearchCharacterProps) => {
|
|
35
36
|
const [characterName, setCharacterName] = useState('');
|
|
36
|
-
const [isFocused, setIsFocused] = useState(false);
|
|
37
37
|
const searchCharacterRef = useRef<HTMLInputElement>(null);
|
|
38
38
|
|
|
39
39
|
useEffect(() => {
|
|
40
|
-
|
|
41
|
-
searchCharacterRef.current
|
|
42
|
-
|
|
40
|
+
const timer = setTimeout(() => {
|
|
41
|
+
if (searchCharacterRef.current) {
|
|
42
|
+
searchCharacterRef.current.focus();
|
|
43
|
+
}
|
|
44
|
+
}, 100);
|
|
45
|
+
|
|
46
|
+
return () => clearTimeout(timer);
|
|
43
47
|
}, []);
|
|
44
48
|
|
|
45
|
-
const handleSubmit = (event: React.
|
|
49
|
+
const handleSubmit = (event: React.SyntheticEvent<HTMLFormElement>) => {
|
|
46
50
|
event.preventDefault();
|
|
47
|
-
if (!characterName.trim()) return;
|
|
51
|
+
if (!characterName || characterName.trim() === '') return;
|
|
48
52
|
onChangeCharacterName(characterName);
|
|
49
53
|
};
|
|
50
54
|
|
|
51
|
-
const handleCharacterClick = (
|
|
55
|
+
const handleCharacterClick = (
|
|
56
|
+
character: PrivateChatCharacter
|
|
57
|
+
) => {
|
|
52
58
|
if (!onCharacterClick) return;
|
|
53
59
|
setCharacterName('');
|
|
54
60
|
onCharacterClick(character);
|
|
55
61
|
hideSearchCharacterUI();
|
|
56
62
|
};
|
|
57
63
|
|
|
58
|
-
const handleFocus = () => {
|
|
59
|
-
setIsFocused(true);
|
|
60
|
-
onFocus?.();
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
const handleBlur = () => {
|
|
64
|
-
setIsFocused(false);
|
|
65
|
-
onBlur?.();
|
|
66
|
-
};
|
|
67
|
-
|
|
68
64
|
return (
|
|
69
|
-
<SearchContainer
|
|
65
|
+
<SearchContainer>
|
|
70
66
|
<Form onSubmit={handleSubmit}>
|
|
71
|
-
<
|
|
72
|
-
<SearchIcon>
|
|
73
|
-
<RxMagnifyingGlass />
|
|
74
|
-
</SearchIcon>
|
|
67
|
+
<Column flex={70}>
|
|
75
68
|
<TextField
|
|
76
69
|
value={characterName}
|
|
77
70
|
ref={searchCharacterRef}
|
|
71
|
+
id="characterName"
|
|
72
|
+
name='characterName'
|
|
78
73
|
onChange={e => {
|
|
79
74
|
setCharacterName(e.target.value);
|
|
80
75
|
onChangeCharacterName(e.target.value);
|
|
81
76
|
}}
|
|
82
|
-
placeholder=
|
|
77
|
+
placeholder='Search for a character...'
|
|
78
|
+
height={20}
|
|
83
79
|
type="text"
|
|
84
80
|
autoComplete="off"
|
|
85
|
-
onFocus={
|
|
86
|
-
onBlur={
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
81
|
+
onFocus={onFocus}
|
|
82
|
+
onBlur={onBlur}
|
|
83
|
+
onPointerDown={onFocus}
|
|
84
|
+
/>
|
|
85
|
+
</Column>
|
|
86
|
+
<Column justifyContent="flex-end">
|
|
87
|
+
<SearchButton
|
|
88
|
+
type='submit'
|
|
89
|
+
buttonColor={styles?.buttonColor || '#005b96'}
|
|
90
|
+
buttonBackgroundColor={
|
|
91
|
+
styles?.buttonBackgroundColor || 'rgba(0,0,0,.5)'
|
|
92
|
+
}
|
|
93
|
+
id="chat-send-button"
|
|
94
|
+
style={{ borderRadius: '20%' }}
|
|
95
|
+
>
|
|
96
|
+
<RxMagnifyingGlass size={15} />
|
|
97
|
+
</SearchButton>
|
|
98
|
+
</Column>
|
|
101
99
|
</Form>
|
|
102
100
|
|
|
103
101
|
{recentCharacters && recentCharacters.length > 0 && (
|
|
104
|
-
<
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
alt={character.name}
|
|
115
|
-
/>
|
|
116
|
-
<CharacterInfo>
|
|
117
|
-
<CharacterName>
|
|
118
|
-
<Ellipsis maxLines={1} maxWidth="150px">
|
|
119
|
-
{character.name}
|
|
120
|
-
</Ellipsis>
|
|
121
|
-
</CharacterName>
|
|
122
|
-
<CharacterDescription>
|
|
123
|
-
<Ellipsis
|
|
124
|
-
maxLines={1}
|
|
125
|
-
maxWidth="150px"
|
|
126
|
-
>{`Class: ${character.class}, Level: ${character.skills.level}`}</Ellipsis>
|
|
127
|
-
</CharacterDescription>
|
|
128
|
-
</CharacterInfo>
|
|
129
|
-
</ResultItem>
|
|
130
|
-
))}
|
|
131
|
-
</ResultsList>
|
|
132
|
-
</ResultsContainer>
|
|
102
|
+
<ListContainer>
|
|
103
|
+
{recentCharacters.map(character => (
|
|
104
|
+
<ListElement onPointerDown={() => handleCharacterClick(character)} key={character._id}>
|
|
105
|
+
<Ellipsis
|
|
106
|
+
maxWidth='150px'
|
|
107
|
+
maxLines={1}
|
|
108
|
+
>{character.name}</Ellipsis>
|
|
109
|
+
</ListElement>
|
|
110
|
+
))}
|
|
111
|
+
</ListContainer>
|
|
133
112
|
)}
|
|
134
|
-
|
|
113
|
+
</SearchContainer>
|
|
135
114
|
);
|
|
136
115
|
};
|
|
137
116
|
|
|
138
|
-
const SearchContainer = styled.div<{ width: string }>`
|
|
139
|
-
width: ${({ width }) => width};
|
|
140
|
-
max-width: 600px;
|
|
141
|
-
margin: 0 auto;
|
|
142
|
-
`;
|
|
143
117
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
118
|
+
interface IButtonProps {
|
|
119
|
+
buttonColor: string;
|
|
120
|
+
buttonBackgroundColor: string;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const SearchContainer = styled.div`
|
|
124
|
+
width: 100%;
|
|
125
|
+
`
|
|
149
126
|
|
|
150
|
-
const
|
|
151
|
-
position: relative;
|
|
152
|
-
flex-grow: 1;
|
|
127
|
+
const Form = styled.form`
|
|
153
128
|
display: flex;
|
|
129
|
+
width: 100%;
|
|
130
|
+
justify-content: center;
|
|
154
131
|
align-items: center;
|
|
155
|
-
background-color: ${uiColors.raisinBlack};
|
|
156
|
-
border-radius: 24px;
|
|
157
|
-
padding: 8px 16px;
|
|
158
|
-
transition: all 0.3s ease;
|
|
159
|
-
box-shadow: ${({ isFocused }) =>
|
|
160
|
-
isFocused ? `0 0 0 2px ${uiColors.orange}` : 'none'};
|
|
161
|
-
`;
|
|
162
|
-
|
|
163
|
-
const SearchIcon = styled.span`
|
|
164
|
-
color: ${uiColors.gray};
|
|
165
|
-
margin-right: 8px;
|
|
166
132
|
`;
|
|
167
133
|
|
|
168
134
|
const TextField = styled.input`
|
|
169
135
|
width: 100%;
|
|
170
|
-
background-color:
|
|
171
|
-
border: none;
|
|
172
|
-
|
|
173
|
-
font-size: ${uiFonts.size.medium};
|
|
174
|
-
outline: none;
|
|
175
|
-
|
|
176
|
-
&::placeholder {
|
|
177
|
-
color: ${uiColors.gray};
|
|
178
|
-
}
|
|
136
|
+
background-color: rgba(0, 0, 0, 0.25) !important;
|
|
137
|
+
border: none !important;
|
|
138
|
+
max-height: 28px !important;
|
|
179
139
|
`;
|
|
180
140
|
|
|
181
|
-
const
|
|
182
|
-
background: none;
|
|
183
|
-
border: none;
|
|
184
|
-
color: ${uiColors.gray};
|
|
185
|
-
cursor: pointer;
|
|
186
|
-
padding: 0;
|
|
187
|
-
display: flex;
|
|
188
|
-
align-items: center;
|
|
189
|
-
justify-content: center;
|
|
190
|
-
`;
|
|
191
|
-
|
|
192
|
-
const SearchButton = styled.button<{
|
|
193
|
-
buttonColor: string;
|
|
194
|
-
buttonBackgroundColor: string;
|
|
195
|
-
}>`
|
|
196
|
-
background-color: ${({ buttonBackgroundColor }) => buttonBackgroundColor};
|
|
141
|
+
const SearchButton = styled.button<IButtonProps>`
|
|
197
142
|
color: ${({ buttonColor }) => buttonColor};
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
font-weight: bold;
|
|
203
|
-
cursor: pointer;
|
|
204
|
-
transition: all 0.3s ease;
|
|
205
|
-
|
|
206
|
-
&:hover {
|
|
207
|
-
background-color: ${uiColors.orange};
|
|
208
|
-
color: ${uiColors.white};
|
|
209
|
-
}
|
|
210
|
-
`;
|
|
211
|
-
|
|
212
|
-
const ResultsContainer = styled.div`
|
|
213
|
-
background-color: ${uiColors.raisinBlack};
|
|
214
|
-
border-radius: 8px;
|
|
215
|
-
padding: 16px;
|
|
216
|
-
`;
|
|
217
|
-
|
|
218
|
-
const ResultsTitle = styled.h3`
|
|
219
|
-
color: ${uiColors.white};
|
|
220
|
-
font-size: ${uiFonts.size.medium};
|
|
221
|
-
margin-bottom: 12px;
|
|
143
|
+
background-color: ${({ buttonBackgroundColor }) => buttonBackgroundColor};
|
|
144
|
+
width: 28px;
|
|
145
|
+
height: 28px;
|
|
146
|
+
border: none !important;
|
|
222
147
|
`;
|
|
223
148
|
|
|
224
|
-
const
|
|
225
|
-
|
|
149
|
+
const ListContainer = styled.ul`
|
|
150
|
+
border: none;
|
|
151
|
+
overflow-y: scroll;
|
|
152
|
+
list-style: none;
|
|
226
153
|
padding: 0;
|
|
227
|
-
margin: 0;
|
|
228
154
|
`;
|
|
229
155
|
|
|
230
|
-
const
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
padding:
|
|
234
|
-
cursor: pointer;
|
|
235
|
-
border-radius: 4px;
|
|
236
|
-
transition: all 0.2s ease;
|
|
156
|
+
const ListElement = styled.li`
|
|
157
|
+
margin: 0.5rem 0 !important;
|
|
158
|
+
font-size: ${uiFonts.size.small};
|
|
159
|
+
padding: 0.5rem 2px;
|
|
237
160
|
|
|
238
161
|
&:hover {
|
|
162
|
+
color: #ff0;
|
|
239
163
|
background-color: ${uiColors.darkGray};
|
|
240
164
|
}
|
|
241
|
-
`;
|
|
242
165
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
border-radius: 50%;
|
|
247
|
-
margin-right: 12px;
|
|
248
|
-
object-fit: cover;
|
|
249
|
-
`;
|
|
250
|
-
|
|
251
|
-
const CharacterInfo = styled.div`
|
|
252
|
-
flex-grow: 1;
|
|
166
|
+
button {
|
|
167
|
+
all: unset;
|
|
168
|
+
}
|
|
253
169
|
`;
|
|
254
170
|
|
|
255
|
-
const CharacterName = styled.div`
|
|
256
|
-
color: ${uiColors.white};
|
|
257
|
-
font-size: ${uiFonts.size.medium};
|
|
258
|
-
font-weight: bold;
|
|
259
|
-
margin-bottom: 4px;
|
|
260
|
-
`;
|
|
261
171
|
|
|
262
|
-
const CharacterDescription = styled.div`
|
|
263
|
-
color: ${uiColors.gray};
|
|
264
|
-
font-size: ${uiFonts.size.small};
|
|
265
|
-
`;
|