@rpg-engine/long-bow 0.7.72 → 0.7.73

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.
@@ -1,8 +1,8 @@
1
- import React, { useState, useEffect, Component, useRef, useContext, createContext, useMemo, useCallback, Fragment } from 'react';
1
+ import React, { useState, useEffect, Component, useRef, useContext, createContext, useCallback, useMemo, Fragment } from 'react';
2
2
  import styled, { css, keyframes } from 'styled-components';
3
3
  import { BeatLoader } from 'react-spinners';
4
4
  import { v4 } from 'uuid';
5
- import { GRID_WIDTH, GRID_HEIGHT, ShortcutType, getItemTextureKeyPath, ItemRarities, ItemContainerType, ItemType, DepotSocketEvents, ItemSocketEvents, ItemSocketEventsDisplayLabels, ActionsForInventory, ActionsForEquipmentSet, ActionsForLoot, ActionsForMapContainer, ItemSubType, ItemSlotType, isMobileOrTablet, CharacterClass, QuestStatus, getSPForLevel, getXPForLevel, PeriodOfDay, UserAccountTypes } from '@rpg-engine/shared';
5
+ import { GRID_WIDTH, GRID_HEIGHT, ShortcutType, getItemTextureKeyPath, ItemRarities, ItemContainerType, ItemType, DepotSocketEvents, ItemSocketEvents, ItemSocketEventsDisplayLabels, ActionsForInventory, ActionsForEquipmentSet, ActionsForLoot, ActionsForMapContainer, ItemSubType, isMobile, ItemSlotType, isMobileOrTablet, CharacterClass, QuestStatus, getSPForLevel, getXPForLevel, PeriodOfDay, UserAccountTypes } from '@rpg-engine/shared';
6
6
  import dayjs from 'dayjs';
7
7
  import { ErrorBoundary as ErrorBoundary$1 } from 'react-error-boundary';
8
8
  import { FaTimes } from 'react-icons/fa';
@@ -27539,188 +27539,6 @@ var ItemSlotRenderer = function ItemSlotRenderer(_ref) {
27539
27539
  return React.createElement(React.Fragment, null, onRenderSlot(item));
27540
27540
  };
27541
27541
 
27542
- var RelativeListMenu = function RelativeListMenu(_ref) {
27543
- var options = _ref.options,
27544
- onSelected = _ref.onSelected,
27545
- onOutsideClick = _ref.onOutsideClick,
27546
- _ref$fontSize = _ref.fontSize,
27547
- fontSize = _ref$fontSize === void 0 ? 0.8 : _ref$fontSize,
27548
- pos = _ref.pos;
27549
- var ref = useRef(null);
27550
- useOutsideClick(ref, 'relative-context-menu');
27551
- useEffect(function () {
27552
- document.addEventListener('clickOutside', function (event) {
27553
- var e = event;
27554
- if (e.detail.id === 'relative-context-menu') {
27555
- if (onOutsideClick) {
27556
- onOutsideClick();
27557
- }
27558
- }
27559
- });
27560
- return function () {
27561
- document.removeEventListener('clickOutside', function (_e) {});
27562
- };
27563
- }, []);
27564
- return React.createElement(ModalPortal, null, React.createElement(Container$9, Object.assign({
27565
- fontSize: fontSize,
27566
- ref: ref
27567
- }, pos), React.createElement("ul", {
27568
- className: "rpgui-list-imp",
27569
- style: {
27570
- overflow: 'hidden'
27571
- }
27572
- }, options.map(function (params, index) {
27573
- return React.createElement(ListElement$2, {
27574
- key: (params == null ? void 0 : params.id) || index,
27575
- onPointerDown: function onPointerDown() {
27576
- onSelected(params == null ? void 0 : params.id);
27577
- }
27578
- }, (params == null ? void 0 : params.text) || 'No text');
27579
- }))));
27580
- };
27581
- var Container$9 = /*#__PURE__*/styled.div.withConfig({
27582
- displayName: "RelativeListMenu__Container",
27583
- componentId: "sc-7hohf-0"
27584
- })(["position:absolute;top:", "px;left:", "px;display:flex;flex-direction:column;width:max-content;justify-content:start;align-items:flex-start;li{font-size:", "em;}"], function (props) {
27585
- return props.y;
27586
- }, function (props) {
27587
- return props.x;
27588
- }, function (props) {
27589
- return props.fontSize;
27590
- });
27591
- var ListElement$2 = /*#__PURE__*/styled.li.withConfig({
27592
- displayName: "RelativeListMenu__ListElement",
27593
- componentId: "sc-7hohf-1"
27594
- })(["margin-right:0.5rem;"]);
27595
-
27596
- var MobileItemTooltip = function MobileItemTooltip(_ref) {
27597
- var item = _ref.item,
27598
- atlasIMG = _ref.atlasIMG,
27599
- atlasJSON = _ref.atlasJSON,
27600
- closeTooltip = _ref.closeTooltip,
27601
- equipmentSet = _ref.equipmentSet,
27602
- _ref$scale = _ref.scale,
27603
- scale = _ref$scale === void 0 ? 1 : _ref$scale,
27604
- options = _ref.options,
27605
- onSelected = _ref.onSelected;
27606
- var ref = useRef(null);
27607
- var handleFadeOut = function handleFadeOut() {
27608
- var _ref$current;
27609
- (_ref$current = ref.current) == null ? void 0 : _ref$current.classList.add('fadeOut');
27610
- };
27611
- return React.createElement(ModalPortal, null, React.createElement(Container$a, {
27612
- ref: ref,
27613
- onTouchEnd: function onTouchEnd() {
27614
- handleFadeOut();
27615
- setTimeout(function () {
27616
- closeTooltip();
27617
- }, 100);
27618
- },
27619
- scale: scale
27620
- }, React.createElement(ItemInfoDisplay, {
27621
- item: item,
27622
- atlasIMG: atlasIMG,
27623
- atlasJSON: atlasJSON,
27624
- equipmentSet: equipmentSet,
27625
- isMobile: true
27626
- }), React.createElement(OptionsContainer, null, options == null ? void 0 : options.map(function (option) {
27627
- return React.createElement(Option, {
27628
- key: option.id,
27629
- onTouchEnd: function onTouchEnd() {
27630
- handleFadeOut();
27631
- setTimeout(function () {
27632
- onSelected == null ? void 0 : onSelected(option.id);
27633
- closeTooltip();
27634
- }, 100);
27635
- }
27636
- }, option.text);
27637
- }))));
27638
- };
27639
- var Container$a = /*#__PURE__*/styled.div.withConfig({
27640
- displayName: "MobileItemTooltip__Container",
27641
- componentId: "sc-ku4p1j-0"
27642
- })(["position:absolute;z-index:100;left:0;top:0;width:100vw;height:100vh;background-color:rgba(0 0 0 / 0.5);display:flex;justify-content:center;align-items:center;gap:0.5rem;transition:opacity 0.08s;animation:fadeIn 0.1s forwards;@keyframes fadeIn{0%{opacity:0;}100%{opacity:0.92;}}@keyframes fadeOut{0%{opacity:0.92;}100%{opacity:0;}}&.fadeOut{animation:fadeOut 0.1s forwards;}@media (max-width:640px){flex-direction:column;}"]);
27643
- var OptionsContainer = /*#__PURE__*/styled.div.withConfig({
27644
- displayName: "MobileItemTooltip__OptionsContainer",
27645
- componentId: "sc-ku4p1j-1"
27646
- })(["display:flex;flex-direction:column;gap:0.5rem;flex-wrap:wrap;@media (max-width:640px){flex-direction:row;justify-content:center;}"]);
27647
- var Option = /*#__PURE__*/styled.button.withConfig({
27648
- displayName: "MobileItemTooltip__Option",
27649
- componentId: "sc-ku4p1j-2"
27650
- })(["padding:1rem;background-color:#333;color:white;border:none;border-radius:3px;width:8rem;transition:background-color 0.1s;&:hover{background-color:#555;}@media (max-width:640px){padding:1rem 0.5rem;}"]);
27651
-
27652
- var ItemSlotToolTips = function ItemSlotToolTips(_ref) {
27653
- var isTooltipVisible = _ref.isTooltipVisible,
27654
- isFocused = _ref.isFocused,
27655
- isContextMenuVisible = _ref.isContextMenuVisible,
27656
- isContextMenuDisabled = _ref.isContextMenuDisabled,
27657
- item = _ref.item,
27658
- contextActions = _ref.contextActions,
27659
- contextMenuPosition = _ref.contextMenuPosition,
27660
- dragScale = _ref.dragScale,
27661
- setIsContextMenuVisible = _ref.setIsContextMenuVisible,
27662
- setIsTooltipMobileVisible = _ref.setIsTooltipMobileVisible,
27663
- isTooltipMobileVisible = _ref.isTooltipMobileVisible,
27664
- _onSelected = _ref.onSelected,
27665
- atlasIMG = _ref.atlasIMG,
27666
- atlasJSON = _ref.atlasJSON,
27667
- equipmentSet = _ref.equipmentSet;
27668
- return React.createElement(React.Fragment, null, isTooltipVisible && item && !isFocused && React.createElement(ItemTooltip, {
27669
- item: item,
27670
- atlasIMG: atlasIMG,
27671
- atlasJSON: atlasJSON,
27672
- equipmentSet: equipmentSet
27673
- }), isTooltipMobileVisible && item && React.createElement(MobileItemTooltip, {
27674
- item: item,
27675
- atlasIMG: atlasIMG,
27676
- atlasJSON: atlasJSON,
27677
- equipmentSet: equipmentSet,
27678
- closeTooltip: function closeTooltip() {
27679
- setIsTooltipMobileVisible(false);
27680
- },
27681
- scale: dragScale,
27682
- options: contextActions,
27683
- onSelected: function onSelected(optionId) {
27684
- setIsContextMenuVisible(false);
27685
- if (item) {
27686
- _onSelected == null ? void 0 : _onSelected(optionId, item);
27687
- }
27688
- }
27689
- }), !isContextMenuDisabled && isContextMenuVisible && contextActions && React.createElement(RelativeListMenu, {
27690
- options: contextActions,
27691
- onSelected: function onSelected(optionId) {
27692
- setIsContextMenuVisible(false);
27693
- if (item) {
27694
- _onSelected == null ? void 0 : _onSelected(optionId, item);
27695
- }
27696
- },
27697
- onOutsideClick: function onOutsideClick() {
27698
- setIsContextMenuVisible(false);
27699
- },
27700
- pos: contextMenuPosition
27701
- }));
27702
- };
27703
-
27704
- var DraggingContext = /*#__PURE__*/createContext({
27705
- item: null,
27706
- setDraggingItem: function setDraggingItem() {}
27707
- });
27708
- var useDragging = function useDragging() {
27709
- return useContext(DraggingContext);
27710
- };
27711
- var DraggingProvider = function DraggingProvider(_ref) {
27712
- var children = _ref.children;
27713
- var _useState = useState(null),
27714
- item = _useState[0],
27715
- setDraggingItem = _useState[1];
27716
- return React.createElement(DraggingContext.Provider, {
27717
- value: {
27718
- item: item,
27719
- setDraggingItem: setDraggingItem
27720
- }
27721
- }, children);
27722
- };
27723
-
27724
27542
  var generateContextMenuListOptions = function generateContextMenuListOptions(actionsByTypeList) {
27725
27543
  var contextMenu = actionsByTypeList.map(function (action) {
27726
27544
  return {
@@ -27846,6 +27664,117 @@ var generateContextMenu = function generateContextMenu(item, itemContainerType,
27846
27664
  return contextActionMenu;
27847
27665
  };
27848
27666
 
27667
+ var initialDetailsState = {
27668
+ item: null,
27669
+ isTooltipVisible: false,
27670
+ isTooltipMobileVisible: false,
27671
+ isContextMenuVisible: false,
27672
+ contextMenuPosition: {
27673
+ x: 0,
27674
+ y: 0
27675
+ },
27676
+ contextActions: [],
27677
+ clearContextActions: function clearContextActions() {},
27678
+ clearDetailsState: function clearDetailsState() {}
27679
+ };
27680
+ var ItemSlotDetailsContext = /*#__PURE__*/createContext({
27681
+ detailsState: initialDetailsState,
27682
+ updateDetailsState: function updateDetailsState() {},
27683
+ clearDetailsState: function clearDetailsState() {},
27684
+ setContextActions: function setContextActions() {},
27685
+ clearContextActions: function clearContextActions() {}
27686
+ });
27687
+ var useItemSlotDetails = function useItemSlotDetails() {
27688
+ return useContext(ItemSlotDetailsContext);
27689
+ };
27690
+ var ItemSlotDetailsProvider = function ItemSlotDetailsProvider(_ref) {
27691
+ var children = _ref.children;
27692
+ var _useState = useState(initialDetailsState),
27693
+ detailsState = _useState[0],
27694
+ setDetailsState = _useState[1];
27695
+ var updateDetailsState = useCallback(function (newState) {
27696
+ setDetailsState(function (prevState) {
27697
+ return _extends({}, prevState, newState);
27698
+ });
27699
+ }, []);
27700
+ var clearDetailsState = useCallback(function () {
27701
+ setDetailsState(initialDetailsState);
27702
+ }, [setDetailsState]);
27703
+ var setContextActions = useCallback(function (item, containerType, isDepotSystem) {
27704
+ if (item && containerType) {
27705
+ var newContextActions = generateContextMenu(item, containerType, isDepotSystem);
27706
+ updateDetailsState({
27707
+ contextActions: newContextActions
27708
+ });
27709
+ } else {
27710
+ updateDetailsState({
27711
+ contextActions: []
27712
+ });
27713
+ }
27714
+ }, []);
27715
+ var clearContextActions = useCallback(function () {
27716
+ updateDetailsState({
27717
+ contextActions: []
27718
+ });
27719
+ }, [updateDetailsState]);
27720
+ var contextValue = useMemo(function () {
27721
+ return {
27722
+ detailsState: detailsState,
27723
+ updateDetailsState: updateDetailsState,
27724
+ clearDetailsState: clearDetailsState,
27725
+ setContextActions: setContextActions,
27726
+ clearContextActions: clearContextActions
27727
+ };
27728
+ }, [detailsState, updateDetailsState, clearDetailsState, setContextActions, clearContextActions]);
27729
+ return React.createElement(ItemSlotDetailsContext.Provider, {
27730
+ value: contextValue
27731
+ }, children);
27732
+ };
27733
+
27734
+ var initialDraggingState = {
27735
+ item: null,
27736
+ isDragging: false,
27737
+ position: {
27738
+ x: 0,
27739
+ y: 0
27740
+ },
27741
+ dropPosition: null,
27742
+ isFocused: false,
27743
+ draggingDistance: 0
27744
+ };
27745
+ var ItemSlotDraggingContext = /*#__PURE__*/createContext({
27746
+ draggingState: initialDraggingState,
27747
+ updateDraggingState: function updateDraggingState() {},
27748
+ clearDraggingState: function clearDraggingState() {}
27749
+ });
27750
+ var useItemSlotDragging = function useItemSlotDragging() {
27751
+ return useContext(ItemSlotDraggingContext);
27752
+ };
27753
+ var ItemSlotDraggingProvider = function ItemSlotDraggingProvider(_ref) {
27754
+ var children = _ref.children;
27755
+ var _useState = useState(initialDraggingState),
27756
+ draggingState = _useState[0],
27757
+ setDraggingState = _useState[1];
27758
+ var updateDraggingState = useCallback(function (newState) {
27759
+ setDraggingState(function (prevState) {
27760
+ return _extends({}, prevState, newState);
27761
+ });
27762
+ }, []);
27763
+ var clearDraggingState = useCallback(function () {
27764
+ setDraggingState(initialDraggingState);
27765
+ }, []);
27766
+ var contextValue = useMemo(function () {
27767
+ return {
27768
+ draggingState: draggingState,
27769
+ updateDraggingState: updateDraggingState,
27770
+ clearDraggingState: clearDraggingState
27771
+ };
27772
+ }, [draggingState, updateDraggingState, clearDraggingState]);
27773
+ return React.createElement(ItemSlotDraggingContext.Provider, {
27774
+ value: contextValue
27775
+ }, children);
27776
+ };
27777
+
27849
27778
  var EquipmentSlotSpriteByType = {
27850
27779
  Neck: 'accessories/corruption-necklace.png',
27851
27780
  LeftHand: 'swords/broad-sword.png',
@@ -27866,7 +27795,6 @@ var ItemSlot = /*#__PURE__*/observer(function (_ref) {
27866
27795
  _onMouseOver = _ref.onMouseOver,
27867
27796
  _onMouseOut = _ref.onMouseOut,
27868
27797
  onPointerDown = _ref.onPointerDown,
27869
- _onSelected = _ref.onSelected,
27870
27798
  atlasJSON = _ref.atlasJSON,
27871
27799
  atlasIMG = _ref.atlasIMG,
27872
27800
  _ref$isContextMenuDis = _ref.isContextMenuDisabled,
@@ -27880,69 +27808,39 @@ var ItemSlot = /*#__PURE__*/observer(function (_ref) {
27880
27808
  checkIfItemShouldDragEnd = _ref.checkIfItemShouldDragEnd,
27881
27809
  dragScale = _ref.dragScale,
27882
27810
  isSelectingShortcut = _ref.isSelectingShortcut,
27883
- equipmentSet = _ref.equipmentSet,
27884
27811
  setItemShortcut = _ref.setItemShortcut,
27885
27812
  isDepotSystem = _ref.isDepotSystem;
27886
- // Centralized state using a single useState hook
27887
- var _useState = useState({
27888
- isTooltipVisible: false,
27889
- isTooltipMobileVisible: false,
27890
- isContextMenuVisible: false,
27891
- contextMenuPosition: {
27892
- x: 0,
27893
- y: 0
27894
- },
27895
- isFocused: false,
27896
- wasDragged: false,
27897
- dragPosition: {
27898
- x: 0,
27899
- y: 0
27900
- },
27901
- dropPosition: null,
27902
- contextActions: [],
27903
- draggingDistance: 0
27904
- }),
27905
- state = _useState[0],
27906
- setState = _useState[1];
27907
- var isTooltipVisible = state.isTooltipVisible,
27908
- isTooltipMobileVisible = state.isTooltipMobileVisible,
27909
- isContextMenuVisible = state.isContextMenuVisible,
27910
- contextMenuPosition = state.contextMenuPosition,
27911
- isFocused = state.isFocused,
27912
- wasDragged = state.wasDragged,
27913
- dragPosition = state.dragPosition,
27914
- dropPosition = state.dropPosition,
27915
- contextActions = state.contextActions;
27813
+ var _useItemSlotDetails = useItemSlotDetails(),
27814
+ detailsState = _useItemSlotDetails.detailsState,
27815
+ updateDetailsState = _useItemSlotDetails.updateDetailsState,
27816
+ setContextActions = _useItemSlotDetails.setContextActions;
27817
+ var isContextMenuVisible = detailsState.isContextMenuVisible,
27818
+ clearContextActions = detailsState.clearContextActions;
27916
27819
  var dragContainer = useRef(null);
27917
- var _useDragging = useDragging(),
27918
- draggingItem = _useDragging.item,
27919
- setDraggingItem = _useDragging.setDraggingItem;
27820
+ var _useItemSlotDragging = useItemSlotDragging(),
27821
+ draggingState = _useItemSlotDragging.draggingState,
27822
+ updateDraggingState = _useItemSlotDragging.updateDraggingState,
27823
+ clearDraggingState = _useItemSlotDragging.clearDraggingState;
27824
+ var isFocused = draggingState.isFocused,
27825
+ dropPosition = draggingState.dropPosition,
27826
+ isDragging = draggingState.isDragging,
27827
+ draggingDistance = draggingState.draggingDistance;
27920
27828
  useEffect(function () {
27921
27829
  // Reset drag position and focus when item changes
27922
- setState(function (prevState) {
27923
- return _extends({}, prevState, {
27924
- dragPosition: {
27925
- x: 0,
27926
- y: 0
27927
- },
27928
- isFocused: false
27929
- });
27830
+ updateDraggingState({
27831
+ position: {
27832
+ x: 0,
27833
+ y: 0
27834
+ },
27835
+ isFocused: false
27930
27836
  });
27931
27837
  // Update context actions when item or depot system changes
27932
- if (item && containerType) {
27933
- setState(function (prevState) {
27934
- return _extends({}, prevState, {
27935
- contextActions: generateContextMenu(item, containerType, isDepotSystem)
27936
- });
27937
- });
27838
+ if (item && containerType && !isContextMenuDisabled) {
27839
+ setContextActions(item, containerType, isDepotSystem != null ? isDepotSystem : false);
27938
27840
  } else {
27939
- setState(function (prevState) {
27940
- return _extends({}, prevState, {
27941
- contextActions: []
27942
- });
27943
- });
27841
+ clearContextActions();
27944
27842
  }
27945
- }, [item, isDepotSystem]);
27843
+ }, [item, containerType, isDepotSystem, setContextActions, clearContextActions]);
27946
27844
  useEffect(function () {
27947
27845
  // Handle outside drop
27948
27846
  if (onDrop && item && dropPosition) {
@@ -27950,47 +27848,41 @@ var ItemSlot = /*#__PURE__*/observer(function (_ref) {
27950
27848
  }
27951
27849
  }, [dropPosition]);
27952
27850
  var resetItem = function resetItem() {
27953
- setState(function (prevState) {
27954
- return _extends({}, prevState, {
27955
- isTooltipVisible: false,
27956
- wasDragged: false
27957
- });
27851
+ clearDraggingState();
27852
+ updateDetailsState({
27853
+ item: item,
27854
+ isTooltipVisible: false
27958
27855
  });
27959
27856
  };
27960
27857
  var onSuccessfulDrag = function onSuccessfulDrag(quantity) {
27961
27858
  resetItem();
27962
27859
  if (quantity === -1) {
27963
- setState(function (prevState) {
27964
- return _extends({}, prevState, {
27965
- dragPosition: {
27966
- x: 0,
27967
- y: 0
27968
- },
27969
- isFocused: false
27970
- });
27860
+ updateDraggingState({
27861
+ position: {
27862
+ x: 0,
27863
+ y: 0
27864
+ },
27865
+ isFocused: false
27971
27866
  });
27972
27867
  } else if (item) {
27973
27868
  onDragEnd == null ? void 0 : onDragEnd(quantity);
27974
27869
  }
27975
27870
  };
27976
27871
  var onDraggableStop = function onDraggableStop(e, data) {
27977
- console.log('>>> ON_DRAGGABLE_STOP');
27978
- // Stop the dragging state
27979
- console.log('setDraggingItem(null)');
27980
- setDraggingItem(null);
27981
- var target = e.target;
27982
- console.log('handleShortcutSetter(target)');
27983
- handleShortcutSetter(target);
27984
- console.log('removeDraggingClass(target)');
27985
- removeDraggingClass(target);
27986
- console.log('shouldHandleDraggedItem()');
27987
- if (shouldHandleDraggedItem()) {
27988
- console.log('handleDraggedItem(e, data)');
27989
- handleDraggedItem(e, data);
27990
- } else if (item && !wasDragged) {
27991
- console.log('handleContextMenuOrTooltip(e)');
27992
- handleContextMenuOrTooltip(e);
27993
- }
27872
+ requestAnimationFrame(function () {
27873
+ updateDraggingState({
27874
+ item: null
27875
+ });
27876
+ var target = e.target;
27877
+ handleShortcutSetter(target);
27878
+ removeDraggingClass(target);
27879
+ var shouldHandleDraggedItemResult = shouldHandleDraggedItem();
27880
+ if (shouldHandleDraggedItemResult) {
27881
+ handleDraggedItem(e, data);
27882
+ } else if (item && !isDragging) {
27883
+ handleContextMenuOrTooltip(e);
27884
+ }
27885
+ });
27994
27886
  };
27995
27887
  /**
27996
27888
  * Handles the shortcut setter logic if the target element is a shortcut setter.
@@ -28013,49 +27905,41 @@ var ItemSlot = /*#__PURE__*/observer(function (_ref) {
28013
27905
  * Determines whether the dragged item should be processed.
28014
27906
  */
28015
27907
  var shouldHandleDraggedItem = function shouldHandleDraggedItem() {
28016
- console.log("Debug: shouldHandleDraggedItem()", "wasDragged: " + wasDragged, "item: " + item, "isSelectingShortcut: " + isSelectingShortcut);
28017
- return !!(wasDragged && item && !isSelectingShortcut);
27908
+ return !!(isDragging && draggingState.item && !isSelectingShortcut);
28018
27909
  };
28019
27910
  /**
28020
27911
  * Handles the logic when an item has been dragged.
28021
27912
  */
28022
27913
  var handleDraggedItem = function handleDraggedItem(e, data) {
28023
- var targetClasses = Array.from(e.target.classList);
28024
- var isOutsideDrop = targetClasses.some(function (elm) {
28025
- return elm.includes('rpgui-content');
28026
- }) || targetClasses.length === 0;
28027
- if (isOutsideDrop) {
28028
- setState(function (prevState) {
28029
- return _extends({}, prevState, {
27914
+ requestAnimationFrame(function () {
27915
+ var targetClasses = Array.from(e.target.classList);
27916
+ var isOutsideDrop = targetClasses.some(function (elm) {
27917
+ return elm.includes('rpgui-content');
27918
+ }) || targetClasses.length === 0;
27919
+ if (isOutsideDrop) {
27920
+ updateDraggingState({
28030
27921
  dropPosition: {
28031
27922
  x: data.x,
28032
27923
  y: data.y
28033
27924
  }
28034
27925
  });
27926
+ }
27927
+ updateDraggingState({
27928
+ isDragging: false
28035
27929
  });
28036
- }
28037
- setState(function (prevState) {
28038
- return _extends({}, prevState, {
28039
- wasDragged: false
28040
- });
28041
- });
28042
- var targetElement = dragContainer.current;
28043
- if (!targetElement) return;
28044
- var _getElementTransform = getElementTransform(targetElement),
28045
- x = _getElementTransform.x,
28046
- y = _getElementTransform.y;
28047
- setState(function (prevState) {
28048
- return _extends({}, prevState, {
28049
- dragPosition: {
27930
+ var targetElement = dragContainer.current;
27931
+ if (!targetElement) return;
27932
+ var _getElementTransform = getElementTransform(targetElement),
27933
+ x = _getElementTransform.x,
27934
+ y = _getElementTransform.y;
27935
+ updateDraggingState({
27936
+ position: {
28050
27937
  x: x,
28051
27938
  y: y
28052
27939
  }
28053
27940
  });
28054
- });
28055
- // Delay to ensure state updates before proceeding
28056
- setTimeout(function () {
28057
27941
  processDragEnd(item);
28058
- }, 50);
27942
+ });
28059
27943
  };
28060
27944
  /**
28061
27945
  * Retrieves the current transform position of the dragged element.
@@ -28072,29 +27956,21 @@ var ItemSlot = /*#__PURE__*/observer(function (_ref) {
28072
27956
  * Processes the end of a drag event, handling quantity selection or resetting state.
28073
27957
  */
28074
27958
  var processDragEnd = function processDragEnd(item) {
28075
- console.log("Debug: processDragEnd(item)", "item: " + item);
28076
27959
  if (checkIfItemCanBeMoved != null && checkIfItemCanBeMoved()) {
28077
- console.log("Debug: checkIfItemCanBeMoved()", "result: " + checkIfItemCanBeMoved());
28078
27960
  if (checkIfItemShouldDragEnd && !checkIfItemShouldDragEnd()) return;
28079
- console.log("Debug: checkIfItemShouldDragEnd()", "result: " + (checkIfItemShouldDragEnd == null ? void 0 : checkIfItemShouldDragEnd()));
28080
27961
  if (item.stackQty && item.stackQty !== 1 && openQuantitySelector) {
28081
- console.log("Debug: openQuantitySelector(item.stackQty, onSuccessfulDrag)");
28082
27962
  openQuantitySelector(item.stackQty, onSuccessfulDrag);
28083
27963
  } else {
28084
- console.log("Debug: onSuccessfulDrag(item.stackQty)");
28085
27964
  onSuccessfulDrag(item.stackQty);
28086
27965
  }
28087
27966
  } else {
28088
- console.log("Debug: resetItem()");
28089
27967
  resetItem();
28090
- setState(function (prevState) {
28091
- return _extends({}, prevState, {
28092
- isFocused: false,
28093
- dragPosition: {
28094
- x: 0,
28095
- y: 0
28096
- }
28097
- });
27968
+ updateDraggingState({
27969
+ isFocused: false,
27970
+ position: {
27971
+ x: 0,
27972
+ y: 0
27973
+ }
28098
27974
  });
28099
27975
  }
28100
27976
  };
@@ -28102,24 +27978,25 @@ var ItemSlot = /*#__PURE__*/observer(function (_ref) {
28102
27978
  * Handles the context menu or tooltip display after dragging stops without a drop.
28103
27979
  */
28104
27980
  var handleContextMenuOrTooltip = function handleContextMenuOrTooltip(e) {
28105
- var isTouchEvent = false;
28106
- if (!isContextMenuDisabled && e.type === 'touchend' && !isSelectingShortcut) {
28107
- isTouchEvent = true;
28108
- setState(function (prevState) {
28109
- return _extends({}, prevState, {
28110
- isTooltipMobileVisible: true
28111
- });
27981
+ var isTouchEvent = e.type === 'touchend';
27982
+ var shouldShowMobileTooltip = !isContextMenuDisabled && isTouchEvent && !isSelectingShortcut;
27983
+ var shouldToggleContextMenu = !isContextMenuDisabled && !isSelectingShortcut && !isTouchEvent;
27984
+ if (shouldShowMobileTooltip) {
27985
+ updateDetailsState({
27986
+ item: item,
27987
+ isTooltipMobileVisible: true,
27988
+ isContextMenuVisible: false
28112
27989
  });
28113
- }
28114
- if (!isContextMenuDisabled && !isSelectingShortcut && !isTouchEvent) {
28115
- setState(function (prevState) {
28116
- return _extends({}, prevState, {
28117
- isContextMenuVisible: !prevState.isContextMenuVisible,
28118
- contextMenuPosition: {
28119
- x: e.clientX - 10,
28120
- y: e.clientY - 5
28121
- }
28122
- });
27990
+ } else if (shouldToggleContextMenu) {
27991
+ var mouseEvent = e;
27992
+ updateDetailsState({
27993
+ item: item,
27994
+ isContextMenuVisible: !isContextMenuVisible && !isMobile(),
27995
+ isTooltipMobileVisible: false,
27996
+ contextMenuPosition: {
27997
+ x: mouseEvent.clientX - 10,
27998
+ y: mouseEvent.clientY - 5
27999
+ }
28123
28000
  });
28124
28001
  }
28125
28002
  if (item) {
@@ -28136,25 +28013,23 @@ var ItemSlot = /*#__PURE__*/observer(function (_ref) {
28136
28013
  };
28137
28014
  var onDraggableProgress = function onDraggableProgress(_e, _data) {
28138
28015
  // increment draggingDistance by 1
28139
- setState(function (prevState) {
28140
- return _extends({}, prevState, {
28141
- draggingDistance: prevState.draggingDistance + 1
28142
- });
28016
+ updateDraggingState({
28017
+ draggingDistance: draggingState.draggingDistance + 1
28143
28018
  });
28144
- if (state.draggingDistance > 10) {
28145
- setState(function (prevState) {
28146
- return _extends({}, prevState, {
28147
- wasDragged: true,
28148
- isFocused: true
28149
- });
28019
+ if (draggingDistance > 10) {
28020
+ updateDraggingState({
28021
+ isDragging: true,
28022
+ isFocused: true
28150
28023
  });
28151
28024
  }
28152
- if (!draggingItem) {
28153
- setDraggingItem(item);
28025
+ if (!draggingState.item) {
28026
+ updateDraggingState({
28027
+ item: item
28028
+ });
28154
28029
  }
28155
28030
  };
28156
- return React.createElement(Container$b, {
28157
- isDraggingItem: !!draggingItem,
28031
+ return React.createElement(Container$9, {
28032
+ isDraggingItem: !!draggingState.item,
28158
28033
  item: item,
28159
28034
  className: "rpgui-icon empty-slot",
28160
28035
  onMouseUp: function onMouseUp() {
@@ -28185,7 +28060,7 @@ var ItemSlot = /*#__PURE__*/observer(function (_ref) {
28185
28060
  onStop: onDraggableStop,
28186
28061
  onStart: onDraggableStart,
28187
28062
  onDrag: onDraggableProgress,
28188
- position: dragPosition,
28063
+ position: draggingState.position,
28189
28064
  cancel: ".empty-slot",
28190
28065
  bounds: ".item-container-body, .equipment-container-body"
28191
28066
  }, React.createElement(ItemContainer, {
@@ -28198,17 +28073,15 @@ var ItemSlot = /*#__PURE__*/observer(function (_ref) {
28198
28073
  if (_onMouseOut) _onMouseOut();
28199
28074
  },
28200
28075
  onMouseEnter: function onMouseEnter() {
28201
- setState(function (prevState) {
28202
- return _extends({}, prevState, {
28203
- isTooltipVisible: true
28204
- });
28076
+ updateDetailsState({
28077
+ item: item,
28078
+ isTooltipVisible: true
28205
28079
  });
28206
28080
  },
28207
28081
  onMouseLeave: function onMouseLeave() {
28208
- setState(function (prevState) {
28209
- return _extends({}, prevState, {
28210
- isTooltipVisible: false
28211
- });
28082
+ updateDetailsState({
28083
+ item: item,
28084
+ isTooltipVisible: false
28212
28085
  });
28213
28086
  }
28214
28087
  }, React.createElement(ItemSlotRenderer, {
@@ -28217,54 +28090,12 @@ var ItemSlot = /*#__PURE__*/observer(function (_ref) {
28217
28090
  atlasIMG: atlasIMG,
28218
28091
  atlasJSON: atlasJSON,
28219
28092
  containerType: containerType
28220
- }))), React.createElement(ItemSlotToolTips, {
28221
- isTooltipVisible: isTooltipVisible,
28222
- isTooltipMobileVisible: isTooltipMobileVisible,
28223
- setIsTooltipMobileVisible: function setIsTooltipMobileVisible(value) {
28224
- return setState(function (prevState) {
28225
- return _extends({}, prevState, {
28226
- isTooltipMobileVisible: value
28227
- });
28228
- });
28229
- },
28230
- isFocused: isFocused,
28231
- isContextMenuVisible: isContextMenuVisible,
28232
- isContextMenuDisabled: isContextMenuDisabled,
28233
- item: item,
28234
- contextActions: contextActions,
28235
- contextMenuPosition: contextMenuPosition,
28236
- dragScale: dragScale,
28237
- setIsContextMenuVisible: function setIsContextMenuVisible(value) {
28238
- return setState(function (prevState) {
28239
- return _extends({}, prevState, {
28240
- isContextMenuVisible: value
28241
- });
28242
- });
28243
- },
28244
- onSelected: function onSelected(optionId, item) {
28245
- setState(function (prevState) {
28246
- return _extends({}, prevState, {
28247
- isContextMenuVisible: false
28248
- });
28249
- });
28250
- if (_onSelected) _onSelected(optionId, item);
28251
- },
28252
- atlasIMG: atlasIMG,
28253
- atlasJSON: atlasJSON,
28254
- equipmentSet: equipmentSet,
28255
- setIsTooltipVisible: function setIsTooltipVisible(value) {
28256
- return setState(function (prevState) {
28257
- return _extends({}, prevState, {
28258
- isTooltipVisible: value
28259
- });
28260
- });
28261
- }
28262
- }));
28093
+ }))));
28263
28094
  });
28264
- var Container$b = /*#__PURE__*/styled.div.withConfig({
28095
+ var Container$9 = /*#__PURE__*/styled.div.withConfig({
28265
28096
  displayName: "ItemSlot__Container",
28266
28097
  componentId: "sc-l2j5ef-0"
28267
- })(["margin:0.1rem;*{border:1px solid blue;}.react-draggable-dragging{opacity:", ";}position:relative;.sprite-from-atlas-img--item{position:relative;top:1.5rem;left:1.5rem;border-color:", ";box-shadow:", " inset,", ";}&::before{content:'';position:absolute;top:0;left:0;width:100%;height:100%;z-index:1;border-radius:12px;pointer-events:none;animation:", ";@keyframes bg-color-change{0%{background-color:rgba(255 255 255 / 0.5);}50%{background-color:transparent;}100%{background-color:rgba(255 255 255 / 0.5);}}}"], function (_ref2) {
28098
+ })(["margin:0.1rem;*{border:1px solid yellow;}.react-draggable-dragging{opacity:", ";}position:relative;.sprite-from-atlas-img--item{position:relative;top:1.5rem;left:1.5rem;border-color:", ";box-shadow:", " inset,", ";}&::before{content:'';position:absolute;top:0;left:0;width:100%;height:100%;z-index:1;border-radius:12px;pointer-events:none;animation:", ";@keyframes bg-color-change{0%{background-color:rgba(255 255 255 / 0.5);}50%{background-color:transparent;}100%{background-color:rgba(255 255 255 / 0.5);}}}"], function (_ref2) {
28268
28099
  var isDraggingItem = _ref2.isDraggingItem;
28269
28100
  return isDraggingItem ? 0 : 1;
28270
28101
  }, function (_ref3) {
@@ -28377,7 +28208,7 @@ var ItemInfo = function ItemInfo(_ref) {
28377
28208
  });
28378
28209
  };
28379
28210
  var skillName = (_item$minRequirements = item.minRequirements) == null ? void 0 : (_item$minRequirements2 = _item$minRequirements.skill) == null ? void 0 : _item$minRequirements2.name;
28380
- return React.createElement(Container$c, {
28211
+ return React.createElement(Container$a, {
28381
28212
  item: item
28382
28213
  }, React.createElement(Header, null, React.createElement("div", null, React.createElement(Title$1, null, item.name), item.rarity !== 'Common' && React.createElement(Rarity, {
28383
28214
  item: item
@@ -28391,7 +28222,7 @@ var ItemInfo = function ItemInfo(_ref) {
28391
28222
  "$isSpecial": true
28392
28223
  }, "Two handed"), React.createElement(Description, null, item.description), item.maxStackSize && item.maxStackSize !== 1 && React.createElement(StackInfo, null, "x", Math.round(((_item$stackQty = item.stackQty) != null ? _item$stackQty : 1) * 100) / 100, "(", item.maxStackSize, ")"), renderMissingStatistic().length > 0 && React.createElement(MissingStatistics, null, React.createElement(Statistic, null, "Equipped Diff"), itemToCompare && renderMissingStatistic()));
28393
28224
  };
28394
- var Container$c = /*#__PURE__*/styled.div.withConfig({
28225
+ var Container$a = /*#__PURE__*/styled.div.withConfig({
28395
28226
  displayName: "ItemInfo__Container",
28396
28227
  componentId: "sc-1xm4q8k-0"
28397
28228
  })(["color:white;background-color:#222;border-radius:5px;padding:0.5rem;font-size:", ";border:3px solid ", ";height:max-content;width:18rem;@media (max-width:640px){width:80vw;}"], uiFonts.size.small, function (_ref2) {
@@ -28537,7 +28368,7 @@ var ItemTooltip = function ItemTooltip(_ref) {
28537
28368
  }
28538
28369
  return;
28539
28370
  }, []);
28540
- return React.createElement(ModalPortal, null, React.createElement(Container$d, {
28371
+ return React.createElement(ModalPortal, null, React.createElement(Container$b, {
28541
28372
  ref: ref
28542
28373
  }, React.createElement(ItemInfoDisplay, {
28543
28374
  item: item,
@@ -28546,11 +28377,67 @@ var ItemTooltip = function ItemTooltip(_ref) {
28546
28377
  equipmentSet: equipmentSet
28547
28378
  })));
28548
28379
  };
28549
- var Container$d = /*#__PURE__*/styled.div.withConfig({
28380
+ var Container$b = /*#__PURE__*/styled.div.withConfig({
28550
28381
  displayName: "ItemTooltip__Container",
28551
28382
  componentId: "sc-11d9r7x-0"
28552
28383
  })(["position:absolute;z-index:100;pointer-events:none;left:0;top:0;opacity:0;transition:opacity 0.08s;"]);
28553
28384
 
28385
+ var MobileItemTooltip = function MobileItemTooltip(_ref) {
28386
+ var item = _ref.item,
28387
+ atlasIMG = _ref.atlasIMG,
28388
+ atlasJSON = _ref.atlasJSON,
28389
+ closeTooltip = _ref.closeTooltip,
28390
+ equipmentSet = _ref.equipmentSet,
28391
+ _ref$scale = _ref.scale,
28392
+ scale = _ref$scale === void 0 ? 1 : _ref$scale,
28393
+ options = _ref.options,
28394
+ onSelected = _ref.onSelected;
28395
+ var ref = useRef(null);
28396
+ var handleFadeOut = function handleFadeOut() {
28397
+ var _ref$current;
28398
+ (_ref$current = ref.current) == null ? void 0 : _ref$current.classList.add('fadeOut');
28399
+ };
28400
+ return React.createElement(ModalPortal, null, React.createElement(Container$c, {
28401
+ ref: ref,
28402
+ onTouchEnd: function onTouchEnd() {
28403
+ handleFadeOut();
28404
+ setTimeout(function () {
28405
+ closeTooltip();
28406
+ }, 100);
28407
+ },
28408
+ scale: scale
28409
+ }, React.createElement(ItemInfoDisplay, {
28410
+ item: item,
28411
+ atlasIMG: atlasIMG,
28412
+ atlasJSON: atlasJSON,
28413
+ equipmentSet: equipmentSet,
28414
+ isMobile: true
28415
+ }), React.createElement(OptionsContainer, null, options == null ? void 0 : options.map(function (option) {
28416
+ return React.createElement(Option, {
28417
+ key: option.id,
28418
+ onTouchEnd: function onTouchEnd() {
28419
+ handleFadeOut();
28420
+ setTimeout(function () {
28421
+ onSelected == null ? void 0 : onSelected(option.id);
28422
+ closeTooltip();
28423
+ }, 100);
28424
+ }
28425
+ }, option.text);
28426
+ }))));
28427
+ };
28428
+ var Container$c = /*#__PURE__*/styled.div.withConfig({
28429
+ displayName: "MobileItemTooltip__Container",
28430
+ componentId: "sc-ku4p1j-0"
28431
+ })(["position:absolute;z-index:100;left:0;top:0;width:100vw;height:100vh;background-color:rgba(0 0 0 / 0.5);display:flex;justify-content:center;align-items:center;gap:0.5rem;transition:opacity 0.08s;animation:fadeIn 0.1s forwards;@keyframes fadeIn{0%{opacity:0;}100%{opacity:0.92;}}@keyframes fadeOut{0%{opacity:0.92;}100%{opacity:0;}}&.fadeOut{animation:fadeOut 0.1s forwards;}@media (max-width:640px){flex-direction:column;}"]);
28432
+ var OptionsContainer = /*#__PURE__*/styled.div.withConfig({
28433
+ displayName: "MobileItemTooltip__OptionsContainer",
28434
+ componentId: "sc-ku4p1j-1"
28435
+ })(["display:flex;flex-direction:column;gap:0.5rem;flex-wrap:wrap;@media (max-width:640px){flex-direction:row;justify-content:center;}"]);
28436
+ var Option = /*#__PURE__*/styled.button.withConfig({
28437
+ displayName: "MobileItemTooltip__Option",
28438
+ componentId: "sc-ku4p1j-2"
28439
+ })(["padding:1rem;background-color:#333;color:white;border:none;border-radius:3px;width:8rem;transition:background-color 0.1s;&:hover{background-color:#555;}@media (max-width:640px){padding:1rem 0.5rem;}"]);
28440
+
28554
28441
  var ItemInfoWrapper = function ItemInfoWrapper(_ref) {
28555
28442
  var children = _ref.children,
28556
28443
  atlasIMG = _ref.atlasIMG,
@@ -28905,7 +28792,7 @@ var Dropdown = function Dropdown(_ref) {
28905
28792
  onChange(selectedValue);
28906
28793
  }
28907
28794
  }, [selectedValue]);
28908
- return React.createElement(Container$e, {
28795
+ return React.createElement(Container$d, {
28909
28796
  onMouseLeave: function onMouseLeave() {
28910
28797
  return setOpened(false);
28911
28798
  },
@@ -28933,7 +28820,7 @@ var Dropdown = function Dropdown(_ref) {
28933
28820
  }, option.option);
28934
28821
  })));
28935
28822
  };
28936
- var Container$e = /*#__PURE__*/styled.div.withConfig({
28823
+ var Container$d = /*#__PURE__*/styled.div.withConfig({
28937
28824
  displayName: "Dropdown__Container",
28938
28825
  componentId: "sc-8arn65-0"
28939
28826
  })(["position:relative;width:", ";"], function (props) {
@@ -29033,8 +28920,9 @@ var DraggedItem = function DraggedItem(_ref) {
29033
28920
  var atlasJSON = _ref.atlasJSON,
29034
28921
  atlasIMG = _ref.atlasIMG,
29035
28922
  scale = _ref.scale;
29036
- var _useDragging = useDragging(),
29037
- item = _useDragging.item;
28923
+ var _useItemSlotDragging = useItemSlotDragging(),
28924
+ draggingState = _useItemSlotDragging.draggingState;
28925
+ var item = draggingState.item;
29038
28926
  var _useCursorPosition = useCursorPosition({
29039
28927
  scale: scale
29040
28928
  }),
@@ -29049,7 +28937,7 @@ var DraggedItem = function DraggedItem(_ref) {
29049
28937
  var centeredX = x - OFFSET;
29050
28938
  var centeredY = y - OFFSET;
29051
28939
  var stackInfo = onRenderStackInfo((_item$_id = item == null ? void 0 : item._id) != null ? _item$_id : '', (_item$stackQty = item == null ? void 0 : item.stackQty) != null ? _item$stackQty : 0);
29052
- return React.createElement(Container$f, null, React.createElement(SpriteContainer, {
28940
+ return React.createElement(Container$e, null, React.createElement(SpriteContainer, {
29053
28941
  x: centeredX,
29054
28942
  y: centeredY
29055
28943
  }, React.createElement(SpriteFromAtlas, {
@@ -29067,7 +28955,7 @@ var DraggedItem = function DraggedItem(_ref) {
29067
28955
  }), stackInfo));
29068
28956
  };
29069
28957
  var pulse = "\n @keyframes pulse {\n 0%, 100% {\n transform: scale(1) rotate(-3deg);\n }\n 50% {\n transform: scale(0.95) rotate(-3deg);\n }\n }\n";
29070
- var Container$f = /*#__PURE__*/styled.div.withConfig({
28958
+ var Container$e = /*#__PURE__*/styled.div.withConfig({
29071
28959
  displayName: "DraggedItem__Container",
29072
28960
  componentId: "sc-mlzzcp-0"
29073
28961
  })(["position:relative;"]);
@@ -29083,11 +28971,128 @@ var SpriteContainer = /*#__PURE__*/styled.div.attrs(function (props) {
29083
28971
  componentId: "sc-mlzzcp-1"
29084
28972
  })(["", " position:absolute;z-index:100;pointer-events:none;width:", "px;height:", "px;transform:rotate(-3deg);filter:grayscale(100%);opacity:0.35;animation:pulse 2s infinite;.item-slot-qty{position:absolute;bottom:0;margin-left:0.8rem;}"], pulse, CONTAINER_SIZE, CONTAINER_SIZE);
29085
28973
 
28974
+ var RelativeListMenu = function RelativeListMenu(_ref) {
28975
+ var options = _ref.options,
28976
+ onSelected = _ref.onSelected,
28977
+ onOutsideClick = _ref.onOutsideClick,
28978
+ _ref$fontSize = _ref.fontSize,
28979
+ fontSize = _ref$fontSize === void 0 ? 0.8 : _ref$fontSize,
28980
+ pos = _ref.pos;
28981
+ var ref = useRef(null);
28982
+ useOutsideClick(ref, 'relative-context-menu');
28983
+ useEffect(function () {
28984
+ document.addEventListener('clickOutside', function (event) {
28985
+ var e = event;
28986
+ if (e.detail.id === 'relative-context-menu') {
28987
+ if (onOutsideClick) {
28988
+ onOutsideClick();
28989
+ }
28990
+ }
28991
+ });
28992
+ return function () {
28993
+ document.removeEventListener('clickOutside', function (_e) {});
28994
+ };
28995
+ }, []);
28996
+ return React.createElement(ModalPortal, null, React.createElement(Container$f, Object.assign({
28997
+ fontSize: fontSize,
28998
+ ref: ref
28999
+ }, pos), React.createElement("ul", {
29000
+ className: "rpgui-list-imp",
29001
+ style: {
29002
+ overflow: 'hidden'
29003
+ }
29004
+ }, options.map(function (params, index) {
29005
+ return React.createElement(ListElement$2, {
29006
+ key: (params == null ? void 0 : params.id) || index,
29007
+ onPointerDown: function onPointerDown() {
29008
+ onSelected(params == null ? void 0 : params.id);
29009
+ }
29010
+ }, (params == null ? void 0 : params.text) || 'No text');
29011
+ }))));
29012
+ };
29013
+ var Container$f = /*#__PURE__*/styled.div.withConfig({
29014
+ displayName: "RelativeListMenu__Container",
29015
+ componentId: "sc-7hohf-0"
29016
+ })(["position:absolute;top:", "px;left:", "px;display:flex;flex-direction:column;width:max-content;justify-content:start;align-items:flex-start;li{font-size:", "em;}"], function (props) {
29017
+ return props.y;
29018
+ }, function (props) {
29019
+ return props.x;
29020
+ }, function (props) {
29021
+ return props.fontSize;
29022
+ });
29023
+ var ListElement$2 = /*#__PURE__*/styled.li.withConfig({
29024
+ displayName: "RelativeListMenu__ListElement",
29025
+ componentId: "sc-7hohf-1"
29026
+ })(["margin-right:0.5rem;"]);
29027
+
29028
+ var ItemSlotToolTips = function ItemSlotToolTips(_ref) {
29029
+ var dragScale = _ref.dragScale,
29030
+ _onSelected = _ref.onSelected,
29031
+ atlasIMG = _ref.atlasIMG,
29032
+ atlasJSON = _ref.atlasJSON,
29033
+ equipmentSet = _ref.equipmentSet,
29034
+ isContextMenuDisabled = _ref.isContextMenuDisabled;
29035
+ var _useItemSlotDetails = useItemSlotDetails(),
29036
+ detailsState = _useItemSlotDetails.detailsState,
29037
+ updateDetailsState = _useItemSlotDetails.updateDetailsState;
29038
+ var isTooltipVisible = detailsState.isTooltipVisible,
29039
+ isTooltipMobileVisible = detailsState.isTooltipMobileVisible,
29040
+ isContextMenuVisible = detailsState.isContextMenuVisible,
29041
+ contextMenuPosition = detailsState.contextMenuPosition,
29042
+ contextActions = detailsState.contextActions,
29043
+ item = detailsState.item;
29044
+ var _useItemSlotDragging = useItemSlotDragging(),
29045
+ draggingState = _useItemSlotDragging.draggingState;
29046
+ var isFocused = draggingState.isFocused;
29047
+ return React.createElement(React.Fragment, null, isTooltipVisible && item && !isFocused && React.createElement(ItemTooltip, {
29048
+ item: item,
29049
+ atlasIMG: atlasIMG,
29050
+ atlasJSON: atlasJSON,
29051
+ equipmentSet: equipmentSet
29052
+ }), isTooltipMobileVisible && item && React.createElement(MobileItemTooltip, {
29053
+ item: item,
29054
+ atlasIMG: atlasIMG,
29055
+ atlasJSON: atlasJSON,
29056
+ equipmentSet: equipmentSet,
29057
+ closeTooltip: function closeTooltip() {
29058
+ updateDetailsState({
29059
+ isTooltipMobileVisible: false
29060
+ });
29061
+ },
29062
+ scale: dragScale,
29063
+ options: contextActions,
29064
+ onSelected: function onSelected(optionId) {
29065
+ updateDetailsState({
29066
+ isContextMenuVisible: false
29067
+ });
29068
+ if (item) {
29069
+ _onSelected == null ? void 0 : _onSelected(optionId, item);
29070
+ }
29071
+ }
29072
+ }), !isContextMenuDisabled && isContextMenuVisible && contextActions && contextActions.length > 0 && React.createElement(RelativeListMenu, {
29073
+ options: contextActions,
29074
+ onSelected: function onSelected(optionId) {
29075
+ updateDetailsState({
29076
+ isContextMenuVisible: false
29077
+ });
29078
+ if (item) {
29079
+ _onSelected == null ? void 0 : _onSelected(optionId, item);
29080
+ }
29081
+ },
29082
+ onOutsideClick: function onOutsideClick() {
29083
+ updateDetailsState({
29084
+ isContextMenuVisible: false
29085
+ });
29086
+ },
29087
+ pos: contextMenuPosition
29088
+ }));
29089
+ };
29090
+
29086
29091
  var EquipmentSet = function EquipmentSet(_ref) {
29087
29092
  var equipmentSet = _ref.equipmentSet,
29088
29093
  onClose = _ref.onClose,
29089
29094
  _onMouseOver = _ref.onMouseOver,
29090
- _onSelected = _ref.onSelected,
29095
+ onSelected = _ref.onSelected,
29091
29096
  onItemClick = _ref.onItemClick,
29092
29097
  atlasIMG = _ref.atlasIMG,
29093
29098
  atlasJSON = _ref.atlasJSON,
@@ -29133,9 +29138,6 @@ var EquipmentSet = function EquipmentSet(_ref) {
29133
29138
  onPointerDown: function onPointerDown(itemType, ContainerType) {
29134
29139
  if (onItemClick) onItemClick(itemType, item, ContainerType);
29135
29140
  },
29136
- onSelected: function onSelected(optionId) {
29137
- if (_onSelected) _onSelected(optionId);
29138
- },
29139
29141
  onDragStart: function onDragStart(item, slotIndex, itemContainerType) {
29140
29142
  if (!item) {
29141
29143
  return;
@@ -29159,7 +29161,7 @@ var EquipmentSet = function EquipmentSet(_ref) {
29159
29161
  });
29160
29162
  });
29161
29163
  };
29162
- return React.createElement(DraggingProvider, null, React.createElement(DraggedItem, {
29164
+ return React.createElement(ItemSlotDraggingProvider, null, React.createElement(ItemSlotDetailsProvider, null, React.createElement(DraggedItem, {
29163
29165
  atlasIMG: atlasIMG,
29164
29166
  atlasJSON: atlasJSON,
29165
29167
  scale: scale
@@ -29177,7 +29179,14 @@ var EquipmentSet = function EquipmentSet(_ref) {
29177
29179
  onPositionChangeStart: onPositionChangeStart
29178
29180
  }, React.createElement(EquipmentSetContainer, {
29179
29181
  className: "equipment-container-body"
29180
- }, React.createElement(EquipmentColumn, null, onRenderEquipmentSlotRange(0, 3)), React.createElement(EquipmentColumn, null, onRenderEquipmentSlotRange(3, 7)), React.createElement(EquipmentColumn, null, onRenderEquipmentSlotRange(7, 10)))));
29182
+ }, React.createElement(EquipmentColumn, null, onRenderEquipmentSlotRange(0, 3)), React.createElement(EquipmentColumn, null, onRenderEquipmentSlotRange(3, 7)), React.createElement(EquipmentColumn, null, onRenderEquipmentSlotRange(7, 10)))), React.createElement(ItemSlotToolTips, {
29183
+ dragScale: scale,
29184
+ atlasIMG: atlasIMG,
29185
+ atlasJSON: atlasJSON,
29186
+ equipmentSet: equipmentSet,
29187
+ onSelected: onSelected,
29188
+ isContextMenuDisabled: isMobile()
29189
+ })));
29181
29190
  };
29182
29191
  var EquipmentSetContainer = /*#__PURE__*/styled.div.withConfig({
29183
29192
  displayName: "EquipmentSet__EquipmentSetContainer",
@@ -30593,11 +30602,11 @@ var QuantitySelectorContainer = /*#__PURE__*/styled.div.withConfig({
30593
30602
  })(["position:absolute;top:0;left:0;width:100vw;height:100vh;z-index:100;display:flex;justify-content:center;align-items:center;background-color:rgba(0,0,0,0.5);"]);
30594
30603
 
30595
30604
  var MIN_SLOTS_FOR_SCROLL = 20;
30596
- var ItemContainer$1 = function ItemContainer(_ref) {
30605
+ var ItemContainer$1 = /*#__PURE__*/React.memo(function (_ref) {
30597
30606
  var itemContainer = _ref.itemContainer,
30598
30607
  onClose = _ref.onClose,
30599
- _onMouseOver = _ref.onMouseOver,
30600
- _onSelected = _ref.onSelected,
30608
+ onMouseOver = _ref.onMouseOver,
30609
+ onSelected = _ref.onSelected,
30601
30610
  onItemClick = _ref.onItemClick,
30602
30611
  type = _ref.type,
30603
30612
  atlasJSON = _ref.atlasJSON,
@@ -30639,11 +30648,11 @@ var ItemContainer$1 = function ItemContainer(_ref) {
30639
30648
  }),
30640
30649
  startScrolling = _useScrollOnDrag.startScrolling,
30641
30650
  stopScrolling = _useScrollOnDrag.stopScrolling;
30642
- var handleSetShortcut = function handleSetShortcut(item, index) {
30651
+ var handleSetShortcut = useCallback(function (item, index) {
30643
30652
  if (item.type === ItemType.Consumable || item.type === ItemType.Tool || item.subType === ItemSubType.Seed) {
30644
30653
  setItemShortcut == null ? void 0 : setItemShortcut(item.key, index);
30645
30654
  }
30646
- };
30655
+ }, [setItemShortcut]);
30647
30656
  var handleMouseMove = useCallback(function (e) {
30648
30657
  startScrolling(e.clientY);
30649
30658
  }, [startScrolling]);
@@ -30652,50 +30661,55 @@ var ItemContainer$1 = function ItemContainer(_ref) {
30652
30661
  document.addEventListener('pointerup', function () {
30653
30662
  stopScrolling();
30654
30663
  document.removeEventListener('pointermove', handleMouseMove);
30664
+ }, {
30665
+ once: true
30655
30666
  });
30656
- }, [handleMouseMove, onItemDragStart, stopScrolling]);
30667
+ }, [handleMouseMove, stopScrolling]);
30657
30668
  var onDragEndScrollingEvents = useCallback(function () {
30658
30669
  stopScrolling();
30659
30670
  document.removeEventListener('pointermove', handleMouseMove);
30660
- }, [handleMouseMove, onItemDragStart, stopScrolling]);
30661
- var onDragStart = function onDragStart(item, slotIndex, itemContainerType) {
30671
+ }, [handleMouseMove, stopScrolling]);
30672
+ var onDragStartHandler = useCallback(function (item, slotIndex, itemContainerType) {
30662
30673
  if (onItemDragStart) {
30663
30674
  onItemDragStart(item, slotIndex, itemContainerType);
30664
30675
  }
30665
30676
  onDragStartScrollingEvents();
30666
- };
30667
- var onDragEnd = function onDragEnd(quantity) {
30677
+ }, [onItemDragStart, onDragStartScrollingEvents]);
30678
+ var onDragEndHandler = useCallback(function (quantity) {
30668
30679
  if (onItemDragEnd) {
30669
30680
  onItemDragEnd(quantity);
30670
30681
  }
30671
30682
  onDragEndScrollingEvents();
30672
- };
30673
- var onRenderSlots = function onRenderSlots() {
30683
+ }, [onItemDragEnd, onDragEndScrollingEvents]);
30684
+ // Memoize handleSetShortcut to prevent unnecessary re-renders
30685
+ var memoizedHandleSetShortcut = useCallback(function (item, index) {
30686
+ handleSetShortcut(item, index);
30687
+ }, [handleSetShortcut]);
30688
+ // Memoize onRenderSlots to prevent re-creating the slots array on every render
30689
+ var onRenderSlots = useMemo(function () {
30674
30690
  var slots = [];
30675
30691
  for (var i = 0; i < itemContainer.slotQty; i++) {
30676
30692
  var _itemContainer$slots;
30693
+ var currentItem = ((_itemContainer$slots = itemContainer.slots) == null ? void 0 : _itemContainer$slots[i]) || null;
30677
30694
  slots.push(React.createElement(ItemSlot, {
30678
- isContextMenuDisabled: disableContextMenu,
30679
30695
  key: i,
30680
30696
  slotIndex: i,
30681
- item: ((_itemContainer$slots = itemContainer.slots) == null ? void 0 : _itemContainer$slots[i]) || null,
30697
+ item: currentItem,
30682
30698
  itemContainerType: type,
30683
- onMouseOver: function onMouseOver(event, slotIndex, item) {
30684
- if (_onMouseOver) _onMouseOver(event, slotIndex, item);
30685
- },
30699
+ onMouseOver: onMouseOver ? function (event, slotIndex, item) {
30700
+ return onMouseOver(event, slotIndex, item);
30701
+ } : undefined,
30702
+ onMouseOut: undefined,
30686
30703
  onPointerDown: function onPointerDown(itemType, containerType, item) {
30687
30704
  if (settingShortcutIndex !== -1) {
30688
30705
  setSettingShortcutIndex(-1);
30689
- handleSetShortcut(item, settingShortcutIndex);
30706
+ memoizedHandleSetShortcut(item, settingShortcutIndex);
30690
30707
  } else if (onItemClick) {
30691
30708
  onItemClick(item, itemType, containerType);
30692
30709
  }
30693
30710
  },
30694
- onSelected: function onSelected(optionId, item) {
30695
- if (_onSelected) _onSelected(optionId, item);
30696
- },
30697
- onDragStart: onDragStart,
30698
- onDragEnd: onDragEnd,
30711
+ onDragStart: onDragStartHandler,
30712
+ onDragEnd: onDragEndHandler,
30699
30713
  dragScale: scale,
30700
30714
  checkIfItemCanBeMoved: checkIfItemCanBeMoved,
30701
30715
  checkIfItemShouldDragEnd: checkIfItemShouldDragEnd,
@@ -30724,13 +30738,13 @@ var ItemContainer$1 = function ItemContainer(_ref) {
30724
30738
  atlasJSON: atlasJSON,
30725
30739
  isSelectingShortcut: settingShortcutIndex !== -1,
30726
30740
  equipmentSet: equipmentSet,
30727
- setItemShortcut: type === ItemContainerType.Inventory ? handleSetShortcut : undefined,
30741
+ setItemShortcut: type === ItemContainerType.Inventory ? memoizedHandleSetShortcut : undefined,
30728
30742
  isDepotSystem: isDepotSystem
30729
30743
  }));
30730
30744
  }
30731
30745
  return slots;
30732
- };
30733
- return React.createElement(DraggingProvider, null, React.createElement(DraggedItem, {
30746
+ }, [itemContainer.slotQty, itemContainer.slots, type, onMouseOver, settingShortcutIndex, memoizedHandleSetShortcut, onItemClick, onDragStartHandler, onDragEndHandler, scale, checkIfItemCanBeMoved, checkIfItemShouldDragEnd, onItemPlaceDrop, _onOutsideDrop, atlasIMG, atlasJSON, equipmentSet, isDepotSystem, onDragEndScrollingEvents]);
30747
+ return React.createElement(ItemSlotDraggingProvider, null, React.createElement(ItemSlotDetailsProvider, null, React.createElement(DraggedItem, {
30734
30748
  atlasIMG: atlasIMG,
30735
30749
  atlasJSON: atlasJSON,
30736
30750
  scale: scale
@@ -30755,11 +30769,18 @@ var ItemContainer$1 = function ItemContainer(_ref) {
30755
30769
  ref: containerRef,
30756
30770
  isScrollable: itemContainer.slotQty > MIN_SLOTS_FOR_SCROLL,
30757
30771
  isFullScreen: isFullScreen
30758
- }, onRenderSlots())), quantitySelect.isOpen && React.createElement(ItemQuantitySelectorModal, {
30772
+ }, onRenderSlots)), quantitySelect.isOpen && React.createElement(ItemQuantitySelectorModal, {
30759
30773
  quantitySelect: quantitySelect,
30760
30774
  setQuantitySelect: setQuantitySelect
30761
- }));
30762
- };
30775
+ }), React.createElement(ItemSlotToolTips, {
30776
+ dragScale: scale,
30777
+ atlasIMG: atlasIMG,
30778
+ atlasJSON: atlasJSON,
30779
+ equipmentSet: equipmentSet,
30780
+ isContextMenuDisabled: disableContextMenu,
30781
+ onSelected: onSelected
30782
+ })));
30783
+ });
30763
30784
  var ItemsContainer = /*#__PURE__*/styled.div.withConfig({
30764
30785
  displayName: "ItemContainer__ItemsContainer",
30765
30786
  componentId: "sc-15y5p9l-0"