@rpg-engine/long-bow 0.7.53 → 0.7.61

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.
@@ -27735,6 +27735,200 @@ var DraggingProvider = function DraggingProvider(_ref) {
27735
27735
  }, children);
27736
27736
  };
27737
27737
 
27738
+ var useItemSlotDragAndDrop = function useItemSlotDragAndDrop(_ref) {
27739
+ var isDepotSystem = _ref.isDepotSystem,
27740
+ item = _ref.item,
27741
+ onDrop = _ref.onDrop,
27742
+ onDragEnd = _ref.onDragEnd,
27743
+ checkIfItemCanBeMoved = _ref.checkIfItemCanBeMoved,
27744
+ checkIfItemShouldDragEnd = _ref.checkIfItemShouldDragEnd,
27745
+ setItemShortcut = _ref.setItemShortcut,
27746
+ isSelectingShortcut = _ref.isSelectingShortcut,
27747
+ onDragStart = _ref.onDragStart,
27748
+ onPointerDown = _ref.onPointerDown,
27749
+ containerType = _ref.containerType,
27750
+ slotIndex = _ref.slotIndex,
27751
+ openQuantitySelector = _ref.openQuantitySelector,
27752
+ isContextMenuDisabled = _ref.isContextMenuDisabled,
27753
+ setTooltipState = _ref.setTooltipState,
27754
+ setContextMenuState = _ref.setContextMenuState;
27755
+ var dragContainer = useRef(null);
27756
+ var _useDragging = useDragging(),
27757
+ draggingItem = _useDragging.item,
27758
+ setDraggingItem = _useDragging.setDraggingItem;
27759
+ var _useState = useState({
27760
+ isFocused: false,
27761
+ wasDragged: false,
27762
+ position: {
27763
+ x: 0,
27764
+ y: 0
27765
+ },
27766
+ dropPosition: null
27767
+ }),
27768
+ dragState = _useState[0],
27769
+ setDragState = _useState[1];
27770
+ useEffect(function () {
27771
+ setDragState(function (prev) {
27772
+ return _extends({}, prev, {
27773
+ position: {
27774
+ x: 0,
27775
+ y: 0
27776
+ },
27777
+ isFocused: false
27778
+ });
27779
+ });
27780
+ }, [item, isDepotSystem]);
27781
+ useEffect(function () {
27782
+ if (onDrop && item && dragState.dropPosition) {
27783
+ onDrop(item, dragState.dropPosition);
27784
+ setDragState(function (prev) {
27785
+ return _extends({}, prev, {
27786
+ dropPosition: null
27787
+ });
27788
+ });
27789
+ }
27790
+ }, [dragState.dropPosition, item, onDrop]);
27791
+ var getContainerBounds = useCallback(function () {
27792
+ var container = dragContainer.current;
27793
+ if (!container) return {
27794
+ left: 0,
27795
+ top: 0,
27796
+ right: 0,
27797
+ bottom: 0
27798
+ };
27799
+ var rect = container.getBoundingClientRect();
27800
+ return {
27801
+ left: rect.left,
27802
+ top: rect.top,
27803
+ right: window.innerWidth - rect.right,
27804
+ bottom: window.innerHeight - rect.bottom
27805
+ };
27806
+ }, []);
27807
+ var resetDragState = useCallback(function () {
27808
+ setTooltipState(function (prev) {
27809
+ return _extends({}, prev, {
27810
+ visible: false
27811
+ });
27812
+ });
27813
+ setDragState(function (prev) {
27814
+ return _extends({}, prev, {
27815
+ wasDragged: false,
27816
+ isFocused: false,
27817
+ position: {
27818
+ x: 0,
27819
+ y: 0
27820
+ }
27821
+ });
27822
+ });
27823
+ }, [setTooltipState]);
27824
+ var handleSuccessfulDrag = useCallback(function (quantity) {
27825
+ resetDragState();
27826
+ if (quantity !== -1 && item) {
27827
+ onDragEnd == null ? void 0 : onDragEnd(quantity);
27828
+ }
27829
+ }, [item, onDragEnd, resetDragState]);
27830
+ var onDraggableStart = useCallback(function () {
27831
+ if (!item || isSelectingShortcut) return;
27832
+ if (onDragStart && containerType) {
27833
+ onDragStart(item, slotIndex, containerType);
27834
+ }
27835
+ }, [item, isSelectingShortcut, onDragStart, containerType, slotIndex]);
27836
+ var onDraggableProgress = useCallback(function (_e, data) {
27837
+ var _dragState$position = dragState.position,
27838
+ x = _dragState$position.x,
27839
+ y = _dragState$position.y;
27840
+ if (Math.abs(data.x - x) > 5 || Math.abs(data.y - y) > 5) {
27841
+ setDragState(function (prev) {
27842
+ return _extends({}, prev, {
27843
+ wasDragged: true,
27844
+ isFocused: true
27845
+ });
27846
+ });
27847
+ }
27848
+ if (!draggingItem) {
27849
+ setDraggingItem(item);
27850
+ }
27851
+ }, [dragState.position, draggingItem, item, setDraggingItem]);
27852
+ var onDraggableStop = useCallback(function (e, data) {
27853
+ setTimeout(function () {
27854
+ setDraggingItem(null);
27855
+ }, 50);
27856
+ var target = e.target;
27857
+ if (!target) return;
27858
+ target.classList.remove('react-draggable-dragging');
27859
+ if (target != null && target.id.includes('shortcutSetter') && setItemShortcut && item) {
27860
+ var index = parseInt(target.id.split('_')[1]);
27861
+ if (!isNaN(index)) {
27862
+ setItemShortcut(item, index);
27863
+ }
27864
+ }
27865
+ if (dragState.wasDragged && item && !isSelectingShortcut) {
27866
+ var classes = Array.from(target.classList);
27867
+ var isOutsideDrop = classes.some(function (elm) {
27868
+ return elm.includes('rpgui-content');
27869
+ }) || classes.length === 0;
27870
+ if (isOutsideDrop) {
27871
+ setDragState(function (prev) {
27872
+ return _extends({}, prev, {
27873
+ dropPosition: {
27874
+ x: data.x,
27875
+ y: data.y
27876
+ }
27877
+ });
27878
+ });
27879
+ }
27880
+ setDragState(function (prev) {
27881
+ return _extends({}, prev, {
27882
+ wasDragged: false
27883
+ });
27884
+ });
27885
+ setTimeout(function () {
27886
+ if (checkIfItemCanBeMoved != null && checkIfItemCanBeMoved() && (!checkIfItemShouldDragEnd || checkIfItemShouldDragEnd())) {
27887
+ if (item.stackQty && item.stackQty !== 1 && openQuantitySelector) {
27888
+ openQuantitySelector(item.stackQty, handleSuccessfulDrag);
27889
+ } else {
27890
+ handleSuccessfulDrag(item.stackQty);
27891
+ }
27892
+ } else {
27893
+ resetDragState();
27894
+ }
27895
+ }, 50);
27896
+ } else if (item) {
27897
+ var isTouch = e.type === 'touchend';
27898
+ if (!isContextMenuDisabled && isTouch && !isSelectingShortcut && !draggingItem) {
27899
+ setTooltipState(function (prev) {
27900
+ return _extends({}, prev, {
27901
+ mobileVisible: true
27902
+ });
27903
+ });
27904
+ } else if (!isContextMenuDisabled && !isSelectingShortcut && !isTouch) {
27905
+ var event = e;
27906
+ setContextMenuState(function (prev) {
27907
+ return {
27908
+ visible: !prev.visible,
27909
+ position: {
27910
+ x: event.clientX - 10,
27911
+ y: event.clientY - 5
27912
+ }
27913
+ };
27914
+ });
27915
+ }
27916
+ onPointerDown == null ? void 0 : onPointerDown(item.type, containerType != null ? containerType : null, item);
27917
+ }
27918
+ }, [dragState.wasDragged, item, isSelectingShortcut, checkIfItemCanBeMoved, checkIfItemShouldDragEnd, openQuantitySelector, handleSuccessfulDrag, resetDragState, isContextMenuDisabled, setTooltipState, setContextMenuState, onPointerDown, containerType, setItemShortcut]);
27919
+ return {
27920
+ dragContainer: dragContainer,
27921
+ dragState: dragState,
27922
+ draggingItem: draggingItem,
27923
+ setDraggingItem: setDraggingItem,
27924
+ getContainerBounds: getContainerBounds,
27925
+ onDraggableStart: onDraggableStart,
27926
+ onDraggableProgress: onDraggableProgress,
27927
+ onDraggableStop: onDraggableStop,
27928
+ resetItem: resetDragState
27929
+ };
27930
+ };
27931
+
27738
27932
  var generateContextMenuListOptions = function generateContextMenuListOptions(actionsByTypeList) {
27739
27933
  var contextMenu = actionsByTypeList.map(function (action) {
27740
27934
  return {
@@ -27878,7 +28072,7 @@ var ItemSlot = /*#__PURE__*/React.memo( /*#__PURE__*/observer(function (_ref) {
27878
28072
  containerType = _ref.itemContainerType,
27879
28073
  slotSpriteMask = _ref.slotSpriteMask,
27880
28074
  _onMouseOver = _ref.onMouseOver,
27881
- _onMouseOut = _ref.onMouseOut,
28075
+ onMouseOut = _ref.onMouseOut,
27882
28076
  onPointerDown = _ref.onPointerDown,
27883
28077
  _onSelected = _ref.onSelected,
27884
28078
  atlasJSON = _ref.atlasJSON,
@@ -27891,7 +28085,6 @@ var ItemSlot = /*#__PURE__*/React.memo( /*#__PURE__*/observer(function (_ref) {
27891
28085
  onDrop = _ref.onOutsideDrop,
27892
28086
  checkIfItemCanBeMoved = _ref.checkIfItemCanBeMoved,
27893
28087
  openQuantitySelector = _ref.openQuantitySelector,
27894
- checkIfItemShouldDragEnd = _ref.checkIfItemShouldDragEnd,
27895
28088
  dragScale = _ref.dragScale,
27896
28089
  isSelectingShortcut = _ref.isSelectingShortcut,
27897
28090
  equipmentSet = _ref.equipmentSet,
@@ -27912,318 +28105,113 @@ var ItemSlot = /*#__PURE__*/React.memo( /*#__PURE__*/observer(function (_ref) {
27912
28105
  }),
27913
28106
  contextMenuState = _useState2[0],
27914
28107
  setContextMenuState = _useState2[1];
27915
- var _useState3 = useState({
27916
- isFocused: false,
27917
- wasDragged: false,
27918
- position: {
27919
- x: 0,
27920
- y: 0
27921
- },
27922
- dropPosition: null
28108
+ var _useState3 = useState([]),
28109
+ contextActions = _useState3[0],
28110
+ setContextActions = _useState3[1];
28111
+ var _useItemSlotDragAndDr = useItemSlotDragAndDrop({
28112
+ isDepotSystem: !!isDepotSystem,
28113
+ item: item,
28114
+ onDrop: onDrop != null ? onDrop : function () {},
28115
+ onDragEnd: onDragEnd,
28116
+ checkIfItemCanBeMoved: checkIfItemCanBeMoved,
28117
+ setItemShortcut: setItemShortcut,
28118
+ isSelectingShortcut: isSelectingShortcut,
28119
+ onDragStart: onDragStart,
28120
+ onPointerDown: onPointerDown,
28121
+ containerType: containerType,
28122
+ slotIndex: slotIndex,
28123
+ openQuantitySelector: openQuantitySelector != null ? openQuantitySelector : function () {},
28124
+ isContextMenuDisabled: isContextMenuDisabled,
28125
+ setTooltipState: setTooltipState,
28126
+ contextMenuState: contextMenuState,
28127
+ setContextMenuState: setContextMenuState
27923
28128
  }),
27924
- dragState = _useState3[0],
27925
- setDragState = _useState3[1];
27926
- var dragContainer = useRef(null);
27927
- var _useDragging = useDragging(),
27928
- draggingItem = _useDragging.item,
27929
- setDraggingItem = _useDragging.setDraggingItem;
27930
- var _useState4 = useState([]),
27931
- contextActions = _useState4[0],
27932
- setContextActions = _useState4[1];
27933
- var _useState5 = useState(null),
27934
- touchStartTime = _useState5[0],
27935
- setTouchStartTime = _useState5[1];
27936
- var _useState6 = useState(null),
27937
- touchStartPosition = _useState6[0],
27938
- setTouchStartPosition = _useState6[1];
27939
- var _useState7 = useState(false),
27940
- isDragging = _useState7[0],
27941
- setIsDragging = _useState7[1]; // New state to track dragging
28129
+ dragContainer = _useItemSlotDragAndDr.dragContainer,
28130
+ dragState = _useItemSlotDragAndDr.dragState,
28131
+ draggingItem = _useItemSlotDragAndDr.draggingItem,
28132
+ getContainerBounds = _useItemSlotDragAndDr.getContainerBounds,
28133
+ onDraggableStart = _useItemSlotDragAndDr.onDraggableStart,
28134
+ onDraggableProgress = _useItemSlotDragAndDr.onDraggableProgress,
28135
+ onDraggableStop = _useItemSlotDragAndDr.onDraggableStop;
27942
28136
  useEffect(function () {
27943
- setDragState(function (prev) {
27944
- return _extends({}, prev, {
27945
- position: {
27946
- x: 0,
27947
- y: 0
27948
- },
27949
- isFocused: false
27950
- });
27951
- });
27952
28137
  if (item && containerType) {
27953
28138
  setContextActions(generateContextMenu(item, containerType, isDepotSystem));
27954
28139
  }
27955
28140
  }, [item, isDepotSystem]);
27956
- useEffect(function () {
27957
- if (onDrop && item && dragState.dropPosition) {
27958
- onDrop(item, dragState.dropPosition);
27959
- setDragState(function (prev) {
27960
- return _extends({}, prev, {
27961
- dropPosition: null
27962
- });
27963
- });
27964
- }
27965
- }, [dragState.dropPosition]);
27966
- var getContainerBounds = useCallback(function () {
27967
- var container = dragContainer.current;
27968
- if (!container) return {
27969
- left: 0,
27970
- top: 0,
27971
- right: 0,
27972
- bottom: 0
27973
- };
27974
- var rect = container.getBoundingClientRect();
27975
- return {
27976
- left: rect.left,
27977
- top: rect.top,
27978
- right: window.innerWidth - rect.right,
27979
- bottom: window.innerHeight - rect.bottom
27980
- };
27981
- }, [dragContainer]);
27982
- var resetItem = function resetItem() {
27983
- setTooltipState(function (prev) {
27984
- return _extends({}, prev, {
27985
- visible: false,
27986
- mobileVisible: false
27987
- });
27988
- });
27989
- setDragState(function (prev) {
27990
- return _extends({}, prev, {
27991
- wasDragged: false
27992
- });
27993
- });
27994
- setIsDragging(false); // Reset dragging flag
27995
- };
27996
- var onSuccessfulDrag = function onSuccessfulDrag(quantity) {
27997
- resetItem();
27998
- if (quantity === -1) {
27999
- setDragState(function (prev) {
28000
- return _extends({}, prev, {
28001
- position: {
28002
- x: 0,
28003
- y: 0
28004
- },
28005
- isFocused: false
28006
- });
28007
- });
28008
- } else if (item) {
28009
- onDragEnd == null ? void 0 : onDragEnd(quantity);
28010
- }
28011
- };
28012
- var onDraggableStop = function onDraggableStop(e, data) {
28013
- setDraggingItem(null);
28014
- var target = e.target;
28015
- if (!target) return;
28016
- if (target != null && target.id.includes('shortcutSetter') && setItemShortcut && item) {
28017
- var index = parseInt(target.id.split('_')[1]);
28018
- if (!isNaN(index)) {
28019
- setItemShortcut(item, index);
28020
- }
28021
- }
28022
- // Remove the class react-draggable-dragging from the element
28023
- // to prevent the item from being dragged again
28024
- target.classList.remove('react-draggable-dragging');
28025
- var isTouch = e.type.startsWith('touch');
28026
- if (isTouch) {
28027
- var touchEvent = e;
28028
- var touch = touchEvent.changedTouches[0];
28029
- var touchEndTime = new Date().getTime();
28030
- var touchDuration = touchStartTime ? touchEndTime - touchStartTime : 0;
28031
- // Check if it's a short tap (less than 200ms) and hasn't moved much
28032
- var isShortTap = touchDuration < 200;
28033
- var hasMovedSignificantly = touchStartPosition && (Math.abs(touch.clientX - touchStartPosition.x) > 10 || Math.abs(touch.clientY - touchStartPosition.y) > 10);
28034
- if (isShortTap && !hasMovedSignificantly) {
28035
- // Handle as a tap/click
28036
- if (item) {
28037
- setTooltipState(function (prev) {
28038
- return _extends({}, prev, {
28039
- mobileVisible: true
28040
- });
28041
- });
28042
- onPointerDown(item.type, containerType != null ? containerType : null, item);
28043
- }
28044
- return;
28045
- }
28046
- }
28047
- // Threshold for considering a tap/click as a drag
28048
- var dragThreshold = 5; // pixels
28049
- var isDrag = Math.abs(data.x) > dragThreshold || Math.abs(data.y) > dragThreshold;
28050
- if (dragState.wasDragged && item && !isSelectingShortcut) {
28051
- var _e$target;
28052
- //@ts-ignore
28053
- var classes = Array.from((_e$target = e.target) == null ? void 0 : _e$target.classList);
28054
- var isOutsideDrop = classes.some(function (elm) {
28055
- return elm.includes('rpgui-content');
28056
- }) || classes.length === 0;
28057
- if (isOutsideDrop) {
28058
- setDragState(function (prev) {
28059
- return _extends({}, prev, {
28060
- dropPosition: {
28061
- x: data.x,
28062
- y: data.y
28063
- }
28064
- });
28065
- });
28066
- }
28067
- setDragState(function (prev) {
28068
- return _extends({}, prev, {
28069
- wasDragged: false
28070
- });
28071
- });
28072
- var _target = dragContainer.current;
28073
- if (!_target || !dragState.wasDragged) return;
28074
- var style = window.getComputedStyle(_target);
28075
- var matrix = new DOMMatrixReadOnly(style.transform);
28076
- var x = matrix.m41;
28077
- var y = matrix.m42;
28078
- setDragState(function (prev) {
28079
- return _extends({}, prev, {
28080
- position: {
28081
- x: x,
28082
- y: y
28083
- }
28084
- });
28085
- });
28086
- setTimeout(function () {
28087
- if (checkIfItemCanBeMoved && checkIfItemCanBeMoved()) {
28088
- if (checkIfItemShouldDragEnd && !checkIfItemShouldDragEnd()) return;
28089
- if (item.stackQty && item.stackQty !== 1 && openQuantitySelector) {
28090
- openQuantitySelector(item.stackQty, onSuccessfulDrag);
28091
- } else onSuccessfulDrag(item.stackQty);
28092
- } else {
28093
- resetItem();
28094
- setDragState(function (prev) {
28095
- return _extends({}, prev, {
28096
- isFocused: false,
28097
- position: {
28098
- x: 0,
28099
- y: 0
28100
- }
28101
- });
28102
- });
28103
- }
28104
- }, 50);
28105
- } else if (item) {
28106
- if (isTouch && isDragging) {
28107
- // If it's a touch and we were dragging, do not show context menu
28108
- return;
28109
- } else if (isTouch && !isDrag) {
28110
- // Handle as a tap/click
28111
- setTooltipState(function (prev) {
28112
- return _extends({}, prev, {
28113
- mobileVisible: true
28114
- });
28115
- });
28116
- onPointerDown(item.type, containerType != null ? containerType : null, item);
28117
- } else if (!isTouch && !isContextMenuDisabled && !isSelectingShortcut) {
28118
- // Handle as context menu for mouse devices
28119
- setContextMenuState(function (prev) {
28120
- return _extends({}, prev, {
28121
- visible: !contextMenuState.visible
28122
- });
28123
- });
28124
- var event = e;
28125
- if (event.clientX && event.clientY) {
28126
- setContextMenuState(function (prev) {
28127
- return _extends({}, prev, {
28128
- position: {
28129
- x: event.clientX - 10,
28130
- y: event.clientY - 5
28131
- }
28132
- });
28133
- });
28134
- }
28141
+ var bounds = getContainerBounds();
28142
+ var handleInteraction = useCallback(function (event) {
28143
+ event.stopPropagation();
28144
+ var _ref2 = 'touches' in event ? event.touches[0] : event,
28145
+ clientX = _ref2.clientX,
28146
+ clientY = _ref2.clientY;
28147
+ if (item && containerType) {
28148
+ if (onPlaceDrop && draggingItem) {
28149
+ onPlaceDrop(item, slotIndex, containerType);
28135
28150
  }
28136
- if (!isDrag && !isTouch) {
28137
- console.log('Calling onPointerDown');
28138
- onPointerDown(item.type, containerType != null ? containerType : null, item);
28151
+ if (onPointerDown && onDragStart === undefined && onDragEnd === undefined) {
28152
+ onPointerDown(item.type, containerType, item);
28139
28153
  }
28140
28154
  }
28141
- setDragState(function (prev) {
28155
+ setTooltipState(function (prev) {
28142
28156
  return _extends({}, prev, {
28143
- wasDragged: false
28157
+ visible: true
28144
28158
  });
28145
28159
  });
28146
- console.log('Final dragState:', dragState);
28147
- };
28148
- var onDraggableStart = function onDraggableStart() {
28149
- if (!item || isSelectingShortcut) {
28150
- return;
28151
- }
28152
- if (onDragStart && containerType) {
28153
- onDragStart(item, slotIndex, containerType);
28154
- }
28155
- setIsDragging(true); // Set dragging flag on start
28156
- };
28157
- var onDraggableProgress = function onDraggableProgress(_e, data) {
28158
- if (Math.abs(data.x - dragState.position.x) > 5 || Math.abs(data.y - dragState.position.y) > 5) {
28159
- setDragState(function (prev) {
28160
- return _extends({}, prev, {
28161
- wasDragged: true,
28162
- isFocused: true
28163
- });
28160
+ _onMouseOver == null ? void 0 : _onMouseOver(event, slotIndex, item, clientX, clientY);
28161
+ }, [item, containerType, slotIndex, onPlaceDrop, onPointerDown, _onMouseOver, onDragStart, onDragEnd]);
28162
+ var handleInteractionEnd = useCallback(function (event) {
28163
+ event.preventDefault();
28164
+ event.stopPropagation();
28165
+ setTooltipState(function (prev) {
28166
+ return _extends({}, prev, {
28167
+ visible: false
28164
28168
  });
28165
- }
28166
- if (!draggingItem) {
28167
- setDraggingItem(item);
28168
- }
28169
- };
28170
- var onTouchStartHandler = function onTouchStartHandler(e) {
28171
- setTouchStartTime(new Date().getTime());
28172
- setTouchStartPosition({
28173
- x: e.touches[0].clientX,
28174
- y: e.touches[0].clientY
28175
28169
  });
28176
- };
28177
- var onTouchEndHandler = function onTouchEndHandler(e) {
28178
- // Only prevent default if not dragging
28179
- if (!isDragging) {
28180
- e.preventDefault();
28181
- }
28182
- var touch = e.changedTouches[0];
28183
- var touchEndTime = new Date().getTime();
28184
- var touchDuration = touchStartTime ? touchEndTime - touchStartTime : 0;
28185
- // Check if it's a short tap (less than 200ms) and hasn't moved much
28186
- var isShortTap = touchDuration < 200;
28187
- var hasMovedSignificantly = touchStartPosition && (Math.abs(touch.clientX - touchStartPosition.x) > 10 || Math.abs(touch.clientY - touchStartPosition.y) > 10);
28188
- if (isShortTap && !hasMovedSignificantly) {
28189
- // Handle as a tap/click
28190
- if (item) {
28191
- setTooltipState(function (prev) {
28192
- return _extends({}, prev, {
28193
- mobileVisible: true
28194
- });
28195
- });
28196
- onPointerDown(item.type, containerType != null ? containerType : null, item);
28197
- }
28198
- } else {
28170
+ onMouseOut == null ? void 0 : onMouseOut();
28171
+ if (event.type === 'touchend' && 'changedTouches' in event) {
28199
28172
  var _document$elementFrom;
28200
- // Handle as a drag end
28173
+ var _event$changedTouches = event.changedTouches[0],
28174
+ clientX = _event$changedTouches.clientX,
28175
+ clientY = _event$changedTouches.clientY;
28201
28176
  var simulatedEvent = new MouseEvent('mouseup', {
28202
- clientX: touch.clientX,
28203
- clientY: touch.clientY,
28177
+ clientX: clientX,
28178
+ clientY: clientY,
28204
28179
  bubbles: true
28205
28180
  });
28206
- (_document$elementFrom = document.elementFromPoint(touch.clientX, touch.clientY)) == null ? void 0 : _document$elementFrom.dispatchEvent(simulatedEvent);
28181
+ (_document$elementFrom = document.elementFromPoint(clientX, clientY)) == null ? void 0 : _document$elementFrom.dispatchEvent(simulatedEvent);
28207
28182
  }
28208
- setIsDragging(false); // Reset dragging flag on touch end
28209
- };
28210
- var bounds = getContainerBounds();
28183
+ }, [onMouseOut]);
28211
28184
  return React.createElement(Container$b, {
28212
28185
  isDraggingItem: !!draggingItem,
28213
28186
  item: item,
28214
28187
  className: "rpgui-icon empty-slot",
28215
- onMouseUp: function onMouseUp() {
28188
+ isSelectingShortcut: isSelectingShortcut && ((item == null ? void 0 : item.type) === ItemType.Consumable || (item == null ? void 0 : item.type) === ItemType.Tool || (item == null ? void 0 : item.subType) === ItemSubType.Seed),
28189
+ onMouseDown: handleInteraction,
28190
+ onTouchStart: handleInteraction,
28191
+ onMouseUp: function onMouseUp(e) {
28192
+ handleInteractionEnd(e);
28216
28193
  var data = item ? item : null;
28217
- if (onPlaceDrop && containerType) {
28194
+ if (onPlaceDrop && containerType && draggingItem) {
28218
28195
  onPlaceDrop(data, slotIndex, containerType);
28219
28196
  }
28220
28197
  },
28198
+ onTouchEnd: function onTouchEnd(e) {
28199
+ var _document$elementFrom2;
28200
+ handleInteractionEnd(e);
28201
+ var _e$changedTouches$ = e.changedTouches[0],
28202
+ clientX = _e$changedTouches$.clientX,
28203
+ clientY = _e$changedTouches$.clientY;
28204
+ var simulatedEvent = new MouseEvent('mouseup', {
28205
+ clientX: clientX,
28206
+ clientY: clientY,
28207
+ bubbles: true
28208
+ });
28209
+ (_document$elementFrom2 = document.elementFromPoint(clientX, clientY)) == null ? void 0 : _document$elementFrom2.dispatchEvent(simulatedEvent);
28210
+ },
28221
28211
  onPointerDown: onDragStart !== undefined && onDragEnd !== undefined ? undefined : function () {
28222
28212
  if (item) onPointerDown(item.type, containerType != null ? containerType : null, item);
28223
28213
  },
28224
- isSelectingShortcut: isSelectingShortcut && ((item == null ? void 0 : item.type) === ItemType.Consumable || (item == null ? void 0 : item.type) === ItemType.Tool || (item == null ? void 0 : item.subType) === ItemSubType.Seed),
28225
- onTouchStart: onTouchStartHandler,
28226
- onTouchEnd: onTouchEndHandler
28214
+ onMouseLeave: handleInteractionEnd
28227
28215
  }, React.createElement(Draggable, {
28228
28216
  axis: isSelectingShortcut ? 'none' : 'both',
28229
28217
  defaultClassName: item ? 'draggable' : 'empty-slot',
@@ -28241,9 +28229,7 @@ var ItemSlot = /*#__PURE__*/React.memo( /*#__PURE__*/observer(function (_ref) {
28241
28229
  onMouseOver: function onMouseOver(event) {
28242
28230
  _onMouseOver == null ? void 0 : _onMouseOver(event, slotIndex, item, event.clientX, event.clientY);
28243
28231
  },
28244
- onMouseOut: function onMouseOut() {
28245
- if (_onMouseOut) _onMouseOut();
28246
- },
28232
+ onMouseOut: onMouseOut,
28247
28233
  onMouseEnter: function onMouseEnter() {
28248
28234
  setTooltipState(function (prev) {
28249
28235
  return _extends({}, prev, {
@@ -28290,28 +28276,27 @@ var ItemSlot = /*#__PURE__*/React.memo( /*#__PURE__*/observer(function (_ref) {
28290
28276
  var Container$b = /*#__PURE__*/styled.div.withConfig({
28291
28277
  displayName: "ItemSlot__Container",
28292
28278
  componentId: "sc-l2j5ef-0"
28293
- })(["margin:0.1rem;.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) {
28294
- var isDraggingItem = _ref2.isDraggingItem;
28279
+ })(["margin:0.1rem;.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 (_ref3) {
28280
+ var isDraggingItem = _ref3.isDraggingItem;
28295
28281
  return isDraggingItem ? 0 : 1;
28296
- }, function (_ref3) {
28297
- var item = _ref3.item;
28298
- return rarityColor(item);
28299
28282
  }, function (_ref4) {
28300
28283
  var item = _ref4.item;
28301
- return "0 0 5px 2px " + rarityColor(item);
28284
+ return rarityColor(item);
28302
28285
  }, function (_ref5) {
28303
28286
  var item = _ref5.item;
28304
- return "0 0 4px 3px " + rarityColor(item);
28287
+ return "0 0 5px 2px " + rarityColor(item);
28305
28288
  }, function (_ref6) {
28306
- var isSelectingShortcut = _ref6.isSelectingShortcut;
28289
+ var item = _ref6.item;
28290
+ return "0 0 4px 3px " + rarityColor(item);
28291
+ }, function (_ref7) {
28292
+ var isSelectingShortcut = _ref7.isSelectingShortcut;
28307
28293
  return isSelectingShortcut ? 'bg-color-change 1s infinite' : 'none';
28308
28294
  });
28309
28295
  var ItemContainer = /*#__PURE__*/styled.div.withConfig({
28310
28296
  displayName: "ItemSlot__ItemContainer",
28311
28297
  componentId: "sc-l2j5ef-1"
28312
- })(["width:64px;height:64px;position:relative;", ";"], function (_ref7) {
28313
- var isFocused = _ref7.isFocused;
28314
- return isFocused ? 'z-index: 100; pointer-events: none;' : '';
28298
+ })(["width:64px;height:64px;position:relative;", ";"], function (props) {
28299
+ return props.isFocused && 'z-index: 100; pointer-events: none;';
28315
28300
  });
28316
28301
 
28317
28302
  var statisticsToDisplay = [{
@@ -30637,7 +30622,6 @@ var ItemContainer$1 = function ItemContainer(_ref) {
30637
30622
  _onOutsideDrop = _ref.onOutsideDrop,
30638
30623
  checkIfItemCanBeMoved = _ref.checkIfItemCanBeMoved,
30639
30624
  initialPosition = _ref.initialPosition,
30640
- checkIfItemShouldDragEnd = _ref.checkIfItemShouldDragEnd,
30641
30625
  scale = _ref.scale,
30642
30626
  shortcuts = _ref.shortcuts,
30643
30627
  setItemShortcut = _ref.setItemShortcut,
@@ -30727,7 +30711,6 @@ var ItemContainer$1 = function ItemContainer(_ref) {
30727
30711
  onDragEnd: onDragEnd,
30728
30712
  dragScale: scale,
30729
30713
  checkIfItemCanBeMoved: checkIfItemCanBeMoved,
30730
- checkIfItemShouldDragEnd: checkIfItemShouldDragEnd,
30731
30714
  openQuantitySelector: function openQuantitySelector(maxQuantity, callback) {
30732
30715
  setQuantitySelect({
30733
30716
  isOpen: true,