@rpg-engine/long-bow 0.5.24 → 0.5.27
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/components/Item/Inventory/DraggedItem.d.ts +2 -1
- package/dist/components/shared/ScalableContainer.d.ts +7 -0
- package/dist/constants/uiBreakpoints.d.ts +2 -0
- package/dist/hooks/useCursorPosition.d.ts +5 -5
- package/dist/long-bow.cjs.development.js +49 -21
- 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 +50 -22
- package/dist/long-bow.esm.js.map +1 -1
- package/dist/stories/ItemContainer.stories.d.ts +2 -0
- package/package.json +2 -2
- package/src/components/Equipment/EquipmentSet.tsx +1 -1
- package/src/components/Item/Inventory/DraggedItem.tsx +10 -1
- package/src/components/Item/Inventory/ItemContainer.tsx +1 -1
- package/src/components/Item/Inventory/ItemSlot.tsx +2 -2
- package/src/components/Spellbook/constants.ts +1 -1
- package/src/components/shared/ScalableContainer.tsx +22 -0
- package/src/constants/uiBreakpoints.ts +3 -0
- package/src/hooks/useCursorPosition.ts +41 -16
- package/src/stories/ItemContainer.stories.tsx +94 -70
package/dist/long-bow.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { Component, useState, useEffect, useRef, useContext, createContext, useMemo, Fragment } from 'react';
|
|
1
|
+
import React, { Component, useState, useEffect, useRef, useContext, createContext, useMemo, useCallback, Fragment } from 'react';
|
|
2
2
|
import styled from 'styled-components';
|
|
3
3
|
import { GRID_WIDTH, GRID_HEIGHT, ShortcutType, getItemTextureKeyPath, ItemContainerType, ItemType, DepotSocketEvents, ItemSocketEvents, ItemSocketEventsDisplayLabels, ActionsForInventory, ActionsForEquipmentSet, ActionsForLoot, ActionsForMapContainer, ItemRarities, ItemSubType, ItemSlotType, isMobileOrTablet, CharacterClass, getSPForLevel, getXPForLevel, PeriodOfDay, UserAccountTypes } from '@rpg-engine/shared';
|
|
4
4
|
import dayjs from 'dayjs';
|
|
@@ -13982,8 +13982,8 @@ var ItemSlot = /*#__PURE__*/observer(function (_ref) {
|
|
|
13982
13982
|
if (!item || isSelectingShortcut) {
|
|
13983
13983
|
return;
|
|
13984
13984
|
}
|
|
13985
|
-
setDraggingItem(item);
|
|
13986
13985
|
if (onDragStart && containerType) {
|
|
13986
|
+
setDraggingItem(item);
|
|
13987
13987
|
onDragStart(item, slotIndex, containerType);
|
|
13988
13988
|
}
|
|
13989
13989
|
},
|
|
@@ -14752,34 +14752,54 @@ var Details = /*#__PURE__*/styled.p.withConfig({
|
|
|
14752
14752
|
componentId: "sc-kaa0h9-0"
|
|
14753
14753
|
})(["font-size:", " !important;"], uiFonts.size.xsmall);
|
|
14754
14754
|
|
|
14755
|
-
var useCursorPosition = function useCursorPosition() {
|
|
14755
|
+
var useCursorPosition = function useCursorPosition(_ref) {
|
|
14756
|
+
var _ref$scale = _ref.scale,
|
|
14757
|
+
scale = _ref$scale === void 0 ? 1 : _ref$scale;
|
|
14756
14758
|
var _useState = useState({
|
|
14757
14759
|
x: 0,
|
|
14758
14760
|
y: 0
|
|
14759
14761
|
}),
|
|
14760
14762
|
position = _useState[0],
|
|
14761
14763
|
setPosition = _useState[1];
|
|
14762
|
-
var
|
|
14764
|
+
var scalePosition = useCallback(function (x, y) {
|
|
14765
|
+
return {
|
|
14766
|
+
x: (x - GRID_WIDTH / 2) / scale + GRID_WIDTH / 2,
|
|
14767
|
+
y: (y - GRID_HEIGHT / 2) / scale + GRID_HEIGHT / 2
|
|
14768
|
+
};
|
|
14769
|
+
}, [scale]);
|
|
14770
|
+
var setFromEvent = useCallback(function (e) {
|
|
14771
|
+
var x, y;
|
|
14763
14772
|
if ('touches' in e) {
|
|
14764
|
-
|
|
14765
|
-
|
|
14766
|
-
y: e.touches[0].clientY
|
|
14767
|
-
});
|
|
14773
|
+
x = e.touches[0].clientX;
|
|
14774
|
+
y = e.touches[0].clientY;
|
|
14768
14775
|
} else {
|
|
14769
|
-
|
|
14770
|
-
|
|
14771
|
-
y: e.clientY
|
|
14772
|
-
});
|
|
14776
|
+
x = e.clientX;
|
|
14777
|
+
y = e.clientY;
|
|
14773
14778
|
}
|
|
14774
|
-
|
|
14779
|
+
var scaledPosition = scalePosition(x, y);
|
|
14780
|
+
setPosition(scaledPosition);
|
|
14781
|
+
}, [scale, scalePosition]);
|
|
14782
|
+
var cleanup = useCallback(function () {
|
|
14783
|
+
setPosition({
|
|
14784
|
+
x: 0,
|
|
14785
|
+
y: 0
|
|
14786
|
+
});
|
|
14787
|
+
}, []);
|
|
14775
14788
|
useEffect(function () {
|
|
14776
|
-
|
|
14777
|
-
|
|
14789
|
+
var handleEvent = function handleEvent(e) {
|
|
14790
|
+
return setFromEvent(e);
|
|
14791
|
+
};
|
|
14792
|
+
window.addEventListener('mousemove', handleEvent);
|
|
14793
|
+
window.addEventListener('touchmove', handleEvent);
|
|
14794
|
+
window.addEventListener('mouseup', cleanup);
|
|
14795
|
+
window.addEventListener('touchend', cleanup);
|
|
14778
14796
|
return function () {
|
|
14779
|
-
window.removeEventListener('mousemove',
|
|
14780
|
-
window.removeEventListener('touchmove',
|
|
14797
|
+
window.removeEventListener('mousemove', handleEvent);
|
|
14798
|
+
window.removeEventListener('touchmove', handleEvent);
|
|
14799
|
+
window.removeEventListener('mouseup', cleanup);
|
|
14800
|
+
window.removeEventListener('touchend', cleanup);
|
|
14781
14801
|
};
|
|
14782
|
-
}, []);
|
|
14802
|
+
}, [setFromEvent, cleanup]);
|
|
14783
14803
|
return position;
|
|
14784
14804
|
};
|
|
14785
14805
|
|
|
@@ -14788,15 +14808,21 @@ var OFFSET = CONTAINER_SIZE / 2;
|
|
|
14788
14808
|
var DraggedItem = function DraggedItem(_ref) {
|
|
14789
14809
|
var _item$_id, _item$stackQty;
|
|
14790
14810
|
var atlasJSON = _ref.atlasJSON,
|
|
14791
|
-
atlasIMG = _ref.atlasIMG
|
|
14811
|
+
atlasIMG = _ref.atlasIMG,
|
|
14812
|
+
scale = _ref.scale;
|
|
14792
14813
|
var _useDragging = useDragging(),
|
|
14793
14814
|
item = _useDragging.item;
|
|
14794
|
-
var _useCursorPosition = useCursorPosition(
|
|
14815
|
+
var _useCursorPosition = useCursorPosition({
|
|
14816
|
+
scale: scale
|
|
14817
|
+
}),
|
|
14795
14818
|
x = _useCursorPosition.x,
|
|
14796
14819
|
y = _useCursorPosition.y;
|
|
14797
14820
|
if (!item) {
|
|
14798
14821
|
return null;
|
|
14799
14822
|
}
|
|
14823
|
+
if (x === 0 && y === 0) {
|
|
14824
|
+
return null;
|
|
14825
|
+
}
|
|
14800
14826
|
var centeredX = x - OFFSET;
|
|
14801
14827
|
var centeredY = y - OFFSET;
|
|
14802
14828
|
var stackInfo = onRenderStackInfo((_item$_id = item == null ? void 0 : item._id) != null ? _item$_id : '', (_item$stackQty = item == null ? void 0 : item.stackQty) != null ? _item$stackQty : 0);
|
|
@@ -14912,7 +14938,8 @@ var EquipmentSet = function EquipmentSet(_ref) {
|
|
|
14912
14938
|
};
|
|
14913
14939
|
return React.createElement(DraggingProvider, null, React.createElement(DraggedItem, {
|
|
14914
14940
|
atlasIMG: atlasIMG,
|
|
14915
|
-
atlasJSON: atlasJSON
|
|
14941
|
+
atlasJSON: atlasJSON,
|
|
14942
|
+
scale: scale
|
|
14916
14943
|
}), React.createElement(DraggableContainer, {
|
|
14917
14944
|
title: 'Equipments',
|
|
14918
14945
|
type: RPGUIContainerTypes.Framed,
|
|
@@ -15992,7 +16019,8 @@ var ItemContainer$1 = function ItemContainer(_ref) {
|
|
|
15992
16019
|
};
|
|
15993
16020
|
return React.createElement(DraggingProvider, null, React.createElement(DraggedItem, {
|
|
15994
16021
|
atlasIMG: atlasIMG,
|
|
15995
|
-
atlasJSON: atlasJSON
|
|
16022
|
+
atlasJSON: atlasJSON,
|
|
16023
|
+
scale: scale
|
|
15996
16024
|
}), React.createElement(SlotsContainer, {
|
|
15997
16025
|
title: itemContainer.name || 'Container',
|
|
15998
16026
|
onClose: onClose,
|