@rpg-engine/long-bow 0.7.94 → 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 +59 -55
- 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 +59 -55
- package/dist/long-bow.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/CraftBook/CraftBook.tsx +8 -45
- package/src/components/CraftBook/hooks/useResponsiveSize.ts +1 -1
- package/src/components/CraftBook/utils/calculateMaxCraftable.ts +16 -16
package/dist/long-bow.esm.js
CHANGED
|
@@ -28763,11 +28763,47 @@ var CraftingRecipe = function CraftingRecipe(_ref) {
|
|
|
28763
28763
|
}), document.body));
|
|
28764
28764
|
};
|
|
28765
28765
|
|
|
28766
|
+
var desktop = {
|
|
28767
|
+
width: 'min(900px, 80%)',
|
|
28768
|
+
height: 'min(auto, 80%)'
|
|
28769
|
+
};
|
|
28770
|
+
var mobileLanscape = {
|
|
28771
|
+
width: '800px',
|
|
28772
|
+
height: '500px'
|
|
28773
|
+
};
|
|
28774
|
+
var mobilePortrait = {
|
|
28775
|
+
width: '500px',
|
|
28776
|
+
height: '700px'
|
|
28777
|
+
};
|
|
28778
|
+
var useResponsiveSize = function useResponsiveSize(scale) {
|
|
28779
|
+
var _useState = useState(),
|
|
28780
|
+
size = _useState[0],
|
|
28781
|
+
setSize = _useState[1];
|
|
28782
|
+
useEffect(function () {
|
|
28783
|
+
var handleResize = function handleResize() {
|
|
28784
|
+
if (window.innerWidth < 500 && (size == null ? void 0 : size.width) !== mobilePortrait.width && (!scale || scale < 1)) {
|
|
28785
|
+
setSize(mobilePortrait);
|
|
28786
|
+
} else if ((!scale || scale < 1) && (size == null ? void 0 : size.width) !== mobileLanscape.width) {
|
|
28787
|
+
setSize(mobileLanscape);
|
|
28788
|
+
} else if ((size == null ? void 0 : size.width) !== desktop.width) {
|
|
28789
|
+
setSize(desktop);
|
|
28790
|
+
}
|
|
28791
|
+
};
|
|
28792
|
+
handleResize();
|
|
28793
|
+
window.addEventListener('resize', handleResize);
|
|
28794
|
+
return function () {
|
|
28795
|
+
return window.removeEventListener('resize', handleResize);
|
|
28796
|
+
};
|
|
28797
|
+
}, [scale]);
|
|
28798
|
+
return size;
|
|
28799
|
+
};
|
|
28800
|
+
|
|
28766
28801
|
function calculateMaxCraftable(recipe, inventory) {
|
|
28802
|
+
var _recipe$ingredients$r;
|
|
28767
28803
|
if (!inventory || !(recipe != null && recipe.ingredients)) {
|
|
28768
28804
|
return 0;
|
|
28769
28805
|
}
|
|
28770
|
-
return recipe.ingredients.reduce(function (maxPossible, ingredient) {
|
|
28806
|
+
return (_recipe$ingredients$r = recipe.ingredients.reduce(function (maxPossible, ingredient) {
|
|
28771
28807
|
var _inventoryItem$stackQ;
|
|
28772
28808
|
var inventoryItem = Object.values(inventory.slots).find(function (item) {
|
|
28773
28809
|
return (item == null ? void 0 : item.key) === ingredient.key;
|
|
@@ -28775,26 +28811,12 @@ function calculateMaxCraftable(recipe, inventory) {
|
|
|
28775
28811
|
if (!inventoryItem) {
|
|
28776
28812
|
return 0;
|
|
28777
28813
|
}
|
|
28778
|
-
var possibleWithThisIngredient = Math.floor((_inventoryItem$stackQ = inventoryItem.stackQty) != null ? _inventoryItem$stackQ : 0 / ingredient.qty);
|
|
28779
|
-
|
|
28780
|
-
|
|
28781
|
-
}
|
|
28782
|
-
return Math.min(maxPossible, possibleWithThisIngredient);
|
|
28783
|
-
}, -1);
|
|
28814
|
+
var possibleWithThisIngredient = Math.floor(((_inventoryItem$stackQ = inventoryItem.stackQty) != null ? _inventoryItem$stackQ : 0) / ingredient.qty);
|
|
28815
|
+
return maxPossible === undefined ? possibleWithThisIngredient : Math.min(maxPossible, possibleWithThisIngredient);
|
|
28816
|
+
}, undefined)) != null ? _recipe$ingredients$r : 0;
|
|
28784
28817
|
}
|
|
28785
28818
|
|
|
28786
|
-
var
|
|
28787
|
-
width: 'min(900px, 80%)',
|
|
28788
|
-
height: 'min(700px, 80%)'
|
|
28789
|
-
};
|
|
28790
|
-
var mobileLanscape = {
|
|
28791
|
-
width: '800px',
|
|
28792
|
-
height: '500px'
|
|
28793
|
-
};
|
|
28794
|
-
var mobilePortrait = {
|
|
28795
|
-
width: '500px',
|
|
28796
|
-
height: '700px'
|
|
28797
|
-
};
|
|
28819
|
+
var MOBILE_WIDTH = '500px';
|
|
28798
28820
|
var ITEMS_PER_PAGE = 8;
|
|
28799
28821
|
var CraftBook = function CraftBook(_ref) {
|
|
28800
28822
|
var atlasIMG = _ref.atlasIMG,
|
|
@@ -28814,46 +28836,28 @@ var CraftBook = function CraftBook(_ref) {
|
|
|
28814
28836
|
var _useState2 = useState(savedSelectedType != null ? savedSelectedType : Object.keys(ItemSubType)[0]),
|
|
28815
28837
|
selectedType = _useState2[0],
|
|
28816
28838
|
setSelectedType = _useState2[1];
|
|
28817
|
-
var
|
|
28818
|
-
|
|
28819
|
-
|
|
28820
|
-
|
|
28821
|
-
|
|
28822
|
-
|
|
28839
|
+
var size = useResponsiveSize(scale);
|
|
28840
|
+
var _useState3 = useState(''),
|
|
28841
|
+
searchTerm = _useState3[0],
|
|
28842
|
+
setSearchTerm = _useState3[1];
|
|
28843
|
+
var _useState4 = useState(false),
|
|
28844
|
+
isSearchVisible = _useState4[0],
|
|
28845
|
+
setIsSearchVisible = _useState4[1];
|
|
28823
28846
|
var _useState5 = useState(false),
|
|
28824
|
-
|
|
28825
|
-
|
|
28826
|
-
var _useState6 = useState(false),
|
|
28827
|
-
isCraftingDisabled = _useState6[0],
|
|
28828
|
-
setIsCraftingDisabled = _useState6[1];
|
|
28847
|
+
isCraftingDisabled = _useState5[0],
|
|
28848
|
+
setIsCraftingDisabled = _useState5[1];
|
|
28829
28849
|
var _useLocalStorage = useLocalStorage('pinnedCraftItems', []),
|
|
28830
28850
|
pinnedItems = _useLocalStorage[0],
|
|
28831
28851
|
setPinnedItems = _useLocalStorage[1];
|
|
28832
|
-
var
|
|
28833
|
-
currentPage =
|
|
28834
|
-
setCurrentPage =
|
|
28835
|
-
var
|
|
28836
|
-
items =
|
|
28837
|
-
setItems =
|
|
28852
|
+
var _useState6 = useState(1),
|
|
28853
|
+
currentPage = _useState6[0],
|
|
28854
|
+
setCurrentPage = _useState6[1];
|
|
28855
|
+
var _useState7 = useState(craftablesItems),
|
|
28856
|
+
items = _useState7[0],
|
|
28857
|
+
setItems = _useState7[1];
|
|
28838
28858
|
useEffect(function () {
|
|
28839
28859
|
setItems(craftablesItems);
|
|
28840
28860
|
}, [craftablesItems]);
|
|
28841
|
-
useEffect(function () {
|
|
28842
|
-
var handleResize = function handleResize() {
|
|
28843
|
-
if (window.innerWidth < 500 && (size == null ? void 0 : size.width) !== mobilePortrait.width && (!scale || scale < 1)) {
|
|
28844
|
-
setSize(mobilePortrait);
|
|
28845
|
-
} else if ((!scale || scale < 1) && (size == null ? void 0 : size.width) !== mobileLanscape.width) {
|
|
28846
|
-
setSize(mobileLanscape);
|
|
28847
|
-
} else if ((size == null ? void 0 : size.width) !== desktop.width) {
|
|
28848
|
-
setSize(desktop);
|
|
28849
|
-
}
|
|
28850
|
-
};
|
|
28851
|
-
handleResize();
|
|
28852
|
-
window.addEventListener('resize', handleResize);
|
|
28853
|
-
return function () {
|
|
28854
|
-
return window.removeEventListener('resize', handleResize);
|
|
28855
|
-
};
|
|
28856
|
-
}, [scale]);
|
|
28857
28861
|
var togglePinItem = function togglePinItem(itemKey) {
|
|
28858
28862
|
setPinnedItems(function (current) {
|
|
28859
28863
|
return current.includes(itemKey) ? current.filter(function (key) {
|
|
@@ -28977,7 +28981,7 @@ var CraftBook = function CraftBook(_ref) {
|
|
|
28977
28981
|
}))), React.createElement(Footer, null, React.createElement(Button, {
|
|
28978
28982
|
buttonType: ButtonTypes.RPGUIButton,
|
|
28979
28983
|
onPointerDown: onClose
|
|
28980
|
-
}, "
|
|
28984
|
+
}, "Close"), React.createElement(Button, {
|
|
28981
28985
|
disabled: !craftItemKey || isCraftingDisabled,
|
|
28982
28986
|
buttonType: ButtonTypes.RPGUIButton,
|
|
28983
28987
|
onPointerDown: function onPointerDown() {
|
|
@@ -29029,7 +29033,7 @@ var ContentContainer = /*#__PURE__*/styled.div.withConfig({
|
|
|
29029
29033
|
var RadioInputScroller = /*#__PURE__*/styled.div.withConfig({
|
|
29030
29034
|
displayName: "CraftBook__RadioInputScroller",
|
|
29031
29035
|
componentId: "sc-19q95ue-8"
|
|
29032
|
-
})(["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;}"],
|
|
29036
|
+
})(["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);
|
|
29033
29037
|
var CraftingRecipeWrapper = /*#__PURE__*/styled.div.withConfig({
|
|
29034
29038
|
displayName: "CraftBook__CraftingRecipeWrapper",
|
|
29035
29039
|
componentId: "sc-19q95ue-9"
|
|
@@ -29047,7 +29051,7 @@ var PinButton = /*#__PURE__*/styled.button.withConfig({
|
|
|
29047
29051
|
var Footer = /*#__PURE__*/styled.div.withConfig({
|
|
29048
29052
|
displayName: "CraftBook__Footer",
|
|
29049
29053
|
componentId: "sc-19q95ue-11"
|
|
29050
|
-
})(["display:flex;justify-content:flex-end;gap:16px;padding:8px;button{min-width:100px;}@media (max-width:", "){justify-content:center;}"],
|
|
29054
|
+
})(["display:flex;justify-content:flex-end;gap:16px;padding:8px;button{min-width:100px;}@media (max-width:", "){justify-content:center;}"], MOBILE_WIDTH);
|
|
29051
29055
|
var PaginationContainer = /*#__PURE__*/styled.div.withConfig({
|
|
29052
29056
|
displayName: "CraftBook__PaginationContainer",
|
|
29053
29057
|
componentId: "sc-19q95ue-12"
|