@rpg-engine/long-bow 0.3.63 → 0.3.64
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/long-bow.cjs.development.js +22 -23
- 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 +22 -23
- package/dist/long-bow.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/DraggableContainer.tsx +12 -0
- package/src/components/TradingMenu/TradingItemRow.tsx +12 -24
package/package.json
CHANGED
|
@@ -41,6 +41,18 @@ export const DraggableContainer: React.FC<IDraggableContainerProps> = ({
|
|
|
41
41
|
|
|
42
42
|
useOutsideClick(draggableRef, 'item-container');
|
|
43
43
|
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
const handleKeyDown = (event: KeyboardEvent) => {
|
|
46
|
+
if (event.key === 'Escape' && onCloseButton) {
|
|
47
|
+
onCloseButton();
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
document.addEventListener('keydown', handleKeyDown);
|
|
51
|
+
return () => {
|
|
52
|
+
document.removeEventListener('keydown', handleKeyDown);
|
|
53
|
+
};
|
|
54
|
+
}, [onCloseButton]);
|
|
55
|
+
|
|
44
56
|
useEffect(() => {
|
|
45
57
|
document.addEventListener('clickOutside', event => {
|
|
46
58
|
const e = event as CustomEvent;
|
|
@@ -18,6 +18,8 @@ export interface ITradeComponentProps {
|
|
|
18
18
|
selectedQty: number;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
const outerQty = 10;
|
|
22
|
+
|
|
21
23
|
export const TradingItemRow: React.FC<ITradeComponentProps> = ({
|
|
22
24
|
atlasIMG,
|
|
23
25
|
atlasJSON,
|
|
@@ -25,29 +27,15 @@ export const TradingItemRow: React.FC<ITradeComponentProps> = ({
|
|
|
25
27
|
traderItem,
|
|
26
28
|
selectedQty,
|
|
27
29
|
}) => {
|
|
28
|
-
const onLeftClick = () => {
|
|
29
|
-
|
|
30
|
-
const newQuantity = selectedQty - 1;
|
|
31
|
-
onQuantityChange(traderItem, newQuantity);
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
const onRightClick = () => {
|
|
35
|
-
if (selectedQty < (traderItem.qty ?? 999)) {
|
|
36
|
-
const newQuantity = selectedQty + 1;
|
|
37
|
-
onQuantityChange(traderItem, newQuantity);
|
|
38
|
-
}
|
|
30
|
+
const onLeftClick = (qty = 1) => {
|
|
31
|
+
onQuantityChange(traderItem, Math.max(0, selectedQty - qty));
|
|
39
32
|
};
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
const onRightOutClick = () => {
|
|
47
|
-
if (selectedQty + 10 <= (traderItem.qty ?? 999)) {
|
|
48
|
-
const newQuantity = selectedQty + 10;
|
|
49
|
-
onQuantityChange(traderItem, newQuantity);
|
|
50
|
-
}
|
|
33
|
+
|
|
34
|
+
const onRightClick = (qty = 1) => {
|
|
35
|
+
onQuantityChange(
|
|
36
|
+
traderItem,
|
|
37
|
+
Math.min(traderItem.qty ?? 999, selectedQty + qty)
|
|
38
|
+
);
|
|
51
39
|
};
|
|
52
40
|
|
|
53
41
|
return (
|
|
@@ -85,7 +73,7 @@ export const TradingItemRow: React.FC<ITradeComponentProps> = ({
|
|
|
85
73
|
size={32}
|
|
86
74
|
className="arrow-selector"
|
|
87
75
|
direction="left"
|
|
88
|
-
onPointerDown={
|
|
76
|
+
onPointerDown={onLeftClick.bind(null, outerQty)}
|
|
89
77
|
/>
|
|
90
78
|
<StyledArrow
|
|
91
79
|
size={32}
|
|
@@ -108,7 +96,7 @@ export const TradingItemRow: React.FC<ITradeComponentProps> = ({
|
|
|
108
96
|
size={32}
|
|
109
97
|
className="arrow-selector"
|
|
110
98
|
direction="right"
|
|
111
|
-
onPointerDown={
|
|
99
|
+
onPointerDown={onRightClick.bind(null, outerQty)}
|
|
112
100
|
/>
|
|
113
101
|
</QuantityContainer>
|
|
114
102
|
</ItemWrapper>
|