@tanstack/alpine-hotkeys 0.11.3 → 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.
@@ -3,7 +3,8 @@ import { getKeyStateTracker } from "@tanstack/hotkeys";
3
3
 
4
4
  // src/createKeyHold.ts
5
5
  function createKeyHold(scope, key) {
6
- return scope.select(getKeyStateTracker().store, (state) => state.heldKeys.includes(read(key)));
6
+ const tracker = getKeyStateTracker();
7
+ return scope.select(tracker.store, () => tracker.isKeyHeld(read(key)));
7
8
  }
8
9
 
9
10
  export { createKeyHold };
package/dist/types.d.ts CHANGED
@@ -4,7 +4,10 @@ import { AdapterAppHotkeyOptions, AdapterCommonOptions, AdapterHotkeyDefinition,
4
4
  export interface AlpineHotkeyState<T> {
5
5
  readonly value: T;
6
6
  }
7
- /** The element to listen on. A `null` target skips registration until it is set. */
7
+ /**
8
+ * The element to listen on. A `null` or `undefined` target skips registration
9
+ * until it is set. Omit `target` for the document.
10
+ */
8
11
  export type AlpineHotkeyTarget = Target | null;
9
12
  /** One hotkey for `createHotkeys`: a chord, a sequence, or an app hotkey. */
10
13
  export type AlpineHotkeyDefinition = AdapterHotkeyDefinition<AlpineHotkeyTarget>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/alpine-hotkeys",
3
- "version": "0.11.3",
3
+ "version": "0.12.0",
4
4
  "description": "Alpine adapter for TanStack Hotkeys",
5
5
  "author": "Tanner Linsley",
6
6
  "license": "MIT",
@@ -35,9 +35,10 @@
35
35
  "skills"
36
36
  ],
37
37
  "dependencies": {
38
- "@tanstack/hotkeys": "0.25.1"
38
+ "@tanstack/hotkeys": "0.27.0"
39
39
  },
40
40
  "devDependencies": {
41
+ "@tanstack/hotkeys-test-utils": "0.0.0",
41
42
  "@types/alpinejs": "^3.17.0",
42
43
  "alpinejs": "^3.17.5"
43
44
  },
@@ -49,8 +50,9 @@
49
50
  "lint": "oxlint ./src",
50
51
  "lint:fix": "oxlint ./src --fix",
51
52
  "test:oxlint": "oxlint ./src",
52
- "test:lib": "vitest --passWithNoTests",
53
+ "test:lib": "vitest",
53
54
  "test:lib:dev": "pnpm test:lib --watch",
55
+ "test:coverage": "vitest --coverage",
54
56
  "test:types": "tsc",
55
57
  "build": "tsdown",
56
58
  "test:build": "publint --strict && node ../../scripts/verify-package.ts"
@@ -85,7 +85,7 @@ Each owner has these methods. Read their state through `.value`, or `.hotkeys` f
85
85
  | `createHotkeyRegistrations()` | List every registered hotkey with its options, `meta`, and `status` (whether it's enabled and in an active scope). |
86
86
  | `createHotkeyScopesState()` | Get the active scopes and the exclusive scope that owns the keyboard. |
87
87
  | `createHotkeyHint(hotkey, options?)` | Get whether held modifiers should reveal a shortcut's hint. False unless a registration of the hotkey can fire: enabled, in an active scope, and with focus inside its element target. |
88
- | `createKeyHold(key)` | Get whether one key is held. |
88
+ | `createKeyHold(key)` | Get whether one key is held. Letters match in any case; other names, such as `Shift`, are case-sensitive. |
89
89
  | `createHeldKeys()` | Get every key that's held right now. |
90
90
  | `createHeldKeyCodes()` | Map each held key to its physical `event.code`. |
91
91
  | `destroy()` | Release every hotkey, subscription, and recorder the owner created. |