@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.
@@ -27936,6 +27936,15 @@ var ItemSlot = /*#__PURE__*/React__default.memo( /*#__PURE__*/mobxReactLite.obse
27936
27936
  var _useState4 = React.useState([]),
27937
27937
  contextActions = _useState4[0],
27938
27938
  setContextActions = _useState4[1];
27939
+ var _useState5 = React.useState(null),
27940
+ touchStartTime = _useState5[0],
27941
+ setTouchStartTime = _useState5[1];
27942
+ var _useState6 = React.useState(null),
27943
+ touchStartPosition = _useState6[0],
27944
+ setTouchStartPosition = _useState6[1];
27945
+ var _useState7 = React.useState(false),
27946
+ isDragging = _useState7[0],
27947
+ setIsDragging = _useState7[1]; // New state to track dragging
27939
27948
  React.useEffect(function () {
27940
27949
  setDragState(function (prev) {
27941
27950
  return _extends({}, prev, {
@@ -27979,7 +27988,8 @@ var ItemSlot = /*#__PURE__*/React__default.memo( /*#__PURE__*/mobxReactLite.obse
27979
27988
  var resetItem = function resetItem() {
27980
27989
  setTooltipState(function (prev) {
27981
27990
  return _extends({}, prev, {
27982
- visible: false
27991
+ visible: false,
27992
+ mobileVisible: false
27983
27993
  });
27984
27994
  });
27985
27995
  setDragState(function (prev) {
@@ -27987,6 +27997,7 @@ var ItemSlot = /*#__PURE__*/React__default.memo( /*#__PURE__*/mobxReactLite.obse
27987
27997
  wasDragged: false
27988
27998
  });
27989
27999
  });
28000
+ setIsDragging(false); // Reset dragging flag
27990
28001
  };
27991
28002
  var onSuccessfulDrag = function onSuccessfulDrag(quantity) {
27992
28003
  resetItem();
@@ -28014,10 +28025,31 @@ var ItemSlot = /*#__PURE__*/React__default.memo( /*#__PURE__*/mobxReactLite.obse
28014
28025
  setItemShortcut(item, index);
28015
28026
  }
28016
28027
  }
28017
- // remove the class react-draggable-dragging from the element
28028
+ // Remove the class react-draggable-dragging from the element
28018
28029
  // to prevent the item from being dragged again
28019
28030
  target.classList.remove('react-draggable-dragging');
28020
28031
  var isTouch = e.type.startsWith('touch');
28032
+ if (isTouch) {
28033
+ var touchEvent = e;
28034
+ var touch = touchEvent.changedTouches[0];
28035
+ var touchEndTime = new Date().getTime();
28036
+ var touchDuration = touchStartTime ? touchEndTime - touchStartTime : 0;
28037
+ // Check if it's a short tap (less than 200ms) and hasn't moved much
28038
+ var isShortTap = touchDuration < 200;
28039
+ var hasMovedSignificantly = touchStartPosition && (Math.abs(touch.clientX - touchStartPosition.x) > 10 || Math.abs(touch.clientY - touchStartPosition.y) > 10);
28040
+ if (isShortTap && !hasMovedSignificantly) {
28041
+ // Handle as a tap/click
28042
+ if (item) {
28043
+ setTooltipState(function (prev) {
28044
+ return _extends({}, prev, {
28045
+ mobileVisible: true
28046
+ });
28047
+ });
28048
+ onPointerDown(item.type, containerType != null ? containerType : null, item);
28049
+ }
28050
+ return;
28051
+ }
28052
+ }
28021
28053
  // Threshold for considering a tap/click as a drag
28022
28054
  var dragThreshold = 5; // pixels
28023
28055
  var isDrag = Math.abs(data.x) > dragThreshold || Math.abs(data.y) > dragThreshold;
@@ -28077,13 +28109,19 @@ var ItemSlot = /*#__PURE__*/React__default.memo( /*#__PURE__*/mobxReactLite.obse
28077
28109
  }
28078
28110
  }, 50);
28079
28111
  } else if (item) {
28080
- if (isTouch && !isDrag) {
28112
+ if (isTouch && isDragging) {
28113
+ // If it's a touch and we were dragging, do not show context menu
28114
+ return;
28115
+ } else if (isTouch && !isDrag) {
28116
+ // Handle as a tap/click
28081
28117
  setTooltipState(function (prev) {
28082
28118
  return _extends({}, prev, {
28083
28119
  mobileVisible: true
28084
28120
  });
28085
28121
  });
28122
+ onPointerDown(item.type, containerType != null ? containerType : null, item);
28086
28123
  } else if (!isTouch && !isContextMenuDisabled && !isSelectingShortcut) {
28124
+ // Handle as context menu for mouse devices
28087
28125
  setContextMenuState(function (prev) {
28088
28126
  return _extends({}, prev, {
28089
28127
  visible: !contextMenuState.visible
@@ -28101,7 +28139,7 @@ var ItemSlot = /*#__PURE__*/React__default.memo( /*#__PURE__*/mobxReactLite.obse
28101
28139
  });
28102
28140
  }
28103
28141
  }
28104
- if (!isDrag || !isTouch) {
28142
+ if (!isDrag && !isTouch) {
28105
28143
  console.log('Calling onPointerDown');
28106
28144
  onPointerDown(item.type, containerType != null ? containerType : null, item);
28107
28145
  }
@@ -28120,6 +28158,7 @@ var ItemSlot = /*#__PURE__*/React__default.memo( /*#__PURE__*/mobxReactLite.obse
28120
28158
  if (onDragStart && containerType) {
28121
28159
  onDragStart(item, slotIndex, containerType);
28122
28160
  }
28161
+ setIsDragging(true); // Set dragging flag on start
28123
28162
  };
28124
28163
  var onDraggableProgress = function onDraggableProgress(_e, data) {
28125
28164
  if (Math.abs(data.x - dragState.position.x) > 5 || Math.abs(data.y - dragState.position.y) > 5) {
@@ -28134,6 +28173,46 @@ var ItemSlot = /*#__PURE__*/React__default.memo( /*#__PURE__*/mobxReactLite.obse
28134
28173
  setDraggingItem(item);
28135
28174
  }
28136
28175
  };
28176
+ var onTouchStartHandler = function onTouchStartHandler(e) {
28177
+ setTouchStartTime(new Date().getTime());
28178
+ setTouchStartPosition({
28179
+ x: e.touches[0].clientX,
28180
+ y: e.touches[0].clientY
28181
+ });
28182
+ };
28183
+ var onTouchEndHandler = function onTouchEndHandler(e) {
28184
+ // Only prevent default if not dragging
28185
+ if (!isDragging) {
28186
+ e.preventDefault();
28187
+ }
28188
+ var touch = e.changedTouches[0];
28189
+ var touchEndTime = new Date().getTime();
28190
+ var touchDuration = touchStartTime ? touchEndTime - touchStartTime : 0;
28191
+ // Check if it's a short tap (less than 200ms) and hasn't moved much
28192
+ var isShortTap = touchDuration < 200;
28193
+ var hasMovedSignificantly = touchStartPosition && (Math.abs(touch.clientX - touchStartPosition.x) > 10 || Math.abs(touch.clientY - touchStartPosition.y) > 10);
28194
+ if (isShortTap && !hasMovedSignificantly) {
28195
+ // Handle as a tap/click
28196
+ if (item) {
28197
+ setTooltipState(function (prev) {
28198
+ return _extends({}, prev, {
28199
+ mobileVisible: true
28200
+ });
28201
+ });
28202
+ onPointerDown(item.type, containerType != null ? containerType : null, item);
28203
+ }
28204
+ } else {
28205
+ var _document$elementFrom;
28206
+ // Handle as a drag end
28207
+ var simulatedEvent = new MouseEvent('mouseup', {
28208
+ clientX: touch.clientX,
28209
+ clientY: touch.clientY,
28210
+ bubbles: true
28211
+ });
28212
+ (_document$elementFrom = document.elementFromPoint(touch.clientX, touch.clientY)) == null ? void 0 : _document$elementFrom.dispatchEvent(simulatedEvent);
28213
+ }
28214
+ setIsDragging(false); // Reset dragging flag on touch end
28215
+ };
28137
28216
  var bounds = getContainerBounds();
28138
28217
  return React__default.createElement(Container$b, {
28139
28218
  isDraggingItem: !!draggingItem,
@@ -28145,22 +28224,12 @@ var ItemSlot = /*#__PURE__*/React__default.memo( /*#__PURE__*/mobxReactLite.obse
28145
28224
  onPlaceDrop(data, slotIndex, containerType);
28146
28225
  }
28147
28226
  },
28148
- onTouchEnd: function onTouchEnd(e) {
28149
- var _document$elementFrom;
28150
- var _e$changedTouches$ = e.changedTouches[0],
28151
- clientX = _e$changedTouches$.clientX,
28152
- clientY = _e$changedTouches$.clientY;
28153
- var simulatedEvent = new MouseEvent('mouseup', {
28154
- clientX: clientX,
28155
- clientY: clientY,
28156
- bubbles: true
28157
- });
28158
- (_document$elementFrom = document.elementFromPoint(clientX, clientY)) == null ? void 0 : _document$elementFrom.dispatchEvent(simulatedEvent);
28159
- },
28160
28227
  onPointerDown: onDragStart !== undefined && onDragEnd !== undefined ? undefined : function () {
28161
28228
  if (item) onPointerDown(item.type, containerType != null ? containerType : null, item);
28162
28229
  },
28163
- isSelectingShortcut: isSelectingShortcut && ((item == null ? void 0 : item.type) === shared.ItemType.Consumable || (item == null ? void 0 : item.type) === shared.ItemType.Tool || (item == null ? void 0 : item.subType) === shared.ItemSubType.Seed)
28230
+ isSelectingShortcut: isSelectingShortcut && ((item == null ? void 0 : item.type) === shared.ItemType.Consumable || (item == null ? void 0 : item.type) === shared.ItemType.Tool || (item == null ? void 0 : item.subType) === shared.ItemSubType.Seed),
28231
+ onTouchStart: onTouchStartHandler,
28232
+ onTouchEnd: onTouchEndHandler
28164
28233
  }, React__default.createElement(Draggable, {
28165
28234
  axis: isSelectingShortcut ? 'none' : 'both',
28166
28235
  defaultClassName: item ? 'draggable' : 'empty-slot',
@@ -28246,8 +28315,9 @@ var Container$b = /*#__PURE__*/styled__default.div.withConfig({
28246
28315
  var ItemContainer = /*#__PURE__*/styled__default.div.withConfig({
28247
28316
  displayName: "ItemSlot__ItemContainer",
28248
28317
  componentId: "sc-l2j5ef-1"
28249
- })(["width:64px;height:64px;position:relative;", ";"], function (props) {
28250
- return props.isFocused && 'z-index: 100; pointer-events: none;';
28318
+ })(["width:64px;height:64px;position:relative;", ";"], function (_ref7) {
28319
+ var isFocused = _ref7.isFocused;
28320
+ return isFocused ? 'z-index: 100; pointer-events: none;' : '';
28251
28321
  });
28252
28322
 
28253
28323
  var statisticsToDisplay = [{