@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.
@@ -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
- if (maxPossible === -1) {
28780
- return possibleWithThisIngredient;
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 desktop = {
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 _useState3 = useState(),
28818
- size = _useState3[0],
28819
- setSize = _useState3[1];
28820
- var _useState4 = useState(''),
28821
- searchTerm = _useState4[0],
28822
- setSearchTerm = _useState4[1];
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
- isSearchVisible = _useState5[0],
28825
- setIsSearchVisible = _useState5[1];
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 _useState7 = useState(1),
28833
- currentPage = _useState7[0],
28834
- setCurrentPage = _useState7[1];
28835
- var _useState8 = useState(craftablesItems),
28836
- items = _useState8[0],
28837
- setItems = _useState8[1];
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) {
@@ -28861,20 +28865,28 @@ var CraftBook = function CraftBook(_ref) {
28861
28865
  }) : [].concat(current, [itemKey]);
28862
28866
  });
28863
28867
  };
28864
- var categoryOptions = ['Suggested'].concat(pinnedItems.length > 0 ? ['Pinned'] : [], Object.keys(ItemSubType)).filter(function (type) {
28868
+ var categoryOptions = [{
28869
+ id: 0,
28870
+ value: 'Suggested',
28871
+ option: 'Suggested'
28872
+ }].concat(pinnedItems.length > 0 ? [{
28873
+ id: 1,
28874
+ value: 'Pinned',
28875
+ option: 'Pinned'
28876
+ }] : [], Object.keys(ItemSubType).filter(function (type) {
28865
28877
  return type !== 'DeadBody';
28866
- }).sort(function (a, b) {
28867
- if (a === 'Suggested') return -1;
28868
- if (b === 'Suggested') return 1;
28869
- if (a === 'Pinned') return -1;
28870
- if (b === 'Pinned') return 1;
28871
- return a.localeCompare(b);
28872
28878
  }).map(function (type, index) {
28873
28879
  return {
28874
- id: index,
28880
+ id: index + (pinnedItems.length > 0 ? 2 : 1),
28875
28881
  value: type,
28876
- option: type
28882
+ option: type === 'CraftingResources' || type === 'CraftingResource' ? 'Resources' : type
28877
28883
  };
28884
+ })).sort(function (a, b) {
28885
+ if (a.value === 'Suggested') return -1;
28886
+ if (b.value === 'Suggested') return 1;
28887
+ if (a.value === 'Pinned') return -1;
28888
+ if (b.value === 'Pinned') return 1;
28889
+ return a.value.localeCompare(b.value);
28878
28890
  });
28879
28891
  var filteredCraftableItems = items == null ? void 0 : items.filter(function (item) {
28880
28892
  var matchesSearch = item.name.toLowerCase().includes(searchTerm.toLowerCase());
@@ -28948,7 +28960,7 @@ var CraftBook = function CraftBook(_ref) {
28948
28960
  inventory: inventory,
28949
28961
  skills: skills
28950
28962
  }));
28951
- }))), React.createElement(PaginationContainer, null, React.createElement(PaginationButton, {
28963
+ }))), totalPages > 1 && React.createElement(PaginationContainer, null, React.createElement(PaginationButton, {
28952
28964
  onClick: function onClick() {
28953
28965
  return setCurrentPage(function (prev) {
28954
28966
  return Math.max(1, prev - 1);
@@ -28969,7 +28981,7 @@ var CraftBook = function CraftBook(_ref) {
28969
28981
  }))), React.createElement(Footer, null, React.createElement(Button, {
28970
28982
  buttonType: ButtonTypes.RPGUIButton,
28971
28983
  onPointerDown: onClose
28972
- }, "Cancel"), React.createElement(Button, {
28984
+ }, "Close"), React.createElement(Button, {
28973
28985
  disabled: !craftItemKey || isCraftingDisabled,
28974
28986
  buttonType: ButtonTypes.RPGUIButton,
28975
28987
  onPointerDown: function onPointerDown() {
@@ -29021,7 +29033,7 @@ var ContentContainer = /*#__PURE__*/styled.div.withConfig({
29021
29033
  var RadioInputScroller = /*#__PURE__*/styled.div.withConfig({
29022
29034
  displayName: "CraftBook__RadioInputScroller",
29023
29035
  componentId: "sc-19q95ue-8"
29024
- })(["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-items:start;@media (max-width:", "){grid-template-columns:1fr;}"], mobilePortrait.width);
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);
29025
29037
  var CraftingRecipeWrapper = /*#__PURE__*/styled.div.withConfig({
29026
29038
  displayName: "CraftBook__CraftingRecipeWrapper",
29027
29039
  componentId: "sc-19q95ue-9"
@@ -29039,7 +29051,7 @@ var PinButton = /*#__PURE__*/styled.button.withConfig({
29039
29051
  var Footer = /*#__PURE__*/styled.div.withConfig({
29040
29052
  displayName: "CraftBook__Footer",
29041
29053
  componentId: "sc-19q95ue-11"
29042
- })(["display:flex;justify-content:flex-end;gap:16px;padding:8px;button{min-width:100px;}@media (max-width:", "){justify-content:center;}"], mobilePortrait.width);
29054
+ })(["display:flex;justify-content:flex-end;gap:16px;padding:8px;button{min-width:100px;}@media (max-width:", "){justify-content:center;}"], MOBILE_WIDTH);
29043
29055
  var PaginationContainer = /*#__PURE__*/styled.div.withConfig({
29044
29056
  displayName: "CraftBook__PaginationContainer",
29045
29057
  componentId: "sc-19q95ue-12"