@tanstack/solid-hotkeys 0.12.1 → 0.13.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/README.md CHANGED
@@ -67,6 +67,9 @@ Type-safe keyboard shortcuts for the web. Template-string bindings, parsed objec
67
67
  > [!NOTE]
68
68
  > You may know **TanStack Hotkeys** by our adapter names, too!
69
69
  >
70
+ > - [**Alpine Hotkeys**](https://tanstack.com/hotkeys/latest/docs/framework/alpine/quick-start)
71
+ > - [**Ember Hotkeys**](https://tanstack.com/hotkeys/latest/docs/framework/ember/quick-start)
72
+ > - [**Octane Hotkeys**](https://tanstack.com/hotkeys/latest/docs/framework/octane/quick-start)
70
73
  > - [**React Hotkeys**](https://tanstack.com/hotkeys/latest/docs/framework/react/react-hotkeys)
71
74
  > - [**Preact Hotkeys**](https://tanstack.com/hotkeys/latest/docs/framework/preact/preact-hotkeys)
72
75
  > - [**Solid Hotkeys**](https://tanstack.com/hotkeys/latest/docs/framework/solid/reference)
@@ -5,9 +5,10 @@ import { createContext, useContext } from "solid-js";
5
5
  const HotkeysContext = createContext(null);
6
6
  const DEFAULT_OPTIONS = {};
7
7
  const HotkeysProvider = (props) => {
8
- const contextValue = { defaultOptions: props.defaultOptions ?? DEFAULT_OPTIONS };
9
8
  return createComponent(HotkeysContext.Provider, {
10
- value: contextValue,
9
+ value: { get defaultOptions() {
10
+ return props.defaultOptions ?? DEFAULT_OPTIONS;
11
+ } },
11
12
  get children() {
12
13
  return props.children;
13
14
  }
@@ -1,4 +1,4 @@
1
- import { useDefaultHotkeysOptions } from "./HotkeysProvider.js";
1
+ import { useDefaultHotkeysOptionsSource } from "./defaultOptions.js";
2
2
  import { detectPlatform, getHotkeyManager, normalizeRegisterableHotkey } from "@tanstack/hotkeys";
3
3
  import { createEffect, onCleanup, untrack } from "solid-js";
4
4
 
@@ -59,7 +59,7 @@ import { createEffect, onCleanup, untrack } from "solid-js";
59
59
  * ```
60
60
  */
61
61
  function createHotkey(hotkey, callback, options = {}) {
62
- const defaultOptions = useDefaultHotkeysOptions();
62
+ const defaultOptions = useDefaultHotkeysOptionsSource();
63
63
  const manager = getHotkeyManager();
64
64
  let registration = null;
65
65
  let lastHotkeyString = null;
@@ -76,7 +76,7 @@ function createHotkey(hotkey, callback, options = {}) {
76
76
  const resolvedHotkey = typeof hotkey === "function" ? hotkey() : hotkey;
77
77
  const resolvedOptions = typeof options === "function" ? options() : options;
78
78
  const mergedOptions = {
79
- ...defaultOptions.hotkey,
79
+ ...defaultOptions().hotkey,
80
80
  ...resolvedOptions
81
81
  };
82
82
  const platform = mergedOptions.platform ?? detectPlatform();
@@ -1,4 +1,4 @@
1
- import { useDefaultHotkeysOptions } from "./HotkeysProvider.js";
1
+ import { useDefaultHotkeysOptionsSource } from "./defaultOptions.js";
2
2
  import { HotkeyRecorder } from "@tanstack/hotkeys";
3
3
  import { createEffect, onCleanup } from "solid-js";
4
4
  import { useSelector } from "@tanstack/solid-store";
@@ -46,10 +46,10 @@ import { useSelector } from "@tanstack/solid-store";
46
46
  * ```
47
47
  */
48
48
  function createHotkeyRecorder(options) {
49
- const defaultOptions = useDefaultHotkeysOptions();
49
+ const defaultOptions = useDefaultHotkeysOptionsSource();
50
50
  const resolvedOptions = typeof options === "function" ? options() : options;
51
51
  const mergedOptions = {
52
- ...defaultOptions.hotkeyRecorder,
52
+ ...defaultOptions().hotkeyRecorder,
53
53
  ...resolvedOptions
54
54
  };
55
55
  const recorder = new HotkeyRecorder(mergedOptions);
@@ -58,7 +58,7 @@ function createHotkeyRecorder(options) {
58
58
  createEffect(() => {
59
59
  const resolved = typeof options === "function" ? options() : options;
60
60
  recorder.setOptions({
61
- ...defaultOptions.hotkeyRecorder,
61
+ ...defaultOptions().hotkeyRecorder,
62
62
  ...resolved
63
63
  });
64
64
  });
@@ -1,4 +1,4 @@
1
- import { useDefaultHotkeysOptions } from "./HotkeysProvider.js";
1
+ import { useDefaultHotkeysOptionsSource } from "./defaultOptions.js";
2
2
  import { formatHotkeySequence, getSequenceManager } from "@tanstack/hotkeys";
3
3
  import { createEffect, onCleanup, untrack } from "solid-js";
4
4
 
@@ -46,7 +46,7 @@ import { createEffect, onCleanup, untrack } from "solid-js";
46
46
  * ```
47
47
  */
48
48
  function createHotkeySequence(sequence, callback, options = {}) {
49
- const defaultOptions = useDefaultHotkeysOptions();
49
+ const defaultOptions = useDefaultHotkeysOptionsSource();
50
50
  const manager = getSequenceManager();
51
51
  let registration = null;
52
52
  let lastSequenceKey = null;
@@ -63,7 +63,7 @@ function createHotkeySequence(sequence, callback, options = {}) {
63
63
  const resolvedSequence = typeof sequence === "function" ? sequence() : sequence;
64
64
  const resolvedOptions = typeof options === "function" ? options() : options;
65
65
  const mergedOptions = {
66
- ...defaultOptions.hotkeySequence,
66
+ ...defaultOptions().hotkeySequence,
67
67
  ...resolvedOptions
68
68
  };
69
69
  const { target: _target, ...optionsWithoutTarget } = mergedOptions;
@@ -1,4 +1,4 @@
1
- import { useDefaultHotkeysOptions } from "./HotkeysProvider.js";
1
+ import { useDefaultHotkeysOptionsSource } from "./defaultOptions.js";
2
2
  import { HotkeySequenceRecorder } from "@tanstack/hotkeys";
3
3
  import { createEffect, onCleanup } from "solid-js";
4
4
  import { useSelector } from "@tanstack/solid-store";
@@ -8,10 +8,10 @@ import { useSelector } from "@tanstack/solid-store";
8
8
  * SolidJS primitive for recording multi-chord sequences (Vim-style shortcuts).
9
9
  */
10
10
  function createHotkeySequenceRecorder(options) {
11
- const defaultOptions = useDefaultHotkeysOptions();
11
+ const defaultOptions = useDefaultHotkeysOptionsSource();
12
12
  const resolvedOptions = typeof options === "function" ? options() : options;
13
13
  const mergedOptions = {
14
- ...defaultOptions.hotkeySequenceRecorder,
14
+ ...defaultOptions().hotkeySequenceRecorder,
15
15
  ...resolvedOptions
16
16
  };
17
17
  const recorder = new HotkeySequenceRecorder(mergedOptions);
@@ -21,7 +21,7 @@ function createHotkeySequenceRecorder(options) {
21
21
  createEffect(() => {
22
22
  const resolved = typeof options === "function" ? options() : options;
23
23
  recorder.setOptions({
24
- ...defaultOptions.hotkeySequenceRecorder,
24
+ ...defaultOptions().hotkeySequenceRecorder,
25
25
  ...resolved
26
26
  });
27
27
  });
@@ -1,4 +1,4 @@
1
- import { useDefaultHotkeysOptions } from "./HotkeysProvider.js";
1
+ import { useDefaultHotkeysOptionsSource } from "./defaultOptions.js";
2
2
  import { formatHotkeySequence, getSequenceManager } from "@tanstack/hotkeys";
3
3
  import { createEffect, onCleanup, untrack } from "solid-js";
4
4
 
@@ -42,7 +42,7 @@ import { createEffect, onCleanup, untrack } from "solid-js";
42
42
  * ```
43
43
  */
44
44
  function createHotkeySequences(sequences, commonOptions = {}) {
45
- const defaultOptions = useDefaultHotkeysOptions();
45
+ const defaultOptions = useDefaultHotkeysOptionsSource();
46
46
  const manager = getSequenceManager();
47
47
  const registrations = /* @__PURE__ */ new Map();
48
48
  onCleanup(() => {
@@ -58,7 +58,7 @@ function createHotkeySequences(sequences, commonOptions = {}) {
58
58
  const def = resolved[i];
59
59
  const resolvedDefOptions = def.options ?? {};
60
60
  const mergedOptions = {
61
- ...defaultOptions.hotkeySequence,
61
+ ...defaultOptions().hotkeySequence,
62
62
  ...resolvedCommonOptions,
63
63
  ...resolvedDefOptions
64
64
  };
@@ -1,4 +1,4 @@
1
- import { useDefaultHotkeysOptions } from "./HotkeysProvider.js";
1
+ import { useDefaultHotkeysOptionsSource } from "./defaultOptions.js";
2
2
  import { detectPlatform, getHotkeyManager, normalizeRegisterableHotkey } from "@tanstack/hotkeys";
3
3
  import { createEffect, onCleanup, untrack } from "solid-js";
4
4
 
@@ -42,7 +42,7 @@ import { createEffect, onCleanup, untrack } from "solid-js";
42
42
  * ```
43
43
  */
44
44
  function createHotkeys(hotkeys, commonOptions = {}) {
45
- const defaultOptions = useDefaultHotkeysOptions();
45
+ const defaultOptions = useDefaultHotkeysOptionsSource();
46
46
  const manager = getHotkeyManager();
47
47
  const registrations = /* @__PURE__ */ new Map();
48
48
  onCleanup(() => {
@@ -58,7 +58,7 @@ function createHotkeys(hotkeys, commonOptions = {}) {
58
58
  const def = resolvedHotkeys[i];
59
59
  const resolvedDefOptions = def.options ?? {};
60
60
  const mergedOptions = {
61
- ...defaultOptions.hotkey,
61
+ ...defaultOptions().hotkey,
62
62
  ...resolvedCommonOptions,
63
63
  ...resolvedDefOptions
64
64
  };
@@ -0,0 +1,11 @@
1
+ import { useHotkeysContext } from "./HotkeysProvider.js";
2
+
3
+ //#region src/defaultOptions.ts
4
+ /** Captures the context once and reads current defaults inside reactive computations. */
5
+ function useDefaultHotkeysOptionsSource() {
6
+ const context = useHotkeysContext();
7
+ return () => context?.defaultOptions ?? {};
8
+ }
9
+
10
+ //#endregion
11
+ export { useDefaultHotkeysOptionsSource };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/solid-hotkeys",
3
- "version": "0.12.1",
3
+ "version": "0.13.0",
4
4
  "description": "SolidJS adapter for TanStack Hotkeys",
5
5
  "author": "Tanner Linsley",
6
6
  "license": "MIT",
@@ -36,8 +36,8 @@
36
36
  "dist"
37
37
  ],
38
38
  "dependencies": {
39
- "@tanstack/hotkeys": "0.10.1",
40
- "@tanstack/solid-store": "^0.11.1"
39
+ "@tanstack/hotkeys": "0.11.0",
40
+ "@tanstack/solid-store": "^0.11.2"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@solidjs/testing-library": "^0.8.10",