@rpg-engine/long-bow 0.7.70 → 0.7.71

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 +5 -18
  2. package/dist/components/Item/Inventory/ItemSlotTooltips.d.ts +12 -1
  3. package/dist/components/Item/Inventory/context/DraggingContext.d.ts +11 -0
  4. package/dist/hooks/useCursorPosition.d.ts +1 -1
  5. package/dist/long-bow.cjs.development.js +572 -660
  6. package/dist/long-bow.cjs.development.js.map +1 -1
  7. package/dist/long-bow.cjs.production.min.js +1 -1
  8. package/dist/long-bow.cjs.production.min.js.map +1 -1
  9. package/dist/long-bow.esm.js +574 -662
  10. package/dist/long-bow.esm.js.map +1 -1
  11. package/package.json +2 -3
  12. package/src/components/Equipment/EquipmentSet.tsx +29 -61
  13. package/src/components/Item/Inventory/DraggedItem.tsx +2 -2
  14. package/src/components/Item/Inventory/ItemContainer.tsx +44 -68
  15. package/src/components/Item/Inventory/ItemSlot.tsx +447 -239
  16. package/src/components/Item/Inventory/ItemSlotTooltips.tsx +46 -48
  17. package/src/components/Item/Inventory/context/DraggingContext.tsx +26 -0
  18. package/src/hooks/useCursorPosition.ts +20 -29
  19. package/src/stories/UI/containers/ItemContainer.stories.tsx +3 -30
  20. package/dist/components/Item/Inventory/context/ItemSlotDraggingContext.d.ts +0 -26
  21. package/dist/components/Item/Inventory/context/ItemSlotTooltipContext.d.ts +0 -28
  22. package/dist/components/Item/Inventory/hooks/useItemSlotDragAndDrop.d.ts +0 -39
  23. package/src/components/Item/Inventory/context/ItemSlotDraggingContext.tsx +0 -52
  24. package/src/components/Item/Inventory/context/ItemSlotTooltipContext.tsx +0 -95
  25. package/src/components/Item/Inventory/hooks/useItemSlotDragAndDrop.ts +0 -248
@@ -1,4 +1,5 @@
1
1
  import {
2
+ IEquipmentSet,
2
3
  IItem,
3
4
  IItemContainer,
4
5
  ItemContainerType,
@@ -8,16 +9,15 @@ import {
8
9
  } from '@rpg-engine/shared';
9
10
 
10
11
  import { observer } from 'mobx-react-lite';
11
- import React, { useCallback, useEffect } from 'react';
12
- import Draggable from 'react-draggable';
12
+ import React, { useEffect, useRef, useState } from 'react';
13
+ import Draggable, { DraggableEventHandler } from 'react-draggable';
13
14
  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 { useItemSlotTooltip } from './context/ItemSlotTooltipContext';
19
- import { useItemSlotDragAndDrop } from './hooks/useItemSlotDragAndDrop';
20
- import { generateContextMenu } from './itemContainerHelper';
18
+ import { ItemSlotToolTips } from './ItemSlotTooltips';
19
+ import { useDragging } from './context/DraggingContext';
20
+ import { IContextMenuItem, generateContextMenu } from './itemContainerHelper';
21
21
 
22
22
  export const EquipmentSlotSpriteByType: any = {
23
23
  Neck: 'accessories/corruption-necklace.png',
@@ -38,6 +38,7 @@ interface IProps {
38
38
  itemContainer?: IItemContainer | null;
39
39
  itemContainerType?: ItemContainerType | null;
40
40
  slotSpriteMask?: ItemSlotType | null;
41
+ onSelected?: (selectedOption: string, item: IItem) => void;
41
42
  onMouseOver?: (
42
43
  event: any,
43
44
  slotIndex: number,
@@ -60,6 +61,7 @@ interface IProps {
60
61
  onOutsideDrop?: (item: IItem, position: IPosition) => void;
61
62
  dragScale?: number;
62
63
  checkIfItemCanBeMoved?: () => boolean;
64
+ checkIfItemShouldDragEnd?: () => boolean;
63
65
  openQuantitySelector?: (maxQuantity: number, callback: () => void) => void;
64
66
  onPlaceDrop?: (
65
67
  item: IItem | null,
@@ -70,251 +72,459 @@ interface IProps {
70
72
  atlasIMG: any;
71
73
  isContextMenuDisabled?: boolean;
72
74
  isSelectingShortcut?: boolean;
75
+ equipmentSet?: IEquipmentSet | null;
73
76
  setItemShortcut?: (item: IItem, shortcutIndex: number) => void;
74
77
  isDepotSystem?: boolean;
75
78
  }
76
79
 
77
- export type TooltipState = {
78
- visible: boolean;
79
- mobileVisible: boolean;
80
- };
80
+ export const ItemSlot: React.FC<IProps> = observer(
81
+ ({
82
+ slotIndex,
83
+ item,
84
+ itemContainerType: containerType,
85
+ slotSpriteMask,
86
+ onMouseOver,
87
+ onMouseOut,
88
+ onPointerDown,
89
+ onSelected,
90
+ atlasJSON,
91
+ atlasIMG,
92
+ isContextMenuDisabled = false,
93
+ onDragEnd,
94
+ onDragStart,
95
+ onPlaceDrop,
96
+ onOutsideDrop: onDrop,
97
+ checkIfItemCanBeMoved,
98
+ openQuantitySelector,
99
+ checkIfItemShouldDragEnd,
100
+ dragScale,
101
+ isSelectingShortcut,
102
+ equipmentSet,
103
+ setItemShortcut,
104
+ isDepotSystem,
105
+ }) => {
106
+ // Centralized state using a single useState hook
107
+ const [state, setState] = useState({
108
+ isTooltipVisible: false,
109
+ isTooltipMobileVisible: false,
110
+ isContextMenuVisible: false,
111
+ contextMenuPosition: { x: 0, y: 0 },
112
+ isFocused: false,
113
+ wasDragged: false,
114
+ dragPosition: { x: 0, y: 0 } as IPosition,
115
+ dropPosition: null as IPosition | null,
116
+ contextActions: [] as IContextMenuItem[],
117
+ draggingDistance: 0,
118
+ });
81
119
 
82
- export type ContextMenuState = {
83
- position: IPosition;
84
- visible: boolean;
85
- };
120
+ const {
121
+ isTooltipVisible,
122
+ isTooltipMobileVisible,
123
+ isContextMenuVisible,
124
+ contextMenuPosition,
125
+ isFocused,
126
+ wasDragged,
127
+ dragPosition,
128
+ dropPosition,
129
+ contextActions,
130
+ } = state;
86
131
 
87
- export type DragState = {
88
- isFocused: boolean;
89
- wasDragged: boolean;
90
- position: IPosition;
91
- dropPosition: IPosition | null;
92
- };
132
+ const dragContainer = useRef<HTMLDivElement>(null);
133
+ const { item: draggingItem, setDraggingItem } = useDragging();
93
134
 
94
- export const ItemSlot = React.memo(
95
- observer(
96
- ({
97
- slotIndex,
98
- item,
99
- itemContainerType: containerType,
100
- slotSpriteMask,
101
- onMouseOver,
102
- onMouseOut,
103
- onPointerDown,
104
- atlasJSON,
105
- atlasIMG,
106
- isContextMenuDisabled = false,
107
- onDragEnd,
108
- onDragStart,
109
- onPlaceDrop,
110
- onOutsideDrop: onDrop,
111
- checkIfItemCanBeMoved,
112
- openQuantitySelector,
113
- dragScale,
114
- isSelectingShortcut,
115
-
116
- setItemShortcut,
117
- isDepotSystem,
118
- }: IProps): JSX.Element => {
119
- const {
120
- dragContainer,
121
- dragState,
122
- draggingItem,
123
- getContainerBounds,
124
- onDraggableStart,
125
- onDraggableProgress,
126
- onDraggableStop,
127
- } = useItemSlotDragAndDrop({
128
- isDepotSystem: !!isDepotSystem,
129
- item: item!,
130
- onDrop: onDrop ?? (() => {}),
131
- onDragEnd,
132
- checkIfItemCanBeMoved,
133
- setItemShortcut,
134
- isSelectingShortcut,
135
- onDragStart,
136
- onPointerDown,
137
- containerType: containerType!,
138
- slotIndex,
139
- openQuantitySelector: openQuantitySelector ?? (() => {}),
140
- isContextMenuDisabled,
141
- });
142
-
143
- const { updateItemDetails, itemDetails } = useItemSlotTooltip();
144
-
145
- const { x: cursorX, y: cursorY } = useCursorPosition({
146
- scale: dragScale,
147
- });
148
-
149
- useEffect(() => {
150
- if (item && containerType) {
151
- updateItemDetails({
135
+ useEffect(() => {
136
+ // Reset drag position and focus when item changes
137
+ setState(prevState => ({
138
+ ...prevState,
139
+ dragPosition: { x: 0, y: 0 },
140
+ isFocused: false,
141
+ }));
142
+
143
+ // Update context actions when item or depot system changes
144
+ if (item && containerType) {
145
+ setState(prevState => ({
146
+ ...prevState,
147
+ contextActions: generateContextMenu(
152
148
  item,
153
- contextMenu: {
154
- actions: generateContextMenu(item, containerType, isDepotSystem),
155
- },
156
- });
149
+ containerType,
150
+ isDepotSystem
151
+ ),
152
+ }));
153
+ } else {
154
+ setState(prevState => ({
155
+ ...prevState,
156
+ contextActions: [],
157
+ }));
158
+ }
159
+ }, [item, isDepotSystem]);
160
+
161
+ useEffect(() => {
162
+ // Handle outside drop
163
+ if (onDrop && item && dropPosition) {
164
+ onDrop(item, dropPosition);
165
+ }
166
+ }, [dropPosition]);
167
+
168
+ const resetItem = () => {
169
+ setState(prevState => ({
170
+ ...prevState,
171
+ isTooltipVisible: false,
172
+ wasDragged: false,
173
+ }));
174
+ };
175
+
176
+ const onSuccessfulDrag = (quantity?: number) => {
177
+ resetItem();
178
+
179
+ if (quantity === -1) {
180
+ setState(prevState => ({
181
+ ...prevState,
182
+ dragPosition: { x: 0, y: 0 },
183
+ isFocused: false,
184
+ }));
185
+ } else if (item) {
186
+ onDragEnd?.(quantity);
187
+ }
188
+ };
189
+
190
+ const onDraggableStop: DraggableEventHandler = (e, data) => {
191
+ console.log('>>> ON_DRAGGABLE_STOP');
192
+ // Stop the dragging state
193
+
194
+ console.log('setDraggingItem(null)');
195
+ setDraggingItem(null);
196
+
197
+ const target = e.target as HTMLElement;
198
+
199
+ console.log('handleShortcutSetter(target)');
200
+ handleShortcutSetter(target);
201
+
202
+ console.log('removeDraggingClass(target)');
203
+ removeDraggingClass(target);
204
+
205
+ console.log('shouldHandleDraggedItem()');
206
+ if (shouldHandleDraggedItem()) {
207
+ console.log('handleDraggedItem(e, data)');
208
+ handleDraggedItem(e, data);
209
+ } else if (item && !wasDragged) {
210
+ console.log('handleContextMenuOrTooltip(e)');
211
+ handleContextMenuOrTooltip(e);
212
+ }
213
+ };
214
+
215
+ /**
216
+ * Handles the shortcut setter logic if the target element is a shortcut setter.
217
+ */
218
+ const handleShortcutSetter = (target: HTMLElement) => {
219
+ if (target?.id.includes('shortcutSetter') && setItemShortcut && item) {
220
+ const index = parseInt(target.id.split('_')[1], 10);
221
+ if (!isNaN(index)) {
222
+ setItemShortcut(item, index);
157
223
  }
158
- }, [item, isDepotSystem]);
159
-
160
- const bounds = getContainerBounds();
161
-
162
- const handleInteraction = useCallback(
163
- (event: React.MouseEvent | React.TouchEvent) => {
164
- event.stopPropagation();
165
-
166
- console.log('handleInteraction');
167
-
168
- if (item && containerType) {
169
- if (onPlaceDrop && draggingItem) {
170
- onPlaceDrop(item, slotIndex, containerType);
171
- }
172
- if (
173
- onPointerDown &&
174
- onDragStart === undefined &&
175
- onDragEnd === undefined
176
- ) {
177
- onPointerDown(item.type, containerType, item);
178
- }
179
- }
224
+ }
225
+ };
180
226
 
181
- onMouseOver?.(event, slotIndex, item, cursorX, cursorY);
182
- },
183
- [
184
- item,
185
- containerType,
186
- slotIndex,
187
- onPlaceDrop,
188
- onPointerDown,
189
- onMouseOver,
190
- onDragStart,
191
- onDragEnd,
192
- cursorX,
193
- cursorY,
194
- ]
195
- );
227
+ /**
228
+ * Removes the dragging CSS class from the target element.
229
+ */
230
+ const removeDraggingClass = (target: HTMLElement) => {
231
+ target.classList.remove('react-draggable-dragging');
232
+ };
196
233
 
197
- const handleInteractionEnd = useCallback(
198
- (event: React.MouseEvent | React.TouchEvent) => {
199
- event.preventDefault();
200
- event.stopPropagation();
201
-
202
- console.log('handleInteractionEnd');
203
-
204
- console.log('itemDetails', itemDetails);
205
- onMouseOut?.();
206
-
207
- if (event.type === 'touchend') {
208
- const simulatedEvent = new MouseEvent('mouseup', {
209
- clientX: cursorX,
210
- clientY: cursorY,
211
- bubbles: true,
212
- });
213
- document
214
- .elementFromPoint(cursorX, cursorY)
215
- ?.dispatchEvent(simulatedEvent);
216
-
217
- updateItemDetails({
218
- item,
219
- tooltip: { visible: false },
220
- });
221
- }
222
- },
223
- [onMouseOut, cursorX, cursorY]
234
+ /**
235
+ * Determines whether the dragged item should be processed.
236
+ */
237
+ const shouldHandleDraggedItem = (): boolean => {
238
+ console.log(
239
+ `Debug: shouldHandleDraggedItem()`,
240
+ `wasDragged: ${wasDragged}`,
241
+ `item: ${item}`,
242
+ `isSelectingShortcut: ${isSelectingShortcut}`
224
243
  );
244
+ return !!(wasDragged && item && !isSelectingShortcut);
245
+ };
246
+
247
+ /**
248
+ * Handles the logic when an item has been dragged.
249
+ */
250
+ const handleDraggedItem = (e: any, data: any) => {
251
+ const targetClasses = Array.from((e.target as HTMLElement).classList);
252
+ const isOutsideDrop =
253
+ targetClasses.some(elm => elm.includes('rpgui-content')) ||
254
+ targetClasses.length === 0;
255
+
256
+ if (isOutsideDrop) {
257
+ setState(prevState => ({
258
+ ...prevState,
259
+ dropPosition: {
260
+ x: data.x,
261
+ y: data.y,
262
+ },
263
+ }));
264
+ }
265
+
266
+ setState(prevState => ({
267
+ ...prevState,
268
+ wasDragged: false,
269
+ }));
270
+
271
+ const targetElement = dragContainer.current;
272
+ if (!targetElement) return;
273
+
274
+ const { x, y } = getElementTransform(targetElement);
275
+ setState(prevState => ({
276
+ ...prevState,
277
+ dragPosition: { x, y },
278
+ }));
279
+
280
+ // Delay to ensure state updates before proceeding
281
+ setTimeout(() => {
282
+ processDragEnd(item!);
283
+ }, 50);
284
+ };
285
+
286
+ /**
287
+ * Retrieves the current transform position of the dragged element.
288
+ */
289
+ const getElementTransform = (
290
+ element: HTMLElement
291
+ ): { x: number; y: number } => {
292
+ const style = window.getComputedStyle(element);
293
+ const matrix = new DOMMatrixReadOnly(style.transform);
294
+ return { x: matrix.m41, y: matrix.m42 };
295
+ };
296
+
297
+ /**
298
+ * Processes the end of a drag event, handling quantity selection or resetting state.
299
+ */
300
+ const processDragEnd = (item: IItem) => {
301
+ console.log(`Debug: processDragEnd(item)`, `item: ${item}`);
302
+ if (checkIfItemCanBeMoved?.()) {
303
+ console.log(
304
+ `Debug: checkIfItemCanBeMoved()`,
305
+ `result: ${checkIfItemCanBeMoved()}`
306
+ );
307
+
308
+ if (checkIfItemShouldDragEnd && !checkIfItemShouldDragEnd()) return;
309
+
310
+ console.log(
311
+ `Debug: checkIfItemShouldDragEnd()`,
312
+ `result: ${checkIfItemShouldDragEnd?.()}`
313
+ );
225
314
 
226
- return (
227
- <Container
228
- isDraggingItem={!!draggingItem}
315
+ if (item.stackQty && item.stackQty !== 1 && openQuantitySelector) {
316
+ console.log(
317
+ `Debug: openQuantitySelector(item.stackQty, onSuccessfulDrag)`
318
+ );
319
+ openQuantitySelector(item.stackQty, onSuccessfulDrag);
320
+ } else {
321
+ console.log(`Debug: onSuccessfulDrag(item.stackQty)`);
322
+ onSuccessfulDrag(item.stackQty);
323
+ }
324
+ } else {
325
+ console.log(`Debug: resetItem()`);
326
+ resetItem();
327
+ setState(prevState => ({
328
+ ...prevState,
329
+ isFocused: false,
330
+ dragPosition: { x: 0, y: 0 },
331
+ }));
332
+ }
333
+ };
334
+
335
+ /**
336
+ * Handles the context menu or tooltip display after dragging stops without a drop.
337
+ */
338
+ const handleContextMenuOrTooltip = (e: any) => {
339
+ let isTouchEvent = false;
340
+
341
+ if (
342
+ !isContextMenuDisabled &&
343
+ e.type === 'touchend' &&
344
+ !isSelectingShortcut
345
+ ) {
346
+ isTouchEvent = true;
347
+ setState(prevState => ({
348
+ ...prevState,
349
+ isTooltipMobileVisible: true,
350
+ }));
351
+ }
352
+
353
+ if (!isContextMenuDisabled && !isSelectingShortcut && !isTouchEvent) {
354
+ setState(prevState => ({
355
+ ...prevState,
356
+ isContextMenuVisible: !prevState.isContextMenuVisible,
357
+ contextMenuPosition: {
358
+ x: (e as MouseEvent).clientX - 10,
359
+ y: (e as MouseEvent).clientY - 5,
360
+ },
361
+ }));
362
+ }
363
+
364
+ if (item) {
365
+ onPointerDown(item.type, containerType ?? null, item);
366
+ }
367
+ };
368
+
369
+ const onDraggableStart: DraggableEventHandler = () => {
370
+ if (!item || isSelectingShortcut) {
371
+ return;
372
+ }
373
+
374
+ if (onDragStart && containerType) {
375
+ onDragStart(item, slotIndex, containerType);
376
+ }
377
+ };
378
+
379
+ const onDraggableProgress: DraggableEventHandler = (_e, _data) => {
380
+ // increment draggingDistance by 1
381
+
382
+ setState(prevState => ({
383
+ ...prevState,
384
+ draggingDistance: prevState.draggingDistance + 1,
385
+ }));
386
+
387
+ if (state.draggingDistance > 10) {
388
+ setState(prevState => ({
389
+ ...prevState,
390
+ wasDragged: true,
391
+ isFocused: true,
392
+ }));
393
+ }
394
+
395
+ if (!draggingItem) {
396
+ setDraggingItem(item);
397
+ }
398
+ };
399
+
400
+ return (
401
+ <Container
402
+ isDraggingItem={!!draggingItem}
403
+ item={item}
404
+ className="rpgui-icon empty-slot"
405
+ onMouseUp={() => {
406
+ const data = item ? item : null;
407
+ if (onPlaceDrop && containerType)
408
+ onPlaceDrop(data, slotIndex, containerType);
409
+ }}
410
+ onTouchEnd={e => {
411
+ const { clientX, clientY } = e.changedTouches[0];
412
+ const simulatedEvent = new MouseEvent('mouseup', {
413
+ clientX,
414
+ clientY,
415
+ bubbles: true,
416
+ });
417
+
418
+ document
419
+ .elementFromPoint(clientX, clientY)
420
+ ?.dispatchEvent(simulatedEvent);
421
+ }}
422
+ onPointerDown={
423
+ onDragStart !== undefined && onDragEnd !== undefined
424
+ ? undefined
425
+ : () => {
426
+ if (item) onPointerDown(item.type, containerType ?? null, item);
427
+ }
428
+ }
429
+ isSelectingShortcut={
430
+ isSelectingShortcut &&
431
+ (item?.type === ItemType.Consumable ||
432
+ item?.type === ItemType.Tool ||
433
+ item?.subType === ItemSubType.Seed)
434
+ }
435
+ >
436
+ <Draggable
437
+ axis={isSelectingShortcut ? 'none' : 'both'}
438
+ defaultClassName={item ? 'draggable' : 'empty-slot'}
439
+ scale={dragScale}
440
+ disabled={onDragStart === undefined || onDragEnd === undefined}
441
+ onStop={onDraggableStop}
442
+ onStart={onDraggableStart}
443
+ onDrag={onDraggableProgress}
444
+ position={dragPosition}
445
+ cancel=".empty-slot"
446
+ bounds=".item-container-body, .equipment-container-body"
447
+ >
448
+ <ItemContainer
449
+ ref={dragContainer}
450
+ isFocused={isFocused}
451
+ onMouseOver={event => {
452
+ onMouseOver?.(
453
+ event,
454
+ slotIndex,
455
+ item,
456
+ event.clientX,
457
+ event.clientY
458
+ );
459
+ }}
460
+ onMouseOut={() => {
461
+ if (onMouseOut) onMouseOut();
462
+ }}
463
+ onMouseEnter={() => {
464
+ setState(prevState => ({
465
+ ...prevState,
466
+ isTooltipVisible: true,
467
+ }));
468
+ }}
469
+ onMouseLeave={() => {
470
+ setState(prevState => ({
471
+ ...prevState,
472
+ isTooltipVisible: false,
473
+ }));
474
+ }}
475
+ >
476
+ <ItemSlotRenderer
477
+ item={item}
478
+ slotSpriteMask={slotSpriteMask}
479
+ atlasIMG={atlasIMG}
480
+ atlasJSON={atlasJSON}
481
+ containerType={containerType}
482
+ />
483
+ </ItemContainer>
484
+ </Draggable>
485
+
486
+ <ItemSlotToolTips
487
+ isTooltipVisible={isTooltipVisible}
488
+ isTooltipMobileVisible={isTooltipMobileVisible}
489
+ setIsTooltipMobileVisible={value =>
490
+ setState(prevState => ({
491
+ ...prevState,
492
+ isTooltipMobileVisible: value,
493
+ }))
494
+ }
495
+ isFocused={isFocused}
496
+ isContextMenuVisible={isContextMenuVisible}
497
+ isContextMenuDisabled={isContextMenuDisabled}
229
498
  item={item}
230
- className="rpgui-icon empty-slot"
231
- isSelectingShortcut={
232
- isSelectingShortcut &&
233
- (item?.type === ItemType.Consumable ||
234
- item?.type === ItemType.Tool ||
235
- item?.subType === ItemSubType.Seed)
499
+ contextActions={contextActions}
500
+ contextMenuPosition={contextMenuPosition}
501
+ dragScale={dragScale}
502
+ setIsContextMenuVisible={value =>
503
+ setState(prevState => ({
504
+ ...prevState,
505
+ isContextMenuVisible: value,
506
+ }))
236
507
  }
237
- onMouseDown={handleInteraction}
238
- onTouchStart={handleInteraction}
239
- onMouseUp={e => {
240
- handleInteractionEnd(e);
241
- const data = item ? item : null;
242
- if (onPlaceDrop && containerType && draggingItem) {
243
- onPlaceDrop(data, slotIndex, containerType);
244
- }
508
+ onSelected={(optionId: string, item: IItem) => {
509
+ setState(prevState => ({
510
+ ...prevState,
511
+ isContextMenuVisible: false,
512
+ }));
513
+ if (onSelected) onSelected(optionId, item);
245
514
  }}
246
- onTouchEnd={e => {
247
- const { clientX, clientY } = e.changedTouches[0];
248
- const simulatedEvent = new MouseEvent('mouseup', {
249
- clientX,
250
- clientY,
251
- bubbles: true,
252
- });
253
- document
254
- .elementFromPoint(clientX, clientY)
255
- ?.dispatchEvent(simulatedEvent);
256
- }}
257
- onPointerDown={
258
- onDragStart !== undefined && onDragEnd !== undefined
259
- ? undefined
260
- : () => {
261
- if (item)
262
- onPointerDown(item.type, containerType ?? null, item);
263
- }
515
+ atlasIMG={atlasIMG}
516
+ atlasJSON={atlasJSON}
517
+ equipmentSet={equipmentSet}
518
+ setIsTooltipVisible={value =>
519
+ setState(prevState => ({
520
+ ...prevState,
521
+ isTooltipVisible: value,
522
+ }))
264
523
  }
265
- onMouseLeave={handleInteractionEnd}
266
- >
267
- <Draggable
268
- axis={isSelectingShortcut ? 'none' : 'both'}
269
- defaultClassName={item ? 'draggable' : 'empty-slot'}
270
- scale={dragScale}
271
- disabled={onDragStart === undefined || onDragEnd === undefined}
272
- onStop={onDraggableStop}
273
- onStart={onDraggableStart}
274
- onDrag={onDraggableProgress}
275
- position={dragState.position}
276
- cancel=".empty-slot"
277
- bounds={bounds}
278
- >
279
- <ItemContainer
280
- ref={dragContainer}
281
- isFocused={dragState.isFocused}
282
- onMouseOver={() => {
283
- onMouseOver?.(
284
- {} as React.MouseEvent,
285
- slotIndex,
286
- item,
287
- cursorX,
288
- cursorY
289
- );
290
- }}
291
- onMouseOut={onMouseOut}
292
- onMouseEnter={() => {
293
- updateItemDetails({
294
- item,
295
- tooltip: { visible: true },
296
- });
297
- }}
298
- onMouseLeave={() => {
299
- updateItemDetails({
300
- item,
301
- tooltip: { visible: false },
302
- });
303
- }}
304
- >
305
- <ItemSlotRenderer
306
- item={item}
307
- slotSpriteMask={slotSpriteMask}
308
- atlasIMG={atlasIMG}
309
- atlasJSON={atlasJSON}
310
- containerType={containerType}
311
- />
312
- </ItemContainer>
313
- </Draggable>
314
- </Container>
315
- );
316
- }
317
- )
524
+ />
525
+ </Container>
526
+ );
527
+ }
318
528
  );
319
529
 
320
530
  interface ContainerTypes {
@@ -328,7 +538,7 @@ const Container = styled.div<ContainerTypes>`
328
538
  margin: 0.1rem;
329
539
 
330
540
  .react-draggable-dragging {
331
- // if is dragging item, set opacity to 0
541
+ // If dragging item, set opacity to 0
332
542
  opacity: ${({ isDraggingItem }) => (isDraggingItem ? 0 : 1)};
333
543
  }
334
544
 
@@ -339,10 +549,8 @@ const Container = styled.div<ContainerTypes>`
339
549
  top: 1.5rem;
340
550
  left: 1.5rem;
341
551
  border-color: ${({ item }) => rarityColor(item)};
342
- box-shadow: ${({ item }) => `0 0 5px 2px ${rarityColor(item)}`} inset, ${({
343
- item,
344
- }) => `0 0 4px 3px ${rarityColor(item)}`};
345
- //background-color: ${({ item }) => rarityColor(item)};
552
+ box-shadow: ${({ item }) => `0 0 5px 2px ${rarityColor(item)}`} inset,
553
+ ${({ item }) => `0 0 4px 3px ${rarityColor(item)}`};
346
554
  }
347
555
 
348
556
  &::before {