@rpg-engine/long-bow 0.7.92 → 0.7.94
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 +27 -13
- 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 +27 -13
- package/dist/long-bow.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/CraftBook/CraftBook.tsx +51 -40
package/package.json
CHANGED
|
@@ -84,6 +84,11 @@ export const CraftBook: React.FC<IItemCraftSelectorProps> = ({
|
|
|
84
84
|
[]
|
|
85
85
|
);
|
|
86
86
|
const [currentPage, setCurrentPage] = useState(1);
|
|
87
|
+
const [items, setItems] = useState<ICraftableItem[]>(craftablesItems);
|
|
88
|
+
|
|
89
|
+
useEffect(() => {
|
|
90
|
+
setItems(craftablesItems);
|
|
91
|
+
}, [craftablesItems]);
|
|
87
92
|
|
|
88
93
|
useEffect(() => {
|
|
89
94
|
const handleResize = (): void => {
|
|
@@ -118,32 +123,36 @@ export const CraftBook: React.FC<IItemCraftSelectorProps> = ({
|
|
|
118
123
|
};
|
|
119
124
|
|
|
120
125
|
const categoryOptions: IOptionsProps[] = [
|
|
121
|
-
'Suggested',
|
|
122
|
-
...(pinnedItems.length > 0
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
.
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
126
|
+
{ id: 0, value: 'Suggested', option: 'Suggested' },
|
|
127
|
+
...(pinnedItems.length > 0
|
|
128
|
+
? [{ id: 1, value: 'Pinned', option: 'Pinned' }]
|
|
129
|
+
: []),
|
|
130
|
+
...Object.keys(ItemSubType)
|
|
131
|
+
.filter(type => type !== 'DeadBody')
|
|
132
|
+
.map((type, index) => ({
|
|
133
|
+
id: index + (pinnedItems.length > 0 ? 2 : 1),
|
|
134
|
+
value: type,
|
|
135
|
+
option:
|
|
136
|
+
type === 'CraftingResources' || type === 'CraftingResource'
|
|
137
|
+
? 'Resources'
|
|
138
|
+
: type,
|
|
139
|
+
})),
|
|
140
|
+
].sort((a, b) => {
|
|
141
|
+
if (a.value === 'Suggested') return -1;
|
|
142
|
+
if (b.value === 'Suggested') return 1;
|
|
143
|
+
if (a.value === 'Pinned') return -1;
|
|
144
|
+
if (b.value === 'Pinned') return 1;
|
|
145
|
+
return a.value.localeCompare(b.value);
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
const filteredCraftableItems = items?.filter(item => {
|
|
140
149
|
const matchesSearch = item.name
|
|
141
150
|
.toLowerCase()
|
|
142
151
|
.includes(searchTerm.toLowerCase());
|
|
143
152
|
const matchesCategory =
|
|
144
153
|
selectedType === 'Suggested' ||
|
|
145
154
|
(selectedType === 'Pinned' && pinnedItems.includes(item.key)) ||
|
|
146
|
-
item.
|
|
155
|
+
item.subType === selectedType;
|
|
147
156
|
return matchesSearch && matchesCategory;
|
|
148
157
|
});
|
|
149
158
|
|
|
@@ -241,25 +250,27 @@ export const CraftBook: React.FC<IItemCraftSelectorProps> = ({
|
|
|
241
250
|
</RadioInputScroller>
|
|
242
251
|
</ContentContainer>
|
|
243
252
|
|
|
244
|
-
|
|
245
|
-
<
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
253
|
+
{totalPages > 1 && (
|
|
254
|
+
<PaginationContainer>
|
|
255
|
+
<PaginationButton
|
|
256
|
+
onClick={() => setCurrentPage(prev => Math.max(1, prev - 1))}
|
|
257
|
+
disabled={currentPage === 1}
|
|
258
|
+
>
|
|
259
|
+
<FaChevronLeft size={12} />
|
|
260
|
+
</PaginationButton>
|
|
261
|
+
<PageInfo>
|
|
262
|
+
Page {currentPage} of {totalPages}
|
|
263
|
+
</PageInfo>
|
|
264
|
+
<PaginationButton
|
|
265
|
+
onClick={() =>
|
|
266
|
+
setCurrentPage(prev => Math.min(totalPages, prev + 1))
|
|
267
|
+
}
|
|
268
|
+
disabled={currentPage === totalPages}
|
|
269
|
+
>
|
|
270
|
+
<FaChevronRight size={12} />
|
|
271
|
+
</PaginationButton>
|
|
272
|
+
</PaginationContainer>
|
|
273
|
+
)}
|
|
263
274
|
|
|
264
275
|
<Footer>
|
|
265
276
|
<Button buttonType={ButtonTypes.RPGUIButton} onPointerDown={onClose}>
|
|
@@ -398,7 +409,7 @@ const RadioInputScroller = styled.div`
|
|
|
398
409
|
display: grid;
|
|
399
410
|
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
400
411
|
gap: 16px;
|
|
401
|
-
align-
|
|
412
|
+
align-content: start;
|
|
402
413
|
|
|
403
414
|
@media (max-width: ${mobilePortrait.width}) {
|
|
404
415
|
grid-template-columns: 1fr;
|