@tanstack/solid-hotkeys 0.24.0 → 0.24.1
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/HotkeysProvider.d.ts +5 -13
- package/dist/appHotkeys.d.ts +3 -19
- package/dist/appHotkeys.js +5 -7
- package/dist/createFormatForDisplay.js +4 -9
- package/dist/createHotkey.d.ts +3 -5
- package/dist/createHotkey.js +3 -2
- package/dist/createHotkeyHint.d.ts +2 -2
- package/dist/createHotkeyHint.js +5 -6
- package/dist/createHotkeyRecorder.d.ts +2 -10
- package/dist/createHotkeyRecorder.js +2 -2
- package/dist/createHotkeyRegistrations.js +3 -2
- package/dist/createHotkeys.d.ts +2 -1
- package/dist/createHotkeys.js +3 -3
- package/dist/createKeyHold.d.ts +2 -2
- package/dist/createKeyHold.js +2 -1
- package/dist/createKeyboardLayout.js +4 -11
- package/package.json +2 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CreateHotkeyCommonOptions } from "./createHotkey.js";
|
|
2
|
-
import { AppHotkeys,
|
|
3
|
-
import { HotkeysProviderScopeProps } from "@tanstack/hotkeys/adapter";
|
|
2
|
+
import { AppHotkeys, CustomHotkeys, HotkeyPlatform } from "@tanstack/hotkeys";
|
|
3
|
+
import { HotkeyRecorderDefaults, HotkeysContextValue, HotkeysProviderScopeProps } from "@tanstack/hotkeys/adapter";
|
|
4
4
|
import { JSX, ParentComponent } from "solid-js";
|
|
5
5
|
export interface HotkeysProviderOptions {
|
|
6
6
|
/**
|
|
@@ -23,14 +23,7 @@ export interface HotkeysProviderOptions {
|
|
|
23
23
|
*/
|
|
24
24
|
hotkey?: CreateHotkeyCommonOptions;
|
|
25
25
|
/** Defaults for every `createHotkeyRecorder`. */
|
|
26
|
-
hotkeyRecorder?:
|
|
27
|
-
}
|
|
28
|
-
interface HotkeysContextValue {
|
|
29
|
-
readonly appHotkeysStore: AppHotkeysStore | null;
|
|
30
|
-
/** Merged with every ancestor provider's defaults, including `hotkey.scope`. */
|
|
31
|
-
readonly defaultOptions: HotkeysProviderOptions;
|
|
32
|
-
/** Whether this provider and every ancestor are enabled. */
|
|
33
|
-
readonly enabled: boolean;
|
|
26
|
+
hotkeyRecorder?: HotkeyRecorderDefaults;
|
|
34
27
|
}
|
|
35
28
|
export interface HotkeysProviderProps extends HotkeysProviderScopeProps {
|
|
36
29
|
children: JSX.Element;
|
|
@@ -80,6 +73,5 @@ export interface HotkeysProviderProps extends HotkeysProviderScopeProps {
|
|
|
80
73
|
* ```
|
|
81
74
|
*/
|
|
82
75
|
export declare const HotkeysProvider: ParentComponent<HotkeysProviderProps>;
|
|
83
|
-
export declare function useHotkeysContext(): HotkeysContextValue | null;
|
|
84
|
-
export declare function useDefaultHotkeysOptions(): HotkeysProviderOptions;
|
|
85
|
-
export {};
|
|
76
|
+
export declare function useHotkeysContext(): HotkeysContextValue<HotkeysProviderOptions> | null;
|
|
77
|
+
export declare function useDefaultHotkeysOptions(): HotkeysProviderOptions;
|
package/dist/appHotkeys.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CustomHotkeyActions, CustomHotkeys, RegisteredAppHotkeyListItem, RegisteredAppHotkeys } from "@tanstack/hotkeys";
|
|
2
2
|
/**
|
|
3
3
|
* Returns an accessor for the effective app hotkeys from `HotkeysProvider`,
|
|
4
4
|
* typed by `Register`: each declaration with the user's custom hotkey applied.
|
|
@@ -15,27 +15,11 @@ export declare function useAppHotkeys(): () => RegisteredAppHotkeys;
|
|
|
15
15
|
* cheat sheets and settings screens. App hotkeys whose components have not
|
|
16
16
|
* mounted are `'inactive'`; those without a hotkey are `'unbound'`.
|
|
17
17
|
*/
|
|
18
|
-
export declare function createAppHotkeyList(): () => Array<
|
|
18
|
+
export declare function createAppHotkeyList(): () => Array<RegisteredAppHotkeyListItem>;
|
|
19
19
|
/** Custom hotkey state and actions returned by `useCustomHotkeys`. */
|
|
20
|
-
export interface UseCustomHotkeysResult {
|
|
20
|
+
export interface UseCustomHotkeysResult extends CustomHotkeyActions {
|
|
21
21
|
/** The user's hotkeys that differ from the defaults. */
|
|
22
22
|
customHotkeys: () => CustomHotkeys;
|
|
23
|
-
/**
|
|
24
|
-
* Sets the user's hotkey for an app hotkey. `null` unbinds it.
|
|
25
|
-
* Returns conflicting app hotkeys; when any exist, nothing changes. Pass
|
|
26
|
-
* the recorder's `context` for a recorded hotkey, as for `findConflicts`.
|
|
27
|
-
*/
|
|
28
|
-
setCustomHotkey: (id: keyof RegisteredAppHotkeys & string, hotkey: Hotkey | null, recordedWith?: RecordedKeyPresses) => Array<AppHotkey>;
|
|
29
|
-
/** Restores the default hotkey for an app hotkey. */
|
|
30
|
-
resetCustomHotkey: (id: keyof RegisteredAppHotkeys & string) => void;
|
|
31
|
-
/** Restores every default hotkey. */
|
|
32
|
-
resetCustomHotkeys: () => void;
|
|
33
|
-
/**
|
|
34
|
-
* Other app hotkeys that would collide if `id` used `hotkey`. Pass the
|
|
35
|
-
* recorder's `context` for a recorded hotkey: it has the key press, which
|
|
36
|
-
* also finds a hotkey written differently that the same press fires.
|
|
37
|
-
*/
|
|
38
|
-
findConflicts: (id: keyof RegisteredAppHotkeys & string, hotkey: Hotkey, recordedWith?: RecordedKeyPresses) => Array<AppHotkey>;
|
|
39
23
|
}
|
|
40
24
|
/**
|
|
41
25
|
* Reads and changes the user's custom hotkeys. Changes apply to every
|
package/dist/appHotkeys.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { createHotkeyRegistrations } from "./createHotkeyRegistrations.js";
|
|
2
2
|
import { useAppHotkeysStoreSource } from "./defaultOptions.js";
|
|
3
|
+
import { bindCustomHotkeyActions, requireAppHotkeysStore } from "@tanstack/hotkeys/adapter";
|
|
3
4
|
import { createMemo } from "solid-js";
|
|
4
5
|
|
|
5
6
|
// src/appHotkeys.ts
|
|
6
7
|
function useRequiredStore(name) {
|
|
7
8
|
const source = useAppHotkeysStoreSource();
|
|
8
|
-
const
|
|
9
|
-
|
|
9
|
+
const message = `${name} requires a HotkeysProvider with an appHotkeys prop`;
|
|
10
|
+
const initial = requireAppHotkeysStore(source.store, message);
|
|
10
11
|
return {
|
|
11
|
-
store: () => source.store ?? initial,
|
|
12
|
+
store: () => requireAppHotkeysStore(source.store ?? initial, message),
|
|
12
13
|
state: source.state
|
|
13
14
|
};
|
|
14
15
|
}
|
|
@@ -54,10 +55,7 @@ function useCustomHotkeys() {
|
|
|
54
55
|
state();
|
|
55
56
|
return store().customHotkeys;
|
|
56
57
|
}),
|
|
57
|
-
|
|
58
|
-
resetCustomHotkey: (id) => store().resetCustomHotkey(id),
|
|
59
|
-
resetCustomHotkeys: () => store().resetCustomHotkeys(),
|
|
60
|
-
findConflicts: (id, hotkey, recordedWith) => store().findConflicts(id, hotkey, recordedWith)
|
|
58
|
+
...bindCustomHotkeyActions(store)
|
|
61
59
|
};
|
|
62
60
|
}
|
|
63
61
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { createKeyboardLayout } from "./createKeyboardLayout.js";
|
|
2
2
|
import { useDefaultHotkeysOptionsSource } from "./defaultOptions.js";
|
|
3
|
-
import {
|
|
4
|
-
import { namesPhysicalKey } from "@tanstack/hotkeys/adapter";
|
|
3
|
+
import { createFormatForDisplay } from "@tanstack/hotkeys/adapter";
|
|
5
4
|
|
|
6
5
|
// src/createFormatForDisplay.ts
|
|
7
6
|
/**
|
|
@@ -27,14 +26,10 @@ import { namesPhysicalKey } from "@tanstack/hotkeys/adapter";
|
|
|
27
26
|
* }
|
|
28
27
|
* ```
|
|
29
28
|
*/
|
|
30
|
-
function createFormatForDisplay() {
|
|
29
|
+
function createFormatForDisplay$1() {
|
|
31
30
|
const defaultOptions = useDefaultHotkeysOptionsSource();
|
|
32
31
|
const layoutMap = createKeyboardLayout();
|
|
33
|
-
return ((
|
|
34
|
-
...options,
|
|
35
|
-
platform: options?.platform ?? defaultOptions().platform,
|
|
36
|
-
layoutMap: options?.layoutMap ?? (namesPhysicalKey(hotkey) ? layoutMap() ?? void 0 : void 0)
|
|
37
|
-
}));
|
|
32
|
+
return createFormatForDisplay(() => defaultOptions().platform, layoutMap);
|
|
38
33
|
}
|
|
39
34
|
|
|
40
|
-
export { createFormatForDisplay };
|
|
35
|
+
export { createFormatForDisplay$1 as createFormatForDisplay };
|
package/dist/createHotkey.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AppHotkey, HotkeyCallback, HotkeyCallbackContextFor, RegisterableHotkey, Target } from "@tanstack/hotkeys";
|
|
1
|
+
import { AppHotkey, HotkeyCallback, HotkeyCallbackContextFor, MaybeGetter, RegisterableHotkey, Target } from "@tanstack/hotkeys";
|
|
2
2
|
import { AdapterAppHotkeyOptions, AdapterChordOptions, AdapterCommonOptions, AdapterHotkeyOptions, AdapterOptionsFor, AdapterSequenceOptions } from "@tanstack/hotkeys/adapter";
|
|
3
3
|
/**
|
|
4
4
|
* The element to listen on. A `null` or `undefined` target skips
|
|
@@ -18,7 +18,6 @@ export type CreateHotkeyCommonOptions = AdapterCommonOptions<CreateHotkeyTarget>
|
|
|
18
18
|
export type CreateHotkeyOptionsFor<T extends RegisterableHotkey> = AdapterOptionsFor<T, CreateHotkeyTarget>;
|
|
19
19
|
/** Call-site options for an app hotkey, typed by its declared default kind. */
|
|
20
20
|
export type CreateAppHotkeyOptions<T extends AppHotkey = AppHotkey> = AdapterAppHotkeyOptions<T, CreateHotkeyTarget>;
|
|
21
|
-
type MaybeAccessor<T> = T | (() => T);
|
|
22
21
|
/**
|
|
23
22
|
* Solid primitive for registering a hotkey: a chord such as `'Mod+S'`, a
|
|
24
23
|
* sequence such as `['G', 'G']`, or an app hotkey from `defineAppHotkeys`.
|
|
@@ -37,6 +36,5 @@ type MaybeAccessor<T> = T | (() => T);
|
|
|
37
36
|
* createHotkey('Escape', () => close(), () => ({ enabled: isOpen() }))
|
|
38
37
|
* ```
|
|
39
38
|
*/
|
|
40
|
-
export declare function createHotkey<T extends AppHotkey>(hotkey:
|
|
41
|
-
export declare function createHotkey<const T extends RegisterableHotkey>(hotkey:
|
|
42
|
-
export {};
|
|
39
|
+
export declare function createHotkey<T extends AppHotkey>(hotkey: MaybeGetter<T | null | undefined>, callback: HotkeyCallback, options?: MaybeGetter<CreateAppHotkeyOptions<T>>): void;
|
|
40
|
+
export declare function createHotkey<const T extends RegisterableHotkey>(hotkey: MaybeGetter<T | null | undefined>, callback: HotkeyCallback<HotkeyCallbackContextFor<T>>, options?: MaybeGetter<CreateHotkeyOptionsFor<T>>): void;
|
package/dist/createHotkey.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { createHotkeys } from "./createHotkeys.js";
|
|
2
|
+
import { resolveMaybeGetter } from "@tanstack/hotkeys/adapter";
|
|
2
3
|
|
|
3
4
|
// src/createHotkey.ts
|
|
4
5
|
function createHotkey(hotkey, callback, options = {}) {
|
|
5
6
|
createHotkeys(() => [{
|
|
6
|
-
hotkey:
|
|
7
|
+
hotkey: resolveMaybeGetter(hotkey),
|
|
7
8
|
callback,
|
|
8
|
-
options:
|
|
9
|
+
options: resolveMaybeGetter(options)
|
|
9
10
|
}]);
|
|
10
11
|
}
|
|
11
12
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AppHotkey, HeldModifierOptions, RegisterableHotkey } from "@tanstack/hotkeys";
|
|
1
|
+
import { AppHotkey, HeldModifierOptions, MaybeGetter, RegisterableHotkey } from "@tanstack/hotkeys";
|
|
2
2
|
/**
|
|
3
3
|
* Returns an accessor indicating whether held modifiers reveal this shortcut.
|
|
4
4
|
* The hint shows only while the hotkey can fire: some registration of it is
|
|
@@ -7,4 +7,4 @@ import { AppHotkey, HeldModifierOptions, RegisterableHotkey } from "@tanstack/ho
|
|
|
7
7
|
* effective hotkey (false while unbound). No hotkey (`undefined`, `null`, or
|
|
8
8
|
* `''`) returns false. This helper does not register a shortcut. A hotkey on an element counts only while focus is inside it.
|
|
9
9
|
*/
|
|
10
|
-
export declare function createHotkeyHint(hotkey: RegisterableHotkey | AppHotkey | null | undefined
|
|
10
|
+
export declare function createHotkeyHint(hotkey: MaybeGetter<RegisterableHotkey | AppHotkey | null | undefined>, options?: MaybeGetter<HeldModifierOptions>): () => boolean;
|
package/dist/createHotkeyHint.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useSelector } from "./_useSelector.js";
|
|
2
2
|
import { useAppHotkeysStoreSource } from "./defaultOptions.js";
|
|
3
|
-
import { getHotkeyManager, getKeyStateTracker
|
|
3
|
+
import { getHotkeyManager, getKeyStateTracker } from "@tanstack/hotkeys";
|
|
4
|
+
import { isHotkeyHintVisible, resolveMaybeGetter } from "@tanstack/hotkeys/adapter";
|
|
4
5
|
import { createMemo } from "solid-js";
|
|
5
6
|
|
|
6
7
|
// src/createHotkeyHint.ts
|
|
@@ -14,14 +15,12 @@ import { createMemo } from "solid-js";
|
|
|
14
15
|
*/
|
|
15
16
|
function createHotkeyHint(hotkey, options = {}) {
|
|
16
17
|
const appHotkeys = useAppHotkeysStoreSource();
|
|
17
|
-
const
|
|
18
|
-
const registrations = useSelector(manager.registrations, (state) => state);
|
|
18
|
+
const registrations = useSelector(getHotkeyManager().registrations, (state) => state);
|
|
19
19
|
const held = useSelector(getKeyStateTracker().store, (state) => state.heldKeys);
|
|
20
20
|
return createMemo(() => {
|
|
21
21
|
appHotkeys.state();
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return resolved !== null && matchesHeldModifiers(resolved, held(), typeof options === "function" ? options() : options) && registrations().size > 0 && manager.hasActiveRegistration(value);
|
|
22
|
+
registrations();
|
|
23
|
+
return isHotkeyHintVisible(resolveMaybeGetter(hotkey), held(), resolveMaybeGetter(options), appHotkeys.store);
|
|
25
24
|
});
|
|
26
25
|
}
|
|
27
26
|
|
|
@@ -1,19 +1,11 @@
|
|
|
1
|
-
import { Hotkey, HotkeyChord, HotkeyChordRecorderOptions, HotkeyRecorderOptions, HotkeySequence, HotkeySequenceRecorderOptions } from "@tanstack/hotkeys";
|
|
2
|
-
export interface SolidHotkeyRecorder<THotkey extends Hotkey = Hotkey> {
|
|
1
|
+
import { Hotkey, HotkeyChord, HotkeyChordRecorderOptions, HotkeyRecorderActions, HotkeyRecorderOptions, HotkeySequence, HotkeySequenceRecorderOptions } from "@tanstack/hotkeys";
|
|
2
|
+
export interface SolidHotkeyRecorder<THotkey extends Hotkey = Hotkey> extends HotkeyRecorderActions {
|
|
3
3
|
/** Whether recording is currently active */
|
|
4
4
|
isRecording: () => boolean;
|
|
5
5
|
/** Chords recorded so far in a multi-step recording (for live preview) */
|
|
6
6
|
steps: () => HotkeySequence;
|
|
7
7
|
/** The last committed hotkey */
|
|
8
8
|
recordedHotkey: () => THotkey | null;
|
|
9
|
-
/** Start recording a new hotkey */
|
|
10
|
-
startRecording: () => void;
|
|
11
|
-
/** Stop recording without calling onCancel */
|
|
12
|
-
stopRecording: () => void;
|
|
13
|
-
/** Cancel recording and call onCancel */
|
|
14
|
-
cancelRecording: () => void;
|
|
15
|
-
/** Commit the recorded steps now (multi-step recordings) */
|
|
16
|
-
commitRecording: () => void;
|
|
17
9
|
}
|
|
18
10
|
/**
|
|
19
11
|
* Solid primitive for recording keyboard shortcuts. Options may be an accessor.
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { useSelector } from "./_useSelector.js";
|
|
2
2
|
import { useDefaultHotkeysOptionsSource } from "./defaultOptions.js";
|
|
3
3
|
import { HotkeyRecorder } from "@tanstack/hotkeys";
|
|
4
|
-
import { withDefaults } from "@tanstack/hotkeys/adapter";
|
|
4
|
+
import { resolveMaybeGetter, withDefaults } from "@tanstack/hotkeys/adapter";
|
|
5
5
|
import { createEffect, onCleanup } from "solid-js";
|
|
6
6
|
|
|
7
7
|
// src/createHotkeyRecorder.ts
|
|
8
8
|
function createHotkeyRecorder(options) {
|
|
9
9
|
const defaultOptions = useDefaultHotkeysOptionsSource();
|
|
10
|
-
const resolve = () => withDefaults(defaultOptions().hotkeyRecorder,
|
|
10
|
+
const resolve = () => withDefaults(defaultOptions().hotkeyRecorder, resolveMaybeGetter(options));
|
|
11
11
|
const recorder = new HotkeyRecorder(resolve());
|
|
12
12
|
const isRecording = useSelector(recorder.store, (state) => state.isRecording);
|
|
13
13
|
const steps = useSelector(recorder.store, (state) => state.steps);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useSelector } from "./_useSelector.js";
|
|
2
|
-
import { getHotkeyManager
|
|
2
|
+
import { getHotkeyManager } from "@tanstack/hotkeys";
|
|
3
|
+
import { getHotkeyRegistrationViews } from "@tanstack/hotkeys/adapter";
|
|
3
4
|
|
|
4
5
|
// src/createHotkeyRegistrations.ts
|
|
5
6
|
/**
|
|
@@ -20,7 +21,7 @@ import { getHotkeyManager, toHotkeyRegistrationView } from "@tanstack/hotkeys";
|
|
|
20
21
|
* ```
|
|
21
22
|
*/
|
|
22
23
|
function createHotkeyRegistrations() {
|
|
23
|
-
return useSelector(getHotkeyManager().registrations,
|
|
24
|
+
return useSelector(getHotkeyManager().registrations, getHotkeyRegistrationViews);
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
export { createHotkeyRegistrations };
|
package/dist/createHotkeys.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CreateHotkeyCommonOptions, CreateHotkeyTarget } from "./createHotkey.js";
|
|
2
|
+
import { MaybeGetter } from "@tanstack/hotkeys";
|
|
2
3
|
import { AdapterHotkeyDefinition } from "@tanstack/hotkeys/adapter";
|
|
3
4
|
/**
|
|
4
5
|
* One hotkey for `createHotkeys`. Chords accept `requireReset`; sequences
|
|
@@ -23,4 +24,4 @@ export type CreateHotkeyDefinition = AdapterHotkeyDefinition<CreateHotkeyTarget>
|
|
|
23
24
|
* ])
|
|
24
25
|
* ```
|
|
25
26
|
*/
|
|
26
|
-
export declare function createHotkeys(hotkeys:
|
|
27
|
+
export declare function createHotkeys(hotkeys: MaybeGetter<ReadonlyArray<CreateHotkeyDefinition>>, commonOptions?: MaybeGetter<CreateHotkeyCommonOptions>): void;
|
package/dist/createHotkeys.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useAppHotkeysStoreSource, useDefaultHotkeysOptionsSource } from "./defaultOptions.js";
|
|
2
2
|
import { delegateEvents } from "solid-js/web";
|
|
3
|
-
import { createHotkeyBindings, prepareHotkeyDefinitions } from "@tanstack/hotkeys/adapter";
|
|
3
|
+
import { createHotkeyBindings, prepareHotkeyDefinitions, resolveMaybeGetter } from "@tanstack/hotkeys/adapter";
|
|
4
4
|
import { createEffect, onCleanup, untrack } from "solid-js";
|
|
5
5
|
|
|
6
6
|
// src/createHotkeys.ts
|
|
@@ -29,10 +29,10 @@ function createHotkeys(hotkeys, commonOptions = {}) {
|
|
|
29
29
|
onCleanup(() => bindings.destroy());
|
|
30
30
|
createEffect(() => {
|
|
31
31
|
appHotkeys.state();
|
|
32
|
-
const definitions = prepareHotkeyDefinitions(
|
|
32
|
+
const definitions = prepareHotkeyDefinitions(resolveMaybeGetter(hotkeys), {
|
|
33
33
|
appHotkeysStore: appHotkeys.store,
|
|
34
34
|
defaults: defaultOptions().hotkey,
|
|
35
|
-
commonOptions:
|
|
35
|
+
commonOptions: resolveMaybeGetter(commonOptions),
|
|
36
36
|
resolveTarget: (target) => target
|
|
37
37
|
});
|
|
38
38
|
delegateEvents(["keydown", "keyup"]);
|
package/dist/createKeyHold.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IndividualKey } from "@tanstack/hotkeys";
|
|
1
|
+
import { IndividualKey, MaybeGetter } from "@tanstack/hotkeys";
|
|
2
2
|
/**
|
|
3
3
|
* SolidJS primitive that returns whether a specific key is currently being held.
|
|
4
4
|
*
|
|
@@ -38,4 +38,4 @@ import { IndividualKey } from "@tanstack/hotkeys";
|
|
|
38
38
|
* }
|
|
39
39
|
* ```
|
|
40
40
|
*/
|
|
41
|
-
export declare function createKeyHold(key: IndividualKey
|
|
41
|
+
export declare function createKeyHold(key: MaybeGetter<IndividualKey>): () => boolean;
|
package/dist/createKeyHold.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useSelector } from "./_useSelector.js";
|
|
2
2
|
import { getKeyStateTracker } from "@tanstack/hotkeys";
|
|
3
|
+
import { resolveMaybeGetter } from "@tanstack/hotkeys/adapter";
|
|
3
4
|
import { createMemo } from "solid-js";
|
|
4
5
|
|
|
5
6
|
// src/createKeyHold.ts
|
|
@@ -47,7 +48,7 @@ function createKeyHold(key) {
|
|
|
47
48
|
const heldKeysSelector = useSelector(tracker.store, (state) => state.heldKeys);
|
|
48
49
|
return createMemo(() => {
|
|
49
50
|
heldKeysSelector();
|
|
50
|
-
return tracker.isKeyHeld(
|
|
51
|
+
return tracker.isKeyHeld(resolveMaybeGetter(key));
|
|
51
52
|
});
|
|
52
53
|
}
|
|
53
54
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useDefaultHotkeysOptionsSource } from "./defaultOptions.js";
|
|
2
|
-
import { getKeyboardLayoutStore
|
|
2
|
+
import { getKeyboardLayoutStore } from "@tanstack/hotkeys";
|
|
3
|
+
import { followKeyboardLayout } from "@tanstack/hotkeys/adapter";
|
|
3
4
|
import { createEffect, createMemo, createSignal, onCleanup } from "solid-js";
|
|
4
5
|
|
|
5
6
|
// src/createKeyboardLayout.ts
|
|
@@ -35,16 +36,8 @@ function createKeyboardLayout() {
|
|
|
35
36
|
const [layoutMap, setLayoutMap] = createSignal(null);
|
|
36
37
|
createEffect(() => {
|
|
37
38
|
if (!enabled()) return;
|
|
38
|
-
|
|
39
|
-
setLayoutMap(() =>
|
|
40
|
-
const { unsubscribe } = store.subscribe((state) => {
|
|
41
|
-
setLayoutMap(() => state);
|
|
42
|
-
});
|
|
43
|
-
const stop = loadKeyboardLayout();
|
|
44
|
-
onCleanup(() => {
|
|
45
|
-
unsubscribe();
|
|
46
|
-
stop();
|
|
47
|
-
});
|
|
39
|
+
onCleanup(followKeyboardLayout((state) => setLayoutMap(() => state)));
|
|
40
|
+
setLayoutMap(() => getKeyboardLayoutStore().get());
|
|
48
41
|
});
|
|
49
42
|
return () => enabled() ? layoutMap() : null;
|
|
50
43
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/solid-hotkeys",
|
|
3
|
-
"version": "0.24.
|
|
3
|
+
"version": "0.24.1",
|
|
4
4
|
"description": "SolidJS adapter for TanStack Hotkeys",
|
|
5
5
|
"author": "Tanner Linsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"skills"
|
|
39
39
|
],
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@tanstack/hotkeys": "0.
|
|
41
|
+
"@tanstack/hotkeys": "0.30.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@solidjs/testing-library": "^0.8.10",
|