@tanstack/alpine-hotkeys 0.7.0 → 0.9.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,13 +1,11 @@
1
1
  import { read } from "./scope.js";
2
2
  import { HotkeyRecorder } from "@tanstack/hotkeys";
3
+ import { withDefaults } from "@tanstack/hotkeys/adapter";
3
4
 
4
5
  //#region src/createHotkeyRecorder.ts
5
6
  function createHotkeyRecorder(scope, options) {
6
7
  scope.assertActive();
7
- const instance = new HotkeyRecorder(() => ({
8
- ...scope.defaultOptions().hotkeyRecorder,
9
- ...read(options)
10
- }));
8
+ const instance = new HotkeyRecorder(() => withDefaults(scope.defaultOptions().hotkeyRecorder, read(options)));
11
9
  const state = scope.select(instance.store, (value) => value);
12
10
  scope.addCleanup(() => instance.destroy());
13
11
  return {
package/dist/types.d.ts CHANGED
@@ -57,8 +57,8 @@ export interface AlpineCustomHotkeys {
57
57
  export type MaybeGetter<T> = T | (() => T);
58
58
  /** Registers a hotkey: a chord, a sequence, or an app hotkey. */
59
59
  export interface AlpineCreateHotkey {
60
- <T extends AppHotkey>(hotkey: MaybeGetter<T>, callback: HotkeyCallback, options?: MaybeGetter<AlpineAppHotkeyOptions<T>>): void;
61
- <const T extends RegisterableHotkey>(hotkey: MaybeGetter<T>, callback: HotkeyCallback<HotkeyCallbackContextFor<T>>, options?: MaybeGetter<AlpineHotkeyOptionsFor<T>>): void;
60
+ <T extends AppHotkey>(hotkey: MaybeGetter<T | null | undefined>, callback: HotkeyCallback, options?: MaybeGetter<AlpineAppHotkeyOptions<T>>): void;
61
+ <const T extends RegisterableHotkey>(hotkey: MaybeGetter<T | null | undefined>, callback: HotkeyCallback<HotkeyCallbackContextFor<T>>, options?: MaybeGetter<AlpineHotkeyOptionsFor<T>>): void;
62
62
  }
63
63
  /** Creates a recorder; `maxSteps` (default 1) selects chords or sequences. */
64
64
  export interface AlpineCreateHotkeyRecorder {
@@ -73,6 +73,7 @@ export interface AlpineHotkeys {
73
73
  /**
74
74
  * Register one hotkey: a chord such as `'Mod+S'`, a sequence such as
75
75
  * `['G', 'G']`, or an app hotkey. Getters track changing hotkeys and options.
76
+ * `undefined`, `null`, or `''` registers nothing, for an optional shortcut.
76
77
  */
77
78
  createHotkey: AlpineCreateHotkey;
78
79
  /** Reconcile a list of hotkeys. Definition options override common options. */
@@ -83,8 +84,11 @@ export interface AlpineHotkeys {
83
84
  createHeldKeyCodes: () => AlpineHotkeyState<Record<string, string>>;
84
85
  /** Read whether a key is held through `.value`. */
85
86
  createKeyHold: (key: MaybeGetter<IndividualKey>) => AlpineHotkeyState<boolean>;
86
- /** Read whether held modifiers reveal a hotkey through `.value`. */
87
- createHotkeyHint: (hotkey: MaybeGetter<RegisterableHotkey | AppHotkey>, options?: MaybeGetter<HeldModifierOptions>) => AlpineHotkeyState<boolean>;
87
+ /**
88
+ * Read whether held modifiers reveal a hotkey through `.value`. No hotkey
89
+ * (`undefined`, `null`, or `''`) is never visible.
90
+ */
91
+ createHotkeyHint: (hotkey: MaybeGetter<RegisterableHotkey | AppHotkey | null | undefined>, options?: MaybeGetter<HeldModifierOptions>) => AlpineHotkeyState<boolean>;
88
92
  /** Read live registrations, including disabled entries. */
89
93
  createHotkeyRegistrations: () => HotkeyRegistrationsResult;
90
94
  /** Read the active, exclusive, allowed, and suspended scopes through `.value`. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/alpine-hotkeys",
3
- "version": "0.7.0",
3
+ "version": "0.9.0",
4
4
  "description": "Alpine adapter for TanStack Hotkeys",
5
5
  "author": "Tanner Linsley",
6
6
  "license": "MIT",
@@ -35,8 +35,7 @@
35
35
  "skills"
36
36
  ],
37
37
  "dependencies": {
38
- "@tanstack/hotkeys": "0.19.0",
39
- "@tanstack/store": "^0.11.2"
38
+ "@tanstack/hotkeys": "0.21.0"
40
39
  },
41
40
  "devDependencies": {
42
41
  "@types/alpinejs": "^3.17.0",