@rpg-engine/long-bow 0.5.28 → 0.5.30
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/ItemSlot.d.ts +0 -1
- package/dist/components/Item/Inventory/ItemSlotRarity.d.ts +2 -0
- package/dist/hooks/useTapAndHold.d.ts +10 -0
- package/dist/long-bow.cjs.development.js +108 -105
- 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 +110 -106
- package/dist/long-bow.esm.js.map +1 -1
- package/dist/stories/ItemContainer.stories.d.ts +0 -1
- package/package.json +1 -1
- package/src/components/Item/Cards/ItemInfo.tsx +2 -1
- package/src/components/Item/Inventory/ItemSlot.tsx +110 -128
- package/src/components/Item/Inventory/ItemSlotRarity.ts +17 -0
- package/src/components/Item/Inventory/ItemSlotRenderer.tsx +8 -8
- package/src/components/Marketplace/MarketplaceRows.tsx +1 -1
- package/src/hooks/useTapAndHold.ts +30 -0
- package/src/stories/ItemContainer.stories.tsx +0 -6
package/dist/long-bow.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { Component, useState, useEffect, useRef, useContext, createContext, useMemo, useCallback, Fragment } from 'react';
|
|
2
2
|
import styled from 'styled-components';
|
|
3
|
-
import { GRID_WIDTH, GRID_HEIGHT, ShortcutType, getItemTextureKeyPath, ItemContainerType, ItemType, DepotSocketEvents, ItemSocketEvents, ItemSocketEventsDisplayLabels, ActionsForInventory, ActionsForEquipmentSet, ActionsForLoot, ActionsForMapContainer,
|
|
3
|
+
import { GRID_WIDTH, GRID_HEIGHT, ShortcutType, getItemTextureKeyPath, ItemRarities, ItemContainerType, ItemType, DepotSocketEvents, ItemSocketEvents, ItemSocketEventsDisplayLabels, ActionsForInventory, ActionsForEquipmentSet, ActionsForLoot, ActionsForMapContainer, ItemSubType, ItemSlotType, isMobileOrTablet, CharacterClass, getSPForLevel, getXPForLevel, PeriodOfDay, UserAccountTypes } from '@rpg-engine/shared';
|
|
4
4
|
import dayjs from 'dayjs';
|
|
5
5
|
import { ErrorBoundary as ErrorBoundary$1 } from 'react-error-boundary';
|
|
6
6
|
import { RxPaperPlane, RxMagnifyingGlass } from 'react-icons/rx';
|
|
@@ -13386,6 +13386,21 @@ var Container$7 = /*#__PURE__*/styled.div.withConfig({
|
|
|
13386
13386
|
componentId: "sc-dgmp04-0"
|
|
13387
13387
|
})(["position:static !important;"]);
|
|
13388
13388
|
|
|
13389
|
+
var rarityColor = function rarityColor(item) {
|
|
13390
|
+
switch (item == null ? void 0 : item.rarity) {
|
|
13391
|
+
case ItemRarities.Uncommon:
|
|
13392
|
+
return 'rgba(13, 193, 13, 0.6)';
|
|
13393
|
+
case ItemRarities.Rare:
|
|
13394
|
+
return 'rgba(8, 104, 187, 0.6)';
|
|
13395
|
+
case ItemRarities.Epic:
|
|
13396
|
+
return 'rgba(191, 0, 255, 0.6)';
|
|
13397
|
+
case ItemRarities.Legendary:
|
|
13398
|
+
return 'rgba(255, 191, 0,0.6)';
|
|
13399
|
+
default:
|
|
13400
|
+
return null;
|
|
13401
|
+
}
|
|
13402
|
+
};
|
|
13403
|
+
|
|
13389
13404
|
var onRenderStackInfo = function onRenderStackInfo(itemId, stackQty) {
|
|
13390
13405
|
var isFractionalStackQty = stackQty % 1 !== 0;
|
|
13391
13406
|
var isLargerThan999 = stackQty > 999;
|
|
@@ -13430,25 +13445,25 @@ var ItemSlotRenderer = function ItemSlotRenderer(_ref) {
|
|
|
13430
13445
|
atlasIMG = _ref.atlasIMG,
|
|
13431
13446
|
slotSpriteMask = _ref.slotSpriteMask,
|
|
13432
13447
|
item = _ref.item;
|
|
13433
|
-
var renderItem = function renderItem(
|
|
13434
|
-
var
|
|
13435
|
-
if (!(
|
|
13448
|
+
var renderItem = function renderItem(item) {
|
|
13449
|
+
var _item$stackQty;
|
|
13450
|
+
if (!(item != null && item.texturePath)) {
|
|
13436
13451
|
return null;
|
|
13437
13452
|
}
|
|
13438
13453
|
return React.createElement(ErrorBoundary, {
|
|
13439
|
-
key:
|
|
13454
|
+
key: item._id
|
|
13440
13455
|
}, React.createElement(SpriteFromAtlas, {
|
|
13441
13456
|
atlasIMG: atlasIMG,
|
|
13442
13457
|
atlasJSON: atlasJSON,
|
|
13443
13458
|
spriteKey: getItemTextureKeyPath({
|
|
13444
|
-
key:
|
|
13445
|
-
texturePath:
|
|
13446
|
-
stackQty:
|
|
13447
|
-
isStackable:
|
|
13459
|
+
key: item.texturePath,
|
|
13460
|
+
texturePath: item.texturePath,
|
|
13461
|
+
stackQty: item.stackQty || 1,
|
|
13462
|
+
isStackable: item.isStackable
|
|
13448
13463
|
}, atlasJSON),
|
|
13449
13464
|
imgScale: 3,
|
|
13450
13465
|
imgClassname: "sprite-from-atlas-img--item"
|
|
13451
|
-
}), onRenderStackInfo(
|
|
13466
|
+
}), onRenderStackInfo(item._id, (_item$stackQty = item.stackQty) != null ? _item$stackQty : 0));
|
|
13452
13467
|
};
|
|
13453
13468
|
var renderEquipment = function renderEquipment(itemToRender) {
|
|
13454
13469
|
var _itemToRender$allowed;
|
|
@@ -13881,6 +13896,86 @@ var ItemSlot = /*#__PURE__*/observer(function (_ref) {
|
|
|
13881
13896
|
onDragEnd == null ? void 0 : onDragEnd(quantity);
|
|
13882
13897
|
}
|
|
13883
13898
|
};
|
|
13899
|
+
var onDraggableStop = function onDraggableStop(e, data) {
|
|
13900
|
+
setDraggingItem(null);
|
|
13901
|
+
var target = e.target;
|
|
13902
|
+
if (target != null && target.id.includes('shortcutSetter') && setItemShortcut && item) {
|
|
13903
|
+
var index = parseInt(target.id.split('_')[1]);
|
|
13904
|
+
if (!isNaN(index)) {
|
|
13905
|
+
setItemShortcut(item, index);
|
|
13906
|
+
}
|
|
13907
|
+
}
|
|
13908
|
+
if (wasDragged && item && !isSelectingShortcut) {
|
|
13909
|
+
var _e$target;
|
|
13910
|
+
//@ts-ignore
|
|
13911
|
+
var classes = Array.from((_e$target = e.target) == null ? void 0 : _e$target.classList);
|
|
13912
|
+
var isOutsideDrop = classes.some(function (elm) {
|
|
13913
|
+
return elm.includes('rpgui-content');
|
|
13914
|
+
}) || classes.length === 0;
|
|
13915
|
+
if (isOutsideDrop) {
|
|
13916
|
+
setDropPosition({
|
|
13917
|
+
x: data.x,
|
|
13918
|
+
y: data.y
|
|
13919
|
+
});
|
|
13920
|
+
}
|
|
13921
|
+
setWasDragged(false);
|
|
13922
|
+
var _target = dragContainer.current;
|
|
13923
|
+
if (!_target || !wasDragged) return;
|
|
13924
|
+
var style = window.getComputedStyle(_target);
|
|
13925
|
+
var matrix = new DOMMatrixReadOnly(style.transform);
|
|
13926
|
+
var x = matrix.m41;
|
|
13927
|
+
var y = matrix.m42;
|
|
13928
|
+
setDragPosition({
|
|
13929
|
+
x: x,
|
|
13930
|
+
y: y
|
|
13931
|
+
});
|
|
13932
|
+
setTimeout(function () {
|
|
13933
|
+
if (checkIfItemCanBeMoved != null && checkIfItemCanBeMoved()) {
|
|
13934
|
+
if (checkIfItemShouldDragEnd && !checkIfItemShouldDragEnd()) return;
|
|
13935
|
+
if (item.stackQty && item.stackQty !== 1 && openQuantitySelector) openQuantitySelector(item.stackQty, onSuccessfulDrag);else onSuccessfulDrag(item.stackQty);
|
|
13936
|
+
} else {
|
|
13937
|
+
resetItem();
|
|
13938
|
+
setIsFocused(false);
|
|
13939
|
+
setDragPosition({
|
|
13940
|
+
x: 0,
|
|
13941
|
+
y: 0
|
|
13942
|
+
});
|
|
13943
|
+
}
|
|
13944
|
+
}, 50);
|
|
13945
|
+
} else if (item) {
|
|
13946
|
+
var isTouch = false;
|
|
13947
|
+
if (!isContextMenuDisabled && e.type === 'touchend' && !isSelectingShortcut) {
|
|
13948
|
+
isTouch = true;
|
|
13949
|
+
setIsTooltipMobileVisible(true);
|
|
13950
|
+
}
|
|
13951
|
+
if (!isContextMenuDisabled && !isSelectingShortcut && !isTouch) {
|
|
13952
|
+
setIsContextMenuVisible(!isContextMenuVisible);
|
|
13953
|
+
var event = e;
|
|
13954
|
+
if (event.clientX && event.clientY) {
|
|
13955
|
+
setContextMenuPosition({
|
|
13956
|
+
x: event.clientX - 10,
|
|
13957
|
+
y: event.clientY - 5
|
|
13958
|
+
});
|
|
13959
|
+
}
|
|
13960
|
+
}
|
|
13961
|
+
onPointerDown(item.type, containerType != null ? containerType : null, item);
|
|
13962
|
+
}
|
|
13963
|
+
};
|
|
13964
|
+
var onDraggableStart = function onDraggableStart() {
|
|
13965
|
+
if (!item || isSelectingShortcut) {
|
|
13966
|
+
return;
|
|
13967
|
+
}
|
|
13968
|
+
if (onDragStart && containerType) {
|
|
13969
|
+
setDraggingItem(item);
|
|
13970
|
+
onDragStart(item, slotIndex, containerType);
|
|
13971
|
+
}
|
|
13972
|
+
};
|
|
13973
|
+
var onDraggableProgress = function onDraggableProgress(_e, data) {
|
|
13974
|
+
if (Math.abs(data.x - dragPosition.x) > 5 || Math.abs(data.y - dragPosition.y) > 5) {
|
|
13975
|
+
setWasDragged(true);
|
|
13976
|
+
setIsFocused(true);
|
|
13977
|
+
}
|
|
13978
|
+
};
|
|
13884
13979
|
return React.createElement(Container$a, {
|
|
13885
13980
|
item: item,
|
|
13886
13981
|
className: "rpgui-icon empty-slot",
|
|
@@ -13909,86 +14004,9 @@ var ItemSlot = /*#__PURE__*/observer(function (_ref) {
|
|
|
13909
14004
|
defaultClassName: item ? 'draggable' : 'empty-slot',
|
|
13910
14005
|
scale: dragScale,
|
|
13911
14006
|
disabled: onDragStart === undefined || onDragEnd === undefined,
|
|
13912
|
-
onStop:
|
|
13913
|
-
|
|
13914
|
-
|
|
13915
|
-
if (target != null && target.id.includes('shortcutSetter') && setItemShortcut && item) {
|
|
13916
|
-
var index = parseInt(target.id.split('_')[1]);
|
|
13917
|
-
if (!isNaN(index)) {
|
|
13918
|
-
setItemShortcut(item, index);
|
|
13919
|
-
}
|
|
13920
|
-
}
|
|
13921
|
-
if (wasDragged && item && !isSelectingShortcut) {
|
|
13922
|
-
var _e$target;
|
|
13923
|
-
//@ts-ignore
|
|
13924
|
-
var classes = Array.from((_e$target = e.target) == null ? void 0 : _e$target.classList);
|
|
13925
|
-
var isOutsideDrop = classes.some(function (elm) {
|
|
13926
|
-
return elm.includes('rpgui-content');
|
|
13927
|
-
}) || classes.length === 0;
|
|
13928
|
-
if (isOutsideDrop) {
|
|
13929
|
-
setDropPosition({
|
|
13930
|
-
x: data.x,
|
|
13931
|
-
y: data.y
|
|
13932
|
-
});
|
|
13933
|
-
}
|
|
13934
|
-
setWasDragged(false);
|
|
13935
|
-
var _target = dragContainer.current;
|
|
13936
|
-
if (!_target || !wasDragged) return;
|
|
13937
|
-
var style = window.getComputedStyle(_target);
|
|
13938
|
-
var matrix = new DOMMatrixReadOnly(style.transform);
|
|
13939
|
-
var x = matrix.m41;
|
|
13940
|
-
var y = matrix.m42;
|
|
13941
|
-
setDragPosition({
|
|
13942
|
-
x: x,
|
|
13943
|
-
y: y
|
|
13944
|
-
});
|
|
13945
|
-
setTimeout(function () {
|
|
13946
|
-
if (checkIfItemCanBeMoved != null && checkIfItemCanBeMoved()) {
|
|
13947
|
-
if (checkIfItemShouldDragEnd && !checkIfItemShouldDragEnd()) return;
|
|
13948
|
-
if (item.stackQty && item.stackQty !== 1 && openQuantitySelector) openQuantitySelector(item.stackQty, onSuccessfulDrag);else onSuccessfulDrag(item.stackQty);
|
|
13949
|
-
} else {
|
|
13950
|
-
resetItem();
|
|
13951
|
-
setIsFocused(false);
|
|
13952
|
-
setDragPosition({
|
|
13953
|
-
x: 0,
|
|
13954
|
-
y: 0
|
|
13955
|
-
});
|
|
13956
|
-
}
|
|
13957
|
-
}, 50);
|
|
13958
|
-
} else if (item) {
|
|
13959
|
-
var isTouch = false;
|
|
13960
|
-
if (!isContextMenuDisabled && e.type === 'touchend' && !isSelectingShortcut) {
|
|
13961
|
-
isTouch = true;
|
|
13962
|
-
setIsTooltipMobileVisible(true);
|
|
13963
|
-
}
|
|
13964
|
-
if (!isContextMenuDisabled && !isSelectingShortcut && !isTouch) {
|
|
13965
|
-
setIsContextMenuVisible(!isContextMenuVisible);
|
|
13966
|
-
var event = e;
|
|
13967
|
-
if (event.clientX && event.clientY) {
|
|
13968
|
-
setContextMenuPosition({
|
|
13969
|
-
x: event.clientX - 10,
|
|
13970
|
-
y: event.clientY - 5
|
|
13971
|
-
});
|
|
13972
|
-
}
|
|
13973
|
-
}
|
|
13974
|
-
onPointerDown(item.type, containerType != null ? containerType : null, item);
|
|
13975
|
-
}
|
|
13976
|
-
},
|
|
13977
|
-
onStart: function onStart() {
|
|
13978
|
-
if (!item || isSelectingShortcut) {
|
|
13979
|
-
return;
|
|
13980
|
-
}
|
|
13981
|
-
if (onDragStart && containerType) {
|
|
13982
|
-
setDraggingItem(item);
|
|
13983
|
-
onDragStart(item, slotIndex, containerType);
|
|
13984
|
-
}
|
|
13985
|
-
},
|
|
13986
|
-
onDrag: function onDrag(_e, data) {
|
|
13987
|
-
if (Math.abs(data.x - dragPosition.x) > 5 || Math.abs(data.y - dragPosition.y) > 5) {
|
|
13988
|
-
setWasDragged(true);
|
|
13989
|
-
setIsFocused(true);
|
|
13990
|
-
}
|
|
13991
|
-
},
|
|
14007
|
+
onStop: onDraggableStop,
|
|
14008
|
+
onStart: onDraggableStart,
|
|
14009
|
+
onDrag: onDraggableProgress,
|
|
13992
14010
|
position: dragPosition,
|
|
13993
14011
|
cancel: ".empty-slot"
|
|
13994
14012
|
}, React.createElement(ItemContainer, {
|
|
@@ -14034,24 +14052,10 @@ var ItemSlot = /*#__PURE__*/observer(function (_ref) {
|
|
|
14034
14052
|
setIsTooltipVisible: setTooltipVisible
|
|
14035
14053
|
}));
|
|
14036
14054
|
});
|
|
14037
|
-
var rarityColor = function rarityColor(item) {
|
|
14038
|
-
switch (item == null ? void 0 : item.rarity) {
|
|
14039
|
-
case ItemRarities.Uncommon:
|
|
14040
|
-
return 'rgba(13, 193, 13, 0.6)';
|
|
14041
|
-
case ItemRarities.Rare:
|
|
14042
|
-
return 'rgba(8, 104, 187, 0.6)';
|
|
14043
|
-
case ItemRarities.Epic:
|
|
14044
|
-
return 'rgba(191, 0, 255, 0.6)';
|
|
14045
|
-
case ItemRarities.Legendary:
|
|
14046
|
-
return 'rgba(255, 191, 0,0.6)';
|
|
14047
|
-
default:
|
|
14048
|
-
return null;
|
|
14049
|
-
}
|
|
14050
|
-
};
|
|
14051
14055
|
var Container$a = /*#__PURE__*/styled.div.withConfig({
|
|
14052
14056
|
displayName: "ItemSlot__Container",
|
|
14053
14057
|
componentId: "sc-l2j5ef-0"
|
|
14054
|
-
})(["margin:0.1rem;.react-draggable-dragging{
|
|
14058
|
+
})(["margin:0.1rem;.react-draggable-dragging{opacity:0;}position:relative;.sprite-from-atlas-img--item{position:relative;top:1.5rem;left:1.5rem;border-color:", ";box-shadow:", " inset,", ";}&::before{content:'';position:absolute;top:0;left:0;width:100%;height:100%;z-index:1;border-radius:12px;pointer-events:none;animation:", ";@keyframes bg-color-change{0%{background-color:rgba(255 255 255 / 0.5);}50%{background-color:transparent;}100%{background-color:rgba(255 255 255 / 0.5);}}}"], function (_ref2) {
|
|
14055
14059
|
var item = _ref2.item;
|
|
14056
14060
|
return rarityColor(item);
|
|
14057
14061
|
}, function (_ref3) {
|
|
@@ -18682,5 +18686,5 @@ var ButtonWrapper$3 = /*#__PURE__*/styled.div.withConfig({
|
|
|
18682
18686
|
componentId: "sc-gptoxp-5"
|
|
18683
18687
|
})(["display:flex;justify-content:space-around;padding-top:20px;width:100%;"]);
|
|
18684
18688
|
|
|
18685
|
-
export { Button, ButtonTypes, CharacterSelection, Chat, ChatDeprecated, ChatRevamp, CheckButton, CircularController, CraftBook, DraggableContainer, Dropdown, DropdownSelectorContainer, DynamicText, EquipmentSet, EquipmentSlotSpriteByType, ErrorBoundary, HistoryDialog, ImageCarousel, ImgSide, Input, InputRadio$1 as InputRadio, ItemContainer$1 as ItemContainer, ItemSelector, ItemSlot, Leaderboard, ListMenu, Marketplace, MarketplaceRows, NPCDialog, NPCDialogType, NPCMultiDialog, PartyCreate, PartyDashboard, PartyInvite, PartyManager, PartyManagerRow, PartyRow, PlayersRow, ProgressBar, PropertySelect, QuestInfo, QuestList, QuestionDialog, RPGUIContainer, RPGUIContainerTypes, RPGUIRoot, RangeSlider, RangeSliderType, Shortcuts, SkillProgressBar, SkillsContainer, Spellbook, SpriteFromAtlas, TextArea, TimeWidget, TradingMenu, Truncate, _RPGUI, mockedPartyManager, mockedPartyRows, mockedPlayersRows, mockedPlayersRows2,
|
|
18689
|
+
export { Button, ButtonTypes, CharacterSelection, Chat, ChatDeprecated, ChatRevamp, CheckButton, CircularController, CraftBook, DraggableContainer, Dropdown, DropdownSelectorContainer, DynamicText, EquipmentSet, EquipmentSlotSpriteByType, ErrorBoundary, HistoryDialog, ImageCarousel, ImgSide, Input, InputRadio$1 as InputRadio, ItemContainer$1 as ItemContainer, ItemSelector, ItemSlot, Leaderboard, ListMenu, Marketplace, MarketplaceRows, NPCDialog, NPCDialogType, NPCMultiDialog, PartyCreate, PartyDashboard, PartyInvite, PartyManager, PartyManagerRow, PartyRow, PlayersRow, ProgressBar, PropertySelect, QuestInfo, QuestList, QuestionDialog, RPGUIContainer, RPGUIContainerTypes, RPGUIRoot, RangeSlider, RangeSliderType, Shortcuts, SkillProgressBar, SkillsContainer, Spellbook, SpriteFromAtlas, TextArea, TimeWidget, TradingMenu, Truncate, _RPGUI, mockedPartyManager, mockedPartyRows, mockedPlayersRows, mockedPlayersRows2, useEventListener };
|
|
18686
18690
|
//# sourceMappingURL=long-bow.esm.js.map
|