@tanstack/solid-hotkeys 0.17.1 → 0.18.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.
@@ -1,7 +1,7 @@
1
- import { AppHotkeysStore, publishAppHotkeysStore } from "@tanstack/hotkeys";
1
+ import { publishAppHotkeysStore } from "@tanstack/hotkeys";
2
2
  import { createComponent } from "solid-js/web";
3
3
  import { createContext, createEffect, createMemo, onCleanup, onMount, useContext } from "solid-js";
4
- import { activateHotkeysProviderScope, getHotkeysProviderScopeKey, mergeHotkeysProviderDefaults } from "@tanstack/hotkeys/adapter";
4
+ import { activateHotkeysProviderScope, createAppHotkeysStore, getHotkeysProviderScopeKey, mergeHotkeysProviderDefaults } from "@tanstack/hotkeys/adapter";
5
5
 
6
6
  //#region src/HotkeysProvider.tsx
7
7
  const HotkeysContext = createContext(null);
@@ -35,7 +35,7 @@ const DEFAULT_OPTIONS = {};
35
35
  */
36
36
  const HotkeysProvider = (props) => {
37
37
  const parent = useContext(HotkeysContext);
38
- const store = props.appHotkeys ? new AppHotkeysStore(props.appHotkeys, {
38
+ const store = props.appHotkeys ? createAppHotkeysStore(props.appHotkeys, {
39
39
  customHotkeys: props.customHotkeys,
40
40
  onCustomHotkeysChange: (custom) => props.onCustomHotkeysChange?.(custom)
41
41
  }) : null;
@@ -0,0 +1,18 @@
1
+ import { createSignal, onCleanup } from "solid-js";
2
+
3
+ //#region src/_useSelector.ts
4
+ /**
5
+ * Subscribes to a store until the owner is cleaned up and returns an accessor
6
+ * for the selected value, which updates when it changes (by `===`).
7
+ */
8
+ function useSelector(store, selector) {
9
+ const [selected, setSelected] = createSignal(selector(store.get()));
10
+ const { unsubscribe } = store.subscribe((state) => {
11
+ setSelected(() => selector(state));
12
+ });
13
+ onCleanup(unsubscribe);
14
+ return selected;
15
+ }
16
+
17
+ //#endregion
18
+ export { useSelector };
@@ -5,8 +5,7 @@
5
5
  * This is useful for debugging which physical key was pressed (e.g. distinguishing
6
6
  * left vs right Shift via "ShiftLeft" / "ShiftRight").
7
7
  *
8
- * This primitive uses `useSelector` from `@tanstack/solid-store` to subscribe
9
- * to the global KeyStateTracker.
8
+ * This primitive subscribes to the global KeyStateTracker.
10
9
  *
11
10
  * @returns Signal accessor for record mapping normalized key names to their `event.code` values
12
11
  *
@@ -1,5 +1,5 @@
1
+ import { useSelector } from "./_useSelector.js";
1
2
  import { getKeyStateTracker } from "@tanstack/hotkeys";
2
- import { useSelector } from "@tanstack/solid-store";
3
3
 
4
4
  //#region src/createHeldKeyCodes.ts
5
5
  /**
@@ -8,8 +8,7 @@ import { useSelector } from "@tanstack/solid-store";
8
8
  * This is useful for debugging which physical key was pressed (e.g. distinguishing
9
9
  * left vs right Shift via "ShiftLeft" / "ShiftRight").
10
10
  *
11
- * This primitive uses `useSelector` from `@tanstack/solid-store` to subscribe
12
- * to the global KeyStateTracker.
11
+ * This primitive subscribes to the global KeyStateTracker.
13
12
  *
14
13
  * @returns Signal accessor for record mapping normalized key names to their `event.code` values
15
14
  *
@@ -2,8 +2,7 @@
2
2
  /**
3
3
  * SolidJS primitive that returns a signal of currently held keyboard keys.
4
4
  *
5
- * This primitive uses `useSelector` from `@tanstack/solid-store` to subscribe
6
- * to the global KeyStateTracker and updates whenever keys are pressed
5
+ * This primitive subscribes to the global KeyStateTracker and updates whenever keys are pressed
7
6
  * or released.
8
7
  *
9
8
  * @returns Signal accessor for array of currently held key names
@@ -1,12 +1,11 @@
1
+ import { useSelector } from "./_useSelector.js";
1
2
  import { getKeyStateTracker } from "@tanstack/hotkeys";
2
- import { useSelector } from "@tanstack/solid-store";
3
3
 
4
4
  //#region src/createHeldKeys.ts
5
5
  /**
6
6
  * SolidJS primitive that returns a signal of currently held keyboard keys.
7
7
  *
8
- * This primitive uses `useSelector` from `@tanstack/solid-store` to subscribe
9
- * to the global KeyStateTracker and updates whenever keys are pressed
8
+ * This primitive subscribes to the global KeyStateTracker and updates whenever keys are pressed
10
9
  * or released.
11
10
  *
12
11
  * @returns Signal accessor for array of currently held key names
@@ -1,7 +1,7 @@
1
+ import { useSelector } from "./_useSelector.js";
1
2
  import { useAppHotkeysStoreSource } from "./defaultOptions.js";
2
3
  import { getHotkeyManager, getKeyStateTracker, isAppHotkey, matchesHeldModifiers, resolveAppHotkey } from "@tanstack/hotkeys";
3
4
  import { createMemo } from "solid-js";
4
- import { useSelector } from "@tanstack/solid-store";
5
5
 
6
6
  //#region src/createHotkeyHint.ts
7
7
  /**
@@ -1,7 +1,7 @@
1
+ import { useSelector } from "./_useSelector.js";
1
2
  import { useDefaultHotkeysOptionsSource } from "./defaultOptions.js";
2
3
  import { HotkeyRecorder } from "@tanstack/hotkeys";
3
4
  import { createEffect, onCleanup } from "solid-js";
4
- import { useSelector } from "@tanstack/solid-store";
5
5
 
6
6
  //#region src/createHotkeyRecorder.ts
7
7
  function createHotkeyRecorder(options) {
@@ -1,5 +1,5 @@
1
+ import { useSelector } from "./_useSelector.js";
1
2
  import { getHotkeyManager, toHotkeyRegistrationView } from "@tanstack/hotkeys";
2
- import { useSelector } from "@tanstack/solid-store";
3
3
 
4
4
  //#region src/createHotkeyRegistrations.ts
5
5
  /**
@@ -1,5 +1,5 @@
1
+ import { useSelector } from "./_useSelector.js";
1
2
  import { getHotkeyManager } from "@tanstack/hotkeys";
2
- import { useSelector } from "@tanstack/solid-store";
3
3
 
4
4
  //#region src/createHotkeyScopesState.ts
5
5
  /**
@@ -3,8 +3,7 @@ import { IndividualKey } from "@tanstack/hotkeys";
3
3
  /**
4
4
  * SolidJS primitive that returns whether a specific key is currently being held.
5
5
  *
6
- * This primitive uses `useSelector` from `@tanstack/solid-store` to subscribe
7
- * to the global KeyStateTracker and uses a selector to determine if the
6
+ * This primitive subscribes to the global KeyStateTracker and uses a selector to determine if the
8
7
  * specified key is held.
9
8
  *
10
9
  * @param key - The key to check (e.g., 'Shift', 'Control', 'A') - can be an accessor function
@@ -1,13 +1,12 @@
1
+ import { useSelector } from "./_useSelector.js";
1
2
  import { getKeyStateTracker } from "@tanstack/hotkeys";
2
3
  import { createMemo } from "solid-js";
3
- import { useSelector } from "@tanstack/solid-store";
4
4
 
5
5
  //#region src/createKeyHold.ts
6
6
  /**
7
7
  * SolidJS primitive that returns whether a specific key is currently being held.
8
8
  *
9
- * This primitive uses `useSelector` from `@tanstack/solid-store` to subscribe
10
- * to the global KeyStateTracker and uses a selector to determine if the
9
+ * This primitive subscribes to the global KeyStateTracker and uses a selector to determine if the
11
10
  * specified key is held.
12
11
  *
13
12
  * @param key - The key to check (e.g., 'Shift', 'Control', 'A') - can be an accessor function
@@ -1,5 +1,6 @@
1
1
  import { useHotkeysContext } from "./HotkeysProvider.js";
2
- import { Store, useSelector } from "@tanstack/solid-store";
2
+ import { useSelector } from "./_useSelector.js";
3
+ import { createStore } from "@tanstack/hotkeys/adapter";
3
4
 
4
5
  //#region src/defaultOptions.ts
5
6
  /** Captures the context once and reads current defaults inside reactive computations. */
@@ -7,7 +8,7 @@ function useDefaultHotkeysOptionsSource() {
7
8
  const context = useHotkeysContext();
8
9
  return () => context?.defaultOptions ?? {};
9
10
  }
10
- const NO_APP_HOTKEYS = new Store(null);
11
+ const NO_APP_HOTKEYS = createStore(null);
11
12
  /**
12
13
  * The provider's app hotkeys store and an accessor that tracks its state, so
13
14
  * computations re-run when app hotkeys or custom hotkeys change.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/solid-hotkeys",
3
- "version": "0.17.1",
3
+ "version": "0.18.0",
4
4
  "description": "SolidJS adapter for TanStack Hotkeys",
5
5
  "author": "Tanner Linsley",
6
6
  "license": "MIT",
@@ -38,8 +38,7 @@
38
38
  "skills"
39
39
  ],
40
40
  "dependencies": {
41
- "@tanstack/hotkeys": "0.19.0",
42
- "@tanstack/solid-store": "^0.11.2"
41
+ "@tanstack/hotkeys": "0.20.0"
43
42
  },
44
43
  "devDependencies": {
45
44
  "@solidjs/testing-library": "^0.8.10",