@rpg-engine/long-bow 0.1.794 → 0.2.2

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 (129) hide show
  1. package/LICENSE +20 -20
  2. package/README.md +181 -181
  3. package/dist/components/Button.d.ts +1 -0
  4. package/dist/components/Equipment/EquipmentSet.d.ts +5 -3
  5. package/dist/components/Item/Cards/ItemTooltip.d.ts +6 -0
  6. package/dist/components/Item/Inventory/ItemContainer.d.ts +4 -6
  7. package/dist/components/Item/Inventory/ItemContainerTypes.d.ts +6 -0
  8. package/dist/components/Item/Inventory/ItemSlot.d.ts +5 -9
  9. package/dist/components/Item/Inventory/itemContainerHelper.d.ts +2 -7
  10. package/dist/components/PropertySelect/PropertySelect.d.ts +12 -0
  11. package/dist/components/QuestInfo/QuestInfo.d.ts +14 -0
  12. package/dist/components/RelativeListMenu.d.ts +13 -0
  13. package/dist/index.d.ts +1 -1
  14. package/dist/long-bow.cjs.development.js +748 -1194
  15. package/dist/long-bow.cjs.development.js.map +1 -1
  16. package/dist/long-bow.cjs.production.min.js +1 -1
  17. package/dist/long-bow.cjs.production.min.js.map +1 -1
  18. package/dist/long-bow.esm.js +748 -1196
  19. package/dist/long-bow.esm.js.map +1 -1
  20. package/dist/mocks/equipmentSet.mocks.d.ts +2 -2
  21. package/dist/stories/Button.stories.d.ts +5 -0
  22. package/dist/stories/Chat.stories.d.ts +5 -0
  23. package/dist/stories/CheckButton.stories.d.ts +5 -0
  24. package/dist/stories/DraggableContainer.stories.d.ts +5 -0
  25. package/dist/stories/Dropdown.stories.d.ts +5 -0
  26. package/dist/stories/EquipmentSet.stories.d.ts +5 -0
  27. package/dist/stories/ItemContainer.stories.d.ts +5 -0
  28. package/dist/stories/ListMenu.stories.d.ts +5 -0
  29. package/dist/stories/Multitab.stories.d.ts +6 -0
  30. package/dist/stories/NPCDialog.stories.d.ts +7 -0
  31. package/dist/stories/ProgressBar.stories.d.ts +8 -0
  32. package/dist/stories/PropertySelect.stories.d.ts +5 -0
  33. package/dist/stories/QuestInfo.stories.d.ts +5 -0
  34. package/dist/stories/RPGUIContainers.stories.d.ts +5 -0
  35. package/dist/stories/RadioButton.stories.d.ts +5 -0
  36. package/dist/stories/RangeSlider.stories.d.ts +5 -0
  37. package/dist/stories/ScrollList.stories.d.ts +5 -0
  38. package/dist/stories/SimpleProgressBar.stories.d.ts +5 -0
  39. package/dist/stories/SkillProgressBar.stories.d.ts +5 -0
  40. package/dist/stories/SkillsContainer.stories.d.ts +5 -0
  41. package/dist/stories/Text.stories.d.ts +7 -0
  42. package/package.json +98 -96
  43. package/src/components/Abstractions/SlotsContainer.tsx +42 -42
  44. package/src/components/Button.tsx +30 -29
  45. package/src/components/Chat/Chat.tsx +193 -193
  46. package/src/components/CheckButton.tsx +65 -65
  47. package/src/components/DraggableContainer.tsx +150 -150
  48. package/src/components/Dropdown.tsx +57 -57
  49. package/src/components/Equipment/EquipmentSet.tsx +138 -180
  50. package/src/components/Input.tsx +11 -11
  51. package/src/components/Item/Cards/ItemTooltip.tsx +32 -0
  52. package/src/components/Item/Inventory/ItemContainer.tsx +68 -113
  53. package/src/components/Item/Inventory/ItemContainerTypes.ts +6 -0
  54. package/src/components/Item/Inventory/ItemSlot.tsx +212 -158
  55. package/src/components/Item/Inventory/itemContainerHelper.ts +146 -81
  56. package/src/components/ListMenu.tsx +65 -65
  57. package/src/components/Multitab/Tab.tsx +57 -57
  58. package/src/components/Multitab/TabBody.tsx +13 -13
  59. package/src/components/Multitab/TabsContainer.tsx +97 -97
  60. package/src/components/NPCDialog/NPCDialog.tsx +145 -145
  61. package/src/components/NPCDialog/NPCDialogText.tsx +53 -53
  62. package/src/components/NPCDialog/QuestionDialog/QuestionDialog.tsx +237 -242
  63. package/src/components/ProgressBar.tsx +91 -91
  64. package/src/components/PropertySelect/PropertySelect.tsx +101 -0
  65. package/src/components/PropertySelect/img/ui-arrows/arrow01-left-clicked.png +0 -0
  66. package/src/components/PropertySelect/img/ui-arrows/arrow01-left.png +0 -0
  67. package/src/components/PropertySelect/img/ui-arrows/arrow01-right-clicked.png +0 -0
  68. package/src/components/PropertySelect/img/ui-arrows/arrow01-right.png +0 -0
  69. package/src/components/PropertySelect/img/ui-arrows/arrow02-left-clicked.png +0 -0
  70. package/src/components/PropertySelect/img/ui-arrows/arrow02-left.png +0 -0
  71. package/src/components/PropertySelect/img/ui-arrows/arrow02-right-clicked.png +0 -0
  72. package/src/components/PropertySelect/img/ui-arrows/arrow02-right.png +0 -0
  73. package/src/components/QuestInfo/QuestInfo.tsx +143 -0
  74. package/src/components/QuestInfo/img/default.png +0 -0
  75. package/src/components/RPGUIContainer.tsx +47 -47
  76. package/src/components/RPGUIRoot.tsx +14 -14
  77. package/src/components/RadioButton.tsx +53 -53
  78. package/src/components/RangeSlider.tsx +68 -68
  79. package/src/components/RelativeListMenu.tsx +83 -0
  80. package/src/components/ScrollList.tsx +77 -77
  81. package/src/components/SimpleProgressBar.tsx +62 -62
  82. package/src/components/SkillProgressBar.tsx +123 -124
  83. package/src/components/SkillsContainer.tsx +196 -235
  84. package/src/components/TextArea.tsx +11 -11
  85. package/src/components/Truncate.tsx +25 -25
  86. package/src/components/shared/Column.tsx +16 -16
  87. package/src/components/shared/SpriteFromAtlas.tsx +99 -99
  88. package/src/components/typography/DynamicText.tsx +49 -49
  89. package/src/constants/uiColors.ts +10 -10
  90. package/src/hooks/useEventListener.ts +21 -21
  91. package/src/hooks/useOutsideAlerter.ts +25 -25
  92. package/src/index.tsx +25 -25
  93. package/src/libs/StringHelpers.ts +3 -3
  94. package/src/mocks/atlas/icons/icons.json +735 -303
  95. package/src/mocks/atlas/icons/icons.png +0 -0
  96. package/src/mocks/atlas/items/items.json +5215 -5195
  97. package/src/mocks/atlas/items/items.png +0 -0
  98. package/src/mocks/equipmentSet.mocks.ts +347 -347
  99. package/src/mocks/itemContainer.mocks.ts +281 -249
  100. package/src/mocks/skills.mocks.ts +122 -122
  101. package/src/stories/Button.stories.tsx +36 -0
  102. package/src/stories/Chat.stories.tsx +170 -0
  103. package/src/stories/CheckButton.stories.tsx +48 -0
  104. package/src/stories/DraggableContainer.stories.tsx +28 -0
  105. package/src/stories/Dropdown.stories.tsx +46 -0
  106. package/src/stories/EquipmentSet.stories.tsx +51 -0
  107. package/src/stories/ItemContainer.stories.tsx +51 -0
  108. package/src/stories/ListMenu.stories.tsx +56 -0
  109. package/src/stories/Multitab.stories.tsx +51 -0
  110. package/src/stories/NPCDialog.stories.tsx +130 -0
  111. package/src/stories/ProgressBar.stories.tsx +23 -0
  112. package/src/stories/PropertySelect.stories.tsx +41 -0
  113. package/src/stories/QuestInfo.stories.tsx +76 -0
  114. package/src/stories/RPGUIContainers.stories.tsx +42 -0
  115. package/src/stories/RadioButton.stories.tsx +49 -0
  116. package/src/stories/RangeSlider.stories.tsx +60 -0
  117. package/src/stories/ScrollList.stories.tsx +85 -0
  118. package/src/stories/SimpleProgressBar.stories.tsx +22 -0
  119. package/src/stories/SkillProgressBar.stories.tsx +30 -0
  120. package/src/stories/SkillsContainer.stories.tsx +31 -0
  121. package/src/stories/Text.stories.tsx +42 -0
  122. package/src/types/eventTypes.ts +4 -4
  123. package/src/types/index.d.ts +2 -2
  124. package/dist/components/Item/Cards/ItemCard.d.ts +0 -9
  125. package/dist/components/shared/SpriteIcon.d.ts +0 -9
  126. package/dist/components/store/UI.store.d.ts +0 -38
  127. package/src/components/Item/Cards/ItemCard.tsx +0 -36
  128. package/src/components/shared/SpriteIcon.tsx +0 -67
  129. package/src/components/store/UI.store.ts +0 -232
@@ -0,0 +1,42 @@
1
+ import { Meta, Story } from '@storybook/react';
2
+ import React from 'react';
3
+ import { RPGUIRoot } from '../../src';
4
+ import {
5
+ IInputProps,
6
+ Input as InputComponent,
7
+ } from '../../src/components/Input';
8
+ import {
9
+ ITextArea,
10
+ TextArea as TextAreaComponent,
11
+ } from '../../src/components/TextArea';
12
+
13
+ const meta: Meta = {
14
+ title: 'Text',
15
+ component: InputComponent,
16
+ };
17
+
18
+ export default meta;
19
+
20
+ const InputTemplate: Story<IInputProps> = args => (
21
+ <RPGUIRoot>
22
+ <InputComponent {...args} />
23
+ </RPGUIRoot>
24
+ );
25
+
26
+ export const Input = InputTemplate.bind({});
27
+
28
+ Input.args = {
29
+ placeholder: 'Test placeholder',
30
+ };
31
+
32
+ const TextAreaTemplate: Story<ITextArea> = args => (
33
+ <RPGUIRoot>
34
+ <TextAreaComponent {...args} />
35
+ </RPGUIRoot>
36
+ );
37
+
38
+ export const TextArea = TextAreaTemplate.bind({});
39
+
40
+ TextArea.args = {
41
+ placeholder: 'Test placeholder',
42
+ };
@@ -1,4 +1,4 @@
1
- export interface IPosition {
2
- x: number;
3
- y: number;
4
- }
1
+ export interface IPosition {
2
+ x: number;
3
+ y: number;
4
+ }
@@ -1,2 +1,2 @@
1
- declare module '*.gif';
2
- declare module '*.png';
1
+ declare module '*.gif';
2
+ declare module '*.png';
@@ -1,9 +0,0 @@
1
- import { IItem } from '@rpg-engine/shared';
2
- import React from 'react';
3
- interface IProps {
4
- item: IItem | null;
5
- x: number;
6
- y: number;
7
- }
8
- export declare const ItemCard: React.FC<IProps>;
9
- export {};
@@ -1,9 +0,0 @@
1
- import React from 'react';
2
- interface IProps {
3
- onClick?: () => void;
4
- spriteKey: string;
5
- baseSpriteKey?: string;
6
- imgStyle?: any;
7
- }
8
- export declare const SpriteIcon: React.FC<IProps>;
9
- export {};
@@ -1,38 +0,0 @@
1
- import { IItem, ItemSocketEvents, ItemType } from '@rpg-engine/shared';
2
- import { IPosition } from '../../types/eventTypes';
3
- import { IContextMenuItem } from '../Item/Inventory/itemContainerHelper';
4
- import { SlotContainerType } from '../Item/Inventory/ItemSlot';
5
- interface IContextMenu {
6
- visible: boolean;
7
- posX: number;
8
- posY: number;
9
- slotItem: IItem | null;
10
- slotIndex?: number | null;
11
- contextActions: IContextMenuItem[];
12
- }
13
- interface IHoverDetail {
14
- visible: boolean;
15
- posX: number;
16
- posY: number;
17
- item: IItem | null;
18
- }
19
- interface ISetContextMenu extends Omit<IContextMenu, 'contextActions'> {
20
- }
21
- declare class UIStore {
22
- contextMenu: IContextMenu | null;
23
- onHoverDetail: IHoverDetail | null;
24
- draggablePosition: IPosition;
25
- constructor();
26
- setContextMenu(contextMenu: ISetContextMenu, itemType: ItemType): void;
27
- setEquipContextMenu(contextMenu: ISetContextMenu, itemType: ItemType, isItemContainer: boolean | undefined): void;
28
- clearContextMenu(): void;
29
- setItemHoverDetail(hoverDetail: IHoverDetail): void;
30
- clearItemHoverDetail(): void;
31
- handleOnItemClick: (item: IItem, posX: number, posY: number, slotContainerType: SlotContainerType | null) => void;
32
- handleOnMouseHover: (event: any, slotIndex: number, item: IItem | null, posX: number, posY: number, onMouseOver: any) => void;
33
- onSelected(selectedActionId: ItemSocketEvents | string, onActionSelected: any): void;
34
- setDraggablePosition(currentPosition: IPosition): void;
35
- private getOffsets;
36
- }
37
- export declare const uiStore: UIStore;
38
- export {};
@@ -1,36 +0,0 @@
1
- import { IItem } from '@rpg-engine/shared';
2
- import React from 'react';
3
- import styled from 'styled-components';
4
-
5
- interface IProps {
6
- item: IItem | null;
7
- x: number;
8
- y: number;
9
- }
10
-
11
- export const ItemCard: React.FC<IProps> = ({ item, x, y }) => {
12
- return (
13
- <Container x={x} y={y}>
14
- {item?.name}
15
- </Container>
16
- );
17
- };
18
-
19
- interface IContainerProps {
20
- x?: number;
21
- y?: number;
22
- fontSize?: number;
23
- }
24
- const Container = styled.div<IContainerProps>`
25
- position: absolute;
26
- top: ${props => props.y || 0}px;
27
- left: ${props => props.x || 0}px;
28
- font-size: 0.5rem;
29
- color: white;
30
- background-color: black;
31
- border-radius: 5px;
32
- padding: 0.5rem;
33
- min-width: 20px;
34
-
35
- opacity: 0.5;
36
- `;
@@ -1,67 +0,0 @@
1
- import React from 'react';
2
- import styled from 'styled-components';
3
- import iconsAtlasJSON from '../../mocks/atlas/icons/icons.json';
4
- import iconsAtlasIMG from '../../mocks/atlas/icons/icons.png';
5
- import { SpriteFromAtlas } from './SpriteFromAtlas';
6
-
7
- interface IProps {
8
- onClick?: () => void;
9
- spriteKey: string;
10
- baseSpriteKey?: string;
11
- imgStyle?: any;
12
- }
13
-
14
- export const SpriteIcon: React.FC<IProps> = ({
15
- onClick,
16
- spriteKey,
17
- baseSpriteKey,
18
- imgStyle,
19
- }) => {
20
- return (
21
- <Container>
22
- {baseSpriteKey && (
23
- <Slot>
24
- <SpriteFromAtlas
25
- onClick={onClick}
26
- atlasJSON={iconsAtlasJSON}
27
- atlasIMG={iconsAtlasIMG}
28
- spriteKey={baseSpriteKey}
29
- width={32}
30
- height={32}
31
- containerStyle={{
32
- zIndex: -1,
33
- }}
34
- />
35
- </Slot>
36
- )}
37
- <Slot>
38
- <SpriteFromAtlas
39
- onClick={onClick}
40
- atlasJSON={iconsAtlasJSON}
41
- atlasIMG={iconsAtlasIMG}
42
- spriteKey={spriteKey}
43
- width={28}
44
- height={28}
45
- containerStyle={{
46
- zIndex: 0,
47
- }}
48
- imgScale={baseSpriteKey ? 1.5 : 2}
49
- imgStyle={imgStyle}
50
- />
51
- </Slot>
52
- </Container>
53
- );
54
- };
55
-
56
- const Container = styled.div`
57
- position: relative;
58
- width: 32px;
59
- height: 32px;
60
- display: flex;
61
- justify-content: center;
62
- align-items: center;
63
- `;
64
-
65
- const Slot = styled.div`
66
- position: absolute;
67
- `;
@@ -1,232 +0,0 @@
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
-
126
- this.setDraggablePosition(this.getOffsets())
127
-
128
- switch (slotContainerType) {
129
- case SlotContainerType.EQUIPMENT_SET:
130
- this.setEquipContextMenu(
131
- {
132
- visible: true,
133
- posX,
134
- posY,
135
- slotItem: item,
136
- },
137
- item.type,
138
- item.isItemContainer
139
- );
140
- break;
141
- case SlotContainerType.INVENTORY:
142
- this.setContextMenu(
143
- {
144
- visible: true,
145
- posX,
146
- posY,
147
- slotItem: item,
148
- },
149
- item.type
150
- );
151
- break;
152
- default:
153
- this.setContextMenu(
154
- {
155
- visible: true,
156
- posX,
157
- posY,
158
- slotItem: item,
159
- },
160
- item.type
161
- );
162
- }
163
-
164
- this.clearItemHoverDetail();
165
- };
166
-
167
- public handleOnMouseHover = (
168
- event: any,
169
- slotIndex: number,
170
- item: IItem | null,
171
- posX: number,
172
- posY: number,
173
- onMouseOver: any
174
- ): void => {
175
- if (item) {
176
- this.setDraggablePosition(this.getOffsets())
177
- this.setItemHoverDetail({
178
- visible: true,
179
- posX: posX,
180
- posY: posY,
181
- item: item,
182
- });
183
- }
184
- if (onMouseOver) {
185
- onMouseOver(event, slotIndex, item);
186
- }
187
- };
188
-
189
- public onSelected(
190
- selectedActionId: ItemSocketEvents | string,
191
- onActionSelected: any
192
- ) {
193
- let payloadData: IPayloadProps = {
194
- actionType: selectedActionId,
195
- item: this.contextMenu?.slotItem!,
196
- };
197
- if (onActionSelected) {
198
- onActionSelected(payloadData);
199
- }
200
- this.clearContextMenu!();
201
- }
202
-
203
- public setDraggablePosition(currentPosition: IPosition){
204
- this.draggablePosition = { ...currentPosition }
205
- }
206
-
207
- private getOffsets = () => {
208
- const p = { x: 0, y: 0};
209
- // const body = document.getElementsByTagName('body')
210
- let body = document.querySelector('body') as any | null;
211
-
212
- if( body != null){
213
- p.x = body.offsetLeft;
214
- p.y = body.offsetTop;
215
- while(body!.offsetParent){
216
- console.log(`offsetParent: ${body!.offsetParent}`)
217
- p.x = p.x + body!.offsetLeft
218
- p.y = p.y + body!.offsetTop;
219
- if (body == document.getElementsByTagName("body")[0]) {
220
- break;
221
- }
222
- else {
223
- body = body!.offsetParent;
224
- }
225
- }
226
- }
227
- return p;
228
- }
229
-
230
- }
231
-
232
- export const uiStore = new UIStore();