@tanstack/octane-hotkeys 0.16.0 → 0.17.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.
package/dist/index.d.ts CHANGED
@@ -4,6 +4,7 @@ import { UseAppHotkeyOptions, UseHotkeyChordOptions, UseHotkeyCommonOptions, Use
4
4
  import { useHeldKeys } from "./useHeldKeys.js";
5
5
  import { useHeldKeyCodes } from "./useHeldKeyCodes.js";
6
6
  import { useKeyHold } from "./useKeyHold.js";
7
+ import { useKeyLockState } from "./useKeyLockState.js";
7
8
  import { useHotkeyHint } from "./useHotkeyHint.js";
8
9
  import { useFormatForDisplay } from "./useFormatForDisplay.js";
9
10
  import { useFormatForAria } from "./useFormatForAria.js";
@@ -16,4 +17,4 @@ import { useHotkeyRecorder } from "./useHotkeyRecorder.js";
16
17
  import { useAppHotkeyList, useAppHotkeys, useCustomHotkeys } from "./useAppHotkeys.js";
17
18
  import { HotkeyRegistrationsResult, OctaneHotkeyRecorder, UseCustomHotkeysResult } from "./types.js";
18
19
  export * from "@tanstack/hotkeys";
19
- export { type DefaultHotkeysOptions, HotkeyRegistrationsResult, HotkeysProvider, type HotkeysProviderOptions, type HotkeysProviderProps, OctaneHotkeyRecorder, UseAppHotkeyOptions, UseCustomHotkeysResult, UseHotkeyChordOptions, UseHotkeyCommonOptions, UseHotkeyDefinition, UseHotkeyOptions, UseHotkeyOptionsFor, UseHotkeySequenceOptions, UseHotkeyTarget, formatForAria, formatForDisplay, useAppHotkeyList, useAppHotkeys, useCustomHotkeys, useDefaultHotkeysOptions, useFormatForAria, useFormatForDisplay, useHeldKeyCodes, useHeldKeys, useHotkey, useHotkeyHint, useHotkeyRecorder, useHotkeyRegistrations, useHotkeyScopesState, useHotkeys, useHotkeysContext, useKeyHold, useKeyboardLayout };
20
+ export { type DefaultHotkeysOptions, HotkeyRegistrationsResult, HotkeysProvider, type HotkeysProviderOptions, type HotkeysProviderProps, OctaneHotkeyRecorder, UseAppHotkeyOptions, UseCustomHotkeysResult, UseHotkeyChordOptions, UseHotkeyCommonOptions, UseHotkeyDefinition, UseHotkeyOptions, UseHotkeyOptionsFor, UseHotkeySequenceOptions, UseHotkeyTarget, formatForAria, formatForDisplay, useAppHotkeyList, useAppHotkeys, useCustomHotkeys, useDefaultHotkeysOptions, useFormatForAria, useFormatForDisplay, useHeldKeyCodes, useHeldKeys, useHotkey, useHotkeyHint, useHotkeyRecorder, useHotkeyRegistrations, useHotkeyScopesState, useHotkeys, useHotkeysContext, useKeyHold, useKeyLockState, useKeyboardLayout };
package/dist/index.js CHANGED
@@ -4,6 +4,7 @@ import { useHotkey } from "./useHotkey.js";
4
4
  import { useHeldKeys } from "./useHeldKeys.js";
5
5
  import { useHeldKeyCodes } from "./useHeldKeyCodes.js";
6
6
  import { useKeyHold } from "./useKeyHold.js";
7
+ import { useKeyLockState } from "./useKeyLockState.js";
7
8
  import { useHotkeyHint } from "./useHotkeyHint.js";
8
9
  import { useFormatForDisplay } from "./useFormatForDisplay.js";
9
10
  import { useFormatForAria } from "./useFormatForAria.js";
@@ -17,4 +18,4 @@ import { useAppHotkeyList, useAppHotkeys, useCustomHotkeys } from "./useAppHotke
17
18
 
18
19
  export * from "@tanstack/hotkeys"
19
20
 
20
- export { HotkeysProvider, formatForAria, formatForDisplay, useAppHotkeyList, useAppHotkeys, useCustomHotkeys, useDefaultHotkeysOptions, useFormatForAria, useFormatForDisplay, useHeldKeyCodes, useHeldKeys, useHotkey, useHotkeyHint, useHotkeyRecorder, useHotkeyRegistrations, useHotkeyScopesState, useHotkeys, useHotkeysContext, useKeyHold, useKeyboardLayout };
21
+ export { HotkeysProvider, formatForAria, formatForDisplay, useAppHotkeyList, useAppHotkeys, useCustomHotkeys, useDefaultHotkeysOptions, useFormatForAria, useFormatForDisplay, useHeldKeyCodes, useHeldKeys, useHotkey, useHotkeyHint, useHotkeyRecorder, useHotkeyRegistrations, useHotkeyScopesState, useHotkeys, useHotkeysContext, useKeyHold, useKeyLockState, useKeyboardLayout };
@@ -0,0 +1,28 @@
1
+ import { LockKey } from "@tanstack/hotkeys";
2
+ /**
3
+ * Reports whether a lock key, such as Caps Lock, is on.
4
+ *
5
+ * Lock keys toggle instead of being held, so this reads the lock state that
6
+ * the browser reports on key and mouse events. It returns `null` until the
7
+ * user presses a key, clicks, or moves the mouse, after the window loses
8
+ * focus or the page is hidden, and always for Num Lock and Scroll Lock on macOS and iOS.
9
+ *
10
+ * @param key - `'CapsLock'`, `'NumLock'`, or `'ScrollLock'`
11
+ * @returns `true` when the lock is on, `false` when it is off, or `null`
12
+ *
13
+ * @example
14
+ * ```tsx
15
+ * function PasswordField() @{
16
+ * const capsLock = useKeyLockState('CapsLock')
17
+ *
18
+ * <label>
19
+ * Password
20
+ * <input type="password" />
21
+ * @if (capsLock) {
22
+ * <span role="status">Caps Lock is on</span>
23
+ * }
24
+ * </label>
25
+ * }
26
+ * ```
27
+ */
28
+ export declare function useKeyLockState(key: LockKey): boolean | null;
@@ -0,0 +1,9 @@
1
+ import { select, subSlot } from "./internal.js";
2
+ import { getKeyStateTracker } from "@tanstack/hotkeys";
3
+
4
+ // src/useKeyLockState.ts
5
+ function useKeyLockState(key, slot) {
6
+ return select(getKeyStateTracker().store, (state) => state.locks[key], subSlot(slot, "key-lock-state"));
7
+ }
8
+
9
+ export { useKeyLockState };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/octane-hotkeys",
3
- "version": "0.16.0",
3
+ "version": "0.17.0",
4
4
  "description": "Octane adapter for TanStack Hotkeys",
5
5
  "author": "Tanner Linsley",
6
6
  "license": "MIT",
@@ -35,7 +35,7 @@
35
35
  "skills"
36
36
  ],
37
37
  "dependencies": {
38
- "@tanstack/hotkeys": "0.37.0"
38
+ "@tanstack/hotkeys": "0.38.0"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@tanstack/hotkeys-test-utils": "0.0.0",
@@ -66,6 +66,7 @@ export function Panel({ onSave }: { onSave: () => void }) @{
66
66
  | `useHotkeyScopesState()` | Get the active scopes and the exclusive scope that owns the keyboard. |
67
67
  | `useHotkeyHint(hotkey, options?)` | Get whether held modifiers should reveal a shortcut's hint, such as labels that appear while Mod is held. False unless a registration of the hotkey can fire: enabled, in an active scope, and with focus inside its element target. |
68
68
  | `useKeyHold(key)` | Get whether one key is held, such as Shift for a range-select mode. Letters match in any case; other names, such as `Shift`, are case-sensitive. |
69
+ | `useKeyLockState(key)` | Get whether `'CapsLock'`, `'NumLock'`, or `'ScrollLock'` is on: `true`, `false`, or `null` until a key press, click, or mouse move reports it. Resets to `null` when the window loses focus. Num Lock and Scroll Lock are always `null` on macOS and iOS. Use it for lock state, not `useKeyHold`, which is true only while the key is down. |
69
70
  | `useHeldKeys()` | Get every key that's held right now. |
70
71
  | `useHeldKeyCodes()` | Map each held key to its physical `event.code`. |
71
72