@rpg-engine/long-bow 0.7.93 → 0.7.95
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 +77 -65
- 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 +77 -65
- package/dist/long-bow.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/CraftBook/CraftBook.tsx +51 -82
- package/src/components/CraftBook/hooks/useResponsiveSize.ts +1 -1
- package/src/components/CraftBook/utils/calculateMaxCraftable.ts +16 -16
|
@@ -28770,11 +28770,47 @@ var CraftingRecipe = function CraftingRecipe(_ref) {
|
|
|
28770
28770
|
}), document.body));
|
|
28771
28771
|
};
|
|
28772
28772
|
|
|
28773
|
+
var desktop = {
|
|
28774
|
+
width: 'min(900px, 80%)',
|
|
28775
|
+
height: 'min(auto, 80%)'
|
|
28776
|
+
};
|
|
28777
|
+
var mobileLanscape = {
|
|
28778
|
+
width: '800px',
|
|
28779
|
+
height: '500px'
|
|
28780
|
+
};
|
|
28781
|
+
var mobilePortrait = {
|
|
28782
|
+
width: '500px',
|
|
28783
|
+
height: '700px'
|
|
28784
|
+
};
|
|
28785
|
+
var useResponsiveSize = function useResponsiveSize(scale) {
|
|
28786
|
+
var _useState = React.useState(),
|
|
28787
|
+
size = _useState[0],
|
|
28788
|
+
setSize = _useState[1];
|
|
28789
|
+
React.useEffect(function () {
|
|
28790
|
+
var handleResize = function handleResize() {
|
|
28791
|
+
if (window.innerWidth < 500 && (size == null ? void 0 : size.width) !== mobilePortrait.width && (!scale || scale < 1)) {
|
|
28792
|
+
setSize(mobilePortrait);
|
|
28793
|
+
} else if ((!scale || scale < 1) && (size == null ? void 0 : size.width) !== mobileLanscape.width) {
|
|
28794
|
+
setSize(mobileLanscape);
|
|
28795
|
+
} else if ((size == null ? void 0 : size.width) !== desktop.width) {
|
|
28796
|
+
setSize(desktop);
|
|
28797
|
+
}
|
|
28798
|
+
};
|
|
28799
|
+
handleResize();
|
|
28800
|
+
window.addEventListener('resize', handleResize);
|
|
28801
|
+
return function () {
|
|
28802
|
+
return window.removeEventListener('resize', handleResize);
|
|
28803
|
+
};
|
|
28804
|
+
}, [scale]);
|
|
28805
|
+
return size;
|
|
28806
|
+
};
|
|
28807
|
+
|
|
28773
28808
|
function calculateMaxCraftable(recipe, inventory) {
|
|
28809
|
+
var _recipe$ingredients$r;
|
|
28774
28810
|
if (!inventory || !(recipe != null && recipe.ingredients)) {
|
|
28775
28811
|
return 0;
|
|
28776
28812
|
}
|
|
28777
|
-
return recipe.ingredients.reduce(function (maxPossible, ingredient) {
|
|
28813
|
+
return (_recipe$ingredients$r = recipe.ingredients.reduce(function (maxPossible, ingredient) {
|
|
28778
28814
|
var _inventoryItem$stackQ;
|
|
28779
28815
|
var inventoryItem = Object.values(inventory.slots).find(function (item) {
|
|
28780
28816
|
return (item == null ? void 0 : item.key) === ingredient.key;
|
|
@@ -28782,26 +28818,12 @@ function calculateMaxCraftable(recipe, inventory) {
|
|
|
28782
28818
|
if (!inventoryItem) {
|
|
28783
28819
|
return 0;
|
|
28784
28820
|
}
|
|
28785
|
-
var possibleWithThisIngredient = Math.floor((_inventoryItem$stackQ = inventoryItem.stackQty) != null ? _inventoryItem$stackQ : 0 / ingredient.qty);
|
|
28786
|
-
|
|
28787
|
-
|
|
28788
|
-
}
|
|
28789
|
-
return Math.min(maxPossible, possibleWithThisIngredient);
|
|
28790
|
-
}, -1);
|
|
28821
|
+
var possibleWithThisIngredient = Math.floor(((_inventoryItem$stackQ = inventoryItem.stackQty) != null ? _inventoryItem$stackQ : 0) / ingredient.qty);
|
|
28822
|
+
return maxPossible === undefined ? possibleWithThisIngredient : Math.min(maxPossible, possibleWithThisIngredient);
|
|
28823
|
+
}, undefined)) != null ? _recipe$ingredients$r : 0;
|
|
28791
28824
|
}
|
|
28792
28825
|
|
|
28793
|
-
var
|
|
28794
|
-
width: 'min(900px, 80%)',
|
|
28795
|
-
height: 'min(700px, 80%)'
|
|
28796
|
-
};
|
|
28797
|
-
var mobileLanscape = {
|
|
28798
|
-
width: '800px',
|
|
28799
|
-
height: '500px'
|
|
28800
|
-
};
|
|
28801
|
-
var mobilePortrait = {
|
|
28802
|
-
width: '500px',
|
|
28803
|
-
height: '700px'
|
|
28804
|
-
};
|
|
28826
|
+
var MOBILE_WIDTH = '500px';
|
|
28805
28827
|
var ITEMS_PER_PAGE = 8;
|
|
28806
28828
|
var CraftBook = function CraftBook(_ref) {
|
|
28807
28829
|
var atlasIMG = _ref.atlasIMG,
|
|
@@ -28821,46 +28843,28 @@ var CraftBook = function CraftBook(_ref) {
|
|
|
28821
28843
|
var _useState2 = React.useState(savedSelectedType != null ? savedSelectedType : Object.keys(shared.ItemSubType)[0]),
|
|
28822
28844
|
selectedType = _useState2[0],
|
|
28823
28845
|
setSelectedType = _useState2[1];
|
|
28824
|
-
var
|
|
28825
|
-
|
|
28826
|
-
|
|
28827
|
-
|
|
28828
|
-
|
|
28829
|
-
|
|
28846
|
+
var size = useResponsiveSize(scale);
|
|
28847
|
+
var _useState3 = React.useState(''),
|
|
28848
|
+
searchTerm = _useState3[0],
|
|
28849
|
+
setSearchTerm = _useState3[1];
|
|
28850
|
+
var _useState4 = React.useState(false),
|
|
28851
|
+
isSearchVisible = _useState4[0],
|
|
28852
|
+
setIsSearchVisible = _useState4[1];
|
|
28830
28853
|
var _useState5 = React.useState(false),
|
|
28831
|
-
|
|
28832
|
-
|
|
28833
|
-
var _useState6 = React.useState(false),
|
|
28834
|
-
isCraftingDisabled = _useState6[0],
|
|
28835
|
-
setIsCraftingDisabled = _useState6[1];
|
|
28854
|
+
isCraftingDisabled = _useState5[0],
|
|
28855
|
+
setIsCraftingDisabled = _useState5[1];
|
|
28836
28856
|
var _useLocalStorage = useLocalStorage('pinnedCraftItems', []),
|
|
28837
28857
|
pinnedItems = _useLocalStorage[0],
|
|
28838
28858
|
setPinnedItems = _useLocalStorage[1];
|
|
28839
|
-
var
|
|
28840
|
-
currentPage =
|
|
28841
|
-
setCurrentPage =
|
|
28842
|
-
var
|
|
28843
|
-
items =
|
|
28844
|
-
setItems =
|
|
28859
|
+
var _useState6 = React.useState(1),
|
|
28860
|
+
currentPage = _useState6[0],
|
|
28861
|
+
setCurrentPage = _useState6[1];
|
|
28862
|
+
var _useState7 = React.useState(craftablesItems),
|
|
28863
|
+
items = _useState7[0],
|
|
28864
|
+
setItems = _useState7[1];
|
|
28845
28865
|
React.useEffect(function () {
|
|
28846
28866
|
setItems(craftablesItems);
|
|
28847
28867
|
}, [craftablesItems]);
|
|
28848
|
-
React.useEffect(function () {
|
|
28849
|
-
var handleResize = function handleResize() {
|
|
28850
|
-
if (window.innerWidth < 500 && (size == null ? void 0 : size.width) !== mobilePortrait.width && (!scale || scale < 1)) {
|
|
28851
|
-
setSize(mobilePortrait);
|
|
28852
|
-
} else if ((!scale || scale < 1) && (size == null ? void 0 : size.width) !== mobileLanscape.width) {
|
|
28853
|
-
setSize(mobileLanscape);
|
|
28854
|
-
} else if ((size == null ? void 0 : size.width) !== desktop.width) {
|
|
28855
|
-
setSize(desktop);
|
|
28856
|
-
}
|
|
28857
|
-
};
|
|
28858
|
-
handleResize();
|
|
28859
|
-
window.addEventListener('resize', handleResize);
|
|
28860
|
-
return function () {
|
|
28861
|
-
return window.removeEventListener('resize', handleResize);
|
|
28862
|
-
};
|
|
28863
|
-
}, [scale]);
|
|
28864
28868
|
var togglePinItem = function togglePinItem(itemKey) {
|
|
28865
28869
|
setPinnedItems(function (current) {
|
|
28866
28870
|
return current.includes(itemKey) ? current.filter(function (key) {
|
|
@@ -28868,20 +28872,28 @@ var CraftBook = function CraftBook(_ref) {
|
|
|
28868
28872
|
}) : [].concat(current, [itemKey]);
|
|
28869
28873
|
});
|
|
28870
28874
|
};
|
|
28871
|
-
var categoryOptions = [
|
|
28875
|
+
var categoryOptions = [{
|
|
28876
|
+
id: 0,
|
|
28877
|
+
value: 'Suggested',
|
|
28878
|
+
option: 'Suggested'
|
|
28879
|
+
}].concat(pinnedItems.length > 0 ? [{
|
|
28880
|
+
id: 1,
|
|
28881
|
+
value: 'Pinned',
|
|
28882
|
+
option: 'Pinned'
|
|
28883
|
+
}] : [], Object.keys(shared.ItemSubType).filter(function (type) {
|
|
28872
28884
|
return type !== 'DeadBody';
|
|
28873
|
-
}).sort(function (a, b) {
|
|
28874
|
-
if (a === 'Suggested') return -1;
|
|
28875
|
-
if (b === 'Suggested') return 1;
|
|
28876
|
-
if (a === 'Pinned') return -1;
|
|
28877
|
-
if (b === 'Pinned') return 1;
|
|
28878
|
-
return a.localeCompare(b);
|
|
28879
28885
|
}).map(function (type, index) {
|
|
28880
28886
|
return {
|
|
28881
|
-
id: index,
|
|
28887
|
+
id: index + (pinnedItems.length > 0 ? 2 : 1),
|
|
28882
28888
|
value: type,
|
|
28883
|
-
option: type
|
|
28889
|
+
option: type === 'CraftingResources' || type === 'CraftingResource' ? 'Resources' : type
|
|
28884
28890
|
};
|
|
28891
|
+
})).sort(function (a, b) {
|
|
28892
|
+
if (a.value === 'Suggested') return -1;
|
|
28893
|
+
if (b.value === 'Suggested') return 1;
|
|
28894
|
+
if (a.value === 'Pinned') return -1;
|
|
28895
|
+
if (b.value === 'Pinned') return 1;
|
|
28896
|
+
return a.value.localeCompare(b.value);
|
|
28885
28897
|
});
|
|
28886
28898
|
var filteredCraftableItems = items == null ? void 0 : items.filter(function (item) {
|
|
28887
28899
|
var matchesSearch = item.name.toLowerCase().includes(searchTerm.toLowerCase());
|
|
@@ -28955,7 +28967,7 @@ var CraftBook = function CraftBook(_ref) {
|
|
|
28955
28967
|
inventory: inventory,
|
|
28956
28968
|
skills: skills
|
|
28957
28969
|
}));
|
|
28958
|
-
}))), React__default.createElement(PaginationContainer, null, React__default.createElement(PaginationButton, {
|
|
28970
|
+
}))), totalPages > 1 && React__default.createElement(PaginationContainer, null, React__default.createElement(PaginationButton, {
|
|
28959
28971
|
onClick: function onClick() {
|
|
28960
28972
|
return setCurrentPage(function (prev) {
|
|
28961
28973
|
return Math.max(1, prev - 1);
|
|
@@ -28976,7 +28988,7 @@ var CraftBook = function CraftBook(_ref) {
|
|
|
28976
28988
|
}))), React__default.createElement(Footer, null, React__default.createElement(Button, {
|
|
28977
28989
|
buttonType: exports.ButtonTypes.RPGUIButton,
|
|
28978
28990
|
onPointerDown: onClose
|
|
28979
|
-
}, "
|
|
28991
|
+
}, "Close"), React__default.createElement(Button, {
|
|
28980
28992
|
disabled: !craftItemKey || isCraftingDisabled,
|
|
28981
28993
|
buttonType: exports.ButtonTypes.RPGUIButton,
|
|
28982
28994
|
onPointerDown: function onPointerDown() {
|
|
@@ -29028,7 +29040,7 @@ var ContentContainer = /*#__PURE__*/styled__default.div.withConfig({
|
|
|
29028
29040
|
var RadioInputScroller = /*#__PURE__*/styled__default.div.withConfig({
|
|
29029
29041
|
displayName: "CraftBook__RadioInputScroller",
|
|
29030
29042
|
componentId: "sc-19q95ue-8"
|
|
29031
|
-
})(["height:100%;overflow-y:scroll;overflow-x:hidden;padding:8px 16px;padding-right:24px;width:100%;box-sizing:border-box;display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:16px;align-
|
|
29043
|
+
})(["height:100%;overflow-y:scroll;overflow-x:hidden;padding:8px 16px;padding-right:24px;width:100%;box-sizing:border-box;display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:16px;align-content:start;@media (max-width:", "){grid-template-columns:1fr;}"], MOBILE_WIDTH);
|
|
29032
29044
|
var CraftingRecipeWrapper = /*#__PURE__*/styled__default.div.withConfig({
|
|
29033
29045
|
displayName: "CraftBook__CraftingRecipeWrapper",
|
|
29034
29046
|
componentId: "sc-19q95ue-9"
|
|
@@ -29046,7 +29058,7 @@ var PinButton = /*#__PURE__*/styled__default.button.withConfig({
|
|
|
29046
29058
|
var Footer = /*#__PURE__*/styled__default.div.withConfig({
|
|
29047
29059
|
displayName: "CraftBook__Footer",
|
|
29048
29060
|
componentId: "sc-19q95ue-11"
|
|
29049
|
-
})(["display:flex;justify-content:flex-end;gap:16px;padding:8px;button{min-width:100px;}@media (max-width:", "){justify-content:center;}"],
|
|
29061
|
+
})(["display:flex;justify-content:flex-end;gap:16px;padding:8px;button{min-width:100px;}@media (max-width:", "){justify-content:center;}"], MOBILE_WIDTH);
|
|
29050
29062
|
var PaginationContainer = /*#__PURE__*/styled__default.div.withConfig({
|
|
29051
29063
|
displayName: "CraftBook__PaginationContainer",
|
|
29052
29064
|
componentId: "sc-19q95ue-12"
|