@tanstack/solid-hotkeys 0.21.0 → 0.21.2

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,12 @@
1
1
  import { CreateHotkeyCommonOptions } from "./createHotkey.js";
2
2
  import { AppHotkeys, AppHotkeysStore, CustomHotkeys, HotkeyChordRecorderOptions, HotkeyPlatform, HotkeySequenceRecorderOptions } from "@tanstack/hotkeys";
3
- import { JSX, ParentComponent } from "solid-js";
4
3
  import { HotkeysProviderScopeProps } from "@tanstack/hotkeys/adapter";
5
- //#region src/HotkeysProvider.d.ts
4
+ import { JSX, ParentComponent } from "solid-js";
6
5
  export interface HotkeysProviderOptions {
7
6
  /**
8
7
  * The user's platform, for labels from `createFormatForDisplay`, hotkeys,
9
- * and recorders. On a server, set it from the request with
10
- * `detectPlatform(userAgent)`.
8
+ * recorders, and app hotkey checks such as conflicts. On a server, set it
9
+ * from the request with `detectPlatform(userAgent)`.
11
10
  */
12
11
  platform?: HotkeyPlatform;
13
12
  /**
@@ -35,8 +34,8 @@ export interface HotkeysProviderProps extends HotkeysProviderScopeProps {
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 | null;
42
41
  /** Called with the custom hotkeys after every change, ready to save. */
@@ -74,4 +73,4 @@ export interface HotkeysProviderProps extends HotkeysProviderScopeProps {
74
73
  export declare const HotkeysProvider: ParentComponent<HotkeysProviderProps>;
75
74
  export declare function useHotkeysContext(): HotkeysContextValue | null;
76
75
  export declare function useDefaultHotkeysOptions(): HotkeysProviderOptions;
77
- //#endregion
76
+ export {};
@@ -1,9 +1,9 @@
1
1
  import { publishAppHotkeysStore } from "@tanstack/hotkeys";
2
2
  import { createComponent } from "solid-js/web";
3
- import { createContext, createEffect, createMemo, onCleanup, onMount, useContext } from "solid-js";
4
3
  import { activateHotkeysProviderScope, createAppHotkeysStore, getHotkeysProviderScopeKey, mergeHotkeysProviderDefaults } from "@tanstack/hotkeys/adapter";
4
+ import { createContext, createEffect, createMemo, onCleanup, onMount, useContext } from "solid-js";
5
5
 
6
- //#region src/HotkeysProvider.tsx
6
+ // src/HotkeysProvider.tsx
7
7
  const HotkeysContext = createContext(null);
8
8
  const DEFAULT_OPTIONS = {};
9
9
  /**
@@ -37,20 +37,25 @@ const HotkeysProvider = (props) => {
37
37
  const parent = useContext(HotkeysContext);
38
38
  const store = props.appHotkeys ? createAppHotkeysStore(props.appHotkeys, {
39
39
  customHotkeys: props.customHotkeys,
40
- onCustomHotkeysChange: (custom) => props.onCustomHotkeysChange?.(custom)
40
+ onCustomHotkeysChange: (custom) => props.onCustomHotkeysChange?.(custom),
41
+ platform: props.defaultOptions?.platform ?? parent?.defaultOptions.platform
41
42
  }) : null;
42
43
  createEffect(() => {
43
44
  if (props.appHotkeys) store?.setAppHotkeys(props.appHotkeys);
44
45
  });
45
- createEffect(() => {
46
- const customHotkeys = props.customHotkeys;
47
- store?.setOptions({ customHotkeys });
48
- });
49
46
  onMount(() => {
50
47
  if (store) onCleanup(publishAppHotkeysStore(store));
51
48
  });
52
49
  const active = () => (parent?.enabled ?? true) && props.enabled !== false;
53
50
  const defaultOptions = createMemo(() => mergeHotkeysProviderDefaults(parent?.defaultOptions, props.defaultOptions, props.scope));
51
+ if (store) createEffect(() => {
52
+ const customHotkeys = props.customHotkeys;
53
+ const platform = defaultOptions().platform;
54
+ store.setOptions({
55
+ customHotkeys,
56
+ platform
57
+ });
58
+ });
54
59
  const scopeKey = createMemo(() => getHotkeysProviderScopeKey({
55
60
  scope: props.scope,
56
61
  exclusive: props.exclusive,
@@ -84,5 +89,4 @@ function useDefaultHotkeysOptions() {
84
89
  return useContext(HotkeysContext)?.defaultOptions ?? DEFAULT_OPTIONS;
85
90
  }
86
91
 
87
- //#endregion
88
92
  export { HotkeysProvider, useDefaultHotkeysOptions, useHotkeysContext };
@@ -1,6 +1,6 @@
1
1
  import { createSignal, onCleanup } from "solid-js";
2
2
 
3
- //#region src/_useSelector.ts
3
+ // src/_useSelector.ts
4
4
  /**
5
5
  * Subscribes to a store until the owner is cleaned up and returns an accessor
6
6
  * for the selected value, which updates when it changes (by `===`).
@@ -14,5 +14,4 @@ function useSelector(store, selector) {
14
14
  return selected;
15
15
  }
16
16
 
17
- //#endregion
18
17
  export { useSelector };
@@ -1,5 +1,4 @@
1
1
  import { AppHotkey, AppHotkeyListItem, CustomHotkeys, Hotkey, RegisteredAppHotkeys } from "@tanstack/hotkeys";
2
- //#region src/appHotkeys.d.ts
3
2
  /**
4
3
  * Returns an accessor for the effective app hotkeys from `HotkeysProvider`,
5
4
  * typed by `Register`: each declaration with the user's custom hotkey applied.
@@ -38,5 +37,4 @@ export interface UseCustomHotkeysResult {
38
37
  * registered app hotkey immediately and are passed to the provider's
39
38
  * `onCustomHotkeysChange`, ready to save.
40
39
  */
41
- export declare function useCustomHotkeys(): UseCustomHotkeysResult;
42
- //#endregion
40
+ export declare function useCustomHotkeys(): UseCustomHotkeysResult;
@@ -1,11 +1,11 @@
1
- import { useAppHotkeysStoreSource } from "./defaultOptions.js";
2
1
  import { createHotkeyRegistrations } from "./createHotkeyRegistrations.js";
2
+ import { useAppHotkeysStoreSource } from "./defaultOptions.js";
3
3
  import { createMemo } from "solid-js";
4
4
 
5
- //#region src/appHotkeys.ts
5
+ // src/appHotkeys.ts
6
6
  function useRequiredStore(name) {
7
7
  const source = useAppHotkeysStoreSource();
8
- if (!source.store) throw new Error(`${name} requires a HotkeysProvider with an appHotkeys prop`);
8
+ if (!source.store) throw new Error(`[hotkeys] ${name} requires a HotkeysProvider with an appHotkeys prop`);
9
9
  return {
10
10
  store: source.store,
11
11
  state: source.state
@@ -60,5 +60,4 @@ function useCustomHotkeys() {
60
60
  };
61
61
  }
62
62
 
63
- //#endregion
64
63
  export { createAppHotkeyList, useAppHotkeys, useCustomHotkeys };
@@ -1,5 +1,4 @@
1
1
  import { formatForDisplay } from "@tanstack/hotkeys";
2
- //#region src/createFormatForDisplay.d.ts
3
2
  /**
4
3
  * Returns `formatForDisplay` with the provider's `platform` as the default,
5
4
  * so labels match the user's platform. Call in a component; the returned
@@ -17,5 +16,4 @@ import { formatForDisplay } from "@tanstack/hotkeys";
17
16
  * }
18
17
  * ```
19
18
  */
20
- export declare function createFormatForDisplay(): typeof formatForDisplay;
21
- //#endregion
19
+ export declare function createFormatForDisplay(): typeof formatForDisplay;
@@ -1,7 +1,7 @@
1
1
  import { useDefaultHotkeysOptionsSource } from "./defaultOptions.js";
2
2
  import { formatForDisplay } from "@tanstack/hotkeys";
3
3
 
4
- //#region src/createFormatForDisplay.ts
4
+ // src/createFormatForDisplay.ts
5
5
  /**
6
6
  * Returns `formatForDisplay` with the provider's `platform` as the default,
7
7
  * so labels match the user's platform. Call in a component; the returned
@@ -27,5 +27,4 @@ function createFormatForDisplay() {
27
27
  }));
28
28
  }
29
29
 
30
- //#endregion
31
30
  export { createFormatForDisplay };
@@ -1,4 +1,3 @@
1
- //#region src/createHeldKeyCodes.d.ts
2
1
  /**
3
2
  * SolidJS primitive that returns a signal of a map from currently held key names to their physical `event.code` values.
4
3
  *
@@ -29,5 +28,4 @@
29
28
  * }
30
29
  * ```
31
30
  */
32
- export declare function createHeldKeyCodes(): () => Record<string, string>;
33
- //#endregion
31
+ export declare function createHeldKeyCodes(): () => Record<string, string>;
@@ -1,7 +1,7 @@
1
1
  import { useSelector } from "./_useSelector.js";
2
2
  import { getKeyStateTracker } from "@tanstack/hotkeys";
3
3
 
4
- //#region src/createHeldKeyCodes.ts
4
+ // src/createHeldKeyCodes.ts
5
5
  /**
6
6
  * SolidJS primitive that returns a signal of a map from currently held key names to their physical `event.code` values.
7
7
  *
@@ -37,5 +37,4 @@ function createHeldKeyCodes() {
37
37
  return useSelector(tracker.store, (state) => state.heldCodes);
38
38
  }
39
39
 
40
- //#endregion
41
40
  export { createHeldKeyCodes };
@@ -1,4 +1,3 @@
1
- //#region src/createHeldKeys.d.ts
2
1
  /**
3
2
  * SolidJS primitive that returns a signal of currently held keyboard keys.
4
3
  *
@@ -20,5 +19,4 @@
20
19
  * }
21
20
  * ```
22
21
  */
23
- export declare function createHeldKeys(): () => Array<string>;
24
- //#endregion
22
+ export declare function createHeldKeys(): () => Array<string>;
@@ -1,7 +1,7 @@
1
1
  import { useSelector } from "./_useSelector.js";
2
2
  import { getKeyStateTracker } from "@tanstack/hotkeys";
3
3
 
4
- //#region src/createHeldKeys.ts
4
+ // src/createHeldKeys.ts
5
5
  /**
6
6
  * SolidJS primitive that returns a signal of currently held keyboard keys.
7
7
  *
@@ -28,5 +28,4 @@ function createHeldKeys() {
28
28
  return useSelector(tracker.store, (state) => state.heldKeys);
29
29
  }
30
30
 
31
- //#endregion
32
31
  export { createHeldKeys };
@@ -1,6 +1,5 @@
1
1
  import { AppHotkey, HotkeyCallback, HotkeyCallbackContextFor, RegisterableHotkey, Target } from "@tanstack/hotkeys";
2
2
  import { AdapterAppHotkeyOptions, AdapterChordOptions, AdapterCommonOptions, AdapterHotkeyOptions, AdapterOptionsFor, AdapterSequenceOptions } from "@tanstack/hotkeys/adapter";
3
- //#region src/createHotkey.d.ts
4
3
  /**
5
4
  * The element to listen on. A `null` target skips registration, so pass an
6
5
  * accessor such as `() => ({ target: element() })` for elements that attach
@@ -40,4 +39,4 @@ type MaybeAccessor<T> = T | (() => T);
40
39
  */
41
40
  export declare function createHotkey<T extends AppHotkey>(hotkey: MaybeAccessor<T | null | undefined>, callback: HotkeyCallback, options?: MaybeAccessor<CreateAppHotkeyOptions<T>>): void;
42
41
  export declare function createHotkey<const T extends RegisterableHotkey>(hotkey: MaybeAccessor<T | null | undefined>, callback: HotkeyCallback<HotkeyCallbackContextFor<T>>, options?: MaybeAccessor<CreateHotkeyOptionsFor<T>>): void;
43
- //#endregion
42
+ export {};
@@ -1,6 +1,6 @@
1
1
  import { createHotkeys } from "./createHotkeys.js";
2
2
 
3
- //#region src/createHotkey.ts
3
+ // src/createHotkey.ts
4
4
  function createHotkey(hotkey, callback, options = {}) {
5
5
  createHotkeys(() => [{
6
6
  hotkey: typeof hotkey === "function" ? hotkey() : hotkey,
@@ -9,5 +9,4 @@ function createHotkey(hotkey, callback, options = {}) {
9
9
  }]);
10
10
  }
11
11
 
12
- //#endregion
13
12
  export { createHotkey };
@@ -1,5 +1,4 @@
1
1
  import { AppHotkey, HeldModifierOptions, RegisterableHotkey } from "@tanstack/hotkeys";
2
- //#region src/createHotkeyHint.d.ts
3
2
  /**
4
3
  * Returns an accessor indicating whether held modifiers reveal this shortcut.
5
4
  * The hint shows only while the hotkey can fire: some registration of it is
@@ -8,5 +7,4 @@ import { AppHotkey, HeldModifierOptions, RegisterableHotkey } from "@tanstack/ho
8
7
  * effective hotkey (false while unbound). No hotkey (`undefined`, `null`, or
9
8
  * `''`) returns false. This helper does not register a shortcut. A hotkey on an element counts only while focus is inside it.
10
9
  */
11
- export declare function createHotkeyHint(hotkey: RegisterableHotkey | AppHotkey | null | undefined | (() => RegisterableHotkey | AppHotkey | null | undefined), options?: HeldModifierOptions | (() => HeldModifierOptions)): () => boolean;
12
- //#endregion
10
+ export declare function createHotkeyHint(hotkey: RegisterableHotkey | AppHotkey | null | undefined | (() => RegisterableHotkey | AppHotkey | null | undefined), options?: HeldModifierOptions | (() => HeldModifierOptions)): () => boolean;
@@ -3,7 +3,7 @@ import { useAppHotkeysStoreSource } from "./defaultOptions.js";
3
3
  import { getHotkeyManager, getKeyStateTracker, isAppHotkey, matchesHeldModifiers, resolveAppHotkey } from "@tanstack/hotkeys";
4
4
  import { createMemo } from "solid-js";
5
5
 
6
- //#region src/createHotkeyHint.ts
6
+ // src/createHotkeyHint.ts
7
7
  /**
8
8
  * Returns an accessor indicating whether held modifiers reveal this shortcut.
9
9
  * The hint shows only while the hotkey can fire: some registration of it is
@@ -25,5 +25,4 @@ function createHotkeyHint(hotkey, options = {}) {
25
25
  });
26
26
  }
27
27
 
28
- //#endregion
29
28
  export { createHotkeyHint };
@@ -1,5 +1,4 @@
1
1
  import { Hotkey, HotkeyChord, HotkeyChordRecorderOptions, HotkeyRecorderOptions, HotkeySequence, HotkeySequenceRecorderOptions } from "@tanstack/hotkeys";
2
- //#region src/createHotkeyRecorder.d.ts
3
2
  export interface SolidHotkeyRecorder<THotkey extends Hotkey = Hotkey> {
4
3
  /** Whether recording is currently active */
5
4
  isRecording: () => boolean;
@@ -34,5 +33,4 @@ export declare function createHotkeyRecorder(options: HotkeyChordRecorderOptions
34
33
  export declare function createHotkeyRecorder(options: HotkeySequenceRecorderOptions): SolidHotkeyRecorder;
35
34
  export declare function createHotkeyRecorder(options: () => HotkeySequenceRecorderOptions): SolidHotkeyRecorder;
36
35
  export declare function createHotkeyRecorder(options: () => HotkeyChordRecorderOptions): SolidHotkeyRecorder<HotkeyChord>;
37
- export declare function createHotkeyRecorder(options: () => HotkeyRecorderOptions): SolidHotkeyRecorder;
38
- //#endregion
36
+ export declare function createHotkeyRecorder(options: () => HotkeyRecorderOptions): SolidHotkeyRecorder;
@@ -1,10 +1,10 @@
1
1
  import { useSelector } from "./_useSelector.js";
2
2
  import { useDefaultHotkeysOptionsSource } from "./defaultOptions.js";
3
3
  import { HotkeyRecorder } from "@tanstack/hotkeys";
4
- import { createEffect, onCleanup } from "solid-js";
5
4
  import { withDefaults } from "@tanstack/hotkeys/adapter";
5
+ import { createEffect, onCleanup } from "solid-js";
6
6
 
7
- //#region src/createHotkeyRecorder.ts
7
+ // src/createHotkeyRecorder.ts
8
8
  function createHotkeyRecorder(options) {
9
9
  const defaultOptions = useDefaultHotkeysOptionsSource();
10
10
  const resolve = () => withDefaults(defaultOptions().hotkeyRecorder, typeof options === "function" ? options() : options);
@@ -29,5 +29,4 @@ function createHotkeyRecorder(options) {
29
29
  };
30
30
  }
31
31
 
32
- //#endregion
33
32
  export { createHotkeyRecorder };
@@ -1,5 +1,4 @@
1
1
  import { HotkeyRegistrationView } from "@tanstack/hotkeys";
2
- //#region src/createHotkeyRegistrations.d.ts
3
2
  /**
4
3
  * Solid primitive that reactively reads every hotkey registration, chords and
5
4
  * sequences, from the singleton HotkeyManager. Narrow each view with `kind`.
@@ -16,5 +15,4 @@ import { HotkeyRegistrationView } from "@tanstack/hotkeys";
16
15
  * </For>
17
16
  * ```
18
17
  */
19
- export declare function createHotkeyRegistrations(): () => Array<HotkeyRegistrationView>;
20
- //#endregion
18
+ export declare function createHotkeyRegistrations(): () => Array<HotkeyRegistrationView>;
@@ -1,7 +1,7 @@
1
1
  import { useSelector } from "./_useSelector.js";
2
2
  import { getHotkeyManager, toHotkeyRegistrationView } from "@tanstack/hotkeys";
3
3
 
4
- //#region src/createHotkeyRegistrations.ts
4
+ // src/createHotkeyRegistrations.ts
5
5
  /**
6
6
  * Solid primitive that reactively reads every hotkey registration, chords and
7
7
  * sequences, from the singleton HotkeyManager. Narrow each view with `kind`.
@@ -22,5 +22,4 @@ function createHotkeyRegistrations() {
22
22
  return useSelector(getHotkeyManager().registrations, (state) => Array.from(state.values()).map(toHotkeyRegistrationView));
23
23
  }
24
24
 
25
- //#endregion
26
25
  export { createHotkeyRegistrations };
@@ -1,5 +1,4 @@
1
1
  import { HotkeyScopesState } from "@tanstack/hotkeys";
2
- //#region src/createHotkeyScopesState.d.ts
3
2
  /**
4
3
  * SolidJS primitive that returns a signal of the hotkey manager's scope state:
5
4
  * the active scopes, the exclusive scope that owns the keyboard, and the
@@ -20,5 +19,4 @@ import { HotkeyScopesState } from "@tanstack/hotkeys";
20
19
  * }
21
20
  * ```
22
21
  */
23
- export declare function createHotkeyScopesState(): () => HotkeyScopesState;
24
- //#endregion
22
+ export declare function createHotkeyScopesState(): () => HotkeyScopesState;
@@ -1,7 +1,7 @@
1
1
  import { useSelector } from "./_useSelector.js";
2
2
  import { getHotkeyManager } from "@tanstack/hotkeys";
3
3
 
4
- //#region src/createHotkeyScopesState.ts
4
+ // src/createHotkeyScopesState.ts
5
5
  /**
6
6
  * SolidJS primitive that returns a signal of the hotkey manager's scope state:
7
7
  * the active scopes, the exclusive scope that owns the keyboard, and the
@@ -26,5 +26,4 @@ function createHotkeyScopesState() {
26
26
  return useSelector(getHotkeyManager().scopes, (state) => state);
27
27
  }
28
28
 
29
- //#endregion
30
29
  export { createHotkeyScopesState };
@@ -1,6 +1,5 @@
1
1
  import { CreateHotkeyCommonOptions, CreateHotkeyTarget } from "./createHotkey.js";
2
2
  import { AdapterHotkeyDefinition } from "@tanstack/hotkeys/adapter";
3
- //#region src/createHotkeys.d.ts
4
3
  /**
5
4
  * One hotkey for `createHotkeys`. Chords accept `requireReset`; sequences
6
5
  * accept `timeout`; hotkeys of unknown kind accept only shared options.
@@ -24,5 +23,4 @@ export type CreateHotkeyDefinition = AdapterHotkeyDefinition<CreateHotkeyTarget>
24
23
  * ])
25
24
  * ```
26
25
  */
27
- export declare function createHotkeys(hotkeys: ReadonlyArray<CreateHotkeyDefinition> | (() => ReadonlyArray<CreateHotkeyDefinition>), commonOptions?: CreateHotkeyCommonOptions | (() => CreateHotkeyCommonOptions)): void;
28
- //#endregion
26
+ export declare function createHotkeys(hotkeys: ReadonlyArray<CreateHotkeyDefinition> | (() => ReadonlyArray<CreateHotkeyDefinition>), commonOptions?: CreateHotkeyCommonOptions | (() => CreateHotkeyCommonOptions)): void;
@@ -1,9 +1,9 @@
1
1
  import { useAppHotkeysStoreSource, useDefaultHotkeysOptionsSource } from "./defaultOptions.js";
2
2
  import { delegateEvents } from "solid-js/web";
3
- import { createEffect, onCleanup, untrack } from "solid-js";
4
3
  import { createHotkeyBindings, prepareHotkeyDefinitions } from "@tanstack/hotkeys/adapter";
4
+ import { createEffect, onCleanup, untrack } from "solid-js";
5
5
 
6
- //#region src/createHotkeys.ts
6
+ // src/createHotkeys.ts
7
7
  /**
8
8
  * Solid primitive for registering several hotkeys at once: chords, sequences,
9
9
  * and app hotkeys. Pass an accessor for a reactive list.
@@ -40,5 +40,4 @@ function createHotkeys(hotkeys, commonOptions = {}) {
40
40
  });
41
41
  }
42
42
 
43
- //#endregion
44
43
  export { createHotkeys };
@@ -1,5 +1,4 @@
1
1
  import { IndividualKey } from "@tanstack/hotkeys";
2
- //#region src/createKeyHold.d.ts
3
2
  /**
4
3
  * SolidJS primitive 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 createKeyHold(key: IndividualKey | (() => IndividualKey)): () => boolean;
43
- //#endregion
41
+ export declare function createKeyHold(key: IndividualKey | (() => IndividualKey)): () => boolean;
@@ -2,7 +2,7 @@ import { useSelector } from "./_useSelector.js";
2
2
  import { getKeyStateTracker } from "@tanstack/hotkeys";
3
3
  import { createMemo } from "solid-js";
4
4
 
5
- //#region src/createKeyHold.ts
5
+ // src/createKeyHold.ts
6
6
  /**
7
7
  * SolidJS primitive that returns whether a specific key is currently being held.
8
8
  *
@@ -51,5 +51,4 @@ function createKeyHold(key) {
51
51
  });
52
52
  }
53
53
 
54
- //#endregion
55
54
  export { createKeyHold };
@@ -2,7 +2,7 @@ import { useHotkeysContext } from "./HotkeysProvider.js";
2
2
  import { useSelector } from "./_useSelector.js";
3
3
  import { createStore } from "@tanstack/hotkeys/adapter";
4
4
 
5
- //#region src/defaultOptions.ts
5
+ // src/defaultOptions.ts
6
6
  /** Captures the context once and reads current defaults inside reactive computations. */
7
7
  function useDefaultHotkeysOptionsSource() {
8
8
  const context = useHotkeysContext();
@@ -21,5 +21,4 @@ function useAppHotkeysStoreSource() {
21
21
  };
22
22
  }
23
23
 
24
- //#endregion
25
24
  export { useAppHotkeysStoreSource, useDefaultHotkeysOptionsSource };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { CreateAppHotkeyOptions, CreateHotkeyChordOptions, CreateHotkeyCommonOptions, CreateHotkeyOptions, CreateHotkeyOptionsFor, CreateHotkeySequenceOptions, CreateHotkeyTarget, createHotkey } from "./createHotkey.js";
2
1
  import { HotkeysProvider, HotkeysProviderOptions, HotkeysProviderProps, useDefaultHotkeysOptions, useHotkeysContext } from "./HotkeysProvider.js";
2
+ import { CreateAppHotkeyOptions, CreateHotkeyChordOptions, CreateHotkeyCommonOptions, CreateHotkeyOptions, CreateHotkeyOptionsFor, CreateHotkeySequenceOptions, CreateHotkeyTarget, createHotkey } from "./createHotkey.js";
3
3
  import { CreateHotkeyDefinition, createHotkeys } from "./createHotkeys.js";
4
4
  import { SolidHotkeyRecorder, createHotkeyRecorder } from "./createHotkeyRecorder.js";
5
5
  import { createHotkeyRegistrations } from "./createHotkeyRegistrations.js";
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { HotkeysProvider, useDefaultHotkeysOptions, useHotkeysContext } from "./HotkeysProvider.js";
2
- import { createHotkeys } from "./createHotkeys.js";
3
2
  import { createHotkey } from "./createHotkey.js";
3
+ import { createHotkeys } from "./createHotkeys.js";
4
4
  import { createHotkeyRecorder } from "./createHotkeyRecorder.js";
5
5
  import { createHotkeyRegistrations } from "./createHotkeyRegistrations.js";
6
6
  import { createHotkeyScopesState } from "./createHotkeyScopesState.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/solid-hotkeys",
3
- "version": "0.21.0",
3
+ "version": "0.21.2",
4
4
  "description": "SolidJS adapter for TanStack Hotkeys",
5
5
  "author": "Tanner Linsley",
6
6
  "license": "MIT",
@@ -38,22 +38,22 @@
38
38
  "skills"
39
39
  ],
40
40
  "dependencies": {
41
- "@tanstack/hotkeys": "0.24.0"
41
+ "@tanstack/hotkeys": "0.25.1"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@solidjs/testing-library": "^0.8.10",
45
45
  "@testing-library/jest-dom": "^7.0.1",
46
- "solid-js": "^1.9.15",
47
- "vite-plugin-solid": "^2.11.14"
46
+ "solid-js": "^1.9.18",
47
+ "vite-plugin-solid": "^2.11.15"
48
48
  },
49
49
  "peerDependencies": {
50
50
  "solid-js": "^1.7.0"
51
51
  },
52
52
  "scripts": {
53
53
  "clean": "premove ./build ./dist",
54
- "lint": "eslint ./src",
55
- "lint:fix": "eslint ./src --fix",
56
- "test:eslint": "eslint ./src",
54
+ "lint": "oxlint ./src",
55
+ "lint:fix": "oxlint ./src --fix",
56
+ "test:oxlint": "oxlint ./src",
57
57
  "test:lib": "vitest --passWithNoTests",
58
58
  "test:lib:dev": "pnpm test:lib --watch",
59
59
  "test:types": "tsc",
@@ -30,8 +30,8 @@ requires:
30
30
  Before starting, load the `@tanstack/hotkeys#hotkeys-core` skill (`npx @tanstack/intent@latest load @tanstack/hotkeys#hotkeys-core`).
31
31
 
32
32
  ```tsx
33
- import { createSignal } from 'solid-js'
34
33
  import { createHotkey } from '@tanstack/solid-hotkeys'
34
+ import { createSignal } from 'solid-js'
35
35
 
36
36
  export function Editor() {
37
37
  const [isDirty, setIsDirty] = createSignal(false)
@@ -85,7 +85,7 @@ The state these return is accessors, including the recorder's fields. No provide
85
85
  - **The callback isn't tracked.** Read props inside it, as `() => props.onClose()`, rather than passing `props.onClose` itself.
86
86
  - **Register a dialog's hotkeys in a child of its provider.** A primitive uses the nearest `HotkeysProvider` above its component, so a dialog that renders `<HotkeysProvider scope={...} exclusive>` and creates `Escape` itself puts it in the suspended outer scope. Give each open dialog its own scope name, such as `` `dialog-${createUniqueId()}` ``.
87
87
  - **Call the primitives directly.** A `createShortcut(keys: string)` wrapper has to cast strings to hotkeys, which turns off type checking and drops sequences, accessor options, and app hotkeys.
88
- - **Server-rendered labels need the user's platform.** On the server, `formatForDisplay` can't see the user's OS, so it renders Linux labels that differ after hydration for Mac and Windows users. Set the provider's `defaultOptions.platform` to `detectPlatform(userAgent)` from the request's `User-Agent` header, and format labels with `const format = createFormatForDisplay()` in the component, then `format(hotkey)`. Keep plain `formatForDisplay` for labels that render only in the browser.
88
+ - **Server-rendered labels need the user's platform.** On the server, `formatForDisplay` can't see the user's OS, so it renders Linux labels that differ after hydration for Mac and Windows users. Set the provider's `defaultOptions.platform` to `detectPlatform(userAgent)` from the request's `User-Agent` header, and format labels with `const format = createFormatForDisplay()` in the component, then `format(hotkey)`. Keep plain `formatForDisplay` for labels that render only in the browser, when no provider sets `platform`.
89
89
 
90
90
  When declaring app hotkeys, building a cheat sheet, or letting users rebind shortcuts, load `@tanstack/hotkeys#app-hotkeys` and read [app hotkeys in Solid](references/app-hotkeys.md).
91
91
 
@@ -19,10 +19,10 @@ declare module '@tanstack/solid-hotkeys' {
19
19
  ```
20
20
 
21
21
  ```tsx no-check
22
- import type { JSX } from 'solid-js'
23
22
  import { HotkeysProvider } from '@tanstack/solid-hotkeys'
24
- import type { CustomHotkeys } from '@tanstack/solid-hotkeys'
25
23
  import { appHotkeys } from './app-hotkeys'
24
+ import type { CustomHotkeys } from '@tanstack/solid-hotkeys'
25
+ import type { JSX } from 'solid-js'
26
26
 
27
27
  const saved: CustomHotkeys = JSON.parse(localStorage.getItem('hotkeys') ?? '{}')
28
28