@rpg-engine/long-bow 0.7.51 → 0.7.53

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.
@@ -27930,6 +27930,15 @@ var ItemSlot = /*#__PURE__*/React.memo( /*#__PURE__*/observer(function (_ref) {
27930
27930
  var _useState4 = useState([]),
27931
27931
  contextActions = _useState4[0],
27932
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
27933
27942
  useEffect(function () {
27934
27943
  setDragState(function (prev) {
27935
27944
  return _extends({}, prev, {
@@ -27973,7 +27982,8 @@ var ItemSlot = /*#__PURE__*/React.memo( /*#__PURE__*/observer(function (_ref) {
27973
27982
  var resetItem = function resetItem() {
27974
27983
  setTooltipState(function (prev) {
27975
27984
  return _extends({}, prev, {
27976
- visible: false
27985
+ visible: false,
27986
+ mobileVisible: false
27977
27987
  });
27978
27988
  });
27979
27989
  setDragState(function (prev) {
@@ -27981,6 +27991,7 @@ var ItemSlot = /*#__PURE__*/React.memo( /*#__PURE__*/observer(function (_ref) {
27981
27991
  wasDragged: false
27982
27992
  });
27983
27993
  });
27994
+ setIsDragging(false); // Reset dragging flag
27984
27995
  };
27985
27996
  var onSuccessfulDrag = function onSuccessfulDrag(quantity) {
27986
27997
  resetItem();
@@ -28008,10 +28019,31 @@ var ItemSlot = /*#__PURE__*/React.memo( /*#__PURE__*/observer(function (_ref) {
28008
28019
  setItemShortcut(item, index);
28009
28020
  }
28010
28021
  }
28011
- // remove the class react-draggable-dragging from the element
28022
+ // Remove the class react-draggable-dragging from the element
28012
28023
  // to prevent the item from being dragged again
28013
28024
  target.classList.remove('react-draggable-dragging');
28014
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
+ }
28015
28047
  // Threshold for considering a tap/click as a drag
28016
28048
  var dragThreshold = 5; // pixels
28017
28049
  var isDrag = Math.abs(data.x) > dragThreshold || Math.abs(data.y) > dragThreshold;
@@ -28071,13 +28103,19 @@ var ItemSlot = /*#__PURE__*/React.memo( /*#__PURE__*/observer(function (_ref) {
28071
28103
  }
28072
28104
  }, 50);
28073
28105
  } else if (item) {
28074
- if (isTouch && !isDrag) {
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
28075
28111
  setTooltipState(function (prev) {
28076
28112
  return _extends({}, prev, {
28077
28113
  mobileVisible: true
28078
28114
  });
28079
28115
  });
28116
+ onPointerDown(item.type, containerType != null ? containerType : null, item);
28080
28117
  } else if (!isTouch && !isContextMenuDisabled && !isSelectingShortcut) {
28118
+ // Handle as context menu for mouse devices
28081
28119
  setContextMenuState(function (prev) {
28082
28120
  return _extends({}, prev, {
28083
28121
  visible: !contextMenuState.visible
@@ -28095,7 +28133,7 @@ var ItemSlot = /*#__PURE__*/React.memo( /*#__PURE__*/observer(function (_ref) {
28095
28133
  });
28096
28134
  }
28097
28135
  }
28098
- if (!isDrag || !isTouch) {
28136
+ if (!isDrag && !isTouch) {
28099
28137
  console.log('Calling onPointerDown');
28100
28138
  onPointerDown(item.type, containerType != null ? containerType : null, item);
28101
28139
  }
@@ -28114,6 +28152,7 @@ var ItemSlot = /*#__PURE__*/React.memo( /*#__PURE__*/observer(function (_ref) {
28114
28152
  if (onDragStart && containerType) {
28115
28153
  onDragStart(item, slotIndex, containerType);
28116
28154
  }
28155
+ setIsDragging(true); // Set dragging flag on start
28117
28156
  };
28118
28157
  var onDraggableProgress = function onDraggableProgress(_e, data) {
28119
28158
  if (Math.abs(data.x - dragState.position.x) > 5 || Math.abs(data.y - dragState.position.y) > 5) {
@@ -28128,6 +28167,46 @@ var ItemSlot = /*#__PURE__*/React.memo( /*#__PURE__*/observer(function (_ref) {
28128
28167
  setDraggingItem(item);
28129
28168
  }
28130
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
+ });
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 {
28199
+ var _document$elementFrom;
28200
+ // Handle as a drag end
28201
+ var simulatedEvent = new MouseEvent('mouseup', {
28202
+ clientX: touch.clientX,
28203
+ clientY: touch.clientY,
28204
+ bubbles: true
28205
+ });
28206
+ (_document$elementFrom = document.elementFromPoint(touch.clientX, touch.clientY)) == null ? void 0 : _document$elementFrom.dispatchEvent(simulatedEvent);
28207
+ }
28208
+ setIsDragging(false); // Reset dragging flag on touch end
28209
+ };
28131
28210
  var bounds = getContainerBounds();
28132
28211
  return React.createElement(Container$b, {
28133
28212
  isDraggingItem: !!draggingItem,
@@ -28139,22 +28218,12 @@ var ItemSlot = /*#__PURE__*/React.memo( /*#__PURE__*/observer(function (_ref) {
28139
28218
  onPlaceDrop(data, slotIndex, containerType);
28140
28219
  }
28141
28220
  },
28142
- onTouchEnd: function onTouchEnd(e) {
28143
- var _document$elementFrom;
28144
- var _e$changedTouches$ = e.changedTouches[0],
28145
- clientX = _e$changedTouches$.clientX,
28146
- clientY = _e$changedTouches$.clientY;
28147
- var simulatedEvent = new MouseEvent('mouseup', {
28148
- clientX: clientX,
28149
- clientY: clientY,
28150
- bubbles: true
28151
- });
28152
- (_document$elementFrom = document.elementFromPoint(clientX, clientY)) == null ? void 0 : _document$elementFrom.dispatchEvent(simulatedEvent);
28153
- },
28154
28221
  onPointerDown: onDragStart !== undefined && onDragEnd !== undefined ? undefined : function () {
28155
28222
  if (item) onPointerDown(item.type, containerType != null ? containerType : null, item);
28156
28223
  },
28157
- 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)
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
28158
28227
  }, React.createElement(Draggable, {
28159
28228
  axis: isSelectingShortcut ? 'none' : 'both',
28160
28229
  defaultClassName: item ? 'draggable' : 'empty-slot',
@@ -28240,8 +28309,9 @@ var Container$b = /*#__PURE__*/styled.div.withConfig({
28240
28309
  var ItemContainer = /*#__PURE__*/styled.div.withConfig({
28241
28310
  displayName: "ItemSlot__ItemContainer",
28242
28311
  componentId: "sc-l2j5ef-1"
28243
- })(["width:64px;height:64px;position:relative;", ";"], function (props) {
28244
- return props.isFocused && 'z-index: 100; pointer-events: none;';
28312
+ })(["width:64px;height:64px;position:relative;", ";"], function (_ref7) {
28313
+ var isFocused = _ref7.isFocused;
28314
+ return isFocused ? 'z-index: 100; pointer-events: none;' : '';
28245
28315
  });
28246
28316
 
28247
28317
  var statisticsToDisplay = [{