@rpg-engine/long-bow 0.7.41 → 0.7.42

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.
@@ -27937,6 +27937,12 @@ var ItemSlot = /*#__PURE__*/React__default.memo( /*#__PURE__*/mobxReactLite.obse
27937
27937
  var _useState4 = React.useState([]),
27938
27938
  contextActions = _useState4[0],
27939
27939
  setContextActions = _useState4[1];
27940
+ var _useState5 = React.useState(false),
27941
+ isClicking = _useState5[0],
27942
+ setIsClicking = _useState5[1];
27943
+ var clickTimeoutRef = React.useRef(null);
27944
+ // Add a ref to track touch events
27945
+ var isTouchEventRef = React.useRef(false);
27940
27946
  React.useEffect(function () {
27941
27947
  setDragState(function (prev) {
27942
27948
  return _extends({}, prev, {
@@ -28125,22 +28131,69 @@ var ItemSlot = /*#__PURE__*/React__default.memo( /*#__PURE__*/mobxReactLite.obse
28125
28131
  setDraggingItem(item);
28126
28132
  }
28127
28133
  };
28134
+ var handleMouseDown = function handleMouseDown(_e) {
28135
+ setIsClicking(true);
28136
+ clickTimeoutRef.current = setTimeout(function () {
28137
+ setIsClicking(false);
28138
+ // Allow dragging by setting wasDragged to true
28139
+ setDragState(function (prev) {
28140
+ return _extends({}, prev, {
28141
+ wasDragged: true,
28142
+ isFocused: true
28143
+ });
28144
+ });
28145
+ }, 200); // 200ms threshold for distinguishing click vs. hold
28146
+ };
28147
+ var handleMouseUp = function handleMouseUp(_e) {
28148
+ if (clickTimeoutRef.current) {
28149
+ clearTimeout(clickTimeoutRef.current);
28150
+ clickTimeoutRef.current = null;
28151
+ }
28152
+ if (isClicking && item) {
28153
+ // Always open the mobile menu when clicking an item
28154
+ setTooltipState(function (prev) {
28155
+ return _extends({}, prev, {
28156
+ mobileVisible: true
28157
+ });
28158
+ });
28159
+ setContextMenuState(function (prev) {
28160
+ return _extends({}, prev, {
28161
+ visible: false
28162
+ });
28163
+ }); // Ensure desktop menu is closed
28164
+ onPointerDown(item.type, containerType != null ? containerType : null, item);
28165
+ setIsClicking(false);
28166
+ } else if (onPlaceDrop && containerType) {
28167
+ // Handle item placement if not clicking (i.e., after dragging)
28168
+ var data = item ? item : null;
28169
+ onPlaceDrop(data, slotIndex, containerType);
28170
+ }
28171
+ // Reset drag state
28172
+ setDragState(function (prev) {
28173
+ return _extends({}, prev, {
28174
+ wasDragged: false
28175
+ });
28176
+ });
28177
+ };
28178
+ var handleMouseLeave = function handleMouseLeave() {
28179
+ if (clickTimeoutRef.current) {
28180
+ clearTimeout(clickTimeoutRef.current);
28181
+ clickTimeoutRef.current = null;
28182
+ }
28183
+ setIsClicking(false);
28184
+ };
28128
28185
  var bounds = getContainerBounds();
28129
28186
  return React__default.createElement(Container$b, {
28130
28187
  isDraggingItem: !!draggingItem,
28131
28188
  item: item,
28132
28189
  className: "rpgui-icon empty-slot",
28133
- onMouseUp: function onMouseUp() {
28134
- var data = item ? item : null;
28135
- if (onPlaceDrop && containerType) {
28136
- onPlaceDrop(data, slotIndex, containerType);
28137
- }
28138
- },
28139
28190
  onTouchEnd: function onTouchEnd(e) {
28140
28191
  var _document$elementFrom;
28141
28192
  var _e$changedTouches$ = e.changedTouches[0],
28142
28193
  clientX = _e$changedTouches$.clientX,
28143
28194
  clientY = _e$changedTouches$.clientY;
28195
+ // Set the flag to indicate a touch event
28196
+ isTouchEventRef.current = true;
28144
28197
  var simulatedEvent = new MouseEvent('mouseup', {
28145
28198
  clientX: clientX,
28146
28199
  clientY: clientY,
@@ -28151,12 +28204,15 @@ var ItemSlot = /*#__PURE__*/React__default.memo( /*#__PURE__*/mobxReactLite.obse
28151
28204
  onPointerDown: onDragStart !== undefined && onDragEnd !== undefined ? undefined : function () {
28152
28205
  if (item) onPointerDown(item.type, containerType != null ? containerType : null, item);
28153
28206
  },
28154
- 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)
28207
+ 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),
28208
+ onMouseDown: handleMouseDown,
28209
+ onMouseUp: handleMouseUp,
28210
+ onMouseLeave: handleMouseLeave
28155
28211
  }, React__default.createElement(Draggable, {
28156
28212
  axis: isSelectingShortcut ? 'none' : 'both',
28157
28213
  defaultClassName: item ? 'draggable' : 'empty-slot',
28158
28214
  scale: dragScale,
28159
- disabled: onDragStart === undefined || onDragEnd === undefined,
28215
+ disabled: isClicking || onDragStart === undefined || onDragEnd === undefined,
28160
28216
  onStop: onDraggableStop,
28161
28217
  onStart: onDraggableStart,
28162
28218
  onDrag: onDraggableProgress,