@tanstack/hotkeys 0.6.3 → 0.7.0
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/README.md +1 -0
- package/dist/hotkey-manager.cjs +17 -1
- package/dist/hotkey-manager.cjs.map +1 -1
- package/dist/hotkey-manager.d.cts +29 -2
- package/dist/hotkey-manager.d.ts +29 -2
- package/dist/hotkey-manager.js +18 -3
- package/dist/hotkey-manager.js.map +1 -1
- package/dist/hotkey-recorder.cjs +4 -0
- package/dist/hotkey-recorder.cjs.map +1 -1
- package/dist/hotkey-recorder.d.cts +8 -0
- package/dist/hotkey-recorder.d.ts +8 -0
- package/dist/hotkey-recorder.js +4 -0
- package/dist/hotkey-recorder.js.map +1 -1
- package/dist/hotkey-sequence-recorder.cjs +4 -0
- package/dist/hotkey-sequence-recorder.cjs.map +1 -1
- package/dist/hotkey-sequence-recorder.d.cts +8 -0
- package/dist/hotkey-sequence-recorder.d.ts +8 -0
- package/dist/hotkey-sequence-recorder.js +4 -0
- package/dist/hotkey-sequence-recorder.js.map +1 -1
- package/dist/hotkey.d.cts +22 -3
- package/dist/hotkey.d.ts +22 -3
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -2
- package/dist/manager.utils.cjs +16 -1
- package/dist/manager.utils.cjs.map +1 -1
- package/dist/manager.utils.js +16 -1
- package/dist/manager.utils.js.map +1 -1
- package/dist/sequence-manager.cjs +7 -3
- package/dist/sequence-manager.cjs.map +1 -1
- package/dist/sequence-manager.d.cts +2 -0
- package/dist/sequence-manager.d.ts +2 -0
- package/dist/sequence-manager.js +8 -4
- package/dist/sequence-manager.js.map +1 -1
- package/package.json +1 -1
- package/src/hotkey-manager.ts +44 -7
- package/src/hotkey-recorder.ts +20 -0
- package/src/hotkey-sequence-recorder.ts +20 -0
- package/src/hotkey.ts +22 -2
- package/src/manager.utils.ts +32 -0
- package/src/sequence-manager.ts +11 -9
package/src/sequence-manager.ts
CHANGED
|
@@ -5,11 +5,10 @@ import { isModifierKey, parseHotkey } from './parse'
|
|
|
5
5
|
import { matchesKeyboardEvent } from './match'
|
|
6
6
|
import {
|
|
7
7
|
defaultHotkeyOptions,
|
|
8
|
-
getActiveElementForListenerTarget,
|
|
9
8
|
getDefaultIgnoreInputs,
|
|
10
9
|
handleConflict,
|
|
11
10
|
isEventForTarget,
|
|
12
|
-
|
|
11
|
+
shouldIgnoreInputEvent,
|
|
13
12
|
} from './manager.utils'
|
|
14
13
|
import type { HotkeyOptions } from './hotkey-manager'
|
|
15
14
|
import type {
|
|
@@ -80,6 +79,8 @@ export interface SequenceRegistrationView {
|
|
|
80
79
|
options: SequenceOptions
|
|
81
80
|
target: Target
|
|
82
81
|
triggerCount: number
|
|
82
|
+
/** Whether this sequence has been triggered at least once. */
|
|
83
|
+
hasFired: boolean
|
|
83
84
|
/** Steps matched in the current attempt (0 when idle or just completed). */
|
|
84
85
|
matchedStepCount: number
|
|
85
86
|
/** `Date.now()` when the last step in the current attempt matched; 0 if none. */
|
|
@@ -99,6 +100,7 @@ interface SequenceRegistration {
|
|
|
99
100
|
currentIndex: number
|
|
100
101
|
lastKeyTime: number
|
|
101
102
|
triggerCount: number
|
|
103
|
+
hasFired: boolean
|
|
102
104
|
}
|
|
103
105
|
|
|
104
106
|
/**
|
|
@@ -161,6 +163,7 @@ function toRegistrationView(
|
|
|
161
163
|
options: reg.options,
|
|
162
164
|
target: reg.target,
|
|
163
165
|
triggerCount: reg.triggerCount,
|
|
166
|
+
hasFired: reg.hasFired,
|
|
164
167
|
matchedStepCount: inProgress ? reg.currentIndex : 0,
|
|
165
168
|
partialMatchLastKeyTime: inProgress ? reg.lastKeyTime : 0,
|
|
166
169
|
}
|
|
@@ -285,6 +288,7 @@ export class SequenceManager {
|
|
|
285
288
|
currentIndex: 0,
|
|
286
289
|
lastKeyTime: 0,
|
|
287
290
|
triggerCount: 0,
|
|
291
|
+
hasFired: false,
|
|
288
292
|
}
|
|
289
293
|
|
|
290
294
|
this.#registrations.set(id, registration)
|
|
@@ -446,7 +450,7 @@ export class SequenceManager {
|
|
|
446
450
|
|
|
447
451
|
const now = Date.now()
|
|
448
452
|
|
|
449
|
-
for (const id of targetRegs) {
|
|
453
|
+
registrationIds: for (const id of targetRegs) {
|
|
450
454
|
const registration = this.#registrations.get(id)
|
|
451
455
|
if (!registration) {
|
|
452
456
|
continue
|
|
@@ -462,12 +466,8 @@ export class SequenceManager {
|
|
|
462
466
|
|
|
463
467
|
// Check if we should ignore input elements (defaults to true)
|
|
464
468
|
if (registration.options.ignoreInputs !== false) {
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
(el) => isInputElement(el) && el !== registration.target,
|
|
468
|
-
)
|
|
469
|
-
if (shouldIgnore) {
|
|
470
|
-
continue
|
|
469
|
+
if (shouldIgnoreInputEvent(event, target, registration.target)) {
|
|
470
|
+
continue registrationIds
|
|
471
471
|
}
|
|
472
472
|
}
|
|
473
473
|
|
|
@@ -520,6 +520,7 @@ export class SequenceManager {
|
|
|
520
520
|
}
|
|
521
521
|
|
|
522
522
|
registration.triggerCount++
|
|
523
|
+
registration.hasFired = true
|
|
523
524
|
registration.currentIndex = 0
|
|
524
525
|
|
|
525
526
|
this.#syncRegistrationView(registration)
|
|
@@ -610,6 +611,7 @@ export class SequenceManager {
|
|
|
610
611
|
)
|
|
611
612
|
|
|
612
613
|
registration.triggerCount++
|
|
614
|
+
registration.hasFired = true
|
|
613
615
|
|
|
614
616
|
this.#syncRegistrationView(registration)
|
|
615
617
|
|