@rpg-engine/long-bow 0.7.81 → 0.7.83

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rpg-engine/long-bow",
3
- "version": "0.7.81",
3
+ "version": "0.7.83",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -13,6 +13,7 @@ import { observer } from 'mobx-react-lite';
13
13
  import React, { useCallback, useEffect, useRef } from 'react';
14
14
  import Draggable, { DraggableEventHandler } from 'react-draggable';
15
15
  import styled from 'styled-components';
16
+ import useTouchTarget from '../../../hooks/useTouchTarget';
16
17
  import { IPosition } from '../../../types/eventTypes';
17
18
  import { rarityColor } from './ItemSlotRarity';
18
19
  import { ItemSlotRenderer } from './ItemSlotRenderer';
@@ -151,6 +152,8 @@ export const ItemSlot: React.FC<IProps> = observer(
151
152
  setContextActions,
152
153
  } = useItemSlotDetails();
153
154
 
155
+ const getTouchTarget = useTouchTarget();
156
+
154
157
  const {
155
158
  isContextMenuVisible,
156
159
  clearDetailsState,
@@ -231,7 +234,12 @@ export const ItemSlot: React.FC<IProps> = observer(
231
234
  item: null,
232
235
  });
233
236
 
234
- const target = e.target as HTMLElement;
237
+ let target = e.target as HTMLElement;
238
+
239
+ if (isMobile()) {
240
+ target = getTouchTarget(e as MouseEvent);
241
+ }
242
+
235
243
  handleShortcutSetter(target);
236
244
  removeDraggingClass(target);
237
245
 
@@ -9,6 +9,7 @@ import { uiColors } from '../../constants/uiColors';
9
9
  import { uiFonts } from '../../constants/uiFonts';
10
10
  import { Button, ButtonTypes } from '../Button';
11
11
  import { ItemInfoWrapper } from '../Item/Cards/ItemInfoWrapper';
12
+ import { onRenderGems } from '../Item/Inventory/ItemGem';
12
13
  import { rarityColor } from '../Item/Inventory/ItemSlotRarity';
13
14
  import { Ellipsis } from '../shared/Ellipsis';
14
15
  import { SpriteFromAtlas } from '../shared/SpriteFromAtlas';
@@ -36,6 +37,10 @@ export const MarketplaceRows: React.FC<IMarketPlaceRowsPropos> = ({
36
37
  onMarketPlaceItemRemove,
37
38
  disabled,
38
39
  }) => {
40
+ const renderGems = (item: IItem) => {
41
+ return item.attachedGems && onRenderGems(item);
42
+ };
43
+
39
44
  return (
40
45
  <MarketplaceWrapper>
41
46
  <ItemIconContainer>
@@ -47,6 +52,7 @@ export const MarketplaceRows: React.FC<IMarketPlaceRowsPropos> = ({
47
52
  equipmentSet={equipmentSet}
48
53
  scale={scale}
49
54
  >
55
+ <GemContainer>{renderGems(item)}</GemContainer>
50
56
  <RarityContainer item={item}>
51
57
  <SpriteFromAtlas
52
58
  atlasIMG={atlasIMG}
@@ -61,8 +67,10 @@ export const MarketplaceRows: React.FC<IMarketPlaceRowsPropos> = ({
61
67
  atlasJSON
62
68
  )}
63
69
  imgScale={2}
70
+ imgClassname="sprite-from-atlas-img--item"
64
71
  />
65
72
  </RarityContainer>
73
+
66
74
  <QuantityContainer>
67
75
  {item.stackQty &&
68
76
  item.stackQty > 1 &&
@@ -139,6 +147,14 @@ const QuantityContainer = styled.p`
139
147
  font-size: ${uiFonts.size.xsmall} !important;
140
148
  `;
141
149
 
150
+ const GemContainer = styled.p`
151
+ position: absolute;
152
+ display: block;
153
+ top: -5px;
154
+ left: -10px;
155
+ font-size: ${uiFonts.size.xsmall} !important;
156
+ `;
157
+
142
158
  const Flex = styled.div`
143
159
  display: flex;
144
160
  gap: 24px;
@@ -0,0 +1,38 @@
1
+ import { useCallback } from 'react';
2
+
3
+ interface IEventWithTarget {
4
+ target: EventTarget | null;
5
+ }
6
+
7
+ interface ITouchEvent extends IEventWithTarget {
8
+ changedTouches?: TouchList;
9
+
10
+ touches?: TouchList;
11
+ }
12
+
13
+ export function useTouchTarget() {
14
+ const getTouchTarget = useCallback(
15
+ (e: MouseEvent | TouchEvent | IEventWithTarget): HTMLElement => {
16
+ // Check if it's a touch event
17
+ if ('changedTouches' in e || 'touches' in e) {
18
+ const touchEvent = e as ITouchEvent;
19
+ const touch = touchEvent.changedTouches?.[0] || touchEvent.touches?.[0];
20
+
21
+ if (touch) {
22
+ return document.elementFromPoint(
23
+ touch.clientX,
24
+ touch.clientY
25
+ ) as HTMLElement;
26
+ }
27
+ }
28
+
29
+ // If it's not a touch event or touch is not available, fallback to target
30
+ return (e.target as HTMLElement) || document.body;
31
+ },
32
+ []
33
+ );
34
+
35
+ return getTouchTarget;
36
+ }
37
+
38
+ export default useTouchTarget;