@rpg-engine/long-bow 0.7.52 → 0.7.60
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.
- package/dist/components/Item/Inventory/ItemSlot.d.ts +1 -2
- package/dist/components/Item/Inventory/hooks/useItemSlotDragAndDrop.d.ts +43 -0
- package/dist/long-bow.cjs.development.js +281 -282
- package/dist/long-bow.cjs.development.js.map +1 -1
- package/dist/long-bow.cjs.production.min.js +1 -1
- package/dist/long-bow.cjs.production.min.js.map +1 -1
- package/dist/long-bow.esm.js +281 -282
- package/dist/long-bow.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Item/Inventory/ItemContainer.tsx +0 -2
- package/src/components/Item/Inventory/ItemSlot.tsx +106 -286
- package/src/components/Item/Inventory/hooks/useItemSlotDragAndDrop.ts +226 -0
package/dist/long-bow.esm.js
CHANGED
|
@@ -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) {
|
|
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
|
-
|
|
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,303 +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
|
-
|
|
27917
|
-
|
|
27918
|
-
|
|
27919
|
-
|
|
27920
|
-
|
|
27921
|
-
},
|
|
27922
|
-
|
|
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
|
-
|
|
27925
|
-
|
|
27926
|
-
|
|
27927
|
-
|
|
27928
|
-
|
|
27929
|
-
|
|
27930
|
-
|
|
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];
|
|
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;
|
|
27939
28136
|
useEffect(function () {
|
|
27940
|
-
setDragState(function (prev) {
|
|
27941
|
-
return _extends({}, prev, {
|
|
27942
|
-
position: {
|
|
27943
|
-
x: 0,
|
|
27944
|
-
y: 0
|
|
27945
|
-
},
|
|
27946
|
-
isFocused: false
|
|
27947
|
-
});
|
|
27948
|
-
});
|
|
27949
28137
|
if (item && containerType) {
|
|
27950
28138
|
setContextActions(generateContextMenu(item, containerType, isDepotSystem));
|
|
27951
28139
|
}
|
|
27952
28140
|
}, [item, isDepotSystem]);
|
|
27953
|
-
|
|
27954
|
-
|
|
27955
|
-
|
|
27956
|
-
|
|
27957
|
-
|
|
27958
|
-
|
|
27959
|
-
|
|
27960
|
-
|
|
27961
|
-
|
|
27962
|
-
}, [dragState.dropPosition]);
|
|
27963
|
-
var getContainerBounds = useCallback(function () {
|
|
27964
|
-
var container = dragContainer.current;
|
|
27965
|
-
if (!container) return {
|
|
27966
|
-
left: 0,
|
|
27967
|
-
top: 0,
|
|
27968
|
-
right: 0,
|
|
27969
|
-
bottom: 0
|
|
27970
|
-
};
|
|
27971
|
-
var rect = container.getBoundingClientRect();
|
|
27972
|
-
return {
|
|
27973
|
-
left: rect.left,
|
|
27974
|
-
top: rect.top,
|
|
27975
|
-
right: window.innerWidth - rect.right,
|
|
27976
|
-
bottom: window.innerHeight - rect.bottom
|
|
27977
|
-
};
|
|
27978
|
-
}, [dragContainer]);
|
|
27979
|
-
var resetItem = function resetItem() {
|
|
27980
|
-
setTooltipState(function (prev) {
|
|
27981
|
-
return _extends({}, prev, {
|
|
27982
|
-
visible: false
|
|
27983
|
-
});
|
|
27984
|
-
});
|
|
27985
|
-
setDragState(function (prev) {
|
|
27986
|
-
return _extends({}, prev, {
|
|
27987
|
-
wasDragged: false
|
|
27988
|
-
});
|
|
27989
|
-
});
|
|
27990
|
-
};
|
|
27991
|
-
var onSuccessfulDrag = function onSuccessfulDrag(quantity) {
|
|
27992
|
-
resetItem();
|
|
27993
|
-
if (quantity === -1) {
|
|
27994
|
-
setDragState(function (prev) {
|
|
27995
|
-
return _extends({}, prev, {
|
|
27996
|
-
position: {
|
|
27997
|
-
x: 0,
|
|
27998
|
-
y: 0
|
|
27999
|
-
},
|
|
28000
|
-
isFocused: false
|
|
28001
|
-
});
|
|
28002
|
-
});
|
|
28003
|
-
} else if (item) {
|
|
28004
|
-
onDragEnd == null ? void 0 : onDragEnd(quantity);
|
|
28005
|
-
}
|
|
28006
|
-
};
|
|
28007
|
-
var onDraggableStop = function onDraggableStop(e, data) {
|
|
28008
|
-
setDraggingItem(null);
|
|
28009
|
-
var target = e.target;
|
|
28010
|
-
if (!target) return;
|
|
28011
|
-
if (target != null && target.id.includes('shortcutSetter') && setItemShortcut && item) {
|
|
28012
|
-
var index = parseInt(target.id.split('_')[1]);
|
|
28013
|
-
if (!isNaN(index)) {
|
|
28014
|
-
setItemShortcut(item, index);
|
|
28015
|
-
}
|
|
28016
|
-
}
|
|
28017
|
-
// remove the class react-draggable-dragging from the element
|
|
28018
|
-
// to prevent the item from being dragged again
|
|
28019
|
-
target.classList.remove('react-draggable-dragging');
|
|
28020
|
-
var isTouch = e.type.startsWith('touch');
|
|
28021
|
-
if (isTouch) {
|
|
28022
|
-
var touchEvent = e;
|
|
28023
|
-
var touch = touchEvent.changedTouches[0];
|
|
28024
|
-
var touchEndTime = new Date().getTime();
|
|
28025
|
-
var touchDuration = touchStartTime ? touchEndTime - touchStartTime : 0;
|
|
28026
|
-
// Check if it's a short tap (less than 200ms) and hasn't moved much
|
|
28027
|
-
var isShortTap = touchDuration < 200;
|
|
28028
|
-
var hasMovedSignificantly = touchStartPosition && (Math.abs(touch.clientX - touchStartPosition.x) > 10 || Math.abs(touch.clientY - touchStartPosition.y) > 10);
|
|
28029
|
-
if (isShortTap && !hasMovedSignificantly) {
|
|
28030
|
-
// Handle as a tap/click
|
|
28031
|
-
if (item) {
|
|
28032
|
-
setTooltipState(function (prev) {
|
|
28033
|
-
return _extends({}, prev, {
|
|
28034
|
-
mobileVisible: true
|
|
28035
|
-
});
|
|
28036
|
-
});
|
|
28037
|
-
onPointerDown(item.type, containerType != null ? containerType : null, item);
|
|
28038
|
-
}
|
|
28039
|
-
return;
|
|
28040
|
-
}
|
|
28041
|
-
}
|
|
28042
|
-
// Threshold for considering a tap/click as a drag
|
|
28043
|
-
var dragThreshold = 5; // pixels
|
|
28044
|
-
var isDrag = Math.abs(data.x) > dragThreshold || Math.abs(data.y) > dragThreshold;
|
|
28045
|
-
if (dragState.wasDragged && item && !isSelectingShortcut) {
|
|
28046
|
-
var _e$target;
|
|
28047
|
-
//@ts-ignore
|
|
28048
|
-
var classes = Array.from((_e$target = e.target) == null ? void 0 : _e$target.classList);
|
|
28049
|
-
var isOutsideDrop = classes.some(function (elm) {
|
|
28050
|
-
return elm.includes('rpgui-content');
|
|
28051
|
-
}) || classes.length === 0;
|
|
28052
|
-
if (isOutsideDrop) {
|
|
28053
|
-
setDragState(function (prev) {
|
|
28054
|
-
return _extends({}, prev, {
|
|
28055
|
-
dropPosition: {
|
|
28056
|
-
x: data.x,
|
|
28057
|
-
y: data.y
|
|
28058
|
-
}
|
|
28059
|
-
});
|
|
28060
|
-
});
|
|
28061
|
-
}
|
|
28062
|
-
setDragState(function (prev) {
|
|
28063
|
-
return _extends({}, prev, {
|
|
28064
|
-
wasDragged: false
|
|
28065
|
-
});
|
|
28066
|
-
});
|
|
28067
|
-
var _target = dragContainer.current;
|
|
28068
|
-
if (!_target || !dragState.wasDragged) return;
|
|
28069
|
-
var style = window.getComputedStyle(_target);
|
|
28070
|
-
var matrix = new DOMMatrixReadOnly(style.transform);
|
|
28071
|
-
var x = matrix.m41;
|
|
28072
|
-
var y = matrix.m42;
|
|
28073
|
-
setDragState(function (prev) {
|
|
28074
|
-
return _extends({}, prev, {
|
|
28075
|
-
position: {
|
|
28076
|
-
x: x,
|
|
28077
|
-
y: y
|
|
28078
|
-
}
|
|
28079
|
-
});
|
|
28080
|
-
});
|
|
28081
|
-
setTimeout(function () {
|
|
28082
|
-
if (checkIfItemCanBeMoved && checkIfItemCanBeMoved()) {
|
|
28083
|
-
if (checkIfItemShouldDragEnd && !checkIfItemShouldDragEnd()) return;
|
|
28084
|
-
if (item.stackQty && item.stackQty !== 1 && openQuantitySelector) {
|
|
28085
|
-
openQuantitySelector(item.stackQty, onSuccessfulDrag);
|
|
28086
|
-
} else onSuccessfulDrag(item.stackQty);
|
|
28087
|
-
} else {
|
|
28088
|
-
resetItem();
|
|
28089
|
-
setDragState(function (prev) {
|
|
28090
|
-
return _extends({}, prev, {
|
|
28091
|
-
isFocused: false,
|
|
28092
|
-
position: {
|
|
28093
|
-
x: 0,
|
|
28094
|
-
y: 0
|
|
28095
|
-
}
|
|
28096
|
-
});
|
|
28097
|
-
});
|
|
28098
|
-
}
|
|
28099
|
-
}, 50);
|
|
28100
|
-
} else if (item) {
|
|
28101
|
-
if (isTouch && !isDrag) {
|
|
28102
|
-
setTooltipState(function (prev) {
|
|
28103
|
-
return _extends({}, prev, {
|
|
28104
|
-
mobileVisible: true
|
|
28105
|
-
});
|
|
28106
|
-
});
|
|
28107
|
-
} else if (!isTouch && !isContextMenuDisabled && !isSelectingShortcut) {
|
|
28108
|
-
setContextMenuState(function (prev) {
|
|
28109
|
-
return _extends({}, prev, {
|
|
28110
|
-
visible: !contextMenuState.visible
|
|
28111
|
-
});
|
|
28112
|
-
});
|
|
28113
|
-
var event = e;
|
|
28114
|
-
if (event.clientX && event.clientY) {
|
|
28115
|
-
setContextMenuState(function (prev) {
|
|
28116
|
-
return _extends({}, prev, {
|
|
28117
|
-
position: {
|
|
28118
|
-
x: event.clientX - 10,
|
|
28119
|
-
y: event.clientY - 5
|
|
28120
|
-
}
|
|
28121
|
-
});
|
|
28122
|
-
});
|
|
28123
|
-
}
|
|
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);
|
|
28124
28150
|
}
|
|
28125
|
-
if (
|
|
28126
|
-
|
|
28127
|
-
onPointerDown(item.type, containerType != null ? containerType : null, item);
|
|
28151
|
+
if (onPointerDown && onDragStart === undefined && onDragEnd === undefined) {
|
|
28152
|
+
onPointerDown(item.type, containerType, item);
|
|
28128
28153
|
}
|
|
28129
28154
|
}
|
|
28130
|
-
|
|
28155
|
+
setTooltipState(function (prev) {
|
|
28131
28156
|
return _extends({}, prev, {
|
|
28132
|
-
|
|
28157
|
+
visible: true
|
|
28133
28158
|
});
|
|
28134
28159
|
});
|
|
28135
|
-
|
|
28136
|
-
};
|
|
28137
|
-
var
|
|
28138
|
-
|
|
28139
|
-
|
|
28140
|
-
|
|
28141
|
-
|
|
28142
|
-
|
|
28143
|
-
}
|
|
28144
|
-
};
|
|
28145
|
-
var onDraggableProgress = function onDraggableProgress(_e, data) {
|
|
28146
|
-
if (Math.abs(data.x - dragState.position.x) > 5 || Math.abs(data.y - dragState.position.y) > 5) {
|
|
28147
|
-
setDragState(function (prev) {
|
|
28148
|
-
return _extends({}, prev, {
|
|
28149
|
-
wasDragged: true,
|
|
28150
|
-
isFocused: true
|
|
28151
|
-
});
|
|
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
|
|
28152
28168
|
});
|
|
28153
|
-
}
|
|
28154
|
-
if (!draggingItem) {
|
|
28155
|
-
setDraggingItem(item);
|
|
28156
|
-
}
|
|
28157
|
-
};
|
|
28158
|
-
var onTouchStart = function onTouchStart(e) {
|
|
28159
|
-
setTouchStartTime(new Date().getTime());
|
|
28160
|
-
setTouchStartPosition({
|
|
28161
|
-
x: e.touches[0].clientX,
|
|
28162
|
-
y: e.touches[0].clientY
|
|
28163
28169
|
});
|
|
28164
|
-
|
|
28165
|
-
|
|
28166
|
-
// Prevent default to stop potential unwanted behaviors
|
|
28167
|
-
e.preventDefault();
|
|
28168
|
-
var touch = e.changedTouches[0];
|
|
28169
|
-
var touchEndTime = new Date().getTime();
|
|
28170
|
-
var touchDuration = touchStartTime ? touchEndTime - touchStartTime : 0;
|
|
28171
|
-
// Check if it's a short tap (less than 200ms) and hasn't moved much
|
|
28172
|
-
var isShortTap = touchDuration < 200;
|
|
28173
|
-
var hasMovedSignificantly = touchStartPosition && (Math.abs(touch.clientX - touchStartPosition.x) > 10 || Math.abs(touch.clientY - touchStartPosition.y) > 10);
|
|
28174
|
-
if (isShortTap && !hasMovedSignificantly) {
|
|
28175
|
-
// Handle as a tap/click
|
|
28176
|
-
if (item) {
|
|
28177
|
-
setTooltipState(function (prev) {
|
|
28178
|
-
return _extends({}, prev, {
|
|
28179
|
-
mobileVisible: true
|
|
28180
|
-
});
|
|
28181
|
-
});
|
|
28182
|
-
onPointerDown(item.type, containerType != null ? containerType : null, item);
|
|
28183
|
-
}
|
|
28184
|
-
} else {
|
|
28170
|
+
onMouseOut == null ? void 0 : onMouseOut();
|
|
28171
|
+
if (event.type === 'touchend' && 'changedTouches' in event) {
|
|
28185
28172
|
var _document$elementFrom;
|
|
28186
|
-
|
|
28173
|
+
var _event$changedTouches = event.changedTouches[0],
|
|
28174
|
+
clientX = _event$changedTouches.clientX,
|
|
28175
|
+
clientY = _event$changedTouches.clientY;
|
|
28187
28176
|
var simulatedEvent = new MouseEvent('mouseup', {
|
|
28188
|
-
clientX:
|
|
28189
|
-
clientY:
|
|
28177
|
+
clientX: clientX,
|
|
28178
|
+
clientY: clientY,
|
|
28190
28179
|
bubbles: true
|
|
28191
28180
|
});
|
|
28192
|
-
(_document$elementFrom = document.elementFromPoint(
|
|
28181
|
+
(_document$elementFrom = document.elementFromPoint(clientX, clientY)) == null ? void 0 : _document$elementFrom.dispatchEvent(simulatedEvent);
|
|
28193
28182
|
}
|
|
28194
|
-
};
|
|
28195
|
-
var bounds = getContainerBounds();
|
|
28183
|
+
}, [onMouseOut]);
|
|
28196
28184
|
return React.createElement(Container$b, {
|
|
28197
28185
|
isDraggingItem: !!draggingItem,
|
|
28198
28186
|
item: item,
|
|
28199
28187
|
className: "rpgui-icon empty-slot",
|
|
28200
|
-
|
|
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);
|
|
28201
28193
|
var data = item ? item : null;
|
|
28202
|
-
if (onPlaceDrop && containerType) {
|
|
28194
|
+
if (onPlaceDrop && containerType && draggingItem) {
|
|
28203
28195
|
onPlaceDrop(data, slotIndex, containerType);
|
|
28204
28196
|
}
|
|
28205
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
|
+
},
|
|
28206
28211
|
onPointerDown: onDragStart !== undefined && onDragEnd !== undefined ? undefined : function () {
|
|
28207
28212
|
if (item) onPointerDown(item.type, containerType != null ? containerType : null, item);
|
|
28208
28213
|
},
|
|
28209
|
-
|
|
28210
|
-
onTouchStart: onTouchStart,
|
|
28211
|
-
onTouchEnd: onTouchEnd
|
|
28214
|
+
onMouseLeave: handleInteractionEnd
|
|
28212
28215
|
}, React.createElement(Draggable, {
|
|
28213
28216
|
axis: isSelectingShortcut ? 'none' : 'both',
|
|
28214
28217
|
defaultClassName: item ? 'draggable' : 'empty-slot',
|
|
@@ -28226,9 +28229,7 @@ var ItemSlot = /*#__PURE__*/React.memo( /*#__PURE__*/observer(function (_ref) {
|
|
|
28226
28229
|
onMouseOver: function onMouseOver(event) {
|
|
28227
28230
|
_onMouseOver == null ? void 0 : _onMouseOver(event, slotIndex, item, event.clientX, event.clientY);
|
|
28228
28231
|
},
|
|
28229
|
-
onMouseOut:
|
|
28230
|
-
if (_onMouseOut) _onMouseOut();
|
|
28231
|
-
},
|
|
28232
|
+
onMouseOut: onMouseOut,
|
|
28232
28233
|
onMouseEnter: function onMouseEnter() {
|
|
28233
28234
|
setTooltipState(function (prev) {
|
|
28234
28235
|
return _extends({}, prev, {
|
|
@@ -28275,20 +28276,20 @@ var ItemSlot = /*#__PURE__*/React.memo( /*#__PURE__*/observer(function (_ref) {
|
|
|
28275
28276
|
var Container$b = /*#__PURE__*/styled.div.withConfig({
|
|
28276
28277
|
displayName: "ItemSlot__Container",
|
|
28277
28278
|
componentId: "sc-l2j5ef-0"
|
|
28278
|
-
})(["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 (
|
|
28279
|
-
var 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;
|
|
28280
28281
|
return isDraggingItem ? 0 : 1;
|
|
28281
|
-
}, function (_ref3) {
|
|
28282
|
-
var item = _ref3.item;
|
|
28283
|
-
return rarityColor(item);
|
|
28284
28282
|
}, function (_ref4) {
|
|
28285
28283
|
var item = _ref4.item;
|
|
28286
|
-
return
|
|
28284
|
+
return rarityColor(item);
|
|
28287
28285
|
}, function (_ref5) {
|
|
28288
28286
|
var item = _ref5.item;
|
|
28289
|
-
return "0 0
|
|
28287
|
+
return "0 0 5px 2px " + rarityColor(item);
|
|
28290
28288
|
}, function (_ref6) {
|
|
28291
|
-
var
|
|
28289
|
+
var item = _ref6.item;
|
|
28290
|
+
return "0 0 4px 3px " + rarityColor(item);
|
|
28291
|
+
}, function (_ref7) {
|
|
28292
|
+
var isSelectingShortcut = _ref7.isSelectingShortcut;
|
|
28292
28293
|
return isSelectingShortcut ? 'bg-color-change 1s infinite' : 'none';
|
|
28293
28294
|
});
|
|
28294
28295
|
var ItemContainer = /*#__PURE__*/styled.div.withConfig({
|
|
@@ -30621,7 +30622,6 @@ var ItemContainer$1 = function ItemContainer(_ref) {
|
|
|
30621
30622
|
_onOutsideDrop = _ref.onOutsideDrop,
|
|
30622
30623
|
checkIfItemCanBeMoved = _ref.checkIfItemCanBeMoved,
|
|
30623
30624
|
initialPosition = _ref.initialPosition,
|
|
30624
|
-
checkIfItemShouldDragEnd = _ref.checkIfItemShouldDragEnd,
|
|
30625
30625
|
scale = _ref.scale,
|
|
30626
30626
|
shortcuts = _ref.shortcuts,
|
|
30627
30627
|
setItemShortcut = _ref.setItemShortcut,
|
|
@@ -30711,7 +30711,6 @@ var ItemContainer$1 = function ItemContainer(_ref) {
|
|
|
30711
30711
|
onDragEnd: onDragEnd,
|
|
30712
30712
|
dragScale: scale,
|
|
30713
30713
|
checkIfItemCanBeMoved: checkIfItemCanBeMoved,
|
|
30714
|
-
checkIfItemShouldDragEnd: checkIfItemShouldDragEnd,
|
|
30715
30714
|
openQuantitySelector: function openQuantitySelector(maxQuantity, callback) {
|
|
30716
30715
|
setQuantitySelect({
|
|
30717
30716
|
isOpen: true,
|