@rpg-engine/long-bow 0.5.9 → 0.5.10
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/long-bow.cjs.development.js +39 -2
- 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 +39 -2
- package/dist/long-bow.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Item/Inventory/ItemContainer.tsx +54 -4
- package/src/mocks/itemContainer.mocks.ts +2 -1
package/package.json
CHANGED
|
@@ -13,6 +13,7 @@ import { ItemQuantitySelector } from './ItemQuantitySelector';
|
|
|
13
13
|
|
|
14
14
|
import { IPosition } from '../../../types/eventTypes';
|
|
15
15
|
import ModalPortal from '../../Abstractions/ModalPortal';
|
|
16
|
+
import SelectArrow from '../../Arrow/SelectArrow';
|
|
16
17
|
import { ShortcutsSetter } from '../../Shortcuts/ShortcutsSetter';
|
|
17
18
|
import { ItemSlot } from './ItemSlot';
|
|
18
19
|
|
|
@@ -81,12 +82,15 @@ export const ItemContainer: React.FC<IItemContainerProps> = ({
|
|
|
81
82
|
onPositionChangeEnd,
|
|
82
83
|
onPositionChangeStart,
|
|
83
84
|
}) => {
|
|
85
|
+
const MAX_SLOTS_PER_PAGE = 20;
|
|
84
86
|
const [quantitySelect, setQuantitySelect] = useState({
|
|
85
87
|
isOpen: false,
|
|
86
88
|
maxQuantity: 1,
|
|
87
|
-
callback: (_quantity: number) => {},
|
|
89
|
+
callback: (_quantity: number) => { },
|
|
88
90
|
});
|
|
89
91
|
const [settingShortcutIndex, setSettingShortcutIndex] = useState(-1);
|
|
92
|
+
const [currentPage, setCurrentPage] = useState(1);
|
|
93
|
+
const totalPages = Math.ceil(itemContainer.slotQty / MAX_SLOTS_PER_PAGE);
|
|
90
94
|
|
|
91
95
|
const handleSetShortcut = (item: IItem, index: number) => {
|
|
92
96
|
if (item.type === ItemType.Consumable || item.type === ItemType.Tool) {
|
|
@@ -96,8 +100,10 @@ export const ItemContainer: React.FC<IItemContainerProps> = ({
|
|
|
96
100
|
|
|
97
101
|
const onRenderSlots = () => {
|
|
98
102
|
const slots = [];
|
|
103
|
+
const start = (currentPage - 1) * MAX_SLOTS_PER_PAGE;
|
|
104
|
+
const end = start + MAX_SLOTS_PER_PAGE;
|
|
99
105
|
|
|
100
|
-
for (let i =
|
|
106
|
+
for (let i = start; i < end && i < itemContainer.slotQty; i++) {
|
|
101
107
|
slots.push(
|
|
102
108
|
<ItemSlot
|
|
103
109
|
isContextMenuDisabled={disableContextMenu}
|
|
@@ -156,6 +162,14 @@ export const ItemContainer: React.FC<IItemContainerProps> = ({
|
|
|
156
162
|
return slots;
|
|
157
163
|
};
|
|
158
164
|
|
|
165
|
+
const goToNextPage = () => {
|
|
166
|
+
setCurrentPage(current => Math.min(current + 1, totalPages));
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
const goToPreviousPage = () => {
|
|
170
|
+
setCurrentPage(current => Math.max(current - 1, 1));
|
|
171
|
+
};
|
|
172
|
+
|
|
159
173
|
return (
|
|
160
174
|
<>
|
|
161
175
|
<SlotsContainer
|
|
@@ -181,6 +195,28 @@ export const ItemContainer: React.FC<IItemContainerProps> = ({
|
|
|
181
195
|
<ItemsContainer className="item-container-body">
|
|
182
196
|
{onRenderSlots()}
|
|
183
197
|
</ItemsContainer>
|
|
198
|
+
{totalPages > 1 && (
|
|
199
|
+
<ArrowContainer>
|
|
200
|
+
<SelectArrow
|
|
201
|
+
className='arrow .arrow-up'
|
|
202
|
+
direction="left"
|
|
203
|
+
onPointerDown={() => {
|
|
204
|
+
if (currentPage > 1) {
|
|
205
|
+
goToPreviousPage();
|
|
206
|
+
}
|
|
207
|
+
}}
|
|
208
|
+
/>
|
|
209
|
+
<SelectArrow
|
|
210
|
+
className='arrow .arrow-down'
|
|
211
|
+
direction="right"
|
|
212
|
+
onPointerDown={() => {
|
|
213
|
+
if (currentPage < totalPages) {
|
|
214
|
+
goToNextPage();
|
|
215
|
+
}
|
|
216
|
+
}}
|
|
217
|
+
/>
|
|
218
|
+
</ArrowContainer>
|
|
219
|
+
)}
|
|
184
220
|
</SlotsContainer>
|
|
185
221
|
{quantitySelect.isOpen && (
|
|
186
222
|
<ModalPortal>
|
|
@@ -192,7 +228,7 @@ export const ItemContainer: React.FC<IItemContainerProps> = ({
|
|
|
192
228
|
setQuantitySelect({
|
|
193
229
|
isOpen: false,
|
|
194
230
|
maxQuantity: 1,
|
|
195
|
-
callback: () => {},
|
|
231
|
+
callback: () => { },
|
|
196
232
|
});
|
|
197
233
|
}}
|
|
198
234
|
onClose={() => {
|
|
@@ -200,7 +236,7 @@ export const ItemContainer: React.FC<IItemContainerProps> = ({
|
|
|
200
236
|
setQuantitySelect({
|
|
201
237
|
isOpen: false,
|
|
202
238
|
maxQuantity: 1,
|
|
203
|
-
callback: () => {},
|
|
239
|
+
callback: () => { },
|
|
204
240
|
});
|
|
205
241
|
}}
|
|
206
242
|
/>
|
|
@@ -229,3 +265,17 @@ const QuantitySelectorContainer = styled.div`
|
|
|
229
265
|
align-items: center;
|
|
230
266
|
background-color: rgba(0, 0, 0, 0.5);
|
|
231
267
|
`;
|
|
268
|
+
|
|
269
|
+
const ArrowContainer = styled.div`
|
|
270
|
+
margin-top: 10px;
|
|
271
|
+
margin-bottom: 30px;
|
|
272
|
+
/* Aplica a margem ao primeiro span (seta para a esquerda) */
|
|
273
|
+
span:first-child {
|
|
274
|
+
margin-left: 20px;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/* Aplica a margem ao último span (seta para a direita) */
|
|
278
|
+
span:last-child {
|
|
279
|
+
margin-right: 20px;
|
|
280
|
+
}
|
|
281
|
+
`;
|
|
@@ -577,7 +577,7 @@ export const itemContainerMock: IItemContainer = {
|
|
|
577
577
|
_id: '629ba0b6fe3f43002f58f23b',
|
|
578
578
|
name: 'Item Container',
|
|
579
579
|
owner: '629ba0b6fe3f43002f58f23b',
|
|
580
|
-
slotQty:
|
|
580
|
+
slotQty: 60,
|
|
581
581
|
slots: {
|
|
582
582
|
0: items[0],
|
|
583
583
|
1: items[1],
|
|
@@ -595,6 +595,7 @@ export const itemContainerMock: IItemContainer = {
|
|
|
595
595
|
13: items[13],
|
|
596
596
|
14: items[14],
|
|
597
597
|
15: items[15],
|
|
598
|
+
21: items[15],
|
|
598
599
|
//remaining slots are considered null by default
|
|
599
600
|
},
|
|
600
601
|
allowedItemTypes: [],
|