@tanstack/alpine-hotkeys 0.5.0 → 0.6.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/dist/createHotkeyHint.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { read } from "./scope.js";
|
|
2
|
-
import { getKeyStateTracker, isAppHotkey, matchesHeldModifiers, resolveAppHotkey } from "@tanstack/hotkeys";
|
|
2
|
+
import { getHotkeyManager, getKeyStateTracker, isAppHotkey, matchesHeldModifiers, resolveAppHotkey } from "@tanstack/hotkeys";
|
|
3
3
|
|
|
4
4
|
//#region src/createHotkeyHint.ts
|
|
5
5
|
function createHotkeyHint(scope, hotkey, options = {}) {
|
|
6
|
+
const manager = getHotkeyManager();
|
|
7
|
+
const registrations = scope.select(manager.registrations, (state) => state);
|
|
6
8
|
return scope.select(getKeyStateTracker().store, (state) => {
|
|
7
9
|
const value = read(hotkey);
|
|
8
10
|
const resolved = isAppHotkey(value) ? resolveAppHotkey(value, scope.appHotkeys()).hotkey : value;
|
|
9
|
-
return resolved !== null && matchesHeldModifiers(resolved, state.heldKeys, read(options));
|
|
11
|
+
return resolved !== null && matchesHeldModifiers(resolved, state.heldKeys, read(options)) && registrations.value.size > 0 && manager.hasActiveRegistration(value);
|
|
10
12
|
});
|
|
11
13
|
}
|
|
12
14
|
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { getHotkeyManager } from "@tanstack/hotkeys";
|
|
2
|
+
|
|
3
|
+
//#region src/createHotkeyScopesState.ts
|
|
4
|
+
function createHotkeyScopesState(scope) {
|
|
5
|
+
return scope.select(getHotkeyManager().scopes, (state) => state);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
//#endregion
|
|
9
|
+
export { createHotkeyScopesState };
|
|
@@ -6,6 +6,7 @@ import { createHeldKeyCodes } from "./createHeldKeyCodes.js";
|
|
|
6
6
|
import { createKeyHold } from "./createKeyHold.js";
|
|
7
7
|
import { createHotkeyHint } from "./createHotkeyHint.js";
|
|
8
8
|
import { createHotkeyRegistrations } from "./createHotkeyRegistrations.js";
|
|
9
|
+
import { createHotkeyScopesState } from "./createHotkeyScopesState.js";
|
|
9
10
|
import { createHotkeyRecorder } from "./createHotkeyRecorder.js";
|
|
10
11
|
import { createAppHotkeyList, createAppHotkeys, createCustomHotkeys } from "./createAppHotkeys.js";
|
|
11
12
|
|
|
@@ -25,6 +26,7 @@ function createHotkeysScope(defaultOptions = {}) {
|
|
|
25
26
|
createKeyHold: (...args) => createKeyHold(scope, ...args),
|
|
26
27
|
createHotkeyHint: (...args) => createHotkeyHint(scope, ...args),
|
|
27
28
|
createHotkeyRegistrations: (...args) => createHotkeyRegistrations(scope, ...args),
|
|
29
|
+
createHotkeyScopesState: () => createHotkeyScopesState(scope),
|
|
28
30
|
createHotkeyRecorder: ((options) => createHotkeyRecorder(scope, options)),
|
|
29
31
|
createAppHotkeys: () => createAppHotkeys(scope),
|
|
30
32
|
createAppHotkeyList: () => createAppHotkeyList(scope),
|
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AppHotkey, AppHotkeyListItem, CustomHotkeys, HeldModifierOptions, Hotkey, HotkeyCallback, HotkeyCallbackContextFor, HotkeyChord, HotkeyChordRecorderOptions, HotkeyRecorderOptions, HotkeyRegistrationView, HotkeySequence, HotkeySequenceRecorderOptions, IndividualKey, RegisterableHotkey, RegisteredAppHotkeys, Target } from "@tanstack/hotkeys";
|
|
1
|
+
import { AppHotkey, AppHotkeyListItem, CustomHotkeys, HeldModifierOptions, Hotkey, HotkeyCallback, HotkeyCallbackContextFor, HotkeyChord, HotkeyChordRecorderOptions, HotkeyRecorderOptions, HotkeyRegistrationView, HotkeyScopesState, HotkeySequence, HotkeySequenceRecorderOptions, IndividualKey, RegisterableHotkey, RegisteredAppHotkeys, Target } from "@tanstack/hotkeys";
|
|
2
2
|
import { AdapterAppHotkeyOptions, AdapterCommonOptions, AdapterHotkeyDefinition, AdapterOptionsFor } from "@tanstack/hotkeys/adapter";
|
|
3
3
|
//#region src/types.d.ts
|
|
4
4
|
/** A reactive value. Read `.value` where the framework tracks dependencies. */
|
|
@@ -87,6 +87,8 @@ export interface AlpineHotkeys {
|
|
|
87
87
|
createHotkeyHint: (hotkey: MaybeGetter<RegisterableHotkey | AppHotkey>, options?: MaybeGetter<HeldModifierOptions>) => AlpineHotkeyState<boolean>;
|
|
88
88
|
/** Read live registrations, including disabled entries. */
|
|
89
89
|
createHotkeyRegistrations: () => HotkeyRegistrationsResult;
|
|
90
|
+
/** Read the active, exclusive, allowed, and suspended scopes through `.value`. */
|
|
91
|
+
createHotkeyScopesState: () => AlpineHotkeyState<HotkeyScopesState>;
|
|
90
92
|
/** Create a recorder whose options can follow Alpine state. */
|
|
91
93
|
createHotkeyRecorder: AlpineCreateHotkeyRecorder;
|
|
92
94
|
/** Read the effective app hotkeys from `provideAppHotkeys` through `.value`. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/alpine-hotkeys",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Alpine adapter for TanStack Hotkeys",
|
|
5
5
|
"author": "Tanner Linsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"skills"
|
|
36
36
|
],
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@tanstack/hotkeys": "0.
|
|
38
|
+
"@tanstack/hotkeys": "0.18.0",
|
|
39
39
|
"@tanstack/store": "^0.11.2"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
@@ -69,20 +69,21 @@ For markup-only components, install `Alpine.plugin(hotkeysPlugin)` before `Alpin
|
|
|
69
69
|
|
|
70
70
|
Each owner has these methods. Read their state through `.value`, or `.hotkeys` for registrations.
|
|
71
71
|
|
|
72
|
-
| Method | What it's for
|
|
73
|
-
| -------------------------------------------- |
|
|
74
|
-
| `createHotkey(hotkey, callback, options?)` | Register one chord, sequence, or app hotkey until the owner is destroyed; options can be a getter.
|
|
75
|
-
| `createHotkeys(definitions, commonOptions?)` | Register several hotkeys, or a getter of a list built from data, in one call.
|
|
76
|
-
| `createHotkeyRecorder(options)` | Record a chord or sequence the user presses, for a settings screen.
|
|
77
|
-
| `createAppHotkeys()` | Get the declared app hotkeys with the user's custom hotkeys applied.
|
|
78
|
-
| `createAppHotkeyList()` | List every app hotkey with its status, for a cheat sheet or settings screen.
|
|
79
|
-
| `createCustomHotkeys()` | Read, change, and reset the user's custom hotkeys, and check a new one for conflicts.
|
|
80
|
-
| `createHotkeyRegistrations()` | List every registered hotkey with its options and `
|
|
81
|
-
| `
|
|
82
|
-
| `
|
|
83
|
-
| `
|
|
84
|
-
| `
|
|
85
|
-
| `
|
|
72
|
+
| Method | What it's for |
|
|
73
|
+
| -------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
74
|
+
| `createHotkey(hotkey, callback, options?)` | Register one chord, sequence, or app hotkey until the owner is destroyed; options can be a getter. |
|
|
75
|
+
| `createHotkeys(definitions, commonOptions?)` | Register several hotkeys, or a getter of a list built from data, in one call. |
|
|
76
|
+
| `createHotkeyRecorder(options)` | Record a chord or sequence the user presses, for a settings screen. |
|
|
77
|
+
| `createAppHotkeys()` | Get the declared app hotkeys with the user's custom hotkeys applied. |
|
|
78
|
+
| `createAppHotkeyList()` | List every app hotkey with its status, for a cheat sheet or settings screen. |
|
|
79
|
+
| `createCustomHotkeys()` | Read, change, and reset the user's custom hotkeys, and check a new one for conflicts. |
|
|
80
|
+
| `createHotkeyRegistrations()` | List every registered hotkey with its options, `meta`, and `status` (whether it's enabled and in an active scope). |
|
|
81
|
+
| `createHotkeyScopesState()` | Get the active scopes and the exclusive scope that owns the keyboard. |
|
|
82
|
+
| `createHotkeyHint(hotkey, options?)` | Get whether held modifiers should reveal a shortcut's hint. False unless a registration of the hotkey can fire: enabled, in an active scope, and with focus inside its element target. |
|
|
83
|
+
| `createKeyHold(key)` | Get whether one key is held. |
|
|
84
|
+
| `createHeldKeys()` | Get every key that's held right now. |
|
|
85
|
+
| `createHeldKeyCodes()` | Map each held key to its physical `event.code`. |
|
|
86
|
+
| `destroy()` | Release every hotkey, subscription, and recorder the owner created. |
|
|
86
87
|
|
|
87
88
|
The package also re-exports `@tanstack/hotkeys`, such as `formatForDisplay`, `matchesKeyboardEvent`, and `defineAppHotkeys`.
|
|
88
89
|
|