@tanstack/ember-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/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/useHotkeyHint.d.ts +4 -2
- package/dist/useHotkeyHint.js +8 -4
- package/dist/useHotkeyScopesState.d.ts +10 -0
- package/dist/useHotkeyScopesState.js +15 -0
- package/package.json +2 -2
- package/skills/ember-hotkeys/SKILL.md +19 -18
package/dist/index.d.ts
CHANGED
|
@@ -7,10 +7,11 @@ import { useHeldKeyCodes } from "./useHeldKeyCodes.js";
|
|
|
7
7
|
import { useKeyHold } from "./useKeyHold.js";
|
|
8
8
|
import { useHotkeyHint } from "./useHotkeyHint.js";
|
|
9
9
|
import { useHotkeyRegistrations } from "./useHotkeyRegistrations.js";
|
|
10
|
+
import { useHotkeyScopesState } from "./useHotkeyScopesState.js";
|
|
10
11
|
import { useHotkeyRecorder } from "./useHotkeyRecorder.js";
|
|
11
12
|
import { useAppHotkeyList, useAppHotkeys, useCustomHotkeys } from "./useAppHotkeys.js";
|
|
12
13
|
import { ElementHotkeyOptions, OnHotkeys } from "./onHotkeys.js";
|
|
13
14
|
import { OnHotkey } from "./onHotkey.js";
|
|
14
15
|
import { EmberHotkeysScope, createHotkeysScope } from "./createHotkeysScope.js";
|
|
15
16
|
export * from "@tanstack/hotkeys";
|
|
16
|
-
export { DefaultHotkeysOptions, type ElementHotkeyOptions, EmberAppHotkeyList, EmberCustomHotkeys, EmberHotkeyCommonOptions, EmberHotkeyDefinition, EmberHotkeyRecorder, EmberHotkeyState, EmberHotkeyTarget, EmberHotkeysScope, HotkeyRegistrationsResult, type MaybeGetter, createHotkeysScope, OnHotkey as onHotkey, OnHotkeys as onHotkeys, useAppHotkeyList, useAppHotkeys, useCustomHotkeys, useHeldKeyCodes, useHeldKeys, UseHotkey as useHotkey, useHotkeyHint, useHotkeyRecorder, useHotkeyRegistrations, UseHotkeys as useHotkeys, useKeyHold };
|
|
17
|
+
export { DefaultHotkeysOptions, type ElementHotkeyOptions, EmberAppHotkeyList, EmberCustomHotkeys, EmberHotkeyCommonOptions, EmberHotkeyDefinition, EmberHotkeyRecorder, EmberHotkeyState, EmberHotkeyTarget, EmberHotkeysScope, HotkeyRegistrationsResult, type MaybeGetter, createHotkeysScope, OnHotkey as onHotkey, OnHotkeys as onHotkeys, useAppHotkeyList, useAppHotkeys, useCustomHotkeys, useHeldKeyCodes, useHeldKeys, UseHotkey as useHotkey, useHotkeyHint, useHotkeyRecorder, useHotkeyRegistrations, useHotkeyScopesState, UseHotkeys as useHotkeys, useKeyHold };
|
package/dist/index.js
CHANGED
|
@@ -5,6 +5,7 @@ import { useHeldKeyCodes } from "./useHeldKeyCodes.js";
|
|
|
5
5
|
import { useKeyHold } from "./useKeyHold.js";
|
|
6
6
|
import { useHotkeyHint } from "./useHotkeyHint.js";
|
|
7
7
|
import { useHotkeyRegistrations } from "./useHotkeyRegistrations.js";
|
|
8
|
+
import { useHotkeyScopesState } from "./useHotkeyScopesState.js";
|
|
8
9
|
import { useHotkeyRecorder } from "./useHotkeyRecorder.js";
|
|
9
10
|
import { useAppHotkeyList, useAppHotkeys, useCustomHotkeys } from "./useAppHotkeys.js";
|
|
10
11
|
import { OnHotkey } from "./onHotkey.js";
|
|
@@ -13,4 +14,4 @@ import { createHotkeysScope } from "./createHotkeysScope.js";
|
|
|
13
14
|
|
|
14
15
|
export * from "@tanstack/hotkeys"
|
|
15
16
|
|
|
16
|
-
export { createHotkeysScope, OnHotkey as onHotkey, OnHotkeys as onHotkeys, useAppHotkeyList, useAppHotkeys, useCustomHotkeys, useHeldKeyCodes, useHeldKeys, UseHotkey as useHotkey, useHotkeyHint, useHotkeyRecorder, useHotkeyRegistrations, UseHotkeys as useHotkeys, useKeyHold };
|
|
17
|
+
export { createHotkeysScope, OnHotkey as onHotkey, OnHotkeys as onHotkeys, useAppHotkeyList, useAppHotkeys, useCustomHotkeys, useHeldKeyCodes, useHeldKeys, UseHotkey as useHotkey, useHotkeyHint, useHotkeyRecorder, useHotkeyRegistrations, useHotkeyScopesState, UseHotkeys as useHotkeys, useKeyHold };
|
package/dist/useHotkeyHint.d.ts
CHANGED
|
@@ -4,8 +4,10 @@ import { AppHotkey, HeldModifierOptions, RegisterableHotkey } from "@tanstack/ho
|
|
|
4
4
|
//#region src/useHotkeyHint.d.ts
|
|
5
5
|
/**
|
|
6
6
|
* Recomputes for held modifiers and tracked changes to the hotkey or options.
|
|
7
|
-
*
|
|
8
|
-
*
|
|
7
|
+
* The hint shows only while the hotkey can fire: some registration of it is
|
|
8
|
+
* enabled and in an active scope. A sequence reveals its hint from its first
|
|
9
|
+
* step, and an app hotkey matches its registrations by id and uses its
|
|
10
|
+
* effective hotkey (false while unbound). A hotkey on an element counts only while focus is inside it.
|
|
9
11
|
*/
|
|
10
12
|
export declare function useHotkeyHint(owner: object, hotkey: MaybeGetter<RegisterableHotkey | AppHotkey>, options?: MaybeGetter<HeldModifierOptions>): EmberHotkeyState<boolean>;
|
|
11
13
|
//#endregion
|
package/dist/useHotkeyHint.js
CHANGED
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
import { read, select, trackPublishedAppHotkeys } from "./utils.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/useHotkeyHint.ts
|
|
5
5
|
/**
|
|
6
6
|
* Recomputes for held modifiers and tracked changes to the hotkey or options.
|
|
7
|
-
*
|
|
8
|
-
*
|
|
7
|
+
* The hint shows only while the hotkey can fire: some registration of it is
|
|
8
|
+
* enabled and in an active scope. A sequence reveals its hint from its first
|
|
9
|
+
* step, and an app hotkey matches its registrations by id and uses its
|
|
10
|
+
* effective hotkey (false while unbound). A hotkey on an element counts only while focus is inside it.
|
|
9
11
|
*/
|
|
10
12
|
function useHotkeyHint(owner, hotkey, options = {}) {
|
|
11
13
|
const appHotkeys = trackPublishedAppHotkeys(owner);
|
|
14
|
+
const manager = getHotkeyManager();
|
|
15
|
+
const registrations = select(owner, manager.registrations, (state) => state);
|
|
12
16
|
return select(owner, getKeyStateTracker().store, (state) => {
|
|
13
17
|
const value = read(hotkey);
|
|
14
18
|
const resolved = isAppHotkey(value) ? resolveAppHotkey(value, appHotkeys()).hotkey : value;
|
|
15
|
-
return resolved !== null && matchesHeldModifiers(resolved, state.heldKeys, read(options));
|
|
19
|
+
return resolved !== null && matchesHeldModifiers(resolved, state.heldKeys, read(options)) && registrations.value.size > 0 && manager.hasActiveRegistration(value);
|
|
16
20
|
});
|
|
17
21
|
}
|
|
18
22
|
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { EmberHotkeyState } from "./types.js";
|
|
2
|
+
import { HotkeyScopesState } from "@tanstack/hotkeys";
|
|
3
|
+
//#region src/useHotkeyScopesState.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Reads the hotkey manager's scope state: the active scopes, the exclusive
|
|
6
|
+
* scope that owns the keyboard, and the scopes it allows or suspends. Pass the
|
|
7
|
+
* containing component as owner to release the subscription on destruction.
|
|
8
|
+
*/
|
|
9
|
+
export declare function useHotkeyScopesState(owner: object): EmberHotkeyState<HotkeyScopesState>;
|
|
10
|
+
//#endregion
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { select } from "./utils.js";
|
|
2
|
+
import { getHotkeyManager } from "@tanstack/hotkeys";
|
|
3
|
+
|
|
4
|
+
//#region src/useHotkeyScopesState.ts
|
|
5
|
+
/**
|
|
6
|
+
* Reads the hotkey manager's scope state: the active scopes, the exclusive
|
|
7
|
+
* scope that owns the keyboard, and the scopes it allows or suspends. Pass the
|
|
8
|
+
* containing component as owner to release the subscription on destruction.
|
|
9
|
+
*/
|
|
10
|
+
function useHotkeyScopesState(owner) {
|
|
11
|
+
return select(owner, getHotkeyManager().scopes, (state) => state);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
export { useHotkeyScopesState };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/ember-hotkeys",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Ember adapter for TanStack Hotkeys",
|
|
5
5
|
"author": "Tanner Linsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
],
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@embroider/addon-shim": "^1.10.3",
|
|
43
|
-
"@tanstack/hotkeys": "0.
|
|
43
|
+
"@tanstack/hotkeys": "0.18.0",
|
|
44
44
|
"@tanstack/store": "^0.11.2",
|
|
45
45
|
"ember-modifier": "4.2.2"
|
|
46
46
|
},
|
|
@@ -54,24 +54,25 @@ export default class Editor extends Component {
|
|
|
54
54
|
|
|
55
55
|
## API
|
|
56
56
|
|
|
57
|
-
| API | What it's for
|
|
58
|
-
| --------------------------------------------------- |
|
|
59
|
-
| `{{useHotkey hotkey callback ...options}}` | Register one chord, sequence, or app hotkey while the template renders the helper.
|
|
60
|
-
| `{{useHotkeys definitions}}` | Register several hotkeys, or a list built from data, in one helper.
|
|
61
|
-
| `{{onHotkey hotkey callback ...options}}` | Attach a hotkey to the element the modifier is on, so it fires while focus is inside that element.
|
|
62
|
-
| `{{onHotkeys definitions}}` | Attach several hotkeys to one element.
|
|
63
|
-
| `createHotkeysScope(defaults?)` | Create `useHotkey`, `useHotkeys`, `onHotkey`, `onHotkeys`, and `useHotkeyRecorder` that share default options.
|
|
64
|
-
| `provideAppHotkeys(appHotkeys, options?)` | Declare app hotkeys and load the user's custom hotkeys before the app boots, since Ember has no provider.
|
|
65
|
-
| `getHotkeyManager().activateScope(scope, options?)` | Turn on a scope, such as an exclusive one for a dialog; it returns the function that turns the scope off.
|
|
66
|
-
| `useAppHotkeys(this)` | Get the declared app hotkeys with the user's custom hotkeys applied.
|
|
67
|
-
| `useAppHotkeyList(this)` | List every app hotkey with its status, for a cheat sheet or settings screen.
|
|
68
|
-
| `useCustomHotkeys(this)` | Read, change, and reset the user's custom hotkeys, and check a new one for conflicts.
|
|
69
|
-
| `useHotkeyRecorder(this, options)` | Record a chord or sequence the user presses, for a settings screen.
|
|
70
|
-
| `useHotkeyRegistrations(this)` | Read `.hotkeys`, every registered hotkey with its options and `
|
|
71
|
-
| `
|
|
72
|
-
| `
|
|
73
|
-
| `
|
|
74
|
-
| `
|
|
57
|
+
| API | What it's for |
|
|
58
|
+
| --------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
59
|
+
| `{{useHotkey hotkey callback ...options}}` | Register one chord, sequence, or app hotkey while the template renders the helper. |
|
|
60
|
+
| `{{useHotkeys definitions}}` | Register several hotkeys, or a list built from data, in one helper. |
|
|
61
|
+
| `{{onHotkey hotkey callback ...options}}` | Attach a hotkey to the element the modifier is on, so it fires while focus is inside that element. |
|
|
62
|
+
| `{{onHotkeys definitions}}` | Attach several hotkeys to one element. |
|
|
63
|
+
| `createHotkeysScope(defaults?)` | Create `useHotkey`, `useHotkeys`, `onHotkey`, `onHotkeys`, and `useHotkeyRecorder` that share default options. |
|
|
64
|
+
| `provideAppHotkeys(appHotkeys, options?)` | Declare app hotkeys and load the user's custom hotkeys before the app boots, since Ember has no provider. |
|
|
65
|
+
| `getHotkeyManager().activateScope(scope, options?)` | Turn on a scope, such as an exclusive one for a dialog; it returns the function that turns the scope off. |
|
|
66
|
+
| `useAppHotkeys(this)` | Get the declared app hotkeys with the user's custom hotkeys applied. |
|
|
67
|
+
| `useAppHotkeyList(this)` | List every app hotkey with its status, for a cheat sheet or settings screen. |
|
|
68
|
+
| `useCustomHotkeys(this)` | Read, change, and reset the user's custom hotkeys, and check a new one for conflicts. |
|
|
69
|
+
| `useHotkeyRecorder(this, options)` | Record a chord or sequence the user presses, for a settings screen. |
|
|
70
|
+
| `useHotkeyRegistrations(this)` | Read `.hotkeys`, every registered hotkey with its options, `meta`, and `status` (whether it's enabled and in an active scope). |
|
|
71
|
+
| `useHotkeyScopesState(this)` | Get the active scopes and the exclusive scope that owns the keyboard. |
|
|
72
|
+
| `useHotkeyHint(this, 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. |
|
|
73
|
+
| `useKeyHold(this, key)` | Get whether one key is held. |
|
|
74
|
+
| `useHeldKeys(this)` | Get every key that's held right now. |
|
|
75
|
+
| `useHeldKeyCodes(this)` | Map each held key to its physical `event.code`. |
|
|
75
76
|
|
|
76
77
|
The package also re-exports `@tanstack/hotkeys`, such as `formatForDisplay`, `matchesKeyboardEvent`, and `defineAppHotkeys`.
|
|
77
78
|
|