@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rpg-engine/long-bow",
3
- "version": "0.7.92",
3
+ "version": "0.7.94",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -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 ? ['Pinned'] : []),
123
- ...Object.keys(ItemSubType),
124
- ]
125
- .filter(type => type !== 'DeadBody')
126
- .sort((a, b) => {
127
- if (a === 'Suggested') return -1;
128
- if (b === 'Suggested') return 1;
129
- if (a === 'Pinned') return -1;
130
- if (b === 'Pinned') return 1;
131
- return a.localeCompare(b);
132
- })
133
- .map((type, index) => ({
134
- id: index,
135
- value: type,
136
- option: type,
137
- }));
138
-
139
- const filteredCraftableItems = craftablesItems?.filter(item => {
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.type === selectedType;
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
- <PaginationContainer>
245
- <PaginationButton
246
- onClick={() => setCurrentPage(prev => Math.max(1, prev - 1))}
247
- disabled={currentPage === 1}
248
- >
249
- <FaChevronLeft size={12} />
250
- </PaginationButton>
251
- <PageInfo>
252
- Page {currentPage} of {totalPages}
253
- </PageInfo>
254
- <PaginationButton
255
- onClick={() =>
256
- setCurrentPage(prev => Math.min(totalPages, prev + 1))
257
- }
258
- disabled={currentPage === totalPages}
259
- >
260
- <FaChevronRight size={12} />
261
- </PaginationButton>
262
- </PaginationContainer>
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-items: start;
412
+ align-content: start;
402
413
 
403
414
  @media (max-width: ${mobilePortrait.width}) {
404
415
  grid-template-columns: 1fr;