@rpg-engine/long-bow 0.2.87 → 0.2.89

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.2.87",
3
+ "version": "0.2.89",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -119,6 +119,10 @@ export const EquipmentSet: React.FC<IEquipmentSetProps> = ({
119
119
  if (onSelected) onSelected(optionId);
120
120
  }}
121
121
  onDragStart={(item, slotIndex, itemContainerType) => {
122
+ if (!item) {
123
+ return;
124
+ }
125
+
122
126
  if (onItemDragStart)
123
127
  onItemDragStart(item, slotIndex, itemContainerType);
124
128
  }}
@@ -2,8 +2,8 @@ import React, { useEffect, useRef, useState } from 'react';
2
2
  import styled from 'styled-components';
3
3
  import { Button, ButtonTypes } from '../../Button';
4
4
  import { Input } from '../../Input';
5
- import { RangeSlider, RangeSliderType } from '../../RangeSlider';
6
5
  import { RPGUIContainer, RPGUIContainerTypes } from '../../RPGUIContainer';
6
+ import { RangeSlider, RangeSliderType } from '../../RangeSlider';
7
7
 
8
8
  export interface IItemQuantitySelectorProps {
9
9
  quantity: number;
@@ -74,6 +74,11 @@ export const ItemQuantitySelector: React.FC<IItemQuantitySelectorProps> = ({
74
74
  max={quantity}
75
75
  value={value}
76
76
  onChange={e => {
77
+ if (Number(e.target.value) >= quantity) {
78
+ setValue(quantity);
79
+ return;
80
+ }
81
+
77
82
  setValue((e.target.value as unknown) as number);
78
83
  }}
79
84
  onBlur={e => {
@@ -267,78 +267,82 @@ export const ItemSlot: React.FC<IProps> = observer(
267
267
  ?.dispatchEvent(simulatedEvent);
268
268
  }}
269
269
  >
270
- {item && (
271
- <Draggable
272
- onStop={() => {
273
- if (wasDragged) {
274
- setWasDragged(false);
275
-
276
- const target = dragContainer.current;
277
- if (!target || !wasDragged) return;
278
-
279
- const style = window.getComputedStyle(target);
280
- const matrix = new DOMMatrixReadOnly(style.transform);
281
- const x = matrix.m41;
282
- const y = matrix.m42;
283
-
284
- setDragPosition({ x, y });
285
-
286
- setTimeout(() => {
287
- if (checkIfItemCanBeMoved()) {
288
- if (
289
- item.stackQty &&
290
- item.stackQty !== 1 &&
291
- openQuantitySelector
292
- )
293
- openQuantitySelector(item.stackQty, onSuccesfulDrag);
294
- else onSuccesfulDrag(item.stackQty);
295
- } else {
296
- resetItem();
297
- setDragPosition({ x: 0, y: 0 });
298
- }
299
- }, 100);
300
- } else if (item) {
301
- if (!isContextMenuDisabled)
302
- setIsContextMenuVisible(!isContextMenuVisible);
303
-
304
- onClick(item.type, containerType, item);
305
- }
270
+ <Draggable
271
+ defaultClassName={item ? 'draggable' : 'empty-slot'}
272
+ onStop={() => {
273
+ if (!item) {
274
+ return;
275
+ }
276
+
277
+ if (wasDragged) {
278
+ setWasDragged(false);
279
+
280
+ const target = dragContainer.current;
281
+ if (!target || !wasDragged) return;
282
+
283
+ const style = window.getComputedStyle(target);
284
+ const matrix = new DOMMatrixReadOnly(style.transform);
285
+ const x = matrix.m41;
286
+ const y = matrix.m42;
287
+
288
+ setDragPosition({ x, y });
289
+
290
+ setTimeout(() => {
291
+ if (checkIfItemCanBeMoved()) {
292
+ if (
293
+ item.stackQty &&
294
+ item.stackQty !== 1 &&
295
+ openQuantitySelector
296
+ )
297
+ openQuantitySelector(item.stackQty, onSuccesfulDrag);
298
+ else onSuccesfulDrag(item.stackQty);
299
+ } else {
300
+ resetItem();
301
+ setDragPosition({ x: 0, y: 0 });
302
+ }
303
+ }, 100);
304
+ } else if (item) {
305
+ if (!isContextMenuDisabled)
306
+ setIsContextMenuVisible(!isContextMenuVisible);
307
+
308
+ onClick(item.type, containerType, item);
309
+ }
310
+ }}
311
+ onStart={() => {
312
+ if (!item) {
313
+ return;
314
+ }
315
+
316
+ if (onDragStart) {
317
+ onDragStart(item, slotIndex, containerType);
318
+ }
319
+ }}
320
+ onDrag={() => {
321
+ setWasDragged(true);
322
+ setIsFocused(true);
323
+ }}
324
+ position={dragPosition}
325
+ cancel=".empty-slot"
326
+ >
327
+ <ItemContainer
328
+ ref={dragContainer}
329
+ isFocused={isFocused}
330
+ onMouseOver={event => {
331
+ onMouseOver(event, slotIndex, item, event.clientX, event.clientY);
306
332
  }}
307
- onStart={() => {
308
- if (onDragStart) onDragStart(item, slotIndex, containerType);
333
+ onMouseOut={() => {
334
+ if (onMouseOut) onMouseOut();
309
335
  }}
310
- onDrag={() => {
311
- setWasDragged(true);
312
- setIsFocused(true);
336
+ onMouseEnter={() => {
337
+ setTooltipVisible(true);
338
+ }}
339
+ onMouseLeave={() => {
340
+ setTooltipVisible(false);
313
341
  }}
314
- position={dragPosition}
315
342
  >
316
- <ItemContainer
317
- ref={dragContainer}
318
- isFocused={isFocused}
319
- onMouseOver={event => {
320
- onMouseOver(
321
- event,
322
- slotIndex,
323
- item,
324
- event.clientX,
325
- event.clientY
326
- );
327
- }}
328
- onMouseOut={() => {
329
- if (onMouseOut) onMouseOut();
330
- }}
331
- onMouseEnter={() => {
332
- setTooltipVisible(true);
333
- }}
334
- onMouseLeave={() => {
335
- setTooltipVisible(false);
336
- }}
337
- >
338
- {onRenderSlot(item)}
339
- </ItemContainer>
340
- </Draggable>
341
- )}
343
+ {onRenderSlot(item)}
344
+ </ItemContainer>
345
+ </Draggable>
342
346
 
343
347
  {isTooltipVisible && item && <ItemTooltip label={item.name} />}
344
348