@rpg-engine/long-bow 0.7.67 → 0.7.70

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.
Files changed (25) hide show
  1. package/dist/components/Item/Inventory/ItemSlot.d.ts +2 -4
  2. package/dist/components/Item/Inventory/ItemSlotTooltips.d.ts +2 -13
  3. package/dist/components/Item/Inventory/context/ItemSlotDraggingContext.d.ts +26 -0
  4. package/dist/components/Item/Inventory/context/ItemSlotTooltipContext.d.ts +28 -0
  5. package/dist/components/Item/Inventory/hooks/useItemSlotDragAndDrop.d.ts +2 -6
  6. package/dist/hooks/useCursorPosition.d.ts +1 -1
  7. package/dist/long-bow.cjs.development.js +465 -421
  8. package/dist/long-bow.cjs.development.js.map +1 -1
  9. package/dist/long-bow.cjs.production.min.js +1 -1
  10. package/dist/long-bow.cjs.production.min.js.map +1 -1
  11. package/dist/long-bow.esm.js +467 -423
  12. package/dist/long-bow.esm.js.map +1 -1
  13. package/package.json +3 -2
  14. package/src/components/Equipment/EquipmentSet.tsx +61 -29
  15. package/src/components/Item/Inventory/DraggedItem.tsx +2 -2
  16. package/src/components/Item/Inventory/ItemContainer.tsx +68 -44
  17. package/src/components/Item/Inventory/ItemSlot.tsx +48 -100
  18. package/src/components/Item/Inventory/ItemSlotTooltips.tsx +47 -49
  19. package/src/components/Item/Inventory/context/ItemSlotDraggingContext.tsx +52 -0
  20. package/src/components/Item/Inventory/context/ItemSlotTooltipContext.tsx +95 -0
  21. package/src/components/Item/Inventory/hooks/useItemSlotDragAndDrop.ts +57 -40
  22. package/src/hooks/useCursorPosition.ts +29 -20
  23. package/src/mocks/skills.mocks.ts +0 -4
  24. package/dist/components/Item/Inventory/context/DraggingContext.d.ts +0 -11
  25. package/src/components/Item/Inventory/context/DraggingContext.tsx +0 -26
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rpg-engine/long-bow",
3
- "version": "0.7.67",
3
+ "version": "0.7.70",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -30,7 +30,8 @@
30
30
  "storybook": "start-storybook -p 6006",
31
31
  "build-storybook": "build-storybook",
32
32
  "configure": "./environment/download-credentials.sh",
33
- "update:shared-deps": "yarn add @rpg-engine/shared"
33
+ "update:shared-deps": "yarn add @rpg-engine/shared",
34
+ "prepublish": "yarn tsc"
34
35
  },
35
36
  "peerDependencies": {
36
37
  "react": ">=16"
@@ -2,6 +2,7 @@ import {
2
2
  IEquipmentSet,
3
3
  IItem,
4
4
  IItemContainer,
5
+ isMobile,
5
6
  ItemContainerType,
6
7
  ItemSlotType,
7
8
  ItemType,
@@ -10,9 +11,17 @@ import React from 'react';
10
11
  import styled from 'styled-components';
11
12
  import { IPosition } from '../../types/eventTypes';
12
13
  import { DraggableContainer } from '../DraggableContainer';
14
+ import {
15
+ ItemSlotDraggingProvider,
16
+ useItemSlotDragging,
17
+ } from '../Item/Inventory/context/ItemSlotDraggingContext';
18
+ import {
19
+ ItemSlotTooltipProvider,
20
+ useItemSlotTooltip,
21
+ } from '../Item/Inventory/context/ItemSlotTooltipContext';
13
22
  import DraggedItem from '../Item/Inventory/DraggedItem';
14
23
  import { ItemSlot } from '../Item/Inventory/ItemSlot';
15
- import { DraggingProvider } from '../Item/Inventory/context/DraggingContext';
24
+ import { ItemSlotToolTips } from '../Item/Inventory/ItemSlotTooltips';
16
25
  import { RPGUIContainerTypes } from '../RPGUI/RPGUIContainer';
17
26
 
18
27
  export interface IEquipmentSetProps {
@@ -52,7 +61,6 @@ export const EquipmentSet: React.FC<IEquipmentSetProps> = ({
52
61
  equipmentSet,
53
62
  onClose,
54
63
  onMouseOver,
55
- onSelected,
56
64
  onItemClick,
57
65
  atlasIMG,
58
66
  atlasJSON,
@@ -61,11 +69,11 @@ export const EquipmentSet: React.FC<IEquipmentSetProps> = ({
61
69
  onItemPlaceDrop,
62
70
  onItemOutsideDrop,
63
71
  checkIfItemCanBeMoved,
64
- checkIfItemShouldDragEnd,
65
72
  scale,
66
73
  initialPosition,
67
74
  onPositionChangeEnd,
68
75
  onPositionChangeStart,
76
+ onSelected,
69
77
  }) => {
70
78
  const {
71
79
  neck,
@@ -106,6 +114,10 @@ export const EquipmentSet: React.FC<IEquipmentSetProps> = ({
106
114
  ItemSlotType.Accessory,
107
115
  ];
108
116
 
117
+ const { dragState } = useItemSlotDragging();
118
+
119
+ const { updateItemDetails } = useItemSlotTooltip();
120
+
109
121
  const onRenderEquipmentSlotRange = (start: number, end: number) => {
110
122
  const equipmentRange = equipmentData.slice(start, end);
111
123
  const slotMaksRange = equipmentMaskSlots.slice(start, end);
@@ -129,9 +141,6 @@ export const EquipmentSet: React.FC<IEquipmentSetProps> = ({
129
141
  onPointerDown={(itemType, ContainerType) => {
130
142
  if (onItemClick) onItemClick(itemType, item, ContainerType);
131
143
  }}
132
- onSelected={(optionId: string) => {
133
- if (onSelected) onSelected(optionId);
134
- }}
135
144
  onDragStart={(item, slotIndex, itemContainerType) => {
136
145
  if (!item) {
137
146
  return;
@@ -145,7 +154,6 @@ export const EquipmentSet: React.FC<IEquipmentSetProps> = ({
145
154
  }}
146
155
  dragScale={scale}
147
156
  checkIfItemCanBeMoved={checkIfItemCanBeMoved}
148
- checkIfItemShouldDragEnd={checkIfItemShouldDragEnd}
149
157
  onPlaceDrop={(item, slotIndex, itemContainerType) => {
150
158
  if (onItemPlaceDrop)
151
159
  onItemPlaceDrop(item, slotIndex, itemContainerType);
@@ -161,28 +169,52 @@ export const EquipmentSet: React.FC<IEquipmentSetProps> = ({
161
169
  };
162
170
 
163
171
  return (
164
- <DraggingProvider>
165
- <DraggedItem atlasIMG={atlasIMG} atlasJSON={atlasJSON} scale={scale} />
166
- <DraggableContainer
167
- title={'Equipments'}
168
- type={RPGUIContainerTypes.Framed}
169
- onCloseButton={() => {
170
- if (onClose) onClose();
171
- }}
172
- width="330px"
173
- cancelDrag=".equipment-container-body"
174
- scale={scale}
175
- initialPosition={initialPosition}
176
- onPositionChangeEnd={onPositionChangeEnd}
177
- onPositionChangeStart={onPositionChangeStart}
178
- >
179
- <EquipmentSetContainer className="equipment-container-body">
180
- <EquipmentColumn>{onRenderEquipmentSlotRange(0, 3)}</EquipmentColumn>
181
- <EquipmentColumn>{onRenderEquipmentSlotRange(3, 7)}</EquipmentColumn>
182
- <EquipmentColumn>{onRenderEquipmentSlotRange(7, 10)}</EquipmentColumn>
183
- </EquipmentSetContainer>
184
- </DraggableContainer>
185
- </DraggingProvider>
172
+ <ItemSlotDraggingProvider>
173
+ <ItemSlotTooltipProvider>
174
+ <DraggedItem atlasIMG={atlasIMG} atlasJSON={atlasJSON} scale={scale} />
175
+ <DraggableContainer
176
+ title={'Equipments'}
177
+ type={RPGUIContainerTypes.Framed}
178
+ onCloseButton={() => {
179
+ if (onClose) onClose();
180
+ }}
181
+ width="330px"
182
+ cancelDrag=".equipment-container-body"
183
+ scale={scale}
184
+ initialPosition={initialPosition}
185
+ onPositionChangeEnd={onPositionChangeEnd}
186
+ onPositionChangeStart={onPositionChangeStart}
187
+ >
188
+ <EquipmentSetContainer className="equipment-container-body">
189
+ <EquipmentColumn>
190
+ {onRenderEquipmentSlotRange(0, 3)}
191
+ </EquipmentColumn>
192
+ <EquipmentColumn>
193
+ {onRenderEquipmentSlotRange(3, 7)}
194
+ </EquipmentColumn>
195
+ <EquipmentColumn>
196
+ {onRenderEquipmentSlotRange(7, 10)}
197
+ </EquipmentColumn>
198
+ </EquipmentSetContainer>
199
+ </DraggableContainer>
200
+
201
+ <ItemSlotToolTips
202
+ isFocused={dragState.isFocused}
203
+ isContextMenuDisabled={isMobile()}
204
+ dragScale={scale}
205
+ onSelected={(optionId: string, item: IItem) => {
206
+ updateItemDetails({
207
+ item,
208
+ contextMenu: { visible: false },
209
+ });
210
+ if (onSelected) onSelected(optionId);
211
+ }}
212
+ atlasIMG={atlasIMG}
213
+ atlasJSON={atlasJSON}
214
+ equipmentSet={equipmentSet}
215
+ />
216
+ </ItemSlotTooltipProvider>
217
+ </ItemSlotDraggingProvider>
186
218
  );
187
219
  };
188
220
 
@@ -4,7 +4,7 @@ import styled from 'styled-components';
4
4
  import { useCursorPosition } from '../../../hooks/useCursorPosition';
5
5
  import { SpriteFromAtlas } from '../../shared/SpriteFromAtlas';
6
6
  import { onRenderStackInfo } from './ItemSlotQty/ItemSlotQty';
7
- import { useDragging } from './context/DraggingContext';
7
+ import { useItemSlotDragging } from './context/ItemSlotDraggingContext';
8
8
 
9
9
  const CONTAINER_SIZE = 32;
10
10
  const OFFSET = CONTAINER_SIZE / 2;
@@ -20,7 +20,7 @@ export const DraggedItem = ({
20
20
  atlasIMG,
21
21
  scale,
22
22
  }: IProps): JSX.Element | null => {
23
- const { item } = useDragging();
23
+ const { item } = useItemSlotDragging();
24
24
 
25
25
  const { x, y } = useCursorPosition({
26
26
  scale,
@@ -14,10 +14,18 @@ import { SlotsContainer } from '../../Abstractions/SlotsContainer';
14
14
  import { useScrollOnDrag } from '../../../hooks/useScrollOnDrag';
15
15
  import { IPosition } from '../../../types/eventTypes';
16
16
  import { ShortcutsSetter } from '../../Shortcuts/ShortcutsSetter';
17
+ import {
18
+ ItemSlotDraggingProvider,
19
+ useItemSlotDragging,
20
+ } from './context/ItemSlotDraggingContext';
21
+ import {
22
+ ItemSlotTooltipProvider,
23
+ useItemSlotTooltip,
24
+ } from './context/ItemSlotTooltipContext';
17
25
  import { DraggedItem } from './DraggedItem';
18
26
  import { ItemQuantitySelectorModal } from './ItemQuantitySelectorModal';
19
27
  import { ItemSlot } from './ItemSlot';
20
- import { DraggingProvider } from './context/DraggingContext';
28
+ import { ItemSlotToolTips } from './ItemSlotTooltips';
21
29
 
22
30
  export interface IItemContainerProps {
23
31
  itemContainer: IItemContainer;
@@ -144,7 +152,6 @@ export const ItemContainer: React.FC<IItemContainerProps> = ({
144
152
  }, [handleMouseMove, onItemDragStart, stopScrolling]);
145
153
 
146
154
  const onDragStart: onDragStart = (item, slotIndex, itemContainerType) => {
147
- console.log('DRAG START');
148
155
  if (onItemDragStart) {
149
156
  onItemDragStart(item, slotIndex, itemContainerType);
150
157
  }
@@ -153,7 +160,6 @@ export const ItemContainer: React.FC<IItemContainerProps> = ({
153
160
  };
154
161
 
155
162
  const onDragEnd: onDragEnd = quantity => {
156
- console.log('DRAG END');
157
163
  if (onItemDragEnd) {
158
164
  onItemDragEnd(quantity);
159
165
  }
@@ -183,9 +189,6 @@ export const ItemContainer: React.FC<IItemContainerProps> = ({
183
189
  onItemClick(item, itemType, containerType);
184
190
  }
185
191
  }}
186
- onSelected={(optionId: string, item: IItem) => {
187
- if (onSelected) onSelected(optionId, item);
188
- }}
189
192
  onDragStart={onDragStart}
190
193
  onDragEnd={onDragEnd}
191
194
  dragScale={scale}
@@ -218,7 +221,6 @@ export const ItemContainer: React.FC<IItemContainerProps> = ({
218
221
  atlasIMG={atlasIMG}
219
222
  atlasJSON={atlasJSON}
220
223
  isSelectingShortcut={settingShortcutIndex !== -1}
221
- equipmentSet={equipmentSet}
222
224
  setItemShortcut={
223
225
  type === ItemContainerType.Inventory ? handleSetShortcut : undefined
224
226
  }
@@ -229,47 +231,69 @@ export const ItemContainer: React.FC<IItemContainerProps> = ({
229
231
  return slots;
230
232
  };
231
233
 
234
+ const { updateItemDetails } = useItemSlotTooltip();
235
+ const { dragState } = useItemSlotDragging();
236
+
232
237
  return (
233
- <DraggingProvider>
234
- <DraggedItem atlasIMG={atlasIMG} atlasJSON={atlasJSON} scale={scale} />
235
- <SlotsContainer
236
- title={itemContainer.name || 'Container'}
237
- onClose={onClose}
238
- initialPosition={initialPosition}
239
- scale={scale}
240
- onPositionChangeEnd={onPositionChangeEnd}
241
- onPositionChangeStart={onPositionChangeStart}
242
- isFullScreen={isFullScreen}
243
- opacity={opacity}
244
- >
245
- {type === ItemContainerType.Inventory &&
246
- shortcuts &&
247
- removeShortcut && (
248
- <ShortcutsSetter
249
- setSettingShortcutIndex={setSettingShortcutIndex}
250
- settingShortcutIndex={settingShortcutIndex}
251
- shortcuts={shortcuts}
252
- removeShortcut={removeShortcut}
253
- atlasIMG={atlasIMG}
254
- atlasJSON={atlasJSON}
255
- />
256
- )}
257
- <ItemsContainer
258
- className="item-container-body"
259
- ref={containerRef}
260
- isScrollable={itemContainer.slotQty > MIN_SLOTS_FOR_SCROLL}
238
+ <ItemSlotDraggingProvider>
239
+ <ItemSlotTooltipProvider>
240
+ <DraggedItem atlasIMG={atlasIMG} atlasJSON={atlasJSON} scale={scale} />
241
+ <SlotsContainer
242
+ title={itemContainer.name || 'Container'}
243
+ onClose={onClose}
244
+ initialPosition={initialPosition}
245
+ scale={scale}
246
+ onPositionChangeEnd={onPositionChangeEnd}
247
+ onPositionChangeStart={onPositionChangeStart}
261
248
  isFullScreen={isFullScreen}
249
+ opacity={opacity}
262
250
  >
263
- {onRenderSlots()}
264
- </ItemsContainer>
265
- </SlotsContainer>
266
- {quantitySelect.isOpen && (
267
- <ItemQuantitySelectorModal
268
- quantitySelect={quantitySelect}
269
- setQuantitySelect={setQuantitySelect}
251
+ {type === ItemContainerType.Inventory &&
252
+ shortcuts &&
253
+ removeShortcut && (
254
+ <ShortcutsSetter
255
+ setSettingShortcutIndex={setSettingShortcutIndex}
256
+ settingShortcutIndex={settingShortcutIndex}
257
+ shortcuts={shortcuts}
258
+ removeShortcut={removeShortcut}
259
+ atlasIMG={atlasIMG}
260
+ atlasJSON={atlasJSON}
261
+ />
262
+ )}
263
+ <ItemsContainer
264
+ className="item-container-body"
265
+ ref={containerRef}
266
+ isScrollable={itemContainer.slotQty > MIN_SLOTS_FOR_SCROLL}
267
+ isFullScreen={isFullScreen}
268
+ >
269
+ {onRenderSlots()}
270
+ </ItemsContainer>
271
+ </SlotsContainer>
272
+
273
+ <ItemSlotToolTips
274
+ isFocused={dragState.isFocused}
275
+ isContextMenuDisabled={disableContextMenu}
276
+ dragScale={scale}
277
+ onSelected={(optionId: string, item: IItem) => {
278
+ updateItemDetails({
279
+ item,
280
+ contextMenu: { visible: false },
281
+ });
282
+ if (onSelected) onSelected(optionId, item);
283
+ }}
284
+ atlasIMG={atlasIMG}
285
+ atlasJSON={atlasJSON}
286
+ equipmentSet={equipmentSet}
270
287
  />
271
- )}
272
- </DraggingProvider>
288
+
289
+ {quantitySelect.isOpen && (
290
+ <ItemQuantitySelectorModal
291
+ quantitySelect={quantitySelect}
292
+ setQuantitySelect={setQuantitySelect}
293
+ />
294
+ )}
295
+ </ItemSlotTooltipProvider>
296
+ </ItemSlotDraggingProvider>
273
297
  );
274
298
  };
275
299
 
@@ -1,5 +1,4 @@
1
1
  import {
2
- IEquipmentSet,
3
2
  IItem,
4
3
  IItemContainer,
5
4
  ItemContainerType,
@@ -9,15 +8,16 @@ import {
9
8
  } from '@rpg-engine/shared';
10
9
 
11
10
  import { observer } from 'mobx-react-lite';
12
- import React, { useCallback, useEffect, useMemo, useState } from 'react';
11
+ import React, { useCallback, useEffect } from 'react';
13
12
  import Draggable from 'react-draggable';
14
13
  import styled from 'styled-components';
14
+ import { useCursorPosition } from '../../../hooks/useCursorPosition';
15
15
  import { IPosition } from '../../../types/eventTypes';
16
16
  import { rarityColor } from './ItemSlotRarity';
17
17
  import { ItemSlotRenderer } from './ItemSlotRenderer';
18
- import { ItemSlotToolTips } from './ItemSlotTooltips';
18
+ import { useItemSlotTooltip } from './context/ItemSlotTooltipContext';
19
19
  import { useItemSlotDragAndDrop } from './hooks/useItemSlotDragAndDrop';
20
- import { IContextMenuItem, generateContextMenu } from './itemContainerHelper';
20
+ import { generateContextMenu } from './itemContainerHelper';
21
21
 
22
22
  export const EquipmentSlotSpriteByType: any = {
23
23
  Neck: 'accessories/corruption-necklace.png',
@@ -38,7 +38,6 @@ interface IProps {
38
38
  itemContainer?: IItemContainer | null;
39
39
  itemContainerType?: ItemContainerType | null;
40
40
  slotSpriteMask?: ItemSlotType | null;
41
- onSelected?: (selectedOption: string, item: IItem) => void;
42
41
  onMouseOver?: (
43
42
  event: any,
44
43
  slotIndex: number,
@@ -71,7 +70,6 @@ interface IProps {
71
70
  atlasIMG: any;
72
71
  isContextMenuDisabled?: boolean;
73
72
  isSelectingShortcut?: boolean;
74
- equipmentSet?: IEquipmentSet | null;
75
73
  setItemShortcut?: (item: IItem, shortcutIndex: number) => void;
76
74
  isDepotSystem?: boolean;
77
75
  }
@@ -103,7 +101,6 @@ export const ItemSlot = React.memo(
103
101
  onMouseOver,
104
102
  onMouseOut,
105
103
  onPointerDown,
106
- onSelected,
107
104
  atlasJSON,
108
105
  atlasIMG,
109
106
  isContextMenuDisabled = false,
@@ -115,37 +112,10 @@ export const ItemSlot = React.memo(
115
112
  openQuantitySelector,
116
113
  dragScale,
117
114
  isSelectingShortcut,
118
- equipmentSet,
115
+
119
116
  setItemShortcut,
120
117
  isDepotSystem,
121
118
  }: IProps): JSX.Element => {
122
- const [tooltipState, setTooltipState] = useState<TooltipState>({
123
- visible: false,
124
- mobileVisible: false,
125
- });
126
- const [contextMenuState, setContextMenuState] = useState<
127
- ContextMenuState
128
- >({
129
- visible: false,
130
- position: { x: 0, y: 0 },
131
- });
132
-
133
- const [contextActions, setContextActions] = useState<IContextMenuItem[]>(
134
- []
135
- );
136
-
137
- const isDraggingDisabled = useMemo(() => {
138
- return (
139
- contextMenuState.visible ||
140
- onDragStart === undefined ||
141
- onDragEnd === undefined
142
- );
143
- }, [contextMenuState.visible, onDragStart, onDragEnd]);
144
-
145
- useEffect(() => {
146
- console.log('isDraggingDisabled', isDraggingDisabled);
147
- }, [isDraggingDisabled]);
148
-
149
119
  const {
150
120
  dragContainer,
151
121
  dragState,
@@ -168,16 +138,22 @@ export const ItemSlot = React.memo(
168
138
  slotIndex,
169
139
  openQuantitySelector: openQuantitySelector ?? (() => {}),
170
140
  isContextMenuDisabled,
171
- setTooltipState,
172
- contextMenuState,
173
- setContextMenuState,
141
+ });
142
+
143
+ const { updateItemDetails, itemDetails } = useItemSlotTooltip();
144
+
145
+ const { x: cursorX, y: cursorY } = useCursorPosition({
146
+ scale: dragScale,
174
147
  });
175
148
 
176
149
  useEffect(() => {
177
150
  if (item && containerType) {
178
- setContextActions(
179
- generateContextMenu(item, containerType, isDepotSystem)
180
- );
151
+ updateItemDetails({
152
+ item,
153
+ contextMenu: {
154
+ actions: generateContextMenu(item, containerType, isDepotSystem),
155
+ },
156
+ });
181
157
  }
182
158
  }, [item, isDepotSystem]);
183
159
 
@@ -187,8 +163,7 @@ export const ItemSlot = React.memo(
187
163
  (event: React.MouseEvent | React.TouchEvent) => {
188
164
  event.stopPropagation();
189
165
 
190
- const { clientX, clientY } =
191
- 'touches' in event ? event.touches[0] : event;
166
+ console.log('handleInteraction');
192
167
 
193
168
  if (item && containerType) {
194
169
  if (onPlaceDrop && draggingItem) {
@@ -203,8 +178,7 @@ export const ItemSlot = React.memo(
203
178
  }
204
179
  }
205
180
 
206
- setTooltipState(prev => ({ ...prev, visible: true }));
207
- onMouseOver?.(event, slotIndex, item, clientX, clientY);
181
+ onMouseOver?.(event, slotIndex, item, cursorX, cursorY);
208
182
  },
209
183
  [
210
184
  item,
@@ -215,6 +189,8 @@ export const ItemSlot = React.memo(
215
189
  onMouseOver,
216
190
  onDragStart,
217
191
  onDragEnd,
192
+ cursorX,
193
+ cursorY,
218
194
  ]
219
195
  );
220
196
 
@@ -223,36 +199,30 @@ export const ItemSlot = React.memo(
223
199
  event.preventDefault();
224
200
  event.stopPropagation();
225
201
 
226
- setTooltipState(prev => ({ ...prev, visible: false }));
202
+ console.log('handleInteractionEnd');
203
+
204
+ console.log('itemDetails', itemDetails);
227
205
  onMouseOut?.();
228
206
 
229
- if (event.type === 'touchend' && 'changedTouches' in event) {
230
- const { clientX, clientY } = event.changedTouches[0];
207
+ if (event.type === 'touchend') {
231
208
  const simulatedEvent = new MouseEvent('mouseup', {
232
- clientX,
233
- clientY,
209
+ clientX: cursorX,
210
+ clientY: cursorY,
234
211
  bubbles: true,
235
212
  });
236
213
  document
237
- .elementFromPoint(clientX, clientY)
214
+ .elementFromPoint(cursorX, cursorY)
238
215
  ?.dispatchEvent(simulatedEvent);
216
+
217
+ updateItemDetails({
218
+ item,
219
+ tooltip: { visible: false },
220
+ });
239
221
  }
240
222
  },
241
- [onMouseOut]
223
+ [onMouseOut, cursorX, cursorY]
242
224
  );
243
225
 
244
- const [showTooltipDelayed, setShowTooltipDelayed] = useState(false);
245
-
246
- //@ts-ignore
247
- useEffect(() => {
248
- if (tooltipState.visible && !isDraggingDisabled) {
249
- const timer = setTimeout(() => setShowTooltipDelayed(true), 50);
250
- return () => clearTimeout(timer);
251
- } else {
252
- setShowTooltipDelayed(false);
253
- }
254
- }, [tooltipState.visible, isDraggingDisabled]);
255
-
256
226
  return (
257
227
  <Container
258
228
  isDraggingItem={!!draggingItem}
@@ -274,7 +244,6 @@ export const ItemSlot = React.memo(
274
244
  }
275
245
  }}
276
246
  onTouchEnd={e => {
277
- handleInteractionEnd(e);
278
247
  const { clientX, clientY } = e.changedTouches[0];
279
248
  const simulatedEvent = new MouseEvent('mouseup', {
280
249
  clientX,
@@ -299,7 +268,7 @@ export const ItemSlot = React.memo(
299
268
  axis={isSelectingShortcut ? 'none' : 'both'}
300
269
  defaultClassName={item ? 'draggable' : 'empty-slot'}
301
270
  scale={dragScale}
302
- disabled={isDraggingDisabled}
271
+ disabled={onDragStart === undefined || onDragEnd === undefined}
303
272
  onStop={onDraggableStop}
304
273
  onStart={onDraggableStart}
305
274
  onDrag={onDraggableProgress}
@@ -310,26 +279,27 @@ export const ItemSlot = React.memo(
310
279
  <ItemContainer
311
280
  ref={dragContainer}
312
281
  isFocused={dragState.isFocused}
313
- onMouseOver={event => {
282
+ onMouseOver={() => {
314
283
  onMouseOver?.(
315
- event,
284
+ {} as React.MouseEvent,
316
285
  slotIndex,
317
286
  item,
318
- event.clientX,
319
- event.clientY
287
+ cursorX,
288
+ cursorY
320
289
  );
321
290
  }}
322
291
  onMouseOut={onMouseOut}
323
292
  onMouseEnter={() => {
324
- setTooltipState(prev => ({ ...prev, visible: true }));
293
+ updateItemDetails({
294
+ item,
295
+ tooltip: { visible: true },
296
+ });
325
297
  }}
326
- onMouseLeave={e => {
327
- if (
328
- !e.relatedTarget ||
329
- !dragContainer.current?.contains(e.relatedTarget as Node)
330
- ) {
331
- setTooltipState(prev => ({ ...prev, visible: false }));
332
- }
298
+ onMouseLeave={() => {
299
+ updateItemDetails({
300
+ item,
301
+ tooltip: { visible: false },
302
+ });
333
303
  }}
334
304
  >
335
305
  <ItemSlotRenderer
@@ -341,28 +311,6 @@ export const ItemSlot = React.memo(
341
311
  />
342
312
  </ItemContainer>
343
313
  </Draggable>
344
-
345
- <ItemSlotToolTips
346
- tooltipState={tooltipState}
347
- setTooltipState={setTooltipState}
348
- contextMenuState={contextMenuState}
349
- setContextMenuState={setContextMenuState}
350
- isFocused={dragState.isFocused}
351
- isContextMenuDisabled={isContextMenuDisabled}
352
- item={item}
353
- contextActions={contextActions}
354
- dragScale={dragScale}
355
- onSelected={(optionId: string, item: IItem) => {
356
- setContextMenuState(prev => ({ ...prev, visible: false }));
357
- if (onSelected) onSelected(optionId, item);
358
- }}
359
- atlasIMG={atlasIMG}
360
- atlasJSON={atlasJSON}
361
- equipmentSet={equipmentSet}
362
- isDragging={!!draggingItem}
363
- isSelectingShortcut={!!isSelectingShortcut}
364
- showTooltipDelayed={showTooltipDelayed}
365
- />
366
314
  </Container>
367
315
  );
368
316
  }