@rpg-engine/long-bow 0.8.87 → 0.8.88
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/long-bow.cjs.development.js +51 -35
- 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 +51 -35
- package/dist/long-bow.esm.js.map +1 -1
- package/package.json +2 -2
- package/src/components/DraggableContainer.tsx +12 -10
- package/src/components/RelativeListMenu.tsx +12 -10
- package/src/components/Shortcuts/Shortcuts.tsx +8 -7
- package/src/components/Shortcuts/useShortcutCooldown.ts +33 -12
|
@@ -27191,19 +27191,36 @@ var useShortcutCooldown = function useShortcutCooldown(onShortcutCast) {
|
|
|
27191
27191
|
var _useState = React.useState(0),
|
|
27192
27192
|
shortcutCooldown = _useState[0],
|
|
27193
27193
|
setShortcutCooldown = _useState[1];
|
|
27194
|
-
var
|
|
27195
|
-
var
|
|
27196
|
-
if (
|
|
27194
|
+
var intervalRef = React.useRef(null);
|
|
27195
|
+
var clearCooldownInterval = React.useCallback(function () {
|
|
27196
|
+
if (intervalRef.current) {
|
|
27197
|
+
clearInterval(intervalRef.current);
|
|
27198
|
+
intervalRef.current = null;
|
|
27199
|
+
}
|
|
27200
|
+
}, []);
|
|
27201
|
+
var handleShortcutCast = React.useCallback(function (index) {
|
|
27202
|
+
if (shortcutCooldown <= 0) {
|
|
27203
|
+
setShortcutCooldown(1.5);
|
|
27204
|
+
}
|
|
27197
27205
|
onShortcutCast(index);
|
|
27198
|
-
};
|
|
27206
|
+
}, [shortcutCooldown, onShortcutCast]);
|
|
27199
27207
|
React.useEffect(function () {
|
|
27200
|
-
if (
|
|
27201
|
-
|
|
27202
|
-
|
|
27203
|
-
|
|
27208
|
+
if (shortcutCooldown > 0 && !intervalRef.current) {
|
|
27209
|
+
intervalRef.current = setInterval(function () {
|
|
27210
|
+
setShortcutCooldown(function (prev) {
|
|
27211
|
+
var next = prev - 0.1;
|
|
27212
|
+
if (next <= 0) {
|
|
27213
|
+
clearCooldownInterval();
|
|
27214
|
+
return 0;
|
|
27215
|
+
}
|
|
27216
|
+
return next;
|
|
27217
|
+
});
|
|
27204
27218
|
}, 100);
|
|
27205
27219
|
}
|
|
27206
|
-
|
|
27220
|
+
return function () {
|
|
27221
|
+
clearCooldownInterval();
|
|
27222
|
+
};
|
|
27223
|
+
}, [shortcutCooldown > 0, clearCooldownInterval]);
|
|
27207
27224
|
return {
|
|
27208
27225
|
shortcutCooldown: shortcutCooldown,
|
|
27209
27226
|
handleShortcutCast: handleShortcutCast
|
|
@@ -27458,19 +27475,18 @@ var DraggableContainer = function DraggableContainer(_ref) {
|
|
|
27458
27475
|
height = '100%';
|
|
27459
27476
|
}
|
|
27460
27477
|
useOutsideClick(draggableRef, 'item-container');
|
|
27478
|
+
var handleClickOutside = React.useCallback(function (event) {
|
|
27479
|
+
var e = event;
|
|
27480
|
+
if (e.detail.id === 'item-container') {
|
|
27481
|
+
onOutsideClick == null ? void 0 : onOutsideClick();
|
|
27482
|
+
}
|
|
27483
|
+
}, [onOutsideClick]);
|
|
27461
27484
|
React.useEffect(function () {
|
|
27462
|
-
document.addEventListener('clickOutside',
|
|
27463
|
-
var e = event;
|
|
27464
|
-
if (e.detail.id === 'item-container') {
|
|
27465
|
-
if (onOutsideClick) {
|
|
27466
|
-
onOutsideClick();
|
|
27467
|
-
}
|
|
27468
|
-
}
|
|
27469
|
-
});
|
|
27485
|
+
document.addEventListener('clickOutside', handleClickOutside);
|
|
27470
27486
|
return function () {
|
|
27471
|
-
document.removeEventListener('clickOutside',
|
|
27487
|
+
document.removeEventListener('clickOutside', handleClickOutside);
|
|
27472
27488
|
};
|
|
27473
|
-
}, []);
|
|
27489
|
+
}, [handleClickOutside]);
|
|
27474
27490
|
return React__default.createElement(Draggable, {
|
|
27475
27491
|
cancel: ".container-close,input,button," + cancelDrag,
|
|
27476
27492
|
disabled: dragDisabled,
|
|
@@ -30572,19 +30588,18 @@ var RelativeListMenu = function RelativeListMenu(_ref) {
|
|
|
30572
30588
|
pos = _ref.pos;
|
|
30573
30589
|
var ref = React.useRef(null);
|
|
30574
30590
|
useOutsideClick(ref, 'relative-context-menu');
|
|
30591
|
+
var handleClickOutside = React.useCallback(function (event) {
|
|
30592
|
+
var e = event;
|
|
30593
|
+
if (e.detail.id === 'relative-context-menu') {
|
|
30594
|
+
onOutsideClick == null ? void 0 : onOutsideClick();
|
|
30595
|
+
}
|
|
30596
|
+
}, [onOutsideClick]);
|
|
30575
30597
|
React.useEffect(function () {
|
|
30576
|
-
document.addEventListener('clickOutside',
|
|
30577
|
-
var e = event;
|
|
30578
|
-
if (e.detail.id === 'relative-context-menu') {
|
|
30579
|
-
if (onOutsideClick) {
|
|
30580
|
-
onOutsideClick();
|
|
30581
|
-
}
|
|
30582
|
-
}
|
|
30583
|
-
});
|
|
30598
|
+
document.addEventListener('clickOutside', handleClickOutside);
|
|
30584
30599
|
return function () {
|
|
30585
|
-
document.removeEventListener('clickOutside',
|
|
30600
|
+
document.removeEventListener('clickOutside', handleClickOutside);
|
|
30586
30601
|
};
|
|
30587
|
-
}, []);
|
|
30602
|
+
}, [handleClickOutside]);
|
|
30588
30603
|
return React__default.createElement(ModalPortal, null, React__default.createElement(Container$k, Object.assign({
|
|
30589
30604
|
fontSize: fontSize,
|
|
30590
30605
|
ref: ref
|
|
@@ -36350,6 +36365,8 @@ var Shortcuts = function Shortcuts(_ref) {
|
|
|
36350
36365
|
var _useShortcutCooldown = useShortcutCooldown(onShortcutCast),
|
|
36351
36366
|
handleShortcutCast = _useShortcutCooldown.handleShortcutCast,
|
|
36352
36367
|
shortcutCooldown = _useShortcutCooldown.shortcutCooldown;
|
|
36368
|
+
// Use a Set to track active timeouts - automatically cleaned when they complete
|
|
36369
|
+
var activeTimeouts = React.useRef(new Set());
|
|
36353
36370
|
var handleKeyDown = React.useCallback(function (e) {
|
|
36354
36371
|
if (isBlockedCastingByKeyboard) return;
|
|
36355
36372
|
var shortcutIndex = Number(e.key) - 1;
|
|
@@ -36360,21 +36377,20 @@ var Shortcuts = function Shortcuts(_ref) {
|
|
|
36360
36377
|
var timeoutId = setTimeout(function () {
|
|
36361
36378
|
var _shortcutsRefs$curren2;
|
|
36362
36379
|
(_shortcutsRefs$curren2 = shortcutsRefs.current[shortcutIndex]) == null ? void 0 : _shortcutsRefs$curren2.classList.remove('active');
|
|
36380
|
+
activeTimeouts.current["delete"](timeoutId);
|
|
36363
36381
|
}, 150);
|
|
36364
|
-
|
|
36365
|
-
timeoutIds.current.push(timeoutId);
|
|
36382
|
+
activeTimeouts.current.add(timeoutId);
|
|
36366
36383
|
}
|
|
36367
36384
|
}, [isBlockedCastingByKeyboard, handleShortcutCast]);
|
|
36368
|
-
// Initialize a ref to store the timeout ids
|
|
36369
|
-
var timeoutIds = React.useRef([]);
|
|
36370
36385
|
React.useEffect(function () {
|
|
36371
36386
|
window.addEventListener('keydown', handleKeyDown);
|
|
36372
36387
|
return function () {
|
|
36373
36388
|
window.removeEventListener('keydown', handleKeyDown);
|
|
36374
|
-
// Clear all timeouts when the component unmounts
|
|
36375
|
-
|
|
36389
|
+
// Clear all active timeouts when the component unmounts
|
|
36390
|
+
activeTimeouts.current.forEach(function (id) {
|
|
36376
36391
|
return clearTimeout(id);
|
|
36377
36392
|
});
|
|
36393
|
+
activeTimeouts.current.clear();
|
|
36378
36394
|
};
|
|
36379
36395
|
}, [handleKeyDown]);
|
|
36380
36396
|
return React__default.createElement(List$1, null, Array.from({
|