@rpg-engine/long-bow 0.7.67 → 0.7.68

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.
@@ -16,9 +16,6 @@ interface IProps {
16
16
  atlasIMG: any;
17
17
  atlasJSON: any;
18
18
  equipmentSet?: IEquipmentSet | null;
19
- isDragging: boolean;
20
- isSelectingShortcut: boolean;
21
- showTooltipDelayed: boolean;
22
19
  }
23
- export declare const ItemSlotToolTips: ({ tooltipState, setTooltipState, contextMenuState, setContextMenuState, isFocused, isContextMenuDisabled, item, contextActions, dragScale, onSelected, atlasIMG, atlasJSON, equipmentSet, isDragging, isSelectingShortcut, showTooltipDelayed, }: IProps) => JSX.Element;
20
+ export declare const ItemSlotToolTips: ({ tooltipState, setTooltipState, contextMenuState, setContextMenuState, isFocused, isContextMenuDisabled, item, contextActions, dragScale, onSelected, atlasIMG, atlasJSON, equipmentSet, }: IProps) => JSX.Element;
24
21
  export {};
@@ -1,11 +1,26 @@
1
1
  import { IItem } from '@rpg-engine/shared';
2
2
  import React from 'react';
3
- export declare const useDragging: () => {
3
+ export interface DragState {
4
+ isFocused: boolean;
5
+ wasDragged: boolean;
6
+ position: {
7
+ x: number;
8
+ y: number;
9
+ };
10
+ dropPosition: {
11
+ x: number;
12
+ y: number;
13
+ } | null;
14
+ }
15
+ interface DraggingContextType {
4
16
  item: IItem | null;
5
17
  setDraggingItem: React.Dispatch<React.SetStateAction<IItem | null>>;
6
- };
18
+ dragState: DragState;
19
+ setDragState: React.Dispatch<React.SetStateAction<DragState>>;
20
+ }
7
21
  interface IProps {
8
22
  children: React.ReactNode;
9
23
  }
10
24
  export declare const DraggingProvider: ({ children }: IProps) => JSX.Element;
25
+ export declare const useDragging: () => DraggingContextType;
11
26
  export {};
@@ -1,7 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import { IItem, ItemContainerType, ItemType } from '@rpg-engine/shared';
3
3
  import { DraggableEventHandler } from 'react-draggable';
4
- import { ContextMenuState, DragState, TooltipState } from '../ItemSlot';
4
+ import { ContextMenuState, TooltipState } from '../ItemSlot';
5
5
  interface IUseItemSlotDragAndDrop {
6
6
  isDepotSystem: boolean;
7
7
  item: IItem;
@@ -26,7 +26,7 @@ interface IUseItemSlotDragAndDrop {
26
26
  }
27
27
  export declare const useItemSlotDragAndDrop: ({ isDepotSystem, item, onDrop, onDragEnd, checkIfItemCanBeMoved, checkIfItemShouldDragEnd, setItemShortcut, isSelectingShortcut, onDragStart, onPointerDown, containerType, slotIndex, openQuantitySelector, isContextMenuDisabled, setTooltipState, setContextMenuState, }: IUseItemSlotDragAndDrop) => {
28
28
  dragContainer: import("react").RefObject<HTMLDivElement>;
29
- dragState: DragState;
29
+ dragState: import("../context/DraggingContext").DragState;
30
30
  draggingItem: IItem | null;
31
31
  setDraggingItem: import("react").Dispatch<import("react").SetStateAction<IItem | null>>;
32
32
  getContainerBounds: () => {
@@ -27668,17 +27668,13 @@ var ItemSlotToolTips = function ItemSlotToolTips(_ref) {
27668
27668
  _onSelected = _ref.onSelected,
27669
27669
  atlasIMG = _ref.atlasIMG,
27670
27670
  atlasJSON = _ref.atlasJSON,
27671
- equipmentSet = _ref.equipmentSet,
27672
- isDragging = _ref.isDragging,
27673
- isSelectingShortcut = _ref.isSelectingShortcut,
27674
- showTooltipDelayed = _ref.showTooltipDelayed;
27675
- var canShow = !isDragging || !isSelectingShortcut || showTooltipDelayed;
27676
- return React__default.createElement(React__default.Fragment, null, tooltipState.visible && item && !isFocused && canShow && React__default.createElement(ItemTooltip, {
27671
+ equipmentSet = _ref.equipmentSet;
27672
+ return React__default.createElement(React__default.Fragment, null, tooltipState.visible && item && !isFocused && React__default.createElement(ItemTooltip, {
27677
27673
  item: item,
27678
27674
  atlasIMG: atlasIMG,
27679
27675
  atlasJSON: atlasJSON,
27680
27676
  equipmentSet: equipmentSet
27681
- }), tooltipState.mobileVisible && item && canShow && React__default.createElement(MobileItemTooltip, {
27677
+ }), tooltipState.mobileVisible && item && React__default.createElement(MobileItemTooltip, {
27682
27678
  item: item,
27683
27679
  atlasIMG: atlasIMG,
27684
27680
  atlasJSON: atlasJSON,
@@ -27702,7 +27698,7 @@ var ItemSlotToolTips = function ItemSlotToolTips(_ref) {
27702
27698
  _onSelected == null ? void 0 : _onSelected(optionId, item);
27703
27699
  }
27704
27700
  }
27705
- }), !isContextMenuDisabled && contextMenuState.visible && contextActions && canShow && React__default.createElement(RelativeListMenu, {
27701
+ }), !isContextMenuDisabled && contextMenuState.visible && contextActions && React__default.createElement(RelativeListMenu, {
27706
27702
  options: contextActions,
27707
27703
  onSelected: function onSelected(optionId) {
27708
27704
  setContextMenuState(function (prev) {
@@ -27727,23 +27723,46 @@ var ItemSlotToolTips = function ItemSlotToolTips(_ref) {
27727
27723
 
27728
27724
  var DraggingContext = /*#__PURE__*/React.createContext({
27729
27725
  item: null,
27730
- setDraggingItem: function setDraggingItem() {}
27726
+ setDraggingItem: function setDraggingItem() {},
27727
+ dragState: {
27728
+ isFocused: false,
27729
+ wasDragged: false,
27730
+ position: {
27731
+ x: 0,
27732
+ y: 0
27733
+ },
27734
+ dropPosition: null
27735
+ },
27736
+ setDragState: function setDragState() {}
27731
27737
  });
27732
- var useDragging = function useDragging() {
27733
- return React.useContext(DraggingContext);
27734
- };
27735
27738
  var DraggingProvider = function DraggingProvider(_ref) {
27736
27739
  var children = _ref.children;
27737
27740
  var _useState = React.useState(null),
27738
27741
  item = _useState[0],
27739
27742
  setDraggingItem = _useState[1];
27743
+ var _useState2 = React.useState({
27744
+ isFocused: false,
27745
+ wasDragged: false,
27746
+ position: {
27747
+ x: 0,
27748
+ y: 0
27749
+ },
27750
+ dropPosition: null
27751
+ }),
27752
+ dragState = _useState2[0],
27753
+ setDragState = _useState2[1];
27740
27754
  return React__default.createElement(DraggingContext.Provider, {
27741
27755
  value: {
27742
27756
  item: item,
27743
- setDraggingItem: setDraggingItem
27757
+ setDraggingItem: setDraggingItem,
27758
+ dragState: dragState,
27759
+ setDragState: setDragState
27744
27760
  }
27745
27761
  }, children);
27746
27762
  };
27763
+ var useDragging = function useDragging() {
27764
+ return React.useContext(DraggingContext);
27765
+ };
27747
27766
 
27748
27767
  var useItemSlotDragAndDrop = function useItemSlotDragAndDrop(_ref) {
27749
27768
  var isDepotSystem = _ref.isDepotSystem,
@@ -27765,18 +27784,9 @@ var useItemSlotDragAndDrop = function useItemSlotDragAndDrop(_ref) {
27765
27784
  var dragContainer = React.useRef(null);
27766
27785
  var _useDragging = useDragging(),
27767
27786
  draggingItem = _useDragging.item,
27768
- setDraggingItem = _useDragging.setDraggingItem;
27769
- var _useState = React.useState({
27770
- isFocused: false,
27771
- wasDragged: false,
27772
- position: {
27773
- x: 0,
27774
- y: 0
27775
- },
27776
- dropPosition: null
27777
- }),
27778
- dragState = _useState[0],
27779
- setDragState = _useState[1];
27787
+ setDraggingItem = _useDragging.setDraggingItem,
27788
+ dragState = _useDragging.dragState,
27789
+ setDragState = _useDragging.setDragState;
27780
27790
  React.useEffect(function () {
27781
27791
  setDragState(function (prev) {
27782
27792
  return _extends({}, prev, {
@@ -27787,7 +27797,7 @@ var useItemSlotDragAndDrop = function useItemSlotDragAndDrop(_ref) {
27787
27797
  isFocused: false
27788
27798
  });
27789
27799
  });
27790
- }, [item, isDepotSystem]);
27800
+ }, [item, isDepotSystem, setDragState]);
27791
27801
  React.useEffect(function () {
27792
27802
  if (onDrop && item && dragState.dropPosition) {
27793
27803
  onDrop(item, dragState.dropPosition);
@@ -27815,11 +27825,6 @@ var useItemSlotDragAndDrop = function useItemSlotDragAndDrop(_ref) {
27815
27825
  };
27816
27826
  }, []);
27817
27827
  var resetDragState = React.useCallback(function () {
27818
- setTooltipState(function (prev) {
27819
- return _extends({}, prev, {
27820
- visible: false
27821
- });
27822
- });
27823
27828
  setDragState(function (prev) {
27824
27829
  return _extends({}, prev, {
27825
27830
  wasDragged: false,
@@ -27830,7 +27835,7 @@ var useItemSlotDragAndDrop = function useItemSlotDragAndDrop(_ref) {
27830
27835
  }
27831
27836
  });
27832
27837
  });
27833
- }, [setTooltipState]);
27838
+ }, [setTooltipState, setDragState]);
27834
27839
  var handleSuccessfulDrag = React.useCallback(function (quantity) {
27835
27840
  resetDragState();
27836
27841
  if (quantity !== -1 && item) {
@@ -27858,7 +27863,7 @@ var useItemSlotDragAndDrop = function useItemSlotDragAndDrop(_ref) {
27858
27863
  if (!draggingItem) {
27859
27864
  setDraggingItem(item);
27860
27865
  }
27861
- }, [dragState.position, draggingItem, item, setDraggingItem]);
27866
+ }, [dragState.position, draggingItem, item, setDraggingItem, setDragState]);
27862
27867
  var onDraggableStop = React.useCallback(function (e, data) {
27863
27868
  setTimeout(function () {
27864
27869
  setDraggingItem(null);
@@ -28118,12 +28123,6 @@ var ItemSlot = /*#__PURE__*/React__default.memo( /*#__PURE__*/mobxReactLite.obse
28118
28123
  var _useState3 = React.useState([]),
28119
28124
  contextActions = _useState3[0],
28120
28125
  setContextActions = _useState3[1];
28121
- var isDraggingDisabled = React.useMemo(function () {
28122
- return contextMenuState.visible || onDragStart === undefined || onDragEnd === undefined;
28123
- }, [contextMenuState.visible, onDragStart, onDragEnd]);
28124
- React.useEffect(function () {
28125
- console.log('isDraggingDisabled', isDraggingDisabled);
28126
- }, [isDraggingDisabled]);
28127
28126
  var _useItemSlotDragAndDr = useItemSlotDragAndDrop({
28128
28127
  isDepotSystem: !!isDepotSystem,
28129
28128
  item: item,
@@ -28197,22 +28196,6 @@ var ItemSlot = /*#__PURE__*/React__default.memo( /*#__PURE__*/mobxReactLite.obse
28197
28196
  (_document$elementFrom = document.elementFromPoint(clientX, clientY)) == null ? void 0 : _document$elementFrom.dispatchEvent(simulatedEvent);
28198
28197
  }
28199
28198
  }, [onMouseOut]);
28200
- var _useState4 = React.useState(false),
28201
- showTooltipDelayed = _useState4[0],
28202
- setShowTooltipDelayed = _useState4[1];
28203
- //@ts-ignore
28204
- React.useEffect(function () {
28205
- if (tooltipState.visible && !isDraggingDisabled) {
28206
- var timer = setTimeout(function () {
28207
- return setShowTooltipDelayed(true);
28208
- }, 50);
28209
- return function () {
28210
- return clearTimeout(timer);
28211
- };
28212
- } else {
28213
- setShowTooltipDelayed(false);
28214
- }
28215
- }, [tooltipState.visible, isDraggingDisabled]);
28216
28199
  return React__default.createElement(Container$b, {
28217
28200
  isDraggingItem: !!draggingItem,
28218
28201
  item: item,
@@ -28229,7 +28212,6 @@ var ItemSlot = /*#__PURE__*/React__default.memo( /*#__PURE__*/mobxReactLite.obse
28229
28212
  },
28230
28213
  onTouchEnd: function onTouchEnd(e) {
28231
28214
  var _document$elementFrom2;
28232
- handleInteractionEnd(e);
28233
28215
  var _e$changedTouches$ = e.changedTouches[0],
28234
28216
  clientX = _e$changedTouches$.clientX,
28235
28217
  clientY = _e$changedTouches$.clientY;
@@ -28248,7 +28230,7 @@ var ItemSlot = /*#__PURE__*/React__default.memo( /*#__PURE__*/mobxReactLite.obse
28248
28230
  axis: isSelectingShortcut ? 'none' : 'both',
28249
28231
  defaultClassName: item ? 'draggable' : 'empty-slot',
28250
28232
  scale: dragScale,
28251
- disabled: isDraggingDisabled,
28233
+ disabled: onDragStart === undefined || onDragEnd === undefined,
28252
28234
  onStop: onDraggableStop,
28253
28235
  onStart: onDraggableStart,
28254
28236
  onDrag: onDraggableProgress,
@@ -28269,15 +28251,12 @@ var ItemSlot = /*#__PURE__*/React__default.memo( /*#__PURE__*/mobxReactLite.obse
28269
28251
  });
28270
28252
  });
28271
28253
  },
28272
- onMouseLeave: function onMouseLeave(e) {
28273
- var _dragContainer$curren;
28274
- if (!e.relatedTarget || !((_dragContainer$curren = dragContainer.current) != null && _dragContainer$curren.contains(e.relatedTarget))) {
28275
- setTooltipState(function (prev) {
28276
- return _extends({}, prev, {
28277
- visible: false
28278
- });
28254
+ onMouseLeave: function onMouseLeave() {
28255
+ setTooltipState(function (prev) {
28256
+ return _extends({}, prev, {
28257
+ visible: false
28279
28258
  });
28280
- }
28259
+ });
28281
28260
  }
28282
28261
  }, React__default.createElement(ItemSlotRenderer, {
28283
28262
  item: item,
@@ -28305,10 +28284,7 @@ var ItemSlot = /*#__PURE__*/React__default.memo( /*#__PURE__*/mobxReactLite.obse
28305
28284
  },
28306
28285
  atlasIMG: atlasIMG,
28307
28286
  atlasJSON: atlasJSON,
28308
- equipmentSet: equipmentSet,
28309
- isDragging: !!draggingItem,
28310
- isSelectingShortcut: !!isSelectingShortcut,
28311
- showTooltipDelayed: showTooltipDelayed
28287
+ equipmentSet: equipmentSet
28312
28288
  }));
28313
28289
  }));
28314
28290
  var Container$b = /*#__PURE__*/styled__default.div.withConfig({