@tanstack/solid-hotkeys 0.27.0 → 0.28.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.
- package/dist/createKeyLockState.d.ts +31 -0
- package/dist/createKeyLockState.js +40 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/package.json +2 -2
- package/skills/solid-hotkeys/SKILL.md +1 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { LockKey, MaybeGetter } from "@tanstack/hotkeys";
|
|
2
|
+
/**
|
|
3
|
+
* SolidJS primitive that returns 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'` - can be an accessor function
|
|
11
|
+
* @returns Signal accessor that returns `true` when the lock is on, `false`
|
|
12
|
+
* when it is off, or `null`
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```tsx
|
|
16
|
+
* function PasswordField() {
|
|
17
|
+
* const capsLock = createKeyLockState('CapsLock')
|
|
18
|
+
*
|
|
19
|
+
* return (
|
|
20
|
+
* <label>
|
|
21
|
+
* Password
|
|
22
|
+
* <input type="password" />
|
|
23
|
+
* <Show when={capsLock()}>
|
|
24
|
+
* <span role="status">Caps Lock is on</span>
|
|
25
|
+
* </Show>
|
|
26
|
+
* </label>
|
|
27
|
+
* )
|
|
28
|
+
* }
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare function createKeyLockState(key: MaybeGetter<LockKey>): () => boolean | null;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { useSelector } from "./_useSelector.js";
|
|
2
|
+
import { getKeyStateTracker } from "@tanstack/hotkeys";
|
|
3
|
+
import { resolveMaybeGetter } from "@tanstack/hotkeys/adapter";
|
|
4
|
+
|
|
5
|
+
// src/createKeyLockState.ts
|
|
6
|
+
/**
|
|
7
|
+
* SolidJS primitive that returns whether a lock key, such as Caps Lock, is on.
|
|
8
|
+
*
|
|
9
|
+
* Lock keys toggle instead of being held, so this reads the lock state that
|
|
10
|
+
* the browser reports on key and mouse events. It returns `null` until the
|
|
11
|
+
* user presses a key, clicks, or moves the mouse, after the window loses
|
|
12
|
+
* focus or the page is hidden, and always for Num Lock and Scroll Lock on macOS and iOS.
|
|
13
|
+
*
|
|
14
|
+
* @param key - `'CapsLock'`, `'NumLock'`, or `'ScrollLock'` - can be an accessor function
|
|
15
|
+
* @returns Signal accessor that returns `true` when the lock is on, `false`
|
|
16
|
+
* when it is off, or `null`
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```tsx
|
|
20
|
+
* function PasswordField() {
|
|
21
|
+
* const capsLock = createKeyLockState('CapsLock')
|
|
22
|
+
*
|
|
23
|
+
* return (
|
|
24
|
+
* <label>
|
|
25
|
+
* Password
|
|
26
|
+
* <input type="password" />
|
|
27
|
+
* <Show when={capsLock()}>
|
|
28
|
+
* <span role="status">Caps Lock is on</span>
|
|
29
|
+
* </Show>
|
|
30
|
+
* </label>
|
|
31
|
+
* )
|
|
32
|
+
* }
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
function createKeyLockState(key) {
|
|
36
|
+
const tracker = getKeyStateTracker();
|
|
37
|
+
return useSelector(tracker.store, (state) => state.locks[resolveMaybeGetter(key)]);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export { createKeyLockState };
|
package/dist/index.d.ts
CHANGED
|
@@ -14,5 +14,6 @@ import { UseCustomHotkeysResult, createAppHotkeyList, useAppHotkeys, useCustomHo
|
|
|
14
14
|
import { createHeldKeys } from "./createHeldKeys.js";
|
|
15
15
|
import { createHeldKeyCodes } from "./createHeldKeyCodes.js";
|
|
16
16
|
import { createKeyHold } from "./createKeyHold.js";
|
|
17
|
+
import { createKeyLockState } from "./createKeyLockState.js";
|
|
17
18
|
export * from "@tanstack/hotkeys";
|
|
18
|
-
export { CreateAppHotkeyOptions, CreateHotkeyChordOptions, CreateHotkeyCommonOptions, CreateHotkeyDefinition, CreateHotkeyOptions, CreateHotkeyOptionsFor, CreateHotkeySequenceOptions, CreateHotkeyTarget, HotkeysProvider, HotkeysProviderOptions, HotkeysProviderProps, SolidHotkeyRecorder, UseCustomHotkeysResult, createAppHotkeyList, createFormatForAria, createFormatForDisplay, createHeldKeyCodes, createHeldKeys, createHotkey, createHotkeyHint, createHotkeyRecorder, createHotkeyRegistrations, createHotkeyScopesState, createHotkeys, createKeyHold, createKeyboardLayout, formatForAria, formatForDisplay, useAppHotkeys, useCustomHotkeys, useDefaultHotkeysOptions, useHotkeysContext };
|
|
19
|
+
export { CreateAppHotkeyOptions, CreateHotkeyChordOptions, CreateHotkeyCommonOptions, CreateHotkeyDefinition, CreateHotkeyOptions, CreateHotkeyOptionsFor, CreateHotkeySequenceOptions, CreateHotkeyTarget, HotkeysProvider, HotkeysProviderOptions, HotkeysProviderProps, SolidHotkeyRecorder, UseCustomHotkeysResult, createAppHotkeyList, createFormatForAria, createFormatForDisplay, createHeldKeyCodes, createHeldKeys, createHotkey, createHotkeyHint, createHotkeyRecorder, createHotkeyRegistrations, createHotkeyScopesState, createHotkeys, createKeyHold, createKeyLockState, createKeyboardLayout, formatForAria, formatForDisplay, useAppHotkeys, useCustomHotkeys, useDefaultHotkeysOptions, useHotkeysContext };
|
package/dist/index.js
CHANGED
|
@@ -14,7 +14,8 @@ import { createAppHotkeyList, useAppHotkeys, useCustomHotkeys } from "./appHotke
|
|
|
14
14
|
import { createHeldKeys } from "./createHeldKeys.js";
|
|
15
15
|
import { createHeldKeyCodes } from "./createHeldKeyCodes.js";
|
|
16
16
|
import { createKeyHold } from "./createKeyHold.js";
|
|
17
|
+
import { createKeyLockState } from "./createKeyLockState.js";
|
|
17
18
|
|
|
18
19
|
export * from "@tanstack/hotkeys"
|
|
19
20
|
|
|
20
|
-
export { HotkeysProvider, createAppHotkeyList, createFormatForAria, createFormatForDisplay, createHeldKeyCodes, createHeldKeys, createHotkey, createHotkeyHint, createHotkeyRecorder, createHotkeyRegistrations, createHotkeyScopesState, createHotkeys, createKeyHold, createKeyboardLayout, formatForAria, formatForDisplay, useAppHotkeys, useCustomHotkeys, useDefaultHotkeysOptions, useHotkeysContext };
|
|
21
|
+
export { HotkeysProvider, createAppHotkeyList, createFormatForAria, createFormatForDisplay, createHeldKeyCodes, createHeldKeys, createHotkey, createHotkeyHint, createHotkeyRecorder, createHotkeyRegistrations, createHotkeyScopesState, createHotkeys, createKeyHold, createKeyLockState, createKeyboardLayout, formatForAria, formatForDisplay, useAppHotkeys, useCustomHotkeys, useDefaultHotkeysOptions, useHotkeysContext };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/solid-hotkeys",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.1",
|
|
4
4
|
"description": "SolidJS adapter for TanStack Hotkeys",
|
|
5
5
|
"author": "Tanner Linsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"skills"
|
|
39
39
|
],
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@tanstack/hotkeys": "0.
|
|
41
|
+
"@tanstack/hotkeys": "0.39.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@solidjs/testing-library": "^1.0.0-rc.2",
|
|
@@ -73,6 +73,7 @@ export function Editor() {
|
|
|
73
73
|
| `createHotkeyScopesState()` | Get an accessor of the active scopes and the exclusive scope that owns the keyboard. |
|
|
74
74
|
| `createHotkeyHint(hotkey, options?)` | Get an accessor of 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. |
|
|
75
75
|
| `createKeyHold(key)` | Get an accessor of whether one key is held. Letters match in any case; other names, such as `Shift`, are case-sensitive. |
|
|
76
|
+
| `createKeyLockState(key)` | Get an accessor of 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 `createKeyHold`, which is true only while the key is down. |
|
|
76
77
|
| `createHeldKeys()` | Get an accessor of every key that's held right now. |
|
|
77
78
|
| `createHeldKeyCodes()` | Get an accessor mapping each held key to its physical `event.code`. |
|
|
78
79
|
|