@rpg-engine/long-bow 0.8.9 → 0.8.10

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.
@@ -31177,7 +31177,7 @@ var ItemContainer$1 = /*#__PURE__*/React.memo(function (_ref) {
31177
31177
  onItemDragEnd = _ref.onItemDragEnd,
31178
31178
  onItemDragStart = _ref.onItemDragStart,
31179
31179
  onItemPlaceDrop = _ref.onItemPlaceDrop,
31180
- _onOutsideDrop = _ref.onOutsideDrop,
31180
+ onOutsideDrop = _ref.onOutsideDrop,
31181
31181
  checkIfItemCanBeMoved = _ref.checkIfItemCanBeMoved,
31182
31182
  initialPosition = _ref.initialPosition,
31183
31183
  checkIfItemShouldDragEnd = _ref.checkIfItemShouldDragEnd,
@@ -31242,12 +31242,49 @@ var ItemContainer$1 = /*#__PURE__*/React.memo(function (_ref) {
31242
31242
  }
31243
31243
  onDragEndScrollingEvents();
31244
31244
  }, [onItemDragEnd, onDragEndScrollingEvents]);
31245
- // Memoize handleSetShortcut to prevent unnecessary re-renders
31246
- var memoizedHandleSetShortcut = useCallback(function (item, index) {
31247
- handleSetShortcut(item, index);
31248
- }, [handleSetShortcut]);
31249
- // Memoize onRenderSlots to prevent re-creating the slots array on every render
31250
- var onRenderSlots = useMemo(function () {
31245
+ var handleItemClick = useCallback(function (itemType, containerType, item) {
31246
+ if (settingShortcutIndex !== -1) {
31247
+ setSettingShortcutIndex(-1);
31248
+ handleSetShortcut(item, settingShortcutIndex);
31249
+ } else if (onItemClick) {
31250
+ onItemClick(item, itemType, containerType);
31251
+ }
31252
+ }, [settingShortcutIndex, handleSetShortcut, onItemClick]);
31253
+ var handlePlaceDrop = useCallback(function (item, slotIndex, itemContainerType) {
31254
+ if (onItemPlaceDrop) {
31255
+ onItemPlaceDrop(item, slotIndex, itemContainerType);
31256
+ }
31257
+ onDragEndScrollingEvents();
31258
+ }, [onItemPlaceDrop, onDragEndScrollingEvents]);
31259
+ var handleOutsideDrop = useCallback(function (item, position) {
31260
+ if (onOutsideDrop) {
31261
+ onOutsideDrop(item, position);
31262
+ }
31263
+ onDragEndScrollingEvents();
31264
+ }, [onOutsideDrop, onDragEndScrollingEvents]);
31265
+ var handleQuantitySelect = useCallback(function (maxQuantity, callback) {
31266
+ setQuantitySelect({
31267
+ isOpen: true,
31268
+ maxQuantity: maxQuantity,
31269
+ callback: callback
31270
+ });
31271
+ }, []);
31272
+ // Memoize slot rendering configuration
31273
+ var slotConfig = useMemo(function () {
31274
+ return {
31275
+ type: type,
31276
+ atlasIMG: atlasIMG,
31277
+ atlasJSON: atlasJSON,
31278
+ scale: scale,
31279
+ equipmentSet: equipmentSet,
31280
+ isDepotSystem: isDepotSystem,
31281
+ isSelectingShortcut: settingShortcutIndex !== -1,
31282
+ checkIfItemCanBeMoved: checkIfItemCanBeMoved,
31283
+ checkIfItemShouldDragEnd: checkIfItemShouldDragEnd
31284
+ };
31285
+ }, [type, atlasIMG, atlasJSON, scale, equipmentSet, isDepotSystem, settingShortcutIndex, checkIfItemCanBeMoved, checkIfItemShouldDragEnd]);
31286
+ // Memoize slots rendering
31287
+ var renderSlots = useMemo(function () {
31251
31288
  var slots = [];
31252
31289
  for (var i = 0; i < itemContainer.slotQty; i++) {
31253
31290
  var _itemContainer$slots;
@@ -31256,55 +31293,27 @@ var ItemContainer$1 = /*#__PURE__*/React.memo(function (_ref) {
31256
31293
  key: i,
31257
31294
  slotIndex: i,
31258
31295
  item: currentItem,
31259
- itemContainerType: type,
31260
- onMouseOver: onMouseOver ? function (event, slotIndex, item) {
31261
- return onMouseOver(event, slotIndex, item);
31262
- } : undefined,
31263
- onMouseOut: undefined,
31264
- onPointerDown: function onPointerDown(itemType, containerType, item) {
31265
- if (settingShortcutIndex !== -1) {
31266
- setSettingShortcutIndex(-1);
31267
- memoizedHandleSetShortcut(item, settingShortcutIndex);
31268
- } else if (onItemClick) {
31269
- onItemClick(item, itemType, containerType);
31270
- }
31271
- },
31296
+ itemContainerType: slotConfig.type,
31297
+ onMouseOver: onMouseOver,
31298
+ onPointerDown: handleItemClick,
31272
31299
  onDragStart: onDragStartHandler,
31273
31300
  onDragEnd: onDragEndHandler,
31274
- dragScale: scale,
31275
- checkIfItemCanBeMoved: checkIfItemCanBeMoved,
31276
- checkIfItemShouldDragEnd: checkIfItemShouldDragEnd,
31277
- openQuantitySelector: function openQuantitySelector(maxQuantity, callback) {
31278
- setQuantitySelect({
31279
- isOpen: true,
31280
- maxQuantity: maxQuantity,
31281
- callback: callback
31282
- });
31283
- },
31284
- onPlaceDrop: function onPlaceDrop(item, slotIndex, itemContainerType) {
31285
- if (onItemPlaceDrop) {
31286
- onItemPlaceDrop(item, slotIndex, itemContainerType);
31287
- }
31288
- console.log('PLACE DROP');
31289
- onDragEndScrollingEvents();
31290
- },
31291
- onOutsideDrop: function onOutsideDrop(item, position) {
31292
- if (_onOutsideDrop) {
31293
- _onOutsideDrop(item, position);
31294
- }
31295
- console.log('OUTSIDE DROP');
31296
- onDragEndScrollingEvents();
31297
- },
31298
- atlasIMG: atlasIMG,
31299
- atlasJSON: atlasJSON,
31300
- isSelectingShortcut: settingShortcutIndex !== -1,
31301
- equipmentSet: equipmentSet,
31302
- setItemShortcut: type === ItemContainerType.Inventory ? memoizedHandleSetShortcut : undefined,
31303
- isDepotSystem: isDepotSystem
31301
+ dragScale: slotConfig.scale,
31302
+ checkIfItemCanBeMoved: slotConfig.checkIfItemCanBeMoved,
31303
+ checkIfItemShouldDragEnd: slotConfig.checkIfItemShouldDragEnd,
31304
+ openQuantitySelector: handleQuantitySelect,
31305
+ onPlaceDrop: handlePlaceDrop,
31306
+ onOutsideDrop: handleOutsideDrop,
31307
+ atlasIMG: slotConfig.atlasIMG,
31308
+ atlasJSON: slotConfig.atlasJSON,
31309
+ isSelectingShortcut: slotConfig.isSelectingShortcut,
31310
+ equipmentSet: slotConfig.equipmentSet,
31311
+ setItemShortcut: type === ItemContainerType.Inventory ? handleSetShortcut : undefined,
31312
+ isDepotSystem: slotConfig.isDepotSystem
31304
31313
  }));
31305
31314
  }
31306
31315
  return slots;
31307
- }, [itemContainer.slotQty, itemContainer.slots, type, onMouseOver, settingShortcutIndex, memoizedHandleSetShortcut, onItemClick, onDragStartHandler, onDragEndHandler, scale, checkIfItemCanBeMoved, checkIfItemShouldDragEnd, onItemPlaceDrop, _onOutsideDrop, atlasIMG, atlasJSON, equipmentSet, isDepotSystem, onDragEndScrollingEvents]);
31316
+ }, [itemContainer.slotQty, itemContainer.slots, slotConfig, onMouseOver, handleItemClick, onDragStartHandler, onDragEndHandler, handleQuantitySelect, handlePlaceDrop, handleOutsideDrop, handleSetShortcut, type]);
31308
31317
  return React.createElement(ItemSlotDraggingProvider, null, React.createElement(ItemSlotDetailsProvider, null, React.createElement(DraggedItem, {
31309
31318
  atlasIMG: atlasIMG,
31310
31319
  atlasJSON: atlasJSON,
@@ -31330,7 +31339,7 @@ var ItemContainer$1 = /*#__PURE__*/React.memo(function (_ref) {
31330
31339
  ref: containerRef,
31331
31340
  isScrollable: itemContainer.slotQty > MIN_SLOTS_FOR_SCROLL,
31332
31341
  isFullScreen: isFullScreen
31333
- }, onRenderSlots)), quantitySelect.isOpen && React.createElement(ItemQuantitySelectorModal, {
31342
+ }, renderSlots)), quantitySelect.isOpen && React.createElement(ItemQuantitySelectorModal, {
31334
31343
  quantitySelect: quantitySelect,
31335
31344
  setQuantitySelect: setQuantitySelect
31336
31345
  }), React.createElement(ItemSlotToolTips, {