@tanstack/solid-hotkeys 0.11.0 → 0.12.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.
Files changed (88) hide show
  1. package/dist/HotkeysProvider.d.ts +6 -9
  2. package/dist/HotkeysProvider.js +1 -2
  3. package/dist/createHeldKeyCodes.d.ts +2 -4
  4. package/dist/createHeldKeyCodes.js +3 -3
  5. package/dist/createHeldKeys.d.ts +2 -4
  6. package/dist/createHeldKeys.js +3 -3
  7. package/dist/createHotkey.d.ts +3 -6
  8. package/dist/createHotkey.js +3 -3
  9. package/dist/createHotkeyHint.d.ts +2 -5
  10. package/dist/createHotkeyHint.js +1 -2
  11. package/dist/createHotkeyRecorder.d.ts +3 -6
  12. package/dist/createHotkeyRecorder.js +4 -4
  13. package/dist/createHotkeyRegistrations.d.ts +3 -6
  14. package/dist/createHotkeyRegistrations.js +1 -2
  15. package/dist/createHotkeySequence.d.ts +3 -6
  16. package/dist/createHotkeySequence.js +1 -2
  17. package/dist/createHotkeySequenceRecorder.d.ts +3 -6
  18. package/dist/createHotkeySequenceRecorder.js +4 -4
  19. package/dist/createHotkeySequences.d.ts +3 -6
  20. package/dist/createHotkeySequences.js +1 -2
  21. package/dist/createHotkeys.d.ts +3 -6
  22. package/dist/createHotkeys.js +1 -2
  23. package/dist/createKeyHold.d.ts +2 -5
  24. package/dist/createKeyHold.js +3 -3
  25. package/package.json +12 -17
  26. package/dist/HotkeysProvider.cjs +0 -27
  27. package/dist/HotkeysProvider.cjs.map +0 -1
  28. package/dist/HotkeysProvider.d.cts +0 -25
  29. package/dist/HotkeysProvider.js.map +0 -1
  30. package/dist/createHeldKeyCodes.cjs +0 -42
  31. package/dist/createHeldKeyCodes.cjs.map +0 -1
  32. package/dist/createHeldKeyCodes.d.cts +0 -36
  33. package/dist/createHeldKeyCodes.js.map +0 -1
  34. package/dist/createHeldKeys.cjs +0 -33
  35. package/dist/createHeldKeys.cjs.map +0 -1
  36. package/dist/createHeldKeys.d.cts +0 -27
  37. package/dist/createHeldKeys.js.map +0 -1
  38. package/dist/createHotkey.cjs +0 -120
  39. package/dist/createHotkey.cjs.map +0 -1
  40. package/dist/createHotkey.d.cts +0 -72
  41. package/dist/createHotkey.js.map +0 -1
  42. package/dist/createHotkeyHint.cjs +0 -20
  43. package/dist/createHotkeyHint.cjs.map +0 -1
  44. package/dist/createHotkeyHint.d.cts +0 -14
  45. package/dist/createHotkeyHint.js.map +0 -1
  46. package/dist/createHotkeyRecorder.cjs +0 -78
  47. package/dist/createHotkeyRecorder.cjs.map +0 -1
  48. package/dist/createHotkeyRecorder.d.cts +0 -60
  49. package/dist/createHotkeyRecorder.js.map +0 -1
  50. package/dist/createHotkeyRegistrations.cjs +0 -26
  51. package/dist/createHotkeyRegistrations.cjs.map +0 -1
  52. package/dist/createHotkeyRegistrations.d.cts +0 -26
  53. package/dist/createHotkeyRegistrations.js.map +0 -1
  54. package/dist/createHotkeySequence.cjs +0 -107
  55. package/dist/createHotkeySequence.cjs.map +0 -1
  56. package/dist/createHotkeySequence.d.cts +0 -56
  57. package/dist/createHotkeySequence.js.map +0 -1
  58. package/dist/createHotkeySequenceRecorder.cjs +0 -43
  59. package/dist/createHotkeySequenceRecorder.cjs.map +0 -1
  60. package/dist/createHotkeySequenceRecorder.d.cts +0 -19
  61. package/dist/createHotkeySequenceRecorder.js.map +0 -1
  62. package/dist/createHotkeySequences.cjs +0 -112
  63. package/dist/createHotkeySequences.cjs.map +0 -1
  64. package/dist/createHotkeySequences.d.cts +0 -57
  65. package/dist/createHotkeySequences.js.map +0 -1
  66. package/dist/createHotkeys.cjs +0 -112
  67. package/dist/createHotkeys.cjs.map +0 -1
  68. package/dist/createHotkeys.d.cts +0 -57
  69. package/dist/createHotkeys.js.map +0 -1
  70. package/dist/createKeyHold.cjs +0 -56
  71. package/dist/createKeyHold.cjs.map +0 -1
  72. package/dist/createKeyHold.d.cts +0 -47
  73. package/dist/createKeyHold.js.map +0 -1
  74. package/dist/index.cjs +0 -35
  75. package/dist/index.d.cts +0 -14
  76. package/src/HotkeysProvider.tsx +0 -51
  77. package/src/createHeldKeyCodes.ts +0 -38
  78. package/src/createHeldKeys.ts +0 -29
  79. package/src/createHotkey.ts +0 -172
  80. package/src/createHotkeyHint.ts +0 -28
  81. package/src/createHotkeyRecorder.ts +0 -103
  82. package/src/createHotkeyRegistrations.ts +0 -45
  83. package/src/createHotkeySequence.ts +0 -155
  84. package/src/createHotkeySequenceRecorder.ts +0 -66
  85. package/src/createHotkeySequences.ts +0 -181
  86. package/src/createHotkeys.ts +0 -187
  87. package/src/createKeyHold.ts +0 -59
  88. package/src/index.ts +0 -18
@@ -2,9 +2,8 @@ import { CreateHotkeyOptions } from "./createHotkey.js";
2
2
  import { CreateHotkeySequenceOptions } from "./createHotkeySequence.js";
3
3
  import { HotkeyRecorderOptions, HotkeySequenceRecorderOptions } from "@tanstack/hotkeys";
4
4
  import { JSX, ParentComponent } from "solid-js";
5
-
6
5
  //#region src/HotkeysProvider.d.ts
7
- interface HotkeysProviderOptions {
6
+ export interface HotkeysProviderOptions {
8
7
  hotkey?: Partial<CreateHotkeyOptions>;
9
8
  hotkeyRecorder?: Partial<HotkeyRecorderOptions>;
10
9
  hotkeySequenceRecorder?: Partial<HotkeySequenceRecorderOptions>;
@@ -13,13 +12,11 @@ interface HotkeysProviderOptions {
13
12
  interface HotkeysContextValue {
14
13
  defaultOptions: HotkeysProviderOptions;
15
14
  }
16
- interface HotkeysProviderProps {
15
+ export interface HotkeysProviderProps {
17
16
  children: JSX.Element;
18
17
  defaultOptions?: HotkeysProviderOptions;
19
18
  }
20
- declare const HotkeysProvider: ParentComponent<HotkeysProviderProps>;
21
- declare function useHotkeysContext(): HotkeysContextValue | null;
22
- declare function useDefaultHotkeysOptions(): HotkeysProviderOptions;
23
- //#endregion
24
- export { HotkeysProvider, HotkeysProviderOptions, HotkeysProviderProps, useDefaultHotkeysOptions, useHotkeysContext };
25
- //# sourceMappingURL=HotkeysProvider.d.ts.map
19
+ export declare const HotkeysProvider: ParentComponent<HotkeysProviderProps>;
20
+ export declare function useHotkeysContext(): HotkeysContextValue | null;
21
+ export declare function useDefaultHotkeysOptions(): HotkeysProviderOptions;
22
+ //#endregion
@@ -21,5 +21,4 @@ function useDefaultHotkeysOptions() {
21
21
  }
22
22
 
23
23
  //#endregion
24
- export { HotkeysProvider, useDefaultHotkeysOptions, useHotkeysContext };
25
- //# sourceMappingURL=HotkeysProvider.js.map
24
+ export { HotkeysProvider, useDefaultHotkeysOptions, useHotkeysContext };
@@ -30,7 +30,5 @@
30
30
  * }
31
31
  * ```
32
32
  */
33
- declare function createHeldKeyCodes(): () => Record<string, string>;
34
- //#endregion
35
- export { createHeldKeyCodes };
36
- //# sourceMappingURL=createHeldKeyCodes.d.ts.map
33
+ export declare function createHeldKeyCodes(): () => Record<string, string>;
34
+ //#endregion
@@ -34,9 +34,9 @@ import { useSelector } from "@tanstack/solid-store";
34
34
  * ```
35
35
  */
36
36
  function createHeldKeyCodes() {
37
- return useSelector(getKeyStateTracker().store, (state) => state.heldCodes);
37
+ const tracker = getKeyStateTracker();
38
+ return useSelector(tracker.store, (state) => state.heldCodes);
38
39
  }
39
40
 
40
41
  //#endregion
41
- export { createHeldKeyCodes };
42
- //# sourceMappingURL=createHeldKeyCodes.js.map
42
+ export { createHeldKeyCodes };
@@ -21,7 +21,5 @@
21
21
  * }
22
22
  * ```
23
23
  */
24
- declare function createHeldKeys(): () => Array<string>;
25
- //#endregion
26
- export { createHeldKeys };
27
- //# sourceMappingURL=createHeldKeys.d.ts.map
24
+ export declare function createHeldKeys(): () => Array<string>;
25
+ //#endregion
@@ -25,9 +25,9 @@ import { useSelector } from "@tanstack/solid-store";
25
25
  * ```
26
26
  */
27
27
  function createHeldKeys() {
28
- return useSelector(getKeyStateTracker().store, (state) => state.heldKeys);
28
+ const tracker = getKeyStateTracker();
29
+ return useSelector(tracker.store, (state) => state.heldKeys);
29
30
  }
30
31
 
31
32
  //#endregion
32
- export { createHeldKeys };
33
- //# sourceMappingURL=createHeldKeys.js.map
33
+ export { createHeldKeys };
@@ -1,7 +1,6 @@
1
1
  import { HotkeyCallback, HotkeyOptions, RegisterableHotkey } from "@tanstack/hotkeys";
2
-
3
2
  //#region src/createHotkey.d.ts
4
- interface CreateHotkeyOptions extends Omit<HotkeyOptions, 'target'> {
3
+ export interface CreateHotkeyOptions extends Omit<HotkeyOptions, 'target'> {
5
4
  /**
6
5
  * The DOM element to attach the event listener to.
7
6
  * Can be a direct DOM element, an accessor (for reactive targets that become
@@ -66,7 +65,5 @@ interface CreateHotkeyOptions extends Omit<HotkeyOptions, 'target'> {
66
65
  * }
67
66
  * ```
68
67
  */
69
- declare function createHotkey(hotkey: RegisterableHotkey | (() => RegisterableHotkey), callback: HotkeyCallback, options?: CreateHotkeyOptions | (() => CreateHotkeyOptions)): void;
70
- //#endregion
71
- export { CreateHotkeyOptions, createHotkey };
72
- //# sourceMappingURL=createHotkey.d.ts.map
68
+ export declare function createHotkey(hotkey: RegisterableHotkey | (() => RegisterableHotkey), callback: HotkeyCallback, options?: CreateHotkeyOptions | (() => CreateHotkeyOptions)): void;
69
+ //#endregion
@@ -79,7 +79,8 @@ function createHotkey(hotkey, callback, options = {}) {
79
79
  ...defaultOptions.hotkey,
80
80
  ...resolvedOptions
81
81
  };
82
- const hotkeyString = normalizeRegisterableHotkey(resolvedHotkey, mergedOptions.platform ?? detectPlatform());
82
+ const platform = mergedOptions.platform ?? detectPlatform();
83
+ const hotkeyString = normalizeRegisterableHotkey(resolvedHotkey, platform);
83
84
  const resolvedTarget = "target" in mergedOptions ? mergedOptions.target ?? null : typeof document !== "undefined" ? document : null;
84
85
  if (!resolvedTarget) {
85
86
  if (registration?.isActive) {
@@ -116,5 +117,4 @@ function createHotkey(hotkey, callback, options = {}) {
116
117
  }
117
118
 
118
119
  //#endregion
119
- export { createHotkey };
120
- //# sourceMappingURL=createHotkey.js.map
120
+ export { createHotkey };
@@ -1,5 +1,4 @@
1
1
  import { HeldModifierOptions, RegisterableHotkey } from "@tanstack/hotkeys";
2
-
3
2
  //#region src/createHotkeyHint.d.ts
4
3
  /**
5
4
  * Returns a boolean accessor indicating whether held modifiers reveal this shortcut.
@@ -8,7 +7,5 @@ import { HeldModifierOptions, RegisterableHotkey } from "@tanstack/hotkeys";
8
7
  * every modifier. Combine with the action's enabled state before showing a badge.
9
8
  * This helper does not register a shortcut or check whether its target is focused.
10
9
  */
11
- declare function createHotkeyHint(hotkey: RegisterableHotkey | (() => RegisterableHotkey), options?: HeldModifierOptions | (() => HeldModifierOptions)): () => boolean;
12
- //#endregion
13
- export { createHotkeyHint };
14
- //# sourceMappingURL=createHotkeyHint.d.ts.map
10
+ export declare function createHotkeyHint(hotkey: RegisterableHotkey | (() => RegisterableHotkey), options?: HeldModifierOptions | (() => HeldModifierOptions)): () => boolean;
11
+ //#endregion
@@ -16,5 +16,4 @@ function createHotkeyHint(hotkey, options = {}) {
16
16
  }
17
17
 
18
18
  //#endregion
19
- export { createHotkeyHint };
20
- //# sourceMappingURL=createHotkeyHint.js.map
19
+ export { createHotkeyHint };
@@ -1,7 +1,6 @@
1
1
  import { Hotkey, HotkeyRecorderOptions } from "@tanstack/hotkeys";
2
-
3
2
  //#region src/createHotkeyRecorder.d.ts
4
- interface SolidHotkeyRecorder {
3
+ export interface SolidHotkeyRecorder {
5
4
  /** Whether recording is currently active */
6
5
  isRecording: () => boolean;
7
6
  /** The currently recorded hotkey (for live preview) */
@@ -54,7 +53,5 @@ interface SolidHotkeyRecorder {
54
53
  * }
55
54
  * ```
56
55
  */
57
- declare function createHotkeyRecorder(options: HotkeyRecorderOptions | (() => HotkeyRecorderOptions)): SolidHotkeyRecorder;
58
- //#endregion
59
- export { SolidHotkeyRecorder, createHotkeyRecorder };
60
- //# sourceMappingURL=createHotkeyRecorder.d.ts.map
56
+ export declare function createHotkeyRecorder(options: HotkeyRecorderOptions | (() => HotkeyRecorderOptions)): SolidHotkeyRecorder;
57
+ //#endregion
@@ -48,10 +48,11 @@ import { useSelector } from "@tanstack/solid-store";
48
48
  function createHotkeyRecorder(options) {
49
49
  const defaultOptions = useDefaultHotkeysOptions();
50
50
  const resolvedOptions = typeof options === "function" ? options() : options;
51
- const recorder = new HotkeyRecorder({
51
+ const mergedOptions = {
52
52
  ...defaultOptions.hotkeyRecorder,
53
53
  ...resolvedOptions
54
- });
54
+ };
55
+ const recorder = new HotkeyRecorder(mergedOptions);
55
56
  const isRecording = useSelector(recorder.store, (state) => state.isRecording);
56
57
  const recordedHotkey = useSelector(recorder.store, (state) => state.recordedHotkey);
57
58
  createEffect(() => {
@@ -74,5 +75,4 @@ function createHotkeyRecorder(options) {
74
75
  }
75
76
 
76
77
  //#endregion
77
- export { createHotkeyRecorder };
78
- //# sourceMappingURL=createHotkeyRecorder.js.map
78
+ export { createHotkeyRecorder };
@@ -1,10 +1,9 @@
1
1
  import { HotkeyRegistrationView, SequenceRegistrationView } from "@tanstack/hotkeys";
2
-
3
2
  //#region src/createHotkeyRegistrations.d.ts
4
3
  /**
5
4
  * Return type for createHotkeyRegistrations.
6
5
  */
7
- interface HotkeyRegistrationsResult {
6
+ export interface HotkeyRegistrationsResult {
8
7
  /** Accessor for all registered hotkeys (public view, no callbacks) */
9
8
  hotkeys: () => Array<HotkeyRegistrationView>;
10
9
  /** Accessor for all registered sequences */
@@ -20,7 +19,5 @@ interface HotkeyRegistrationsResult {
20
19
  *
21
20
  * @returns Object with `hotkeys` and `sequences` signal accessors
22
21
  */
23
- declare function createHotkeyRegistrations(): HotkeyRegistrationsResult;
24
- //#endregion
25
- export { HotkeyRegistrationsResult, createHotkeyRegistrations };
26
- //# sourceMappingURL=createHotkeyRegistrations.d.ts.map
22
+ export declare function createHotkeyRegistrations(): HotkeyRegistrationsResult;
23
+ //#endregion
@@ -22,5 +22,4 @@ function createHotkeyRegistrations() {
22
22
  }
23
23
 
24
24
  //#endregion
25
- export { createHotkeyRegistrations };
26
- //# sourceMappingURL=createHotkeyRegistrations.js.map
25
+ export { createHotkeyRegistrations };
@@ -1,7 +1,6 @@
1
1
  import { HotkeyCallback, HotkeySequence, SequenceOptions } from "@tanstack/hotkeys";
2
-
3
2
  //#region src/createHotkeySequence.d.ts
4
- interface CreateHotkeySequenceOptions extends Omit<SequenceOptions, 'target'> {
3
+ export interface CreateHotkeySequenceOptions extends Omit<SequenceOptions, 'target'> {
5
4
  /**
6
5
  * The DOM element to attach the event listener to.
7
6
  * Can be a direct DOM element, an accessor, or null. Defaults to document.
@@ -50,7 +49,5 @@ interface CreateHotkeySequenceOptions extends Omit<SequenceOptions, 'target'> {
50
49
  * }
51
50
  * ```
52
51
  */
53
- declare function createHotkeySequence(sequence: HotkeySequence | (() => HotkeySequence), callback: HotkeyCallback, options?: CreateHotkeySequenceOptions | (() => CreateHotkeySequenceOptions)): void;
54
- //#endregion
55
- export { CreateHotkeySequenceOptions, createHotkeySequence };
56
- //# sourceMappingURL=createHotkeySequence.d.ts.map
52
+ export declare function createHotkeySequence(sequence: HotkeySequence | (() => HotkeySequence), callback: HotkeyCallback, options?: CreateHotkeySequenceOptions | (() => CreateHotkeySequenceOptions)): void;
53
+ //#endregion
@@ -103,5 +103,4 @@ function createHotkeySequence(sequence, callback, options = {}) {
103
103
  }
104
104
 
105
105
  //#endregion
106
- export { createHotkeySequence };
107
- //# sourceMappingURL=createHotkeySequence.js.map
106
+ export { createHotkeySequence };
@@ -1,7 +1,6 @@
1
1
  import { HotkeySequence, HotkeySequenceRecorderOptions } from "@tanstack/hotkeys";
2
-
3
2
  //#region src/createHotkeySequenceRecorder.d.ts
4
- interface SolidHotkeySequenceRecorder {
3
+ export interface SolidHotkeySequenceRecorder {
5
4
  isRecording: () => boolean;
6
5
  steps: () => HotkeySequence;
7
6
  recordedSequence: () => HotkeySequence | null;
@@ -13,7 +12,5 @@ interface SolidHotkeySequenceRecorder {
13
12
  /**
14
13
  * SolidJS primitive for recording multi-chord sequences (Vim-style shortcuts).
15
14
  */
16
- declare function createHotkeySequenceRecorder(options: HotkeySequenceRecorderOptions | (() => HotkeySequenceRecorderOptions)): SolidHotkeySequenceRecorder;
17
- //#endregion
18
- export { SolidHotkeySequenceRecorder, createHotkeySequenceRecorder };
19
- //# sourceMappingURL=createHotkeySequenceRecorder.d.ts.map
15
+ export declare function createHotkeySequenceRecorder(options: HotkeySequenceRecorderOptions | (() => HotkeySequenceRecorderOptions)): SolidHotkeySequenceRecorder;
16
+ //#endregion
@@ -10,10 +10,11 @@ import { useSelector } from "@tanstack/solid-store";
10
10
  function createHotkeySequenceRecorder(options) {
11
11
  const defaultOptions = useDefaultHotkeysOptions();
12
12
  const resolvedOptions = typeof options === "function" ? options() : options;
13
- const recorder = new HotkeySequenceRecorder({
13
+ const mergedOptions = {
14
14
  ...defaultOptions.hotkeySequenceRecorder,
15
15
  ...resolvedOptions
16
- });
16
+ };
17
+ const recorder = new HotkeySequenceRecorder(mergedOptions);
17
18
  const isRecording = useSelector(recorder.store, (state) => state.isRecording);
18
19
  const steps = useSelector(recorder.store, (state) => state.steps);
19
20
  const recordedSequence = useSelector(recorder.store, (state) => state.recordedSequence);
@@ -39,5 +40,4 @@ function createHotkeySequenceRecorder(options) {
39
40
  }
40
41
 
41
42
  //#endregion
42
- export { createHotkeySequenceRecorder };
43
- //# sourceMappingURL=createHotkeySequenceRecorder.js.map
43
+ export { createHotkeySequenceRecorder };
@@ -1,11 +1,10 @@
1
1
  import { CreateHotkeySequenceOptions } from "./createHotkeySequence.js";
2
2
  import { HotkeyCallback, HotkeySequence } from "@tanstack/hotkeys";
3
-
4
3
  //#region src/createHotkeySequences.d.ts
5
4
  /**
6
5
  * A single sequence definition for use with `createHotkeySequences`.
7
6
  */
8
- interface CreateHotkeySequenceDefinition {
7
+ export interface CreateHotkeySequenceDefinition {
9
8
  /** Array of hotkey strings that form the sequence */
10
9
  sequence: HotkeySequence;
11
10
  /** The function to call when the sequence is completed */
@@ -51,7 +50,5 @@ interface CreateHotkeySequenceDefinition {
51
50
  * }
52
51
  * ```
53
52
  */
54
- declare function createHotkeySequences(sequences: Array<CreateHotkeySequenceDefinition> | (() => Array<CreateHotkeySequenceDefinition>), commonOptions?: CreateHotkeySequenceOptions | (() => CreateHotkeySequenceOptions)): void;
55
- //#endregion
56
- export { CreateHotkeySequenceDefinition, createHotkeySequences };
57
- //# sourceMappingURL=createHotkeySequences.d.ts.map
53
+ export declare function createHotkeySequences(sequences: Array<CreateHotkeySequenceDefinition> | (() => Array<CreateHotkeySequenceDefinition>), commonOptions?: CreateHotkeySequenceOptions | (() => CreateHotkeySequenceOptions)): void;
54
+ //#endregion
@@ -108,5 +108,4 @@ function createHotkeySequences(sequences, commonOptions = {}) {
108
108
  }
109
109
 
110
110
  //#endregion
111
- export { createHotkeySequences };
112
- //# sourceMappingURL=createHotkeySequences.js.map
111
+ export { createHotkeySequences };
@@ -1,11 +1,10 @@
1
1
  import { CreateHotkeyOptions } from "./createHotkey.js";
2
2
  import { HotkeyCallback, RegisterableHotkey } from "@tanstack/hotkeys";
3
-
4
3
  //#region src/createHotkeys.d.ts
5
4
  /**
6
5
  * A single hotkey definition for use with `createHotkeys`.
7
6
  */
8
- interface CreateHotkeyDefinition {
7
+ export interface CreateHotkeyDefinition {
9
8
  /** The hotkey string (e.g., 'Mod+S', 'Escape') or RawHotkey object */
10
9
  hotkey: RegisterableHotkey;
11
10
  /** The function to call when the hotkey is pressed */
@@ -51,7 +50,5 @@ interface CreateHotkeyDefinition {
51
50
  * }
52
51
  * ```
53
52
  */
54
- declare function createHotkeys(hotkeys: Array<CreateHotkeyDefinition> | (() => Array<CreateHotkeyDefinition>), commonOptions?: CreateHotkeyOptions | (() => CreateHotkeyOptions)): void;
55
- //#endregion
56
- export { CreateHotkeyDefinition, createHotkeys };
57
- //# sourceMappingURL=createHotkeys.d.ts.map
53
+ export declare function createHotkeys(hotkeys: Array<CreateHotkeyDefinition> | (() => Array<CreateHotkeyDefinition>), commonOptions?: CreateHotkeyOptions | (() => CreateHotkeyOptions)): void;
54
+ //#endregion
@@ -108,5 +108,4 @@ function createHotkeys(hotkeys, commonOptions = {}) {
108
108
  }
109
109
 
110
110
  //#endregion
111
- export { createHotkeys };
112
- //# sourceMappingURL=createHotkeys.js.map
111
+ export { createHotkeys };
@@ -1,5 +1,4 @@
1
1
  import { IndividualKey } from "@tanstack/hotkeys";
2
-
3
2
  //#region src/createKeyHold.d.ts
4
3
  /**
5
4
  * SolidJS primitive that returns whether a specific key is currently being held.
@@ -41,7 +40,5 @@ import { IndividualKey } from "@tanstack/hotkeys";
41
40
  * }
42
41
  * ```
43
42
  */
44
- declare function createKeyHold(key: IndividualKey | (() => IndividualKey)): () => boolean;
45
- //#endregion
46
- export { createKeyHold };
47
- //# sourceMappingURL=createKeyHold.d.ts.map
43
+ export declare function createKeyHold(key: IndividualKey | (() => IndividualKey)): () => boolean;
44
+ //#endregion
@@ -44,7 +44,8 @@ import { useSelector } from "@tanstack/solid-store";
44
44
  * ```
45
45
  */
46
46
  function createKeyHold(key) {
47
- const heldKeysSelector = useSelector(getKeyStateTracker().store, (state) => state.heldKeys);
47
+ const tracker = getKeyStateTracker();
48
+ const heldKeysSelector = useSelector(tracker.store, (state) => state.heldKeys);
48
49
  return createMemo(() => {
49
50
  const normalizedKey = (typeof key === "function" ? key() : key).toLowerCase();
50
51
  return heldKeysSelector().some((heldKey) => heldKey.toLowerCase() === normalizedKey);
@@ -52,5 +53,4 @@ function createKeyHold(key) {
52
53
  }
53
54
 
54
55
  //#endregion
55
- export { createKeyHold };
56
- //# sourceMappingURL=createKeyHold.js.map
56
+ export { createKeyHold };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/solid-hotkeys",
3
- "version": "0.11.0",
3
+ "version": "0.12.0",
4
4
  "description": "SolidJS adapter for TanStack Hotkeys",
5
5
  "author": "Tanner Linsley",
6
6
  "license": "MIT",
@@ -23,33 +23,27 @@
23
23
  "shortcuts"
24
24
  ],
25
25
  "type": "module",
26
- "main": "./dist/index.cjs",
27
- "module": "./dist/index.js",
28
- "types": "./dist/index.d.cts",
26
+ "types": "./dist/index.d.ts",
29
27
  "exports": {
30
- ".": {
31
- "import": "./dist/index.js",
32
- "require": "./dist/index.cjs"
33
- },
28
+ ".": "./dist/index.js",
34
29
  "./package.json": "./package.json"
35
30
  },
36
31
  "sideEffects": false,
37
32
  "engines": {
38
- "node": ">=18"
33
+ "node": ">=20"
39
34
  },
40
35
  "files": [
41
- "dist",
42
- "src"
36
+ "dist"
43
37
  ],
44
38
  "dependencies": {
45
- "@tanstack/solid-store": "^0.11.0",
46
- "@tanstack/hotkeys": "0.9.0"
39
+ "@tanstack/hotkeys": "0.10.0",
40
+ "@tanstack/solid-store": "^0.11.1"
47
41
  },
48
42
  "devDependencies": {
49
43
  "@solidjs/testing-library": "^0.8.10",
50
- "@testing-library/jest-dom": "^6.9.1",
51
- "solid-js": "^1.9.12",
52
- "vite-plugin-solid": "^2.11.12"
44
+ "@testing-library/jest-dom": "^7.0.1",
45
+ "solid-js": "^1.9.15",
46
+ "vite-plugin-solid": "^2.11.14"
53
47
  },
54
48
  "peerDependencies": {
55
49
  "solid-js": ">=1.7.0"
@@ -62,6 +56,7 @@
62
56
  "test:lib": "vitest --passWithNoTests",
63
57
  "test:lib:dev": "pnpm test:lib --watch",
64
58
  "test:types": "tsc",
65
- "build": "tsdown"
59
+ "build": "tsdown",
60
+ "test:build": "publint --strict && node ../../scripts/verify-package.ts"
66
61
  }
67
62
  }
@@ -1,27 +0,0 @@
1
- let solid_js_web = require("solid-js/web");
2
- let solid_js = require("solid-js");
3
-
4
- //#region src/HotkeysProvider.tsx
5
- const HotkeysContext = (0, solid_js.createContext)(null);
6
- const DEFAULT_OPTIONS = {};
7
- const HotkeysProvider = (props) => {
8
- const contextValue = { defaultOptions: props.defaultOptions ?? DEFAULT_OPTIONS };
9
- return (0, solid_js_web.createComponent)(HotkeysContext.Provider, {
10
- value: contextValue,
11
- get children() {
12
- return props.children;
13
- }
14
- });
15
- };
16
- function useHotkeysContext() {
17
- return (0, solid_js.useContext)(HotkeysContext);
18
- }
19
- function useDefaultHotkeysOptions() {
20
- return (0, solid_js.useContext)(HotkeysContext)?.defaultOptions ?? {};
21
- }
22
-
23
- //#endregion
24
- exports.HotkeysProvider = HotkeysProvider;
25
- exports.useDefaultHotkeysOptions = useDefaultHotkeysOptions;
26
- exports.useHotkeysContext = useHotkeysContext;
27
- //# sourceMappingURL=HotkeysProvider.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"HotkeysProvider.cjs","names":["createContext","useContext","JSX","ParentComponent","HotkeyRecorderOptions","HotkeySequenceRecorderOptions","CreateHotkeyOptions","CreateHotkeySequenceOptions","HotkeysProviderOptions","hotkey","Partial","hotkeyRecorder","hotkeySequenceRecorder","hotkeySequence","HotkeysContextValue","defaultOptions","HotkeysContext","HotkeysProviderProps","children","Element","DEFAULT_OPTIONS","HotkeysProvider","props","contextValue","_$createComponent","Provider","value","useHotkeysContext","useDefaultHotkeysOptions","context"],"sources":["../src/HotkeysProvider.tsx"],"sourcesContent":["import { createContext, useContext } from 'solid-js'\nimport type { JSX, ParentComponent } from 'solid-js'\nimport type {\n HotkeyRecorderOptions,\n HotkeySequenceRecorderOptions,\n} from '@tanstack/hotkeys'\nimport type { CreateHotkeyOptions } from './createHotkey'\nimport type { CreateHotkeySequenceOptions } from './createHotkeySequence'\n\nexport interface HotkeysProviderOptions {\n hotkey?: Partial<CreateHotkeyOptions>\n hotkeyRecorder?: Partial<HotkeyRecorderOptions>\n hotkeySequenceRecorder?: Partial<HotkeySequenceRecorderOptions>\n hotkeySequence?: Partial<CreateHotkeySequenceOptions>\n}\n\ninterface HotkeysContextValue {\n defaultOptions: HotkeysProviderOptions\n}\n\nconst HotkeysContext = createContext<HotkeysContextValue | null>(null)\n\nexport interface HotkeysProviderProps {\n children: JSX.Element\n defaultOptions?: HotkeysProviderOptions\n}\n\nconst DEFAULT_OPTIONS: HotkeysProviderOptions = {}\n\nexport const HotkeysProvider: ParentComponent<HotkeysProviderProps> = (\n props,\n) => {\n const contextValue: HotkeysContextValue = {\n defaultOptions: props.defaultOptions ?? DEFAULT_OPTIONS,\n }\n\n return (\n <HotkeysContext.Provider value={contextValue}>\n {props.children}\n </HotkeysContext.Provider>\n )\n}\n\nexport function useHotkeysContext() {\n return useContext(HotkeysContext)\n}\n\nexport function useDefaultHotkeysOptions() {\n const context = useContext(HotkeysContext)\n return context?.defaultOptions ?? {}\n}\n"],"mappings":";;;;AAoBA,MAAMgB,6CAA2D,KAAK;AAOtE,MAAMI,kBAA0C,EAAE;AAElD,MAAaC,mBACXC,UACG;CACH,MAAMC,eAAoC,EACxCR,gBAAgBO,MAAMP,kBAAkBK,iBACzC;AAED,0CACGJ,eAAeS,UAAQ;EAACC,OAAOH;EAAY,IAAAL,WAAA;AAAA,UACzCI,MAAMJ;;EAAQ,CAAA;;AAKrB,SAAgBS,oBAAoB;AAClC,iCAAkBX,eAAe;;AAGnC,SAAgBY,2BAA2B;AAEzC,iCAD2BZ,eAAe,EAC1BD,kBAAkB,EAAE"}
@@ -1,25 +0,0 @@
1
- import { CreateHotkeyOptions } from "./createHotkey.cjs";
2
- import { CreateHotkeySequenceOptions } from "./createHotkeySequence.cjs";
3
- import { HotkeyRecorderOptions, HotkeySequenceRecorderOptions } from "@tanstack/hotkeys";
4
- import { JSX, ParentComponent } from "solid-js";
5
-
6
- //#region src/HotkeysProvider.d.ts
7
- interface HotkeysProviderOptions {
8
- hotkey?: Partial<CreateHotkeyOptions>;
9
- hotkeyRecorder?: Partial<HotkeyRecorderOptions>;
10
- hotkeySequenceRecorder?: Partial<HotkeySequenceRecorderOptions>;
11
- hotkeySequence?: Partial<CreateHotkeySequenceOptions>;
12
- }
13
- interface HotkeysContextValue {
14
- defaultOptions: HotkeysProviderOptions;
15
- }
16
- interface HotkeysProviderProps {
17
- children: JSX.Element;
18
- defaultOptions?: HotkeysProviderOptions;
19
- }
20
- declare const HotkeysProvider: ParentComponent<HotkeysProviderProps>;
21
- declare function useHotkeysContext(): HotkeysContextValue | null;
22
- declare function useDefaultHotkeysOptions(): HotkeysProviderOptions;
23
- //#endregion
24
- export { HotkeysProvider, HotkeysProviderOptions, HotkeysProviderProps, useDefaultHotkeysOptions, useHotkeysContext };
25
- //# sourceMappingURL=HotkeysProvider.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"HotkeysProvider.js","names":["createContext","useContext","JSX","ParentComponent","HotkeyRecorderOptions","HotkeySequenceRecorderOptions","CreateHotkeyOptions","CreateHotkeySequenceOptions","HotkeysProviderOptions","hotkey","Partial","hotkeyRecorder","hotkeySequenceRecorder","hotkeySequence","HotkeysContextValue","defaultOptions","HotkeysContext","HotkeysProviderProps","children","Element","DEFAULT_OPTIONS","HotkeysProvider","props","contextValue","_$createComponent","Provider","value","useHotkeysContext","useDefaultHotkeysOptions","context"],"sources":["../src/HotkeysProvider.tsx"],"sourcesContent":["import { createContext, useContext } from 'solid-js'\nimport type { JSX, ParentComponent } from 'solid-js'\nimport type {\n HotkeyRecorderOptions,\n HotkeySequenceRecorderOptions,\n} from '@tanstack/hotkeys'\nimport type { CreateHotkeyOptions } from './createHotkey'\nimport type { CreateHotkeySequenceOptions } from './createHotkeySequence'\n\nexport interface HotkeysProviderOptions {\n hotkey?: Partial<CreateHotkeyOptions>\n hotkeyRecorder?: Partial<HotkeyRecorderOptions>\n hotkeySequenceRecorder?: Partial<HotkeySequenceRecorderOptions>\n hotkeySequence?: Partial<CreateHotkeySequenceOptions>\n}\n\ninterface HotkeysContextValue {\n defaultOptions: HotkeysProviderOptions\n}\n\nconst HotkeysContext = createContext<HotkeysContextValue | null>(null)\n\nexport interface HotkeysProviderProps {\n children: JSX.Element\n defaultOptions?: HotkeysProviderOptions\n}\n\nconst DEFAULT_OPTIONS: HotkeysProviderOptions = {}\n\nexport const HotkeysProvider: ParentComponent<HotkeysProviderProps> = (\n props,\n) => {\n const contextValue: HotkeysContextValue = {\n defaultOptions: props.defaultOptions ?? DEFAULT_OPTIONS,\n }\n\n return (\n <HotkeysContext.Provider value={contextValue}>\n {props.children}\n </HotkeysContext.Provider>\n )\n}\n\nexport function useHotkeysContext() {\n return useContext(HotkeysContext)\n}\n\nexport function useDefaultHotkeysOptions() {\n const context = useContext(HotkeysContext)\n return context?.defaultOptions ?? {}\n}\n"],"mappings":";;;;AAoBA,MAAMgB,iBAAiBhB,cAA0C,KAAK;AAOtE,MAAMoB,kBAA0C,EAAE;AAElD,MAAaC,mBACXC,UACG;CACH,MAAMC,eAAoC,EACxCR,gBAAgBO,MAAMP,kBAAkBK,iBACzC;AAED,QAAAI,gBACGR,eAAeS,UAAQ;EAACC,OAAOH;EAAY,IAAAL,WAAA;AAAA,UACzCI,MAAMJ;;EAAQ,CAAA;;AAKrB,SAAgBS,oBAAoB;AAClC,QAAO1B,WAAWe,eAAe;;AAGnC,SAAgBY,2BAA2B;AAEzC,QADgB3B,WAAWe,eAAe,EAC1BD,kBAAkB,EAAE"}
@@ -1,42 +0,0 @@
1
- let _tanstack_hotkeys = require("@tanstack/hotkeys");
2
- let _tanstack_solid_store = require("@tanstack/solid-store");
3
-
4
- //#region src/createHeldKeyCodes.ts
5
- /**
6
- * SolidJS primitive that returns a signal of a map from currently held key names to their physical `event.code` values.
7
- *
8
- * This is useful for debugging which physical key was pressed (e.g. distinguishing
9
- * left vs right Shift via "ShiftLeft" / "ShiftRight").
10
- *
11
- * This primitive uses `useSelector` from `@tanstack/solid-store` to subscribe
12
- * to the global KeyStateTracker.
13
- *
14
- * @returns Signal accessor for record mapping normalized key names to their `event.code` values
15
- *
16
- * @example
17
- * ```tsx
18
- * function KeyDebugDisplay() {
19
- * const heldKeys = createHeldKeys()
20
- * const heldCodes = createHeldKeyCodes()
21
- *
22
- * return (
23
- * <div>
24
- * <For each={heldKeys()}>
25
- * {(key) => (
26
- * <kbd>
27
- * {key} <small>{heldCodes()[key]}</small>
28
- * </kbd>
29
- * )}
30
- * </For>
31
- * </div>
32
- * )
33
- * }
34
- * ```
35
- */
36
- function createHeldKeyCodes() {
37
- return (0, _tanstack_solid_store.useSelector)((0, _tanstack_hotkeys.getKeyStateTracker)().store, (state) => state.heldCodes);
38
- }
39
-
40
- //#endregion
41
- exports.createHeldKeyCodes = createHeldKeyCodes;
42
- //# sourceMappingURL=createHeldKeyCodes.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createHeldKeyCodes.cjs","names":[],"sources":["../src/createHeldKeyCodes.ts"],"sourcesContent":["import { useSelector } from '@tanstack/solid-store'\nimport { getKeyStateTracker } from '@tanstack/hotkeys'\n\n/**\n * SolidJS primitive that returns a signal of a map from currently held key names to their physical `event.code` values.\n *\n * This is useful for debugging which physical key was pressed (e.g. distinguishing\n * left vs right Shift via \"ShiftLeft\" / \"ShiftRight\").\n *\n * This primitive uses `useSelector` from `@tanstack/solid-store` to subscribe\n * to the global KeyStateTracker.\n *\n * @returns Signal accessor for record mapping normalized key names to their `event.code` values\n *\n * @example\n * ```tsx\n * function KeyDebugDisplay() {\n * const heldKeys = createHeldKeys()\n * const heldCodes = createHeldKeyCodes()\n *\n * return (\n * <div>\n * <For each={heldKeys()}>\n * {(key) => (\n * <kbd>\n * {key} <small>{heldCodes()[key]}</small>\n * </kbd>\n * )}\n * </For>\n * </div>\n * )\n * }\n * ```\n */\nexport function createHeldKeyCodes(): () => Record<string, string> {\n const tracker = getKeyStateTracker()\n return useSelector(tracker.store, (state) => state.heldCodes)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,SAAgB,qBAAmD;AAEjE,0FADoC,CACT,QAAQ,UAAU,MAAM,UAAU"}
@@ -1,36 +0,0 @@
1
- //#region src/createHeldKeyCodes.d.ts
2
- /**
3
- * SolidJS primitive that returns a signal of a map from currently held key names to their physical `event.code` values.
4
- *
5
- * This is useful for debugging which physical key was pressed (e.g. distinguishing
6
- * left vs right Shift via "ShiftLeft" / "ShiftRight").
7
- *
8
- * This primitive uses `useSelector` from `@tanstack/solid-store` to subscribe
9
- * to the global KeyStateTracker.
10
- *
11
- * @returns Signal accessor for record mapping normalized key names to their `event.code` values
12
- *
13
- * @example
14
- * ```tsx
15
- * function KeyDebugDisplay() {
16
- * const heldKeys = createHeldKeys()
17
- * const heldCodes = createHeldKeyCodes()
18
- *
19
- * return (
20
- * <div>
21
- * <For each={heldKeys()}>
22
- * {(key) => (
23
- * <kbd>
24
- * {key} <small>{heldCodes()[key]}</small>
25
- * </kbd>
26
- * )}
27
- * </For>
28
- * </div>
29
- * )
30
- * }
31
- * ```
32
- */
33
- declare function createHeldKeyCodes(): () => Record<string, string>;
34
- //#endregion
35
- export { createHeldKeyCodes };
36
- //# sourceMappingURL=createHeldKeyCodes.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createHeldKeyCodes.js","names":[],"sources":["../src/createHeldKeyCodes.ts"],"sourcesContent":["import { useSelector } from '@tanstack/solid-store'\nimport { getKeyStateTracker } from '@tanstack/hotkeys'\n\n/**\n * SolidJS primitive that returns a signal of a map from currently held key names to their physical `event.code` values.\n *\n * This is useful for debugging which physical key was pressed (e.g. distinguishing\n * left vs right Shift via \"ShiftLeft\" / \"ShiftRight\").\n *\n * This primitive uses `useSelector` from `@tanstack/solid-store` to subscribe\n * to the global KeyStateTracker.\n *\n * @returns Signal accessor for record mapping normalized key names to their `event.code` values\n *\n * @example\n * ```tsx\n * function KeyDebugDisplay() {\n * const heldKeys = createHeldKeys()\n * const heldCodes = createHeldKeyCodes()\n *\n * return (\n * <div>\n * <For each={heldKeys()}>\n * {(key) => (\n * <kbd>\n * {key} <small>{heldCodes()[key]}</small>\n * </kbd>\n * )}\n * </For>\n * </div>\n * )\n * }\n * ```\n */\nexport function createHeldKeyCodes(): () => Record<string, string> {\n const tracker = getKeyStateTracker()\n return useSelector(tracker.store, (state) => state.heldCodes)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,SAAgB,qBAAmD;AAEjE,QAAO,YADS,oBAAoB,CACT,QAAQ,UAAU,MAAM,UAAU"}