@rpg-engine/long-bow 0.1.79 → 0.1.82

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.
Files changed (60) hide show
  1. package/LICENSE +20 -20
  2. package/README.md +181 -181
  3. package/dist/components/Equipment/EquipmentSet.d.ts +2 -2
  4. package/dist/components/store/UI.store.d.ts +0 -3
  5. package/dist/long-bow.cjs.development.js +282 -272
  6. package/dist/long-bow.cjs.development.js.map +1 -1
  7. package/dist/long-bow.cjs.production.min.js +1 -1
  8. package/dist/long-bow.cjs.production.min.js.map +1 -1
  9. package/dist/long-bow.esm.js +282 -272
  10. package/dist/long-bow.esm.js.map +1 -1
  11. package/dist/mocks/equipmentSet.mocks.d.ts +2 -2
  12. package/package.json +96 -96
  13. package/src/components/Abstractions/SlotsContainer.tsx +42 -42
  14. package/src/components/Button.tsx +29 -29
  15. package/src/components/Chat/Chat.tsx +193 -193
  16. package/src/components/CheckButton.tsx +65 -65
  17. package/src/components/DraggableContainer.tsx +150 -150
  18. package/src/components/Dropdown.tsx +57 -57
  19. package/src/components/Equipment/EquipmentSet.tsx +179 -179
  20. package/src/components/Input.tsx +11 -11
  21. package/src/components/Item/Cards/ItemCard.tsx +36 -36
  22. package/src/components/Item/Inventory/ItemContainer.tsx +113 -113
  23. package/src/components/Item/Inventory/ItemSlot.tsx +158 -158
  24. package/src/components/Item/Inventory/itemContainerHelper.ts +81 -81
  25. package/src/components/ListMenu.tsx +65 -65
  26. package/src/components/Multitab/Tab.tsx +57 -57
  27. package/src/components/Multitab/TabBody.tsx +13 -13
  28. package/src/components/Multitab/TabsContainer.tsx +97 -97
  29. package/src/components/NPCDialog/NPCDialog.tsx +145 -145
  30. package/src/components/NPCDialog/NPCDialogText.tsx +53 -53
  31. package/src/components/NPCDialog/QuestionDialog/QuestionDialog.tsx +242 -242
  32. package/src/components/ProgressBar.tsx +91 -91
  33. package/src/components/RPGUIContainer.tsx +47 -47
  34. package/src/components/RPGUIRoot.tsx +14 -14
  35. package/src/components/RadioButton.tsx +53 -53
  36. package/src/components/RangeSlider.tsx +68 -68
  37. package/src/components/ScrollList.tsx +77 -77
  38. package/src/components/SimpleProgressBar.tsx +62 -62
  39. package/src/components/SkillProgressBar.tsx +124 -124
  40. package/src/components/SkillsContainer.tsx +235 -235
  41. package/src/components/TextArea.tsx +11 -11
  42. package/src/components/Truncate.tsx +25 -25
  43. package/src/components/shared/Column.tsx +16 -16
  44. package/src/components/shared/SpriteFromAtlas.tsx +99 -99
  45. package/src/components/shared/SpriteIcon.tsx +67 -67
  46. package/src/components/store/UI.store.ts +192 -205
  47. package/src/components/typography/DynamicText.tsx +49 -49
  48. package/src/constants/uiColors.ts +10 -10
  49. package/src/hooks/useEventListener.ts +21 -21
  50. package/src/hooks/useOutsideAlerter.ts +25 -25
  51. package/src/index.tsx +25 -25
  52. package/src/libs/StringHelpers.ts +3 -3
  53. package/src/mocks/atlas/icons/icons.json +303 -303
  54. package/src/mocks/atlas/items/items.json +5215 -5195
  55. package/src/mocks/atlas/items/items.png +0 -0
  56. package/src/mocks/equipmentSet.mocks.ts +347 -347
  57. package/src/mocks/itemContainer.mocks.ts +249 -249
  58. package/src/mocks/skills.mocks.ts +122 -122
  59. package/src/types/eventTypes.ts +4 -4
  60. package/src/types/index.d.ts +2 -2
@@ -1,205 +1,192 @@
1
- import {
2
- IItem,
3
- IPayloadProps,
4
- ItemSocketEvents,
5
- ItemSocketEventsDisplayLabels,
6
- ItemType,
7
- } from '@rpg-engine/shared';
8
- import { makeAutoObservable, toJS } from 'mobx';
9
- import { IPosition } from '../../types/eventTypes';
10
- import {
11
- handleContextMenuList,
12
- handleEquipmentContextMenuList,
13
- IContextMenuItem,
14
- } from '../Item/Inventory/itemContainerHelper';
15
- import { SlotContainerType } from '../Item/Inventory/ItemSlot';
16
-
17
- interface IContextMenu {
18
- visible: boolean;
19
- posX: number;
20
- posY: number;
21
- slotItem: IItem | null;
22
- slotIndex?: number | null;
23
- contextActions: IContextMenuItem[];
24
- }
25
-
26
- interface IHoverDetail {
27
- visible: boolean;
28
- posX: number;
29
- posY: number;
30
- item: IItem | null;
31
- }
32
-
33
- interface ISetContextMenu extends Omit<IContextMenu, 'contextActions'> {}
34
-
35
- const initialState = {
36
- visible: false,
37
- posX: 0,
38
- posY: 0,
39
- contextActions: [],
40
- slotItem: null,
41
- };
42
-
43
- const initialHoverState = {
44
- visible: false,
45
- posX: 0,
46
- posY: 0,
47
- item: null,
48
- };
49
-
50
- const initialPosition = {
51
- x: 0,
52
- y: 0
53
- }
54
- class UIStore {
55
- public contextMenu: IContextMenu | null = initialState;
56
- public onHoverDetail: IHoverDetail | null = initialHoverState;
57
-
58
- public draggablePosition: IPosition = initialPosition;
59
-
60
-
61
- constructor() {
62
- makeAutoObservable(this);
63
- }
64
-
65
- public setContextMenu(contextMenu: ISetContextMenu, itemType: ItemType) {
66
- const contextActions = handleContextMenuList(itemType);
67
-
68
- this.contextMenu = {
69
- ...contextMenu,
70
- contextActions,
71
- };
72
-
73
- console.log(toJS(this.contextMenu));
74
- }
75
-
76
- public setEquipContextMenu(
77
- contextMenu: ISetContextMenu,
78
- itemType: ItemType,
79
- isItemContainer: boolean | undefined
80
- ) {
81
- const contextActions = handleEquipmentContextMenuList(itemType);
82
- if (isItemContainer)
83
- contextActions.push({
84
- id: ItemSocketEvents.ContainerOpen,
85
- text: ItemSocketEventsDisplayLabels[ItemSocketEvents.ContainerOpen],
86
- });
87
- this.contextMenu = {
88
- ...contextMenu,
89
- contextActions,
90
- };
91
-
92
- console.log(toJS(this.contextMenu));
93
- }
94
-
95
- public clearContextMenu() {
96
- this.contextMenu = initialState;
97
- }
98
-
99
- public setItemHoverDetail(hoverDetail: IHoverDetail) {
100
- if (hoverDetail?.item === null) this.clearItemHoverDetail();
101
-
102
- this.onHoverDetail = {
103
- ...hoverDetail,
104
- };
105
- }
106
-
107
- public clearItemHoverDetail() {
108
- this.onHoverDetail = initialHoverState;
109
- }
110
-
111
- public handleOnItemClick = (
112
- item: IItem,
113
- posX: number,
114
- posY: number,
115
- slotContainerType: SlotContainerType | null
116
- ): void => {
117
- if (
118
- !item ||
119
- JSON.stringify(this.contextMenu?.slotItem) === JSON.stringify(item)
120
- ) {
121
- this.clearContextMenu();
122
- this.clearItemHoverDetail();
123
- return;
124
- }
125
- switch (slotContainerType) {
126
- case SlotContainerType.EQUIPMENT_SET:
127
- this.setEquipContextMenu(
128
- {
129
- visible: true,
130
- posX,
131
- posY,
132
- slotItem: item,
133
- },
134
- item.type,
135
- item.isItemContainer
136
- );
137
- break;
138
- case SlotContainerType.INVENTORY:
139
- this.setContextMenu(
140
- {
141
- visible: true,
142
- posX,
143
- posY,
144
- slotItem: item,
145
- },
146
- item.type
147
- );
148
- break;
149
- default:
150
- this.setContextMenu(
151
- {
152
- visible: true,
153
- posX,
154
- posY,
155
- slotItem: item,
156
- },
157
- item.type
158
- );
159
- }
160
-
161
- this.clearItemHoverDetail();
162
- };
163
-
164
- public handleOnMouseHover = (
165
- event: any,
166
- slotIndex: number,
167
- item: IItem | null,
168
- posX: number,
169
- posY: number,
170
- onMouseOver: any
171
- ): void => {
172
- if (item) {
173
- this.setItemHoverDetail({
174
- visible: true,
175
- posX,
176
- posY,
177
- item: item,
178
- });
179
- }
180
- if (onMouseOver) {
181
- onMouseOver(event, slotIndex, item);
182
- }
183
- };
184
-
185
- public onSelected(
186
- selectedActionId: ItemSocketEvents | string,
187
- onActionSelected: any
188
- ) {
189
- let payloadData: IPayloadProps = {
190
- actionType: selectedActionId,
191
- item: this.contextMenu?.slotItem!,
192
- };
193
- if (onActionSelected) {
194
- onActionSelected(payloadData);
195
- }
196
- this.clearContextMenu!();
197
- }
198
-
199
- public setDraggablePosition(currentPosition: IPosition){
200
- this.draggablePosition = { ...currentPosition }
201
- }
202
-
203
- }
204
-
205
- export const uiStore = new UIStore();
1
+ import {
2
+ IItem,
3
+ IPayloadProps,
4
+ ItemSocketEvents,
5
+ ItemSocketEventsDisplayLabels,
6
+ ItemType,
7
+ } from '@rpg-engine/shared';
8
+ import { makeAutoObservable, toJS } from 'mobx';
9
+ import {
10
+ handleContextMenuList,
11
+ handleEquipmentContextMenuList,
12
+ IContextMenuItem,
13
+ } from '../Item/Inventory/itemContainerHelper';
14
+ import { SlotContainerType } from '../Item/Inventory/ItemSlot';
15
+
16
+ interface IContextMenu {
17
+ visible: boolean;
18
+ posX: number;
19
+ posY: number;
20
+ slotItem: IItem | null;
21
+ slotIndex?: number | null;
22
+ contextActions: IContextMenuItem[];
23
+ }
24
+
25
+ interface IHoverDetail {
26
+ visible: boolean;
27
+ posX: number;
28
+ posY: number;
29
+ item: IItem | null;
30
+ }
31
+
32
+ interface ISetContextMenu extends Omit<IContextMenu, 'contextActions'> {}
33
+
34
+ const initialState = {
35
+ visible: false,
36
+ posX: 0,
37
+ posY: 0,
38
+ contextActions: [],
39
+ slotItem: null,
40
+ };
41
+
42
+ const initialHoverState = {
43
+ visible: false,
44
+ posX: 0,
45
+ posY: 0,
46
+ item: null,
47
+ };
48
+ class UIStore {
49
+ public contextMenu: IContextMenu | null = initialState;
50
+
51
+ public onHoverDetail: IHoverDetail | null = initialHoverState;
52
+
53
+ constructor() {
54
+ makeAutoObservable(this);
55
+ }
56
+
57
+ public setContextMenu(contextMenu: ISetContextMenu, itemType: ItemType) {
58
+ const contextActions = handleContextMenuList(itemType);
59
+
60
+ this.contextMenu = {
61
+ ...contextMenu,
62
+ contextActions,
63
+ };
64
+
65
+ console.log(toJS(this.contextMenu));
66
+ }
67
+
68
+ public setEquipContextMenu(
69
+ contextMenu: ISetContextMenu,
70
+ itemType: ItemType,
71
+ isItemContainer: boolean | undefined
72
+ ) {
73
+ const contextActions = handleEquipmentContextMenuList(itemType);
74
+ if (isItemContainer)
75
+ contextActions.push({
76
+ id: ItemSocketEvents.ContainerOpen,
77
+ text: ItemSocketEventsDisplayLabels[ItemSocketEvents.ContainerOpen],
78
+ });
79
+ this.contextMenu = {
80
+ ...contextMenu,
81
+ contextActions,
82
+ };
83
+
84
+ console.log(toJS(this.contextMenu));
85
+ }
86
+
87
+ public clearContextMenu() {
88
+ this.contextMenu = initialState;
89
+ }
90
+
91
+ public setItemHoverDetail(hoverDetail: IHoverDetail) {
92
+ if (hoverDetail?.item === null) this.clearItemHoverDetail();
93
+
94
+ this.onHoverDetail = {
95
+ ...hoverDetail,
96
+ };
97
+ }
98
+
99
+ public clearItemHoverDetail() {
100
+ this.onHoverDetail = initialHoverState;
101
+ }
102
+
103
+ public handleOnItemClick = (
104
+ item: IItem,
105
+ posX: number,
106
+ posY: number,
107
+ slotContainerType: SlotContainerType | null
108
+ ): void => {
109
+ if (
110
+ !item ||
111
+ JSON.stringify(this.contextMenu?.slotItem) === JSON.stringify(item)
112
+ ) {
113
+ this.clearContextMenu();
114
+ this.clearItemHoverDetail();
115
+ return;
116
+ }
117
+ switch (slotContainerType) {
118
+ case SlotContainerType.EQUIPMENT_SET:
119
+ this.setEquipContextMenu(
120
+ {
121
+ visible: true,
122
+ posX,
123
+ posY,
124
+ slotItem: item,
125
+ },
126
+ item.type,
127
+ item.isItemContainer
128
+ );
129
+ break;
130
+ case SlotContainerType.INVENTORY:
131
+ this.setContextMenu(
132
+ {
133
+ visible: true,
134
+ posX,
135
+ posY,
136
+ slotItem: item,
137
+ },
138
+ item.type
139
+ );
140
+ break;
141
+ default:
142
+ this.setContextMenu(
143
+ {
144
+ visible: true,
145
+ posX,
146
+ posY,
147
+ slotItem: item,
148
+ },
149
+ item.type
150
+ );
151
+ }
152
+
153
+ this.clearItemHoverDetail();
154
+ };
155
+
156
+ public handleOnMouseHover = (
157
+ event: any,
158
+ slotIndex: number,
159
+ item: IItem | null,
160
+ posX: number,
161
+ posY: number,
162
+ onMouseOver: any
163
+ ): void => {
164
+ if (item) {
165
+ this.setItemHoverDetail({
166
+ visible: true,
167
+ posX,
168
+ posY,
169
+ item: item,
170
+ });
171
+ }
172
+ if (onMouseOver) {
173
+ onMouseOver(event, slotIndex, item);
174
+ }
175
+ };
176
+
177
+ public onSelected(
178
+ selectedActionId: ItemSocketEvents | string,
179
+ onActionSelected: any
180
+ ) {
181
+ let payloadData: IPayloadProps = {
182
+ actionType: selectedActionId,
183
+ item: this.contextMenu?.slotItem!,
184
+ };
185
+ if (onActionSelected) {
186
+ onActionSelected(payloadData);
187
+ }
188
+ this.clearContextMenu!();
189
+ }
190
+ }
191
+
192
+ export const uiStore = new UIStore();
@@ -1,49 +1,49 @@
1
- import React, { useEffect, useState } from 'react';
2
- import styled from 'styled-components';
3
-
4
- interface IProps {
5
- text: string;
6
- onFinish?: () => void;
7
- onStart?: () => void;
8
- }
9
-
10
- export const DynamicText: React.FC<IProps> = ({ text, onFinish, onStart }) => {
11
- const [textState, setTextState] = useState<string>('');
12
-
13
- useEffect(() => {
14
- let i = 0;
15
- const interval = setInterval(() => {
16
- // on every interval, show one more character
17
-
18
- if (i === 0) {
19
- if (onStart) {
20
- onStart();
21
- }
22
- }
23
-
24
- if (i < text.length) {
25
- setTextState(text.substring(0, i + 1));
26
- i++;
27
- } else {
28
- clearInterval(interval);
29
- if (onFinish) {
30
- onFinish();
31
- }
32
- }
33
- }, 50);
34
-
35
- return () => {
36
- clearInterval(interval);
37
- };
38
- }, [text]);
39
-
40
- return <TextContainer>{textState}</TextContainer>;
41
- };
42
-
43
- const TextContainer = styled.p`
44
- font-size: 0.7rem !important;
45
- color: white;
46
- text-shadow: 1px 1px 0px #000000;
47
- letter-spacing: 1.2px;
48
- word-break: normal;
49
- `;
1
+ import React, { useEffect, useState } from 'react';
2
+ import styled from 'styled-components';
3
+
4
+ interface IProps {
5
+ text: string;
6
+ onFinish?: () => void;
7
+ onStart?: () => void;
8
+ }
9
+
10
+ export const DynamicText: React.FC<IProps> = ({ text, onFinish, onStart }) => {
11
+ const [textState, setTextState] = useState<string>('');
12
+
13
+ useEffect(() => {
14
+ let i = 0;
15
+ const interval = setInterval(() => {
16
+ // on every interval, show one more character
17
+
18
+ if (i === 0) {
19
+ if (onStart) {
20
+ onStart();
21
+ }
22
+ }
23
+
24
+ if (i < text.length) {
25
+ setTextState(text.substring(0, i + 1));
26
+ i++;
27
+ } else {
28
+ clearInterval(interval);
29
+ if (onFinish) {
30
+ onFinish();
31
+ }
32
+ }
33
+ }, 50);
34
+
35
+ return () => {
36
+ clearInterval(interval);
37
+ };
38
+ }, [text]);
39
+
40
+ return <TextContainer>{textState}</TextContainer>;
41
+ };
42
+
43
+ const TextContainer = styled.p`
44
+ font-size: 0.7rem !important;
45
+ color: white;
46
+ text-shadow: 1px 1px 0px #000000;
47
+ letter-spacing: 1.2px;
48
+ word-break: normal;
49
+ `;
@@ -1,10 +1,10 @@
1
- export const colors = {
2
- darkGrey: '#3e3e3e',
3
- darkYellow: '#FFC857',
4
- orange: '#E9724C',
5
- cardinal: '#C5283D',
6
- raisinBlack: '#191923',
7
- navyBlue: '#0E79B2',
8
- purple: '#8C3D8C',
9
- blue: '#3772FF',
10
- };
1
+ export const colors = {
2
+ darkGrey: '#3e3e3e',
3
+ darkYellow: '#FFC857',
4
+ orange: '#E9724C',
5
+ cardinal: '#C5283D',
6
+ raisinBlack: '#191923',
7
+ navyBlue: '#0E79B2',
8
+ purple: '#8C3D8C',
9
+ blue: '#3772FF',
10
+ };
@@ -1,21 +1,21 @@
1
- import React from 'react';
2
-
3
- //@ts-ignore
4
- export const useEventListener = (type, handler, el = window) => {
5
- const savedHandler = React.useRef();
6
-
7
- React.useEffect(() => {
8
- savedHandler.current = handler;
9
- }, [handler]);
10
-
11
- React.useEffect(() => {
12
- //@ts-ignore
13
- const listener = e => savedHandler.current(e);
14
-
15
- el.addEventListener(type, listener);
16
-
17
- return () => {
18
- el.removeEventListener(type, listener);
19
- };
20
- }, [type, el]);
21
- };
1
+ import React from 'react';
2
+
3
+ //@ts-ignore
4
+ export const useEventListener = (type, handler, el = window) => {
5
+ const savedHandler = React.useRef();
6
+
7
+ React.useEffect(() => {
8
+ savedHandler.current = handler;
9
+ }, [handler]);
10
+
11
+ React.useEffect(() => {
12
+ //@ts-ignore
13
+ const listener = e => savedHandler.current(e);
14
+
15
+ el.addEventListener(type, listener);
16
+
17
+ return () => {
18
+ el.removeEventListener(type, listener);
19
+ };
20
+ }, [type, el]);
21
+ };
@@ -1,25 +1,25 @@
1
- import { useEffect } from 'react';
2
-
3
- export function useOutsideClick(ref: any, id: string) {
4
- useEffect(() => {
5
- /**
6
- * Alert if clicked on outside of element
7
- */
8
- function handleClickOutside(event: any) {
9
- if (ref.current && !ref.current.contains(event.target)) {
10
- const event = new CustomEvent('clickOutside', {
11
- detail: {
12
- id,
13
- },
14
- });
15
- document.dispatchEvent(event);
16
- }
17
- }
18
- // Bind the event listener
19
- document.addEventListener('mousedown', handleClickOutside);
20
- return () => {
21
- // Unbind the event listener on clean up
22
- document.removeEventListener('mousedown', handleClickOutside);
23
- };
24
- }, [ref]);
25
- }
1
+ import { useEffect } from 'react';
2
+
3
+ export function useOutsideClick(ref: any, id: string) {
4
+ useEffect(() => {
5
+ /**
6
+ * Alert if clicked on outside of element
7
+ */
8
+ function handleClickOutside(event: any) {
9
+ if (ref.current && !ref.current.contains(event.target)) {
10
+ const event = new CustomEvent('clickOutside', {
11
+ detail: {
12
+ id,
13
+ },
14
+ });
15
+ document.dispatchEvent(event);
16
+ }
17
+ }
18
+ // Bind the event listener
19
+ document.addEventListener('mousedown', handleClickOutside);
20
+ return () => {
21
+ // Unbind the event listener on clean up
22
+ document.removeEventListener('mousedown', handleClickOutside);
23
+ };
24
+ }, [ref]);
25
+ }
package/src/index.tsx CHANGED
@@ -1,25 +1,25 @@
1
- export * from './components/Button';
2
- export * from './components/Chat/Chat';
3
- export * from './components/CheckButton';
4
- export * from './components/DraggableContainer';
5
- export * from './components/Dropdown';
6
- export * from './components/Equipment/EquipmentSet';
7
- export * from './components/Input';
8
- export * from './components/Item/Inventory/ItemContainer';
9
- export * from './components/Item/Inventory/ItemSlot';
10
- export * from './components/ListMenu';
11
- export * from './components/NPCDialog/NPCDialog';
12
- export * from './components/NPCDialog/QuestionDialog/QuestionDialog';
13
- export * from './components/ProgressBar';
14
- export * from './components/RadioButton';
15
- export * from './components/RangeSlider';
16
- export * from './components/RPGUIContainer';
17
- export * from './components/RPGUIRoot';
18
- export * from './components/shared/SpriteFromAtlas';
19
- export * from './components/shared/SpriteIcon';
20
- export * from './components/SkillProgressBar';
21
- export * from './components/SkillsContainer';
22
- export * from './components/TextArea';
23
- export * from './components/Truncate';
24
- export * from './components/typography/DynamicText';
25
- export { useEventListener } from './hooks/useEventListener';
1
+ export * from './components/Button';
2
+ export * from './components/Chat/Chat';
3
+ export * from './components/CheckButton';
4
+ export * from './components/DraggableContainer';
5
+ export * from './components/Dropdown';
6
+ export * from './components/Equipment/EquipmentSet';
7
+ export * from './components/Input';
8
+ export * from './components/Item/Inventory/ItemContainer';
9
+ export * from './components/Item/Inventory/ItemSlot';
10
+ export * from './components/ListMenu';
11
+ export * from './components/NPCDialog/NPCDialog';
12
+ export * from './components/NPCDialog/QuestionDialog/QuestionDialog';
13
+ export * from './components/ProgressBar';
14
+ export * from './components/RadioButton';
15
+ export * from './components/RangeSlider';
16
+ export * from './components/RPGUIContainer';
17
+ export * from './components/RPGUIRoot';
18
+ export * from './components/shared/SpriteFromAtlas';
19
+ export * from './components/shared/SpriteIcon';
20
+ export * from './components/SkillProgressBar';
21
+ export * from './components/SkillsContainer';
22
+ export * from './components/TextArea';
23
+ export * from './components/Truncate';
24
+ export * from './components/typography/DynamicText';
25
+ export { useEventListener } from './hooks/useEventListener';
@@ -1,3 +1,3 @@
1
- export const chunkString = (str: string, length: number) => {
2
- return str.match(new RegExp('.{1,' + length + '}', 'g'));
3
- };
1
+ export const chunkString = (str: string, length: number) => {
2
+ return str.match(new RegExp('.{1,' + length + '}', 'g'));
3
+ };