@rpg-engine/long-bow 0.2.89 → 0.2.91
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/Equipment/EquipmentSet.d.ts +2 -0
- package/dist/components/Item/Inventory/ItemContainer.d.ts +2 -0
- package/dist/components/Item/Inventory/ItemSlot.d.ts +2 -0
- package/dist/long-bow.cjs.development.js +35 -8
- 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 +35 -8
- package/dist/long-bow.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Equipment/EquipmentSet.tsx +6 -0
- package/src/components/Item/Inventory/ItemContainer.tsx +6 -0
- package/src/components/Item/Inventory/ItemSlot.tsx +28 -6
- package/src/stories/EquipmentSet.stories.tsx +6 -0
- package/src/stories/ItemContainer.stories.tsx +1 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { IEquipmentSet, IItem, ItemContainerType, ItemType } from '@rpg-engine/shared';
|
|
2
2
|
import React from 'react';
|
|
3
|
+
import { IPosition } from '../../types/eventTypes';
|
|
3
4
|
export interface IEquipmentSetProps {
|
|
4
5
|
equipmentSet: IEquipmentSet;
|
|
5
6
|
onClose?: () => void;
|
|
@@ -7,6 +8,7 @@ export interface IEquipmentSetProps {
|
|
|
7
8
|
onItemDragStart?: (item: IItem, slotIndex: number, itemContainerType: ItemContainerType | null) => void;
|
|
8
9
|
onItemDragEnd?: (quantity?: number) => void;
|
|
9
10
|
onItemPlaceDrop?: (item: IItem | null, slotIndex: number, itemContainerType: ItemContainerType | null) => void;
|
|
11
|
+
onItemOutsideDrop?: (item: IItem, position: IPosition) => void;
|
|
10
12
|
checkIfItemCanBeMoved: () => boolean;
|
|
11
13
|
onMouseOver?: (e: any, slotIndex: number, item: IItem | null) => void;
|
|
12
14
|
onSelected?: (optionId: string) => void;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { IItem, IItemContainer, ItemContainerType } from '@rpg-engine/shared';
|
|
2
2
|
import React from 'react';
|
|
3
|
+
import { IPosition } from '../../../types/eventTypes';
|
|
3
4
|
export interface IItemContainerProps {
|
|
4
5
|
itemContainer: IItemContainer;
|
|
5
6
|
onClose?: () => void;
|
|
6
7
|
onItemClick?: (item: IItem, ItemType: IItem['type'], itemContainerType: ItemContainerType | null) => void;
|
|
7
8
|
onItemDragStart?: (item: IItem, slotIndex: number, itemContainerType: ItemContainerType | null) => void;
|
|
8
9
|
onItemDragEnd?: (quantity?: number) => void;
|
|
10
|
+
onOutsideDrop?: (item: IItem, position: IPosition) => void;
|
|
9
11
|
onItemPlaceDrop?: (item: IItem | null, slotIndex: number, itemContainerType: ItemContainerType | null) => void;
|
|
10
12
|
checkIfItemCanBeMoved: () => boolean;
|
|
11
13
|
onMouseOver?: (e: any, slotIndex: number, item: IItem | null) => void;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { IItem, IItemContainer, ItemContainerType, ItemSlotType, ItemType } from '@rpg-engine/shared';
|
|
2
2
|
import React from 'react';
|
|
3
|
+
import { IPosition } from '../../../types/eventTypes';
|
|
3
4
|
interface IProps {
|
|
4
5
|
slotIndex: number;
|
|
5
6
|
item: IItem | null;
|
|
@@ -12,6 +13,7 @@ interface IProps {
|
|
|
12
13
|
onClick: (ItemType: ItemType, itemContainerType: ItemContainerType | null, item: IItem) => void;
|
|
13
14
|
onDragStart: (item: IItem, slotIndex: number, itemContainerType: ItemContainerType | null) => void;
|
|
14
15
|
onDragEnd: (quantity?: number) => void;
|
|
16
|
+
onOutsideDrop?: (item: IItem, position: IPosition) => void;
|
|
15
17
|
checkIfItemCanBeMoved: () => boolean;
|
|
16
18
|
openQuantitySelector?: (maxQuantity: number, callback: () => void) => void;
|
|
17
19
|
onPlaceDrop: (item: IItem | null, slotIndex: number, itemContainerType: ItemContainerType | null) => void;
|
|
@@ -33482,6 +33482,7 @@ var ItemSlot = /*#__PURE__*/mobxReactLite.observer(function (_ref) {
|
|
|
33482
33482
|
onDragEnd = _ref.onDragEnd,
|
|
33483
33483
|
onDragStart = _ref.onDragStart,
|
|
33484
33484
|
onPlaceDrop = _ref.onPlaceDrop,
|
|
33485
|
+
onDrop = _ref.onOutsideDrop,
|
|
33485
33486
|
checkIfItemCanBeMoved = _ref.checkIfItemCanBeMoved,
|
|
33486
33487
|
openQuantitySelector = _ref.openQuantitySelector;
|
|
33487
33488
|
var _useState = React.useState(false),
|
|
@@ -33502,10 +33503,13 @@ var ItemSlot = /*#__PURE__*/mobxReactLite.observer(function (_ref) {
|
|
|
33502
33503
|
}),
|
|
33503
33504
|
dragPosition = _useState5[0],
|
|
33504
33505
|
setDragPosition = _useState5[1];
|
|
33506
|
+
var _useState6 = React.useState(null),
|
|
33507
|
+
dropPosition = _useState6[0],
|
|
33508
|
+
setDropPosition = _useState6[1];
|
|
33505
33509
|
var dragContainer = React.useRef(null);
|
|
33506
|
-
var
|
|
33507
|
-
contextActions =
|
|
33508
|
-
setContextActions =
|
|
33510
|
+
var _useState7 = React.useState([]),
|
|
33511
|
+
contextActions = _useState7[0],
|
|
33512
|
+
setContextActions = _useState7[1];
|
|
33509
33513
|
React.useEffect(function () {
|
|
33510
33514
|
setDragPosition({
|
|
33511
33515
|
x: 0,
|
|
@@ -33515,6 +33519,11 @@ var ItemSlot = /*#__PURE__*/mobxReactLite.observer(function (_ref) {
|
|
|
33515
33519
|
setContextActions(generateContextMenu(item, containerType));
|
|
33516
33520
|
}
|
|
33517
33521
|
}, [item]);
|
|
33522
|
+
React.useEffect(function () {
|
|
33523
|
+
if (onDrop && item && dropPosition) {
|
|
33524
|
+
onDrop(item, dropPosition);
|
|
33525
|
+
}
|
|
33526
|
+
}, [dropPosition]);
|
|
33518
33527
|
var getStackInfo = function getStackInfo(itemId, stackQty) {
|
|
33519
33528
|
// if (itemToRender?.isStackable && itemToRender?.stackQty) {
|
|
33520
33529
|
var isFractionalStackQty = stackQty % 1 !== 0;
|
|
@@ -33637,11 +33646,21 @@ var ItemSlot = /*#__PURE__*/mobxReactLite.observer(function (_ref) {
|
|
|
33637
33646
|
}
|
|
33638
33647
|
}, React__default.createElement(Draggable, {
|
|
33639
33648
|
defaultClassName: item ? 'draggable' : 'empty-slot',
|
|
33640
|
-
onStop: function onStop() {
|
|
33641
|
-
if (
|
|
33642
|
-
|
|
33643
|
-
|
|
33644
|
-
|
|
33649
|
+
onStop: function onStop(e, data) {
|
|
33650
|
+
if (wasDragged && item) {
|
|
33651
|
+
var _e$target;
|
|
33652
|
+
//@ts-ignore
|
|
33653
|
+
var classes = Array.from((_e$target = e.target) == null ? void 0 : _e$target.classList);
|
|
33654
|
+
var isOutsideDrop = classes.some(function (elm) {
|
|
33655
|
+
//elm matches ItemContainer string
|
|
33656
|
+
return elm.includes('rpgui-content');
|
|
33657
|
+
});
|
|
33658
|
+
if (isOutsideDrop) {
|
|
33659
|
+
setDropPosition({
|
|
33660
|
+
x: data.x,
|
|
33661
|
+
y: data.y
|
|
33662
|
+
});
|
|
33663
|
+
}
|
|
33645
33664
|
setWasDragged(false);
|
|
33646
33665
|
var target = dragContainer.current;
|
|
33647
33666
|
if (!target || !wasDragged) return;
|
|
@@ -33743,6 +33762,7 @@ var EquipmentSet = function EquipmentSet(_ref) {
|
|
|
33743
33762
|
onItemDragEnd = _ref.onItemDragEnd,
|
|
33744
33763
|
onItemDragStart = _ref.onItemDragStart,
|
|
33745
33764
|
onItemPlaceDrop = _ref.onItemPlaceDrop,
|
|
33765
|
+
onItemOutsideDrop = _ref.onItemOutsideDrop,
|
|
33746
33766
|
checkIfItemCanBeMoved = _ref.checkIfItemCanBeMoved;
|
|
33747
33767
|
var neck = equipmentSet.neck,
|
|
33748
33768
|
leftHand = equipmentSet.leftHand,
|
|
@@ -33792,6 +33812,9 @@ var EquipmentSet = function EquipmentSet(_ref) {
|
|
|
33792
33812
|
onPlaceDrop: function onPlaceDrop(item, slotIndex, itemContainerType) {
|
|
33793
33813
|
if (onItemPlaceDrop) onItemPlaceDrop(item, slotIndex, itemContainerType);
|
|
33794
33814
|
},
|
|
33815
|
+
onOutsideDrop: function onOutsideDrop(item, position) {
|
|
33816
|
+
if (onItemOutsideDrop) onItemOutsideDrop(item, position);
|
|
33817
|
+
},
|
|
33795
33818
|
atlasIMG: atlasIMG,
|
|
33796
33819
|
atlasJSON: atlasJSON
|
|
33797
33820
|
});
|
|
@@ -34559,6 +34582,7 @@ var ItemContainer$1 = function ItemContainer(_ref) {
|
|
|
34559
34582
|
onItemDragEnd = _ref.onItemDragEnd,
|
|
34560
34583
|
onItemDragStart = _ref.onItemDragStart,
|
|
34561
34584
|
onItemPlaceDrop = _ref.onItemPlaceDrop,
|
|
34585
|
+
_onOutsideDrop = _ref.onOutsideDrop,
|
|
34562
34586
|
checkIfItemCanBeMoved = _ref.checkIfItemCanBeMoved,
|
|
34563
34587
|
initialPosition = _ref.initialPosition;
|
|
34564
34588
|
var _useState = React.useState({
|
|
@@ -34604,6 +34628,9 @@ var ItemContainer$1 = function ItemContainer(_ref) {
|
|
|
34604
34628
|
onPlaceDrop: function onPlaceDrop(item, slotIndex, itemContainerType) {
|
|
34605
34629
|
if (onItemPlaceDrop) onItemPlaceDrop(item, slotIndex, itemContainerType);
|
|
34606
34630
|
},
|
|
34631
|
+
onOutsideDrop: function onOutsideDrop(item, position) {
|
|
34632
|
+
if (_onOutsideDrop) _onOutsideDrop(item, position);
|
|
34633
|
+
},
|
|
34607
34634
|
atlasIMG: atlasIMG,
|
|
34608
34635
|
atlasJSON: atlasJSON
|
|
34609
34636
|
}));
|