@rpg-engine/long-bow 0.7.94 → 0.7.96
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 +60 -56
- 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 +60 -56
- package/dist/long-bow.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/CraftBook/CraftBook.tsx +11 -47
- 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) {
|
|
@@ -28893,7 +28897,7 @@ var CraftBook = function CraftBook(_ref) {
|
|
|
28893
28897
|
});
|
|
28894
28898
|
var filteredCraftableItems = items == null ? void 0 : items.filter(function (item) {
|
|
28895
28899
|
var matchesSearch = item.name.toLowerCase().includes(searchTerm.toLowerCase());
|
|
28896
|
-
var matchesCategory = selectedType === 'Suggested' || selectedType === 'Pinned'
|
|
28900
|
+
var matchesCategory = selectedType === 'Suggested' || (selectedType === 'Pinned' ? pinnedItems.includes(item.key) : item.subType === selectedType);
|
|
28897
28901
|
return matchesSearch && matchesCategory;
|
|
28898
28902
|
});
|
|
28899
28903
|
var sortedItems = [].concat(filteredCraftableItems || []).sort(function (a, b) {
|
|
@@ -28984,7 +28988,7 @@ var CraftBook = function CraftBook(_ref) {
|
|
|
28984
28988
|
}))), React__default.createElement(Footer, null, React__default.createElement(Button, {
|
|
28985
28989
|
buttonType: exports.ButtonTypes.RPGUIButton,
|
|
28986
28990
|
onPointerDown: onClose
|
|
28987
|
-
}, "
|
|
28991
|
+
}, "Close"), React__default.createElement(Button, {
|
|
28988
28992
|
disabled: !craftItemKey || isCraftingDisabled,
|
|
28989
28993
|
buttonType: exports.ButtonTypes.RPGUIButton,
|
|
28990
28994
|
onPointerDown: function onPointerDown() {
|
|
@@ -29036,7 +29040,7 @@ var ContentContainer = /*#__PURE__*/styled__default.div.withConfig({
|
|
|
29036
29040
|
var RadioInputScroller = /*#__PURE__*/styled__default.div.withConfig({
|
|
29037
29041
|
displayName: "CraftBook__RadioInputScroller",
|
|
29038
29042
|
componentId: "sc-19q95ue-8"
|
|
29039
|
-
})(["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;}"],
|
|
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);
|
|
29040
29044
|
var CraftingRecipeWrapper = /*#__PURE__*/styled__default.div.withConfig({
|
|
29041
29045
|
displayName: "CraftBook__CraftingRecipeWrapper",
|
|
29042
29046
|
componentId: "sc-19q95ue-9"
|
|
@@ -29054,7 +29058,7 @@ var PinButton = /*#__PURE__*/styled__default.button.withConfig({
|
|
|
29054
29058
|
var Footer = /*#__PURE__*/styled__default.div.withConfig({
|
|
29055
29059
|
displayName: "CraftBook__Footer",
|
|
29056
29060
|
componentId: "sc-19q95ue-11"
|
|
29057
|
-
})(["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);
|
|
29058
29062
|
var PaginationContainer = /*#__PURE__*/styled__default.div.withConfig({
|
|
29059
29063
|
displayName: "CraftBook__PaginationContainer",
|
|
29060
29064
|
componentId: "sc-19q95ue-12"
|