@rpg-engine/long-bow 0.5.14 → 0.5.16

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.
@@ -0,0 +1,6 @@
1
+ import { Meta } from '@storybook/react';
2
+ import { IChatRevampProps } from '../components/ChatRevamp/ChatRevamp';
3
+ declare const meta: Meta;
4
+ export default meta;
5
+ export declare const Default: import("@storybook/csf").AnnotatedStoryFn<import("@storybook/react").ReactFramework, IChatRevampProps>;
6
+ export declare const PrivateCharacters: 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.14",
3
+ "version": "0.5.16",
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.8.83",
86
+ "@rpg-engine/shared": "^0.8.87",
87
87
  "dayjs": "^1.11.2",
88
88
  "font-awesome": "^4.7.0",
89
89
  "fs-extra": "^10.1.0",
@@ -1,4 +1,4 @@
1
- import { IChatMessage } from '@rpg-engine/shared';
1
+ import { IChatMessage, IPrivateChatMessage } from '@rpg-engine/shared';
2
2
  import dayjs from 'dayjs';
3
3
  import React, { useEffect, useState } from 'react';
4
4
  import { ErrorBoundary } from 'react-error-boundary';
@@ -11,7 +11,7 @@ interface IEmitter {
11
11
  name: string;
12
12
  }
13
13
 
14
- interface IStyles {
14
+ export interface IStyles {
15
15
  textColor?: string;
16
16
  buttonColor?: string;
17
17
  buttonBackgroundColor?: string;
@@ -20,7 +20,7 @@ interface IStyles {
20
20
  }
21
21
 
22
22
  export interface IChatProps {
23
- chatMessages: IChatMessage[];
23
+ chatMessages: IChatMessage[] | IPrivateChatMessage[];
24
24
  onSendChatMessage: (message: string) => void;
25
25
  onCloseButton: () => void;
26
26
  onFocus?: () => void;
@@ -80,11 +80,20 @@ export const Chat: React.FC<IChatProps> = ({
80
80
  } ${message}`;
81
81
  };
82
82
 
83
- const onRenderChatMessages = (chatMessages: IChatMessage[]) => {
83
+ const onRenderChatMessages = (
84
+ chatMessages: (IChatMessage | IPrivateChatMessage)[]
85
+ ) => {
84
86
  return chatMessages?.length ? (
85
- chatMessages?.map(({ _id, createdAt, emitter, message }, index) => (
86
- <Message color={styles?.textColor || '#c65102'} key={`${_id}_${index}`}>
87
- {onRenderMessageLines(emitter, createdAt as string, message)}
87
+ chatMessages?.map((chatMessage, index) => (
88
+ <Message
89
+ color={styles?.textColor || '#c65102'}
90
+ key={`${chatMessage._id}_${index}`}
91
+ >
92
+ {onRenderMessageLines(
93
+ chatMessage.emitter,
94
+ chatMessage.createdAt as string,
95
+ chatMessage.message
96
+ )}
88
97
  </Message>
89
98
  ))
90
99
  ) : (
@@ -0,0 +1,121 @@
1
+ import {
2
+ ICharacter,
3
+ IChatMessage,
4
+ IPrivateChatMessage,
5
+ } from '@rpg-engine/shared';
6
+ import React, { useEffect, useState } from 'react';
7
+ import styled from 'styled-components';
8
+ import { uiColors } from '../../constants/uiColors';
9
+ import { Chat, IStyles } from '../Chat/Chat';
10
+ import { SearchCharacter } from './SearchCharacter';
11
+
12
+ export interface ITabStyles {
13
+ width?: string;
14
+ height?: string;
15
+ }
16
+
17
+ export type PrivateChatCharacter = Pick<ICharacter, '_id' | 'name'>;
18
+
19
+ export interface IChatRevampProps {
20
+ chatMessages: IChatMessage[] | IPrivateChatMessage[];
21
+ onSendGlobalChatMessage: (message: string) => void;
22
+ onCloseButton: () => void;
23
+ onFocus?: () => void;
24
+ onBlur?: () => void;
25
+ opacity?: number;
26
+ styles?: IStyles;
27
+ tabs: { label: string; id: string }[];
28
+ activeTab: string;
29
+ onChangeTab: (tabId: string) => void;
30
+ privateChatCharacters?: PrivateChatCharacter[];
31
+ onChangeCharacterName: (characterName: string) => void;
32
+ onCharacterClick?: (character: PrivateChatCharacter) => void;
33
+ onSendPrivateChatMessage: (message: string) => void;
34
+ }
35
+
36
+ export const ChatRevamp = ({
37
+ chatMessages,
38
+ onSendGlobalChatMessage,
39
+ onChangeCharacterName,
40
+ onFocus,
41
+ onBlur,
42
+ onCloseButton,
43
+ styles,
44
+ tabs,
45
+ onChangeTab,
46
+ activeTab,
47
+ privateChatCharacters,
48
+ onCharacterClick,
49
+ onSendPrivateChatMessage,
50
+ }: IChatRevampProps) => {
51
+ const [showSearchCharacter, setShowSearchCharacter] = useState(true);
52
+
53
+ useEffect(() => {
54
+ setShowSearchCharacter(true);
55
+ }, [activeTab]);
56
+
57
+ const isPrivate = activeTab === 'private';
58
+
59
+ return (
60
+ <>
61
+ <TabContainer>
62
+ {tabs.map((tab, index) => (
63
+ <Tab
64
+ key={`${tab.label}_${index}`}
65
+ active={tab.id === activeTab}
66
+ onPointerDown={() => onChangeTab(tab.id)}
67
+ >
68
+ {tab.label}
69
+ </Tab>
70
+ ))}
71
+ </TabContainer>
72
+ {isPrivate && showSearchCharacter ? (
73
+ <SearchCharacter
74
+ onFocus={onFocus}
75
+ onBlur={onBlur}
76
+ onChangeCharacterName={onChangeCharacterName}
77
+ styles={styles}
78
+ recentCharacters={privateChatCharacters}
79
+ setShowSearchCharacter={setShowSearchCharacter}
80
+ onCharacterClick={onCharacterClick}
81
+ />
82
+ ) : (
83
+ <Chat
84
+ chatMessages={chatMessages}
85
+ onSendChatMessage={
86
+ isPrivate ? onSendPrivateChatMessage : onSendGlobalChatMessage
87
+ }
88
+ sendMessage={true}
89
+ onCloseButton={onCloseButton}
90
+ styles={styles}
91
+ onFocus={onFocus}
92
+ onBlur={onBlur}
93
+ />
94
+ )}
95
+ </>
96
+ );
97
+ };
98
+
99
+ const TabContainer = styled.div`
100
+ width: 100%;
101
+ display: flex;
102
+ gap: 10px;
103
+ `;
104
+
105
+ const Tab = styled.button<{ active: boolean }>`
106
+ width: 120px;
107
+ color: white;
108
+ font-size: 0.8rem;
109
+ all: unset;
110
+ padding: 0.6rem;
111
+ font-size: 0.8rem;
112
+
113
+ border-radius: 5px 5px 0 0;
114
+ border-width: 0.25rem 0.25rem 0 0.25rem;
115
+ border-style: solid;
116
+ border-color: ${props => (props.active ? '#c65102' : uiColors.gray)};
117
+
118
+ background-color: ${props =>
119
+ props.active ? uiColors.orange : 'transparent'};
120
+ color: ${props => (props.active ? 'white' : uiColors.raisinBlack)};
121
+ `;
@@ -0,0 +1,163 @@
1
+ import React, { useState } from 'react';
2
+ import { RxMagnifyingGlass } from 'react-icons/rx';
3
+ import styled from 'styled-components';
4
+ import { uiColors } from '../../constants/uiColors';
5
+ import { uiFonts } from '../../constants/uiFonts';
6
+ import { IStyles } from '../Chat/Chat';
7
+ import { Column } from '../shared/Column';
8
+ import type { PrivateChatCharacter } from './ChatRevamp';
9
+
10
+ interface ISearchCharacterProps {
11
+ onFocus?: () => void;
12
+ onBlur?: () => void;
13
+ onChangeCharacterName: (characterName: string) => void;
14
+ styles?: IStyles;
15
+ recentCharacters?: PrivateChatCharacter[];
16
+ setShowSearchCharacter: (show: boolean) => void;
17
+ onCharacterClick?: (character: PrivateChatCharacter) => void;
18
+ }
19
+
20
+ export const SearchCharacter = ({
21
+ onChangeCharacterName,
22
+ onBlur,
23
+ onFocus,
24
+ recentCharacters,
25
+ setShowSearchCharacter,
26
+ onCharacterClick,
27
+ styles = {
28
+ textColor: '#c65102',
29
+ buttonColor: '#005b96',
30
+ buttonBackgroundColor: 'rgba(0,0,0,.2)',
31
+ width: '80%',
32
+ height: 'auto',
33
+ },
34
+ }: ISearchCharacterProps) => {
35
+ const [characterName, setCharacterName] = useState('');
36
+
37
+ const handleSubmit = (event: React.SyntheticEvent<HTMLFormElement>) => {
38
+ event.preventDefault();
39
+ if (!characterName || characterName.trim() === '') return;
40
+ onChangeCharacterName(characterName);
41
+ };
42
+
43
+ const handleCharacterClick = (
44
+ character: PrivateChatCharacter
45
+ ) => {
46
+ if (!onCharacterClick) return;
47
+ setCharacterName('');
48
+ onCharacterClick(character);
49
+ setShowSearchCharacter(false);
50
+ };
51
+
52
+ return (
53
+ <SearchCharacterContainer
54
+ width={styles?.width || '80%'}
55
+ height={styles?.height || 'auto'}
56
+ >
57
+ <Form onSubmit={handleSubmit}>
58
+ <Column flex={70}>
59
+ <TextField
60
+ value={characterName}
61
+ id="inputCharacterName"
62
+ onChange={e => {
63
+ setCharacterName(e.target.value);
64
+ onChangeCharacterName(e.target.value);
65
+ }}
66
+ height={20}
67
+ type="text"
68
+ autoComplete="off"
69
+ onFocus={onFocus}
70
+ onBlur={onBlur}
71
+ onPointerDown={onFocus}
72
+ autoFocus
73
+ />
74
+ </Column>
75
+ <Column justifyContent="flex-end">
76
+ <SearchButton
77
+ buttonColor={styles?.buttonColor || '#005b96'}
78
+ buttonBackgroundColor={
79
+ styles?.buttonBackgroundColor || 'rgba(0,0,0,.5)'
80
+ }
81
+ id="chat-send-button"
82
+ style={{ borderRadius: '20%' }}
83
+ >
84
+ <RxMagnifyingGlass size={15} />
85
+ </SearchButton>
86
+ </Column>
87
+ </Form>
88
+
89
+ {recentCharacters && recentCharacters.length > 0 && (
90
+ <ListContainer>
91
+ {recentCharacters.map(character => (
92
+ <ListElement onPointerDown={() => handleCharacterClick(character)} key={character._id}>
93
+ {character.name}
94
+ </ListElement>
95
+ ))}
96
+ </ListContainer>
97
+ )}
98
+ </SearchCharacterContainer>
99
+ );
100
+ };
101
+
102
+ interface IContainerProps {
103
+ width: string;
104
+ height: string;
105
+ }
106
+
107
+ interface IButtonProps {
108
+ buttonColor: string;
109
+ buttonBackgroundColor: string;
110
+ }
111
+
112
+ const SearchCharacterContainer = styled.div<IContainerProps>`
113
+ height: ${props => props.height};
114
+ width: ${({ width }) => width};
115
+ padding: 10px;
116
+ background-color: rgba(0, 0, 0, 0.2);
117
+ height: auto;
118
+ `;
119
+
120
+ const Form = styled.form`
121
+ display: flex;
122
+ width: 100%;
123
+ justify-content: center;
124
+ align-items: center;
125
+ `;
126
+
127
+ const TextField = styled.input`
128
+ width: 100%;
129
+ background-color: rgba(0, 0, 0, 0.25) !important;
130
+ border: none !important;
131
+ max-height: 28px !important;
132
+ `;
133
+
134
+ const SearchButton = styled.button<IButtonProps>`
135
+ color: ${({ buttonColor }) => buttonColor};
136
+ background-color: ${({ buttonBackgroundColor }) => buttonBackgroundColor};
137
+ width: 28px;
138
+ height: 28px;
139
+ border: none !important;
140
+ `;
141
+
142
+ const ListContainer = styled.ul`
143
+ border: none;
144
+ overflow-y: scroll;
145
+ list-style: none;
146
+ padding: 0;
147
+ `;
148
+
149
+ const ListElement = styled.li`
150
+ margin: 0.5rem 0 !important;
151
+ font-size: ${uiFonts.size.small};
152
+
153
+ &:hover {
154
+ color: #ff0;
155
+ background-color: ${uiColors.darkGray};
156
+ }
157
+
158
+ button {
159
+ all: unset;
160
+ }
161
+ `;
162
+
163
+
@@ -84,7 +84,7 @@ export const ItemContainer: React.FC<IItemContainerProps> = ({
84
84
  const [quantitySelect, setQuantitySelect] = useState({
85
85
  isOpen: false,
86
86
  maxQuantity: 1,
87
- callback: (_quantity: number) => {},
87
+ callback: (_quantity: number) => { },
88
88
  });
89
89
  const [settingShortcutIndex, setSettingShortcutIndex] = useState(-1);
90
90
 
@@ -192,7 +192,7 @@ export const ItemContainer: React.FC<IItemContainerProps> = ({
192
192
  setQuantitySelect({
193
193
  isOpen: false,
194
194
  maxQuantity: 1,
195
- callback: () => {},
195
+ callback: () => { },
196
196
  });
197
197
  }}
198
198
  onClose={() => {
@@ -200,7 +200,7 @@ export const ItemContainer: React.FC<IItemContainerProps> = ({
200
200
  setQuantitySelect({
201
201
  isOpen: false,
202
202
  maxQuantity: 1,
203
- callback: () => {},
203
+ callback: () => { },
204
204
  });
205
205
  }}
206
206
  />
@@ -215,6 +215,8 @@ const ItemsContainer = styled.div`
215
215
  display: flex;
216
216
  justify-content: center;
217
217
  flex-wrap: wrap;
218
+ max-height: 270px; /* Defina a altura máxima desejada */
219
+ overflow-y: auto; /* Adicione uma barra de rolagem vertical quando necessário */
218
220
  `;
219
221
 
220
222
  const QuantitySelectorContainer = styled.div`
@@ -39,6 +39,8 @@ const CustomTab = styled.div<ICustomTab>`
39
39
  border-left: 0.25rem solid rgba(0, 0, 0, 0.25);
40
40
  border-right: 0.25rem solid rgba(0, 0, 0, 0.25);
41
41
  border-top: 0.25rem solid rgba(0, 0, 0, 0.25);
42
+ border-bottom: ${props =>
43
+ props.activeTab ? '' : '0.25rem solid rgba(0, 0, 0, 0.25)'};
42
44
  background: ${props => (props.activeTab ? '#4E4A4E' : '#2b292b')};
43
45
  }
44
46
 
@@ -46,6 +48,7 @@ const CustomTab = styled.div<ICustomTab>`
46
48
  border-left: 0.25rem solid #996d55;
47
49
  border-right: 0.25rem solid #996d55;
48
50
  border-top: 0.25rem solid #996d55;
51
+ border-bottom: ${props => (props.activeTab ? '' : '0.25rem solid #996d55')};
49
52
  background: ${props => (props.activeTab ? '#BF886A' : '#B67051')};
50
53
  }
51
54
 
@@ -59,8 +62,6 @@ const CustomTab = styled.div<ICustomTab>`
59
62
 
60
63
  border-radius: 5px 5px 0 0;
61
64
 
62
- z-index: ${props => (props.activeTab ? 1 : -1)};
63
-
64
65
  position: relative;
65
66
  top: 0.3rem;
66
67
  `;
@@ -1,13 +1,27 @@
1
1
  import React from 'react';
2
2
  import styled from 'styled-components';
3
+ import { IStyles } from '../Chat/Chat';
3
4
 
4
5
  interface IProps {
5
6
  id: string;
6
7
  children: React.ReactNode;
8
+ styles?: IStyles;
7
9
  }
8
10
 
9
- export const TabBody: React.FC<IProps> = ({ id, children }) => {
10
- return <Container data-tab-id={id}>{children}</Container>;
11
+ export const TabBody: React.FC<IProps> = ({ id, children, styles }) => {
12
+ return (
13
+ <Container styles={styles} data-tab-id={id}>
14
+ {children}
15
+ </Container>
16
+ );
11
17
  };
12
18
 
13
- const Container = styled.div``;
19
+ interface IContainerProps {
20
+ styles?: IStyles;
21
+ }
22
+
23
+ const Container = styled.div<IContainerProps>`
24
+ width: 100%;
25
+ height: ${props => props.styles?.height || 'auto'};
26
+ overflow-y: auto;
27
+ `;
@@ -42,9 +42,9 @@ export const TabsContainer: React.FC<ITabsContainer> = ({
42
42
 
43
43
  const onGetContainerType = () => {
44
44
  switch (type) {
45
- case 'brown':
45
+ case MultitabType.Brown:
46
46
  return RPGUIContainerTypes.FramedGold;
47
- case 'gray':
47
+ case MultitabType.Gray:
48
48
  return RPGUIContainerTypes.Framed;
49
49
  default:
50
50
  return RPGUIContainerTypes.Framed;
@@ -22,7 +22,7 @@ export const mockSpells: ISpell[] = [
22
22
  castingAnimationKey: AnimationEffectKeys.SkillLevelUp,
23
23
  targetHitAnimationKey: AnimationEffectKeys.Rooted,
24
24
  projectileAnimationKey: AnimationEffectKeys.Energy,
25
- usableEffect: () => {},
25
+ usableEffect: () => { },
26
26
  onlyPremiumAccountType: [],
27
27
  },
28
28
  {
@@ -41,7 +41,7 @@ export const mockSpells: ISpell[] = [
41
41
  castingAnimationKey: AnimationEffectKeys.SkillLevelUp,
42
42
  targetHitAnimationKey: AnimationEffectKeys.Rooted,
43
43
  projectileAnimationKey: AnimationEffectKeys.Energy,
44
- usableEffect: () => {},
44
+ usableEffect: () => { },
45
45
  onlyPremiumAccountType: [],
46
46
  },
47
47
  {
@@ -60,7 +60,7 @@ export const mockSpells: ISpell[] = [
60
60
  castingAnimationKey: AnimationEffectKeys.SkillLevelUp,
61
61
  targetHitAnimationKey: AnimationEffectKeys.Rooted,
62
62
  projectileAnimationKey: AnimationEffectKeys.Energy,
63
- usableEffect: () => {},
63
+ usableEffect: () => { },
64
64
  onlyPremiumAccountType: [],
65
65
  },
66
66
  {
@@ -79,7 +79,7 @@ export const mockSpells: ISpell[] = [
79
79
  castingAnimationKey: AnimationEffectKeys.SkillLevelUp,
80
80
  targetHitAnimationKey: AnimationEffectKeys.Rooted,
81
81
  projectileAnimationKey: AnimationEffectKeys.Energy,
82
- usableEffect: () => {},
82
+ usableEffect: () => { },
83
83
  onlyPremiumAccountType: [],
84
84
  },
85
85
  {
@@ -98,7 +98,7 @@ export const mockSpells: ISpell[] = [
98
98
  castingAnimationKey: AnimationEffectKeys.SkillLevelUp,
99
99
  targetHitAnimationKey: AnimationEffectKeys.Rooted,
100
100
  projectileAnimationKey: AnimationEffectKeys.Energy,
101
- usableEffect: () => {},
101
+ usableEffect: () => { },
102
102
  onlyPremiumAccountType: [],
103
103
  },
104
104
  ];
package/src/index.tsx CHANGED
@@ -1,6 +1,7 @@
1
1
  export * from './components/Button';
2
2
  export * from './components/Character/CharacterSelection';
3
3
  export * from './components/Chat/Chat';
4
+ export * from './components/ChatRevamp/ChatRevamp';
4
5
  export * from './components/Chatdeprecated/ChatDeprecated';
5
6
  export * from './components/CheckButton';
6
7
  export * from './components/CircularController/CircularController';
@@ -582,7 +582,7 @@ export const itemContainerMock: IItemContainer = {
582
582
  _id: '629ba0b6fe3f43002f58f23b',
583
583
  name: 'Item Container',
584
584
  owner: '629ba0b6fe3f43002f58f23b',
585
- slotQty: 20,
585
+ slotQty: 60,
586
586
  slots: {
587
587
  0: items[0],
588
588
  1: items[1],