@rpg-engine/long-bow 0.7.79 → 0.7.81

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rpg-engine/long-bow",
3
- "version": "0.7.79",
3
+ "version": "0.7.81",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -153,7 +153,7 @@ export const ItemSlot: React.FC<IProps> = observer(
153
153
 
154
154
  const {
155
155
  isContextMenuVisible,
156
-
156
+ clearDetailsState,
157
157
  clearContextActions,
158
158
  } = detailsState;
159
159
 
@@ -165,12 +165,7 @@ export const ItemSlot: React.FC<IProps> = observer(
165
165
  clearDraggingState,
166
166
  } = useItemSlotDragging();
167
167
 
168
- const {
169
- isFocused,
170
- dropPosition,
171
- isDragging,
172
- draggingDistance,
173
- } = draggingState;
168
+ const { isFocused, isDragging, draggingDistance } = draggingState;
174
169
 
175
170
  useEffect(() => {
176
171
  // Reset drag position and focus when item changes
@@ -187,18 +182,25 @@ export const ItemSlot: React.FC<IProps> = observer(
187
182
  ]);
188
183
 
189
184
  useEffect(() => {
190
- // Handle outside drop
191
- if (onDrop && item && dropPosition) {
192
- onDrop(item, dropPosition);
193
- }
194
- }, [dropPosition, onDrop, item]);
185
+ // Reset drag position and focus when item changes
186
+ clearDraggingState();
187
+
188
+ // Clear context actions when component unmounts or dependencies change
189
+ return () => {
190
+ clearContextActions();
191
+ };
192
+ }, [
193
+ containerType,
194
+ isDepotSystem,
195
+ setContextActions,
196
+ clearContextActions,
197
+ isContextMenuDisabled,
198
+ updateDraggingState, // Add this dependency
199
+ ]);
195
200
 
196
201
  const resetItem = () => {
197
202
  clearDraggingState();
198
- updateDetailsState({
199
- item,
200
- isTooltipVisible: false,
201
- });
203
+ clearDetailsState();
202
204
  };
203
205
 
204
206
  const onSuccessfulDrag = (quantity?: number) => {
@@ -324,27 +326,31 @@ export const ItemSlot: React.FC<IProps> = observer(
324
326
  return { x: matrix.m41, y: matrix.m42 };
325
327
  };
326
328
 
327
- /**
328
- * Processes the end of a drag event, handling quantity selection or resetting state.
329
- */
330
- const processDragEnd = (item: IItem) => {
331
- if (checkIfItemCanBeMoved?.()) {
332
- if (checkIfItemShouldDragEnd && !checkIfItemShouldDragEnd()) return;
333
-
334
- if (item.stackQty && item.stackQty !== 1 && openQuantitySelector) {
335
- openQuantitySelector(item.stackQty, onSuccessfulDrag);
329
+ const processDragEnd = useCallback(
330
+ (item: IItem) => {
331
+ if (checkIfItemCanBeMoved?.()) {
332
+ if (checkIfItemShouldDragEnd && !checkIfItemShouldDragEnd()) {
333
+ resetItem();
334
+ return;
335
+ }
336
+
337
+ if (item.stackQty && item.stackQty !== 1 && openQuantitySelector) {
338
+ openQuantitySelector(item.stackQty, onSuccessfulDrag);
339
+ } else {
340
+ onSuccessfulDrag(item.stackQty);
341
+ }
336
342
  } else {
337
- onSuccessfulDrag(item.stackQty);
343
+ resetItem();
338
344
  }
339
- } else {
340
- resetItem();
341
-
342
- updateDraggingState({
343
- isFocused: false,
344
- position: { x: 0, y: 0 },
345
- });
346
- }
347
- };
345
+ },
346
+ [
347
+ checkIfItemCanBeMoved,
348
+ checkIfItemShouldDragEnd,
349
+ openQuantitySelector,
350
+ onSuccessfulDrag,
351
+ resetItem,
352
+ ]
353
+ );
348
354
 
349
355
  /**
350
356
  * Handles the context menu or tooltip display after dragging stops without a drop.