@tanstack/react-hotkeys 0.21.0 → 0.22.1

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,8 +1,7 @@
1
1
  import { UseHotkeyCommonOptions } from "./useHotkey.js";
2
2
  import { AppHotkeys, AppHotkeysStore, CustomHotkeys, HotkeyChordRecorderOptions, HotkeyPlatform, HotkeySequenceRecorderOptions } from "@tanstack/hotkeys";
3
- import { ReactElement, ReactNode } from "react";
4
3
  import { HotkeysProviderScopeProps } from "@tanstack/hotkeys/adapter";
5
- //#region src/HotkeysProvider.d.ts
4
+ import { ReactElement, ReactNode } from "react";
6
5
  export interface HotkeysProviderOptions {
7
6
  /**
8
7
  * The user's platform, for labels from `useFormatForDisplay`, hotkeys, and
@@ -35,8 +34,8 @@ export interface HotkeysProviderProps<T extends AppHotkeys = AppHotkeys> extends
35
34
  /**
36
35
  * The user's saved custom hotkeys. When the value changes, such as after
37
36
  * saved data loads or the user signs in, it replaces the current custom
38
- * hotkeys. `undefined` leaves them unchanged; `null` clears them. Invalid
39
- * entries are ignored with a warning.
37
+ * hotkeys. `undefined` leaves them unchanged; `null` clears them. Unknown
38
+ * ids and invalid entries are ignored.
40
39
  */
41
40
  customHotkeys?: CustomHotkeys<T> | null;
42
41
  /** Called with the custom hotkeys after every change, ready to save. */
@@ -78,4 +77,4 @@ export interface HotkeysProviderProps<T extends AppHotkeys = AppHotkeys> extends
78
77
  export declare function HotkeysProvider<T extends AppHotkeys = AppHotkeys>({ children, appHotkeys, customHotkeys, onCustomHotkeysChange, defaultOptions, scope, exclusive, enabled }: HotkeysProviderProps<T>): ReactElement;
79
78
  export declare function useHotkeysContext(): HotkeysContextValue | null;
80
79
  export declare function useDefaultHotkeysOptions(): HotkeysProviderOptions;
81
- //#endregion
80
+ export {};
@@ -1,10 +1,10 @@
1
1
  'use client';
2
2
 
3
3
  import { publishAppHotkeysStore } from "@tanstack/hotkeys";
4
- import React, { createContext, useContext, useEffect, useMemo, useState } from "react";
5
4
  import { activateHotkeysProviderScope, createAppHotkeysStore, getHotkeysProviderScopeKey, mergeHotkeysProviderDefaults } from "@tanstack/hotkeys/adapter";
5
+ import React, { createContext, useContext, useEffect, useMemo, useState } from "react";
6
6
 
7
- //#region src/HotkeysProvider.tsx
7
+ // src/HotkeysProvider.tsx
8
8
  const HotkeysContext = createContext(null);
9
9
  const DEFAULT_OPTIONS = {};
10
10
  const NO_PARENT = {
@@ -96,5 +96,4 @@ function useDefaultHotkeysOptions() {
96
96
  return useContext(HotkeysContext)?.defaultOptions ?? DEFAULT_OPTIONS;
97
97
  }
98
98
 
99
- //#endregion
100
99
  export { HotkeysProvider, useDefaultHotkeysOptions, useHotkeysContext };
@@ -4,7 +4,7 @@ import { useHotkeysContext } from "./HotkeysProvider.js";
4
4
  import { useSelector } from "./_useSelector.js";
5
5
  import { createStore } from "@tanstack/hotkeys/adapter";
6
6
 
7
- //#region src/_appHotkeysStore.ts
7
+ // src/_appHotkeysStore.ts
8
8
  const NO_APP_HOTKEYS = createStore(null);
9
9
  /**
10
10
  * The provider's app hotkeys store, re-rendering when app hotkeys or custom
@@ -16,5 +16,4 @@ function useAppHotkeysStoreState() {
16
16
  return store;
17
17
  }
18
18
 
19
- //#endregion
20
19
  export { useAppHotkeysStoreState };
@@ -2,10 +2,10 @@
2
2
 
3
3
  import { useDefaultHotkeysOptions } from "./HotkeysProvider.js";
4
4
  import { detectPlatform } from "@tanstack/hotkeys";
5
- import { useSyncExternalStore } from "react";
6
5
  import { getServerPlatformSnapshot } from "@tanstack/hotkeys/adapter";
6
+ import { useSyncExternalStore } from "react";
7
7
 
8
- //#region src/_usePlatform.ts
8
+ // src/_usePlatform.ts
9
9
  const subscribe = () => () => {};
10
10
  /**
11
11
  * The provider's platform, or the detected one. Without a provider platform,
@@ -17,5 +17,4 @@ function usePlatform() {
17
17
  return useSyncExternalStore(subscribe, () => platform ?? detectPlatform(), () => platform ?? getServerPlatformSnapshot());
18
18
  }
19
19
 
20
- //#endregion
21
20
  export { usePlatform };
@@ -2,7 +2,7 @@
2
2
 
3
3
  import { useCallback, useRef, useSyncExternalStore } from "react";
4
4
 
5
- //#region src/_useSelector.ts
5
+ // src/_useSelector.ts
6
6
  /**
7
7
  * Subscribes to a store and returns the selected value, re-rendering when it
8
8
  * changes (by `Object.is`). The selector runs again only when the store's
@@ -10,20 +10,19 @@ import { useCallback, useRef, useSyncExternalStore } from "react";
10
10
  */
11
11
  function useSelector(store, selector) {
12
12
  const subscribe = useCallback((onChange) => store.subscribe(onChange).unsubscribe, [store]);
13
- const memo = useRef(null);
13
+ const memoRef = useRef(null);
14
14
  const getSelection = () => {
15
15
  const state = store.get();
16
- const last = memo.current;
16
+ const last = memoRef.current;
17
17
  if (last && last.selector === selector && Object.is(last.state, state)) return last.selected;
18
- memo.current = {
18
+ memoRef.current = {
19
19
  state,
20
20
  selector,
21
21
  selected: selector(state)
22
22
  };
23
- return memo.current.selected;
23
+ return memoRef.current.selected;
24
24
  };
25
25
  return useSyncExternalStore(subscribe, getSelection, getSelection);
26
26
  }
27
27
 
28
- //#endregion
29
28
  export { useSelector };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { UseAppHotkeyOptions, UseHotkeyChordOptions, UseHotkeyCommonOptions, UseHotkeyOptions, UseHotkeyOptionsFor, UseHotkeySequenceOptions, UseHotkeyTarget, useHotkey } from "./useHotkey.js";
2
1
  import { HotkeysProvider, HotkeysProviderOptions, HotkeysProviderProps, useDefaultHotkeysOptions, useHotkeysContext } from "./HotkeysProvider.js";
2
+ import { UseAppHotkeyOptions, UseHotkeyChordOptions, UseHotkeyCommonOptions, UseHotkeyOptions, UseHotkeyOptionsFor, UseHotkeySequenceOptions, UseHotkeyTarget, useHotkey } from "./useHotkey.js";
3
3
  import { UseHotkeyDefinition, useHotkeys } from "./useHotkeys.js";
4
4
  import { ReactHotkeyRecorder, useHotkeyRecorder } from "./useHotkeyRecorder.js";
5
5
  import { useHotkeyRegistrations } from "./useHotkeyRegistrations.js";
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { HotkeysProvider, useDefaultHotkeysOptions, useHotkeysContext } from "./HotkeysProvider.js";
2
- import { useHotkeys } from "./useHotkeys.js";
3
2
  import { useHotkey } from "./useHotkey.js";
3
+ import { useHotkeys } from "./useHotkeys.js";
4
4
  import { useHotkeyRecorder } from "./useHotkeyRecorder.js";
5
5
  import { useHotkeyRegistrations } from "./useHotkeyRegistrations.js";
6
6
  import { useHotkeyScopesState } from "./useHotkeyScopesState.js";
@@ -1,5 +1,4 @@
1
1
  import { AppHotkey, AppHotkeyListItem, CustomHotkeys, Hotkey, RegisteredAppHotkeys } from "@tanstack/hotkeys";
2
- //#region src/useAppHotkeys.d.ts
3
2
  /**
4
3
  * Returns the effective app hotkeys from `HotkeysProvider`, typed by
5
4
  * `Register`: each declaration with the user's custom hotkey applied.
@@ -67,5 +66,4 @@ export interface UseCustomHotkeysResult {
67
66
  * })
68
67
  * ```
69
68
  */
70
- export declare function useCustomHotkeys(): UseCustomHotkeysResult;
71
- //#endregion
69
+ export declare function useCustomHotkeys(): UseCustomHotkeysResult;
@@ -3,10 +3,10 @@
3
3
  import { useAppHotkeysStoreState } from "./_appHotkeysStore.js";
4
4
  import { useHotkeyRegistrations } from "./useHotkeyRegistrations.js";
5
5
 
6
- //#region src/useAppHotkeys.ts
6
+ // src/useAppHotkeys.ts
7
7
  function useRequiredStore(hook) {
8
8
  const store = useAppHotkeysStoreState();
9
- if (!store) throw new Error(`${hook} requires a HotkeysProvider with an appHotkeys prop`);
9
+ if (!store) throw new Error(`[hotkeys] ${hook} requires a HotkeysProvider with an appHotkeys prop`);
10
10
  return store;
11
11
  }
12
12
  /**
@@ -77,5 +77,4 @@ function useCustomHotkeys() {
77
77
  };
78
78
  }
79
79
 
80
- //#endregion
81
80
  export { useAppHotkeyList, useAppHotkeys, useCustomHotkeys };
@@ -1,5 +1,4 @@
1
1
  import { formatForDisplay } from "@tanstack/hotkeys";
2
- //#region src/useFormatForDisplay.d.ts
3
2
  /**
4
3
  * Returns `formatForDisplay` with the platform from `HotkeysProvider`, or the
5
4
  * detected platform without one. A `platform` passed to the returned function
@@ -23,5 +22,4 @@ import { formatForDisplay } from "@tanstack/hotkeys";
23
22
  * }
24
23
  * ```
25
24
  */
26
- export declare function useFormatForDisplay(): typeof formatForDisplay;
27
- //#endregion
25
+ export declare function useFormatForDisplay(): typeof formatForDisplay;
@@ -4,7 +4,7 @@ import { usePlatform } from "./_usePlatform.js";
4
4
  import { formatForDisplay } from "@tanstack/hotkeys";
5
5
  import { useCallback } from "react";
6
6
 
7
- //#region src/useFormatForDisplay.ts
7
+ // src/useFormatForDisplay.ts
8
8
  /**
9
9
  * Returns `formatForDisplay` with the platform from `HotkeysProvider`, or the
10
10
  * detected platform without one. A `platform` passed to the returned function
@@ -36,5 +36,4 @@ function useFormatForDisplay() {
36
36
  }), [platform]);
37
37
  }
38
38
 
39
- //#endregion
40
39
  export { useFormatForDisplay };
@@ -1,4 +1,3 @@
1
- //#region src/useHeldKeyCodes.d.ts
2
1
  /**
3
2
  * React hook that returns a map of currently held key names to their physical `event.code` values.
4
3
  *
@@ -25,5 +24,4 @@
25
24
  * }
26
25
  * ```
27
26
  */
28
- export declare function useHeldKeyCodes(): Record<string, string>;
29
- //#endregion
27
+ export declare function useHeldKeyCodes(): Record<string, string>;
@@ -3,7 +3,7 @@
3
3
  import { useSelector } from "./_useSelector.js";
4
4
  import { getKeyStateTracker } from "@tanstack/hotkeys";
5
5
 
6
- //#region src/useHeldKeyCodes.ts
6
+ // src/useHeldKeyCodes.ts
7
7
  /**
8
8
  * React hook that returns a map of currently held key names to their physical `event.code` values.
9
9
  *
@@ -35,5 +35,4 @@ function useHeldKeyCodes() {
35
35
  return useSelector(tracker.store, (state) => state.heldCodes);
36
36
  }
37
37
 
38
- //#endregion
39
38
  export { useHeldKeyCodes };
@@ -1,4 +1,3 @@
1
- //#region src/useHeldKeys.d.ts
2
1
  /**
3
2
  * React hook that returns an array of currently held keyboard keys.
4
3
  *
@@ -20,5 +19,4 @@
20
19
  * }
21
20
  * ```
22
21
  */
23
- export declare function useHeldKeys(): Array<string>;
24
- //#endregion
22
+ export declare function useHeldKeys(): Array<string>;
@@ -3,7 +3,7 @@
3
3
  import { useSelector } from "./_useSelector.js";
4
4
  import { getKeyStateTracker } from "@tanstack/hotkeys";
5
5
 
6
- //#region src/useHeldKeys.ts
6
+ // src/useHeldKeys.ts
7
7
  /**
8
8
  * React hook that returns an array of currently held keyboard keys.
9
9
  *
@@ -30,5 +30,4 @@ function useHeldKeys() {
30
30
  return useSelector(tracker.store, (state) => state.heldKeys);
31
31
  }
32
32
 
33
- //#endregion
34
33
  export { useHeldKeys };
@@ -1,6 +1,5 @@
1
1
  import { AppHotkey, HotkeyCallback, HotkeyCallbackContextFor, RegisterableHotkey } from "@tanstack/hotkeys";
2
2
  import { AdapterAppHotkeyOptions, AdapterChordOptions, AdapterCommonOptions, AdapterHotkeyOptions, AdapterOptionsFor, AdapterSequenceOptions } from "@tanstack/hotkeys/adapter";
3
- //#region src/useHotkey.d.ts
4
3
  /** A React ref, element, document, or window to listen on. */
5
4
  export type UseHotkeyTarget = React.RefObject<HTMLElement | null> | HTMLElement | Document | Window | null;
6
5
  /** Options shared by chords and sequences. */
@@ -62,5 +61,4 @@ export type UseAppHotkeyOptions<T extends AppHotkey = AppHotkey> = AdapterAppHot
62
61
  * ```
63
62
  */
64
63
  export declare function useHotkey<T extends AppHotkey>(hotkey: T | null | undefined, callback: HotkeyCallback, options?: UseAppHotkeyOptions<T>): void;
65
- export declare function useHotkey<const T extends RegisterableHotkey>(hotkey: T | null | undefined, callback: HotkeyCallback<HotkeyCallbackContextFor<T>>, options?: UseHotkeyOptionsFor<T>): void;
66
- //#endregion
64
+ export declare function useHotkey<const T extends RegisterableHotkey>(hotkey: T | null | undefined, callback: HotkeyCallback<HotkeyCallbackContextFor<T>>, options?: UseHotkeyOptionsFor<T>): void;
package/dist/useHotkey.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  import { useHotkeys } from "./useHotkeys.js";
4
4
 
5
- //#region src/useHotkey.ts
5
+ // src/useHotkey.ts
6
6
  function useHotkey(hotkey, callback, options) {
7
7
  useHotkeys([{
8
8
  hotkey,
@@ -11,5 +11,4 @@ function useHotkey(hotkey, callback, options) {
11
11
  }]);
12
12
  }
13
13
 
14
- //#endregion
15
14
  export { useHotkey };
@@ -1,5 +1,4 @@
1
1
  import { AppHotkey, HeldModifierOptions, RegisterableHotkey } from "@tanstack/hotkeys";
2
- //#region src/useHotkeyHint.d.ts
3
2
  /**
4
3
  * Returns a boolean indicating whether held modifiers reveal this shortcut.
5
4
  * The hint shows only while the hotkey can fire: some registration of it is
@@ -10,5 +9,4 @@ import { AppHotkey, HeldModifierOptions, RegisterableHotkey } from "@tanstack/ho
10
9
  * requires every modifier. A sequence reveals its hint from its first step.
11
10
  * Only visibility changes cause a rerender. This helper does not register a shortcut. A hotkey on an element counts only while focus is inside it.
12
11
  */
13
- export declare function useHotkeyHint(hotkey: RegisterableHotkey | AppHotkey | null | undefined, options?: HeldModifierOptions): boolean;
14
- //#endregion
12
+ export declare function useHotkeyHint(hotkey: RegisterableHotkey | AppHotkey | null | undefined, options?: HeldModifierOptions): boolean;
@@ -1,10 +1,10 @@
1
1
  'use client';
2
2
 
3
- import { useSelector } from "./_useSelector.js";
4
3
  import { useAppHotkeysStoreState } from "./_appHotkeysStore.js";
4
+ import { useSelector } from "./_useSelector.js";
5
5
  import { getHotkeyManager, getKeyStateTracker, isAppHotkey, matchesHeldModifiers, resolveAppHotkey } from "@tanstack/hotkeys";
6
6
 
7
- //#region src/useHotkeyHint.ts
7
+ // src/useHotkeyHint.ts
8
8
  /**
9
9
  * Returns a boolean indicating whether held modifiers reveal this shortcut.
10
10
  * The hint shows only while the hotkey can fire: some registration of it is
@@ -24,5 +24,4 @@ function useHotkeyHint(hotkey, options = {}) {
24
24
  return active && held;
25
25
  }
26
26
 
27
- //#endregion
28
27
  export { useHotkeyHint };
@@ -1,5 +1,4 @@
1
1
  import { Hotkey, HotkeyChord, HotkeyChordRecorderOptions, HotkeySequence, HotkeySequenceRecorderOptions } from "@tanstack/hotkeys";
2
- //#region src/useHotkeyRecorder.d.ts
3
2
  export interface ReactHotkeyRecorder<THotkey extends Hotkey = Hotkey> {
4
3
  /** Whether recording is currently active */
5
4
  isRecording: boolean;
@@ -54,5 +53,4 @@ export interface ReactHotkeyRecorder<THotkey extends Hotkey = Hotkey> {
54
53
  * ```
55
54
  */
56
55
  export declare function useHotkeyRecorder(options: HotkeyChordRecorderOptions): ReactHotkeyRecorder<HotkeyChord>;
57
- export declare function useHotkeyRecorder(options: HotkeySequenceRecorderOptions): ReactHotkeyRecorder;
58
- //#endregion
56
+ export declare function useHotkeyRecorder(options: HotkeySequenceRecorderOptions): ReactHotkeyRecorder;
@@ -3,10 +3,10 @@
3
3
  import { useDefaultHotkeysOptions } from "./HotkeysProvider.js";
4
4
  import { useSelector } from "./_useSelector.js";
5
5
  import { HotkeyRecorder } from "@tanstack/hotkeys";
6
- import { useEffect, useRef, useState } from "react";
7
6
  import { withDefaults } from "@tanstack/hotkeys/adapter";
7
+ import { useEffect, useRef, useState } from "react";
8
8
 
9
- //#region src/useHotkeyRecorder.ts
9
+ // src/useHotkeyRecorder.ts
10
10
  function useHotkeyRecorder(options) {
11
11
  const mergedOptions = withDefaults(useDefaultHotkeysOptions().hotkeyRecorder, options);
12
12
  const recorderRef = useRef(null);
@@ -35,5 +35,4 @@ function useHotkeyRecorder(options) {
35
35
  };
36
36
  }
37
37
 
38
- //#endregion
39
38
  export { useHotkeyRecorder };
@@ -1,5 +1,4 @@
1
1
  import { HotkeyRegistrationView } from "@tanstack/hotkeys";
2
- //#region src/useHotkeyRegistrations.d.ts
3
2
  /**
4
3
  * React hook that reactively reads every hotkey registration, chords and
5
4
  * sequences, from the singleton HotkeyManager. Narrow each view with `kind`.
@@ -26,5 +25,4 @@ import { HotkeyRegistrationView } from "@tanstack/hotkeys";
26
25
  * }
27
26
  * ```
28
27
  */
29
- export declare function useHotkeyRegistrations(): Array<HotkeyRegistrationView>;
30
- //#endregion
28
+ export declare function useHotkeyRegistrations(): Array<HotkeyRegistrationView>;
@@ -3,7 +3,7 @@
3
3
  import { useSelector } from "./_useSelector.js";
4
4
  import { getHotkeyManager, toHotkeyRegistrationView } from "@tanstack/hotkeys";
5
5
 
6
- //#region src/useHotkeyRegistrations.ts
6
+ // src/useHotkeyRegistrations.ts
7
7
  /**
8
8
  * React hook that reactively reads every hotkey registration, chords and
9
9
  * sequences, from the singleton HotkeyManager. Narrow each view with `kind`.
@@ -34,5 +34,4 @@ function useHotkeyRegistrations() {
34
34
  return useSelector(getHotkeyManager().registrations, (state) => Array.from(state.values()).map(toHotkeyRegistrationView));
35
35
  }
36
36
 
37
- //#endregion
38
37
  export { useHotkeyRegistrations };
@@ -1,5 +1,4 @@
1
1
  import { HotkeyScopesState } from "@tanstack/hotkeys";
2
- //#region src/useHotkeyScopesState.d.ts
3
2
  /**
4
3
  * React hook that returns the hotkey manager's scope state: the active
5
4
  * scopes, the exclusive scope that owns the keyboard, and the scopes it
@@ -16,5 +15,4 @@ import { HotkeyScopesState } from "@tanstack/hotkeys";
16
15
  * }
17
16
  * ```
18
17
  */
19
- export declare function useHotkeyScopesState(): HotkeyScopesState;
20
- //#endregion
18
+ export declare function useHotkeyScopesState(): HotkeyScopesState;
@@ -3,7 +3,7 @@
3
3
  import { useSelector } from "./_useSelector.js";
4
4
  import { getHotkeyManager } from "@tanstack/hotkeys";
5
5
 
6
- //#region src/useHotkeyScopesState.ts
6
+ // src/useHotkeyScopesState.ts
7
7
  /**
8
8
  * React hook that returns the hotkey manager's scope state: the active
9
9
  * scopes, the exclusive scope that owns the keyboard, and the scopes it
@@ -24,5 +24,4 @@ function useHotkeyScopesState() {
24
24
  return useSelector(getHotkeyManager().scopes, (state) => state);
25
25
  }
26
26
 
27
- //#endregion
28
27
  export { useHotkeyScopesState };
@@ -1,6 +1,5 @@
1
1
  import { UseHotkeyCommonOptions, UseHotkeyTarget } from "./useHotkey.js";
2
2
  import { AdapterHotkeyDefinition } from "@tanstack/hotkeys/adapter";
3
- //#region src/useHotkeys.d.ts
4
3
  /**
5
4
  * One hotkey for `useHotkeys`. Chords accept `requireReset`; sequences accept
6
5
  * `timeout`; hotkeys of unknown kind accept only shared options.
@@ -47,5 +46,4 @@ export type UseHotkeyDefinition = AdapterHotkeyDefinition<UseHotkeyTarget>;
47
46
  * }
48
47
  * ```
49
48
  */
50
- export declare function useHotkeys(hotkeys: ReadonlyArray<UseHotkeyDefinition>, commonOptions?: UseHotkeyCommonOptions): void;
51
- //#endregion
49
+ export declare function useHotkeys(hotkeys: ReadonlyArray<UseHotkeyDefinition>, commonOptions?: UseHotkeyCommonOptions): void;
@@ -3,10 +3,10 @@
3
3
  import { useHotkeysContext } from "./HotkeysProvider.js";
4
4
  import { useAppHotkeysStoreState } from "./_appHotkeysStore.js";
5
5
  import { resolveTarget } from "./utils.js";
6
- import { useEffect, useRef } from "react";
7
6
  import { createHotkeyBindings, prepareHotkeyDefinitions } from "@tanstack/hotkeys/adapter";
7
+ import { useEffect, useRef } from "react";
8
8
 
9
- //#region src/useHotkeys.ts
9
+ // src/useHotkeys.ts
10
10
  /**
11
11
  * React hook for registering several hotkeys at once: chords, sequences, and
12
12
  * app hotkeys. Accepts a dynamic array, so it is safe to use with
@@ -65,7 +65,7 @@ function useHotkeys(hotkeys, commonOptions = {}) {
65
65
  };
66
66
  const bindingsRef = useRef(null);
67
67
  useEffect(() => {
68
- bindingsRef.current ??= createHotkeyBindings();
68
+ bindingsRef.current ??= createHotkeyBindings({ afterDelegatedHandlers: true });
69
69
  const { hotkeys, ...context } = latestRef.current;
70
70
  bindingsRef.current.update(prepareHotkeyDefinitions(hotkeys, {
71
71
  ...context,
@@ -80,5 +80,4 @@ function useHotkeys(hotkeys, commonOptions = {}) {
80
80
  }, []);
81
81
  }
82
82
 
83
- //#endregion
84
83
  export { useHotkeys };
@@ -1,5 +1,4 @@
1
1
  import { IndividualKey } from "@tanstack/hotkeys";
2
- //#region src/useKeyHold.d.ts
3
2
  /**
4
3
  * React hook that returns whether a specific key is currently being held.
5
4
  *
@@ -39,5 +38,4 @@ import { IndividualKey } from "@tanstack/hotkeys";
39
38
  * }
40
39
  * ```
41
40
  */
42
- export declare function useKeyHold(key: IndividualKey): boolean;
43
- //#endregion
41
+ export declare function useKeyHold(key: IndividualKey): boolean;
@@ -3,7 +3,7 @@
3
3
  import { useSelector } from "./_useSelector.js";
4
4
  import { getKeyStateTracker } from "@tanstack/hotkeys";
5
5
 
6
- //#region src/useKeyHold.ts
6
+ // src/useKeyHold.ts
7
7
  /**
8
8
  * React hook that returns whether a specific key is currently being held.
9
9
  *
@@ -49,5 +49,4 @@ function useKeyHold(key) {
49
49
  return useSelector(tracker.store, (state) => state.heldKeys.some((heldKey) => heldKey.toLowerCase() === normalizedKey));
50
50
  }
51
51
 
52
- //#endregion
53
52
  export { useKeyHold };
package/dist/utils.js CHANGED
@@ -1,4 +1,4 @@
1
- //#region src/utils.ts
1
+ // src/utils.ts
2
2
  /**
3
3
  * Type guard to check if a value is a React ref-like object.
4
4
  */
@@ -13,5 +13,4 @@ function resolveTarget(target) {
13
13
  return isRef(target) ? target.current : target;
14
14
  }
15
15
 
16
- //#endregion
17
16
  export { resolveTarget };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/react-hotkeys",
3
- "version": "0.21.0",
3
+ "version": "0.22.1",
4
4
  "description": "React adapter for TanStack Hotkeys",
5
5
  "author": "Tanner Linsley",
6
6
  "license": "MIT",
@@ -35,19 +35,16 @@
35
35
  "skills"
36
36
  ],
37
37
  "dependencies": {
38
- "@tanstack/hotkeys": "0.23.0"
38
+ "@tanstack/hotkeys": "0.25.0"
39
39
  },
40
40
  "devDependencies": {
41
- "@eslint-react/eslint-plugin": "^4.2.3",
42
41
  "@tanstack/react-store": "^0.11.2",
43
42
  "@testing-library/react": "^16.3.3",
44
43
  "@types/react": "^19.3.0",
45
44
  "@types/react-dom": "^19.3.0",
46
- "@vitejs/plugin-react": "^6.1.1",
47
- "eslint-plugin-react-compiler": "19.1.0-rc.2",
48
- "eslint-plugin-react-hooks": "^7.1.1",
49
- "react": "^19.3.0",
50
- "react-dom": "^19.3.0"
45
+ "@vitejs/plugin-react": "^6.2.1",
46
+ "react": "^19.3.1",
47
+ "react-dom": "^19.3.1"
51
48
  },
52
49
  "peerDependencies": {
53
50
  "react": ">=18.0.0",
@@ -55,9 +52,9 @@
55
52
  },
56
53
  "scripts": {
57
54
  "clean": "premove ./build ./dist",
58
- "lint": "eslint ./src",
59
- "lint:fix": "eslint ./src --fix",
60
- "test:eslint": "eslint ./src",
55
+ "lint": "oxlint ./src",
56
+ "lint:fix": "oxlint ./src --fix",
57
+ "test:oxlint": "oxlint ./src",
61
58
  "test:lib": "vitest --passWithNoTests",
62
59
  "test:lib:dev": "pnpm test:lib --watch",
63
60
  "test:types": "tsc",
@@ -74,9 +74,9 @@ No provider is required. In React Server Components frameworks, call the hooks f
74
74
  ## A dialog that owns the keyboard
75
75
 
76
76
  ```tsx
77
+ import { HotkeysProvider, useHotkey } from '@tanstack/react-hotkeys'
77
78
  import { useId } from 'react'
78
79
  import type { ReactNode } from 'react'
79
- import { HotkeysProvider, useHotkey } from '@tanstack/react-hotkeys'
80
80
 
81
81
  export function Dialog(props: { onClose: () => void; children: ReactNode }) {
82
82
  return (
@@ -19,10 +19,10 @@ declare module '@tanstack/react-hotkeys' {
19
19
  ```
20
20
 
21
21
  ```tsx
22
- import type { ReactNode } from 'react'
23
22
  import { HotkeysProvider } from '@tanstack/react-hotkeys'
24
- import type { CustomHotkeys } from '@tanstack/react-hotkeys'
25
23
  import { appHotkeys } from './app-hotkeys'
24
+ import type { CustomHotkeys } from '@tanstack/react-hotkeys'
25
+ import type { ReactNode } from 'react'
26
26
 
27
27
  const saved: CustomHotkeys = JSON.parse(localStorage.getItem('hotkeys') ?? '{}')
28
28