@tanstack/ember-hotkeys 0.7.0 → 0.8.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/bindings.js +1 -0
- package/dist/createHotkeysScope.js +6 -20
- package/dist/onHotkey.d.ts +7 -3
- package/dist/onHotkey.js +5 -1
- package/dist/useHotkey.d.ts +3 -2
- package/dist/useHotkey.js +1 -0
- package/dist/useHotkeyHint.d.ts +3 -2
- package/dist/useHotkeyHint.js +2 -1
- package/package.json +2 -2
package/dist/bindings.js
CHANGED
|
@@ -6,6 +6,7 @@ import { createHotkeyBindings, prepareHotkeyDefinitions, subscribePublishedAppHo
|
|
|
6
6
|
//#region src/bindings.ts
|
|
7
7
|
/** Copies a hotkey so tracked getters are read while Ember tracks the caller. */
|
|
8
8
|
function copyHotkey(hotkey) {
|
|
9
|
+
if (hotkey == null) return hotkey;
|
|
9
10
|
if (typeof hotkey === "string" || isAppHotkey(hotkey)) return hotkey;
|
|
10
11
|
if (isHotkeySequence(hotkey)) return [...hotkey];
|
|
11
12
|
return { ...hotkey };
|
|
@@ -4,6 +4,7 @@ import { read } from "./utils.js";
|
|
|
4
4
|
import { useHotkeyRecorder } from "./useHotkeyRecorder.js";
|
|
5
5
|
import { OnHotkey } from "./onHotkey.js";
|
|
6
6
|
import { OnHotkeys } from "./onHotkeys.js";
|
|
7
|
+
import { definedOptions, withDefaults } from "@tanstack/hotkeys/adapter";
|
|
7
8
|
|
|
8
9
|
//#region src/createHotkeysScope.ts
|
|
9
10
|
/**
|
|
@@ -14,40 +15,25 @@ function createHotkeysScope(defaultOptions = {}) {
|
|
|
14
15
|
return {
|
|
15
16
|
onHotkey: class extends OnHotkey {
|
|
16
17
|
modify(...[element, args, options]) {
|
|
17
|
-
super.modify(element, args, {
|
|
18
|
-
...read(defaultOptions).hotkey,
|
|
19
|
-
...options
|
|
20
|
-
});
|
|
18
|
+
super.modify(element, args, { ...definedOptions(read(defaultOptions).hotkey, options) });
|
|
21
19
|
}
|
|
22
20
|
},
|
|
23
21
|
onHotkeys: class extends OnHotkeys {
|
|
24
22
|
modify(...[element, args, options]) {
|
|
25
|
-
super.modify(element, args, {
|
|
26
|
-
...read(defaultOptions).hotkey,
|
|
27
|
-
...options
|
|
28
|
-
});
|
|
23
|
+
super.modify(element, args, { ...definedOptions(read(defaultOptions).hotkey, options) });
|
|
29
24
|
}
|
|
30
25
|
},
|
|
31
26
|
useHotkey: class extends UseHotkey {
|
|
32
27
|
compute(...[args, options]) {
|
|
33
|
-
super.compute(args, {
|
|
34
|
-
...read(defaultOptions).hotkey,
|
|
35
|
-
...options
|
|
36
|
-
});
|
|
28
|
+
super.compute(args, { ...definedOptions(read(defaultOptions).hotkey, options) });
|
|
37
29
|
}
|
|
38
30
|
},
|
|
39
31
|
useHotkeys: class extends UseHotkeys {
|
|
40
32
|
compute(...[args, options]) {
|
|
41
|
-
super.compute(args, {
|
|
42
|
-
...read(defaultOptions).hotkey,
|
|
43
|
-
...options
|
|
44
|
-
});
|
|
33
|
+
super.compute(args, { ...definedOptions(read(defaultOptions).hotkey, options) });
|
|
45
34
|
}
|
|
46
35
|
},
|
|
47
|
-
useHotkeyRecorder: ((owner, options) => useHotkeyRecorder(owner, () => (
|
|
48
|
-
...read(defaultOptions).hotkeyRecorder,
|
|
49
|
-
...read(options)
|
|
50
|
-
})))
|
|
36
|
+
useHotkeyRecorder: ((owner, options) => useHotkeyRecorder(owner, () => withDefaults(read(defaultOptions).hotkeyRecorder, read(options))))
|
|
51
37
|
};
|
|
52
38
|
}
|
|
53
39
|
|
package/dist/onHotkey.d.ts
CHANGED
|
@@ -2,15 +2,19 @@ import { ElementHotkeyOptions } from "./onHotkeys.js";
|
|
|
2
2
|
import { AppHotkey, HotkeyCallback, RegisterableHotkey } from "@tanstack/hotkeys";
|
|
3
3
|
import Modifier from "ember-modifier";
|
|
4
4
|
//#region src/onHotkey.d.ts
|
|
5
|
-
/**
|
|
5
|
+
/**
|
|
6
|
+
* Attaches a hotkey (chord, sequence, or app hotkey) to the element that owns
|
|
7
|
+
* the modifier. `undefined`, `null`, or `''` registers nothing, for an
|
|
8
|
+
* optional shortcut.
|
|
9
|
+
*/
|
|
6
10
|
export declare class OnHotkey extends Modifier<{
|
|
7
11
|
Element: HTMLElement;
|
|
8
12
|
Args: {
|
|
9
|
-
Positional: [RegisterableHotkey | AppHotkey, HotkeyCallback];
|
|
13
|
+
Positional: [RegisterableHotkey | AppHotkey | null | undefined, HotkeyCallback];
|
|
10
14
|
Named: ElementHotkeyOptions;
|
|
11
15
|
};
|
|
12
16
|
}> {
|
|
13
17
|
private bindings;
|
|
14
|
-
modify(element: HTMLElement, [hotkey, callback]: [RegisterableHotkey | AppHotkey, HotkeyCallback], options: ElementHotkeyOptions): void;
|
|
18
|
+
modify(element: HTMLElement, [hotkey, callback]: [RegisterableHotkey | AppHotkey | null | undefined, HotkeyCallback], options: ElementHotkeyOptions): void;
|
|
15
19
|
}
|
|
16
20
|
//#endregion
|
package/dist/onHotkey.js
CHANGED
|
@@ -2,7 +2,11 @@ import { createOwnedBindings } from "./bindings.js";
|
|
|
2
2
|
import Modifier from "ember-modifier";
|
|
3
3
|
|
|
4
4
|
//#region src/onHotkey.ts
|
|
5
|
-
/**
|
|
5
|
+
/**
|
|
6
|
+
* Attaches a hotkey (chord, sequence, or app hotkey) to the element that owns
|
|
7
|
+
* the modifier. `undefined`, `null`, or `''` registers nothing, for an
|
|
8
|
+
* optional shortcut.
|
|
9
|
+
*/
|
|
6
10
|
var OnHotkey = class extends Modifier {
|
|
7
11
|
bindings = createOwnedBindings(this);
|
|
8
12
|
modify(element, [hotkey, callback], options) {
|
package/dist/useHotkey.d.ts
CHANGED
|
@@ -7,15 +7,16 @@ import Helper from "@ember/component/helper";
|
|
|
7
7
|
* `"Mod+S"`, a sequence such as `(array "G" "G")`, or an app hotkey.
|
|
8
8
|
*
|
|
9
9
|
* Use `{{useHotkey "Mod+S" this.save enabled=this.enabled}}` in a template.
|
|
10
|
+
* `undefined`, `null`, or `''` registers nothing, for an optional shortcut.
|
|
10
11
|
*/
|
|
11
12
|
export declare class UseHotkey extends Helper<{
|
|
12
13
|
Args: {
|
|
13
|
-
Positional: [RegisterableHotkey | AppHotkey, HotkeyCallback];
|
|
14
|
+
Positional: [RegisterableHotkey | AppHotkey | null | undefined, HotkeyCallback];
|
|
14
15
|
Named: EmberHotkeyCommonOptions;
|
|
15
16
|
};
|
|
16
17
|
Return: void;
|
|
17
18
|
}> {
|
|
18
19
|
private bindings;
|
|
19
|
-
compute([hotkey, callback]: [RegisterableHotkey | AppHotkey, HotkeyCallback], options: EmberHotkeyCommonOptions): void;
|
|
20
|
+
compute([hotkey, callback]: [RegisterableHotkey | AppHotkey | null | undefined, HotkeyCallback], options: EmberHotkeyCommonOptions): void;
|
|
20
21
|
}
|
|
21
22
|
//#endregion
|
package/dist/useHotkey.js
CHANGED
|
@@ -7,6 +7,7 @@ import Helper from "@ember/component/helper";
|
|
|
7
7
|
* `"Mod+S"`, a sequence such as `(array "G" "G")`, or an app hotkey.
|
|
8
8
|
*
|
|
9
9
|
* Use `{{useHotkey "Mod+S" this.save enabled=this.enabled}}` in a template.
|
|
10
|
+
* `undefined`, `null`, or `''` registers nothing, for an optional shortcut.
|
|
10
11
|
*/
|
|
11
12
|
var UseHotkey = class extends Helper {
|
|
12
13
|
bindings = createOwnedBindings(this);
|
package/dist/useHotkeyHint.d.ts
CHANGED
|
@@ -7,7 +7,8 @@ import { AppHotkey, HeldModifierOptions, RegisterableHotkey } from "@tanstack/ho
|
|
|
7
7
|
* The hint shows only while the hotkey can fire: some registration of it is
|
|
8
8
|
* enabled and in an active scope. A sequence reveals its hint from its first
|
|
9
9
|
* step, and an app hotkey matches its registrations by id and uses its
|
|
10
|
-
* effective hotkey (false while unbound).
|
|
10
|
+
* effective hotkey (false while unbound). No hotkey (`undefined`, `null`, or
|
|
11
|
+
* `''`) returns false. A hotkey on an element counts only while focus is inside it.
|
|
11
12
|
*/
|
|
12
|
-
export declare function useHotkeyHint(owner: object, hotkey: MaybeGetter<RegisterableHotkey | AppHotkey>, options?: MaybeGetter<HeldModifierOptions>): EmberHotkeyState<boolean>;
|
|
13
|
+
export declare function useHotkeyHint(owner: object, hotkey: MaybeGetter<RegisterableHotkey | AppHotkey | null | undefined>, options?: MaybeGetter<HeldModifierOptions>): EmberHotkeyState<boolean>;
|
|
13
14
|
//#endregion
|
package/dist/useHotkeyHint.js
CHANGED
|
@@ -7,7 +7,8 @@ import { getHotkeyManager, getKeyStateTracker, isAppHotkey, matchesHeldModifiers
|
|
|
7
7
|
* The hint shows only while the hotkey can fire: some registration of it is
|
|
8
8
|
* enabled and in an active scope. A sequence reveals its hint from its first
|
|
9
9
|
* step, and an app hotkey matches its registrations by id and uses its
|
|
10
|
-
* effective hotkey (false while unbound).
|
|
10
|
+
* effective hotkey (false while unbound). No hotkey (`undefined`, `null`, or
|
|
11
|
+
* `''`) returns false. A hotkey on an element counts only while focus is inside it.
|
|
11
12
|
*/
|
|
12
13
|
function useHotkeyHint(owner, hotkey, options = {}) {
|
|
13
14
|
const appHotkeys = trackPublishedAppHotkeys(owner);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/ember-hotkeys",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.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.21.0",
|
|
44
44
|
"ember-modifier": "^4.2.2"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|