@tanstack/solid-hotkeys 0.21.2 → 0.21.3
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/createHotkey.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
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
3
|
/**
|
|
4
|
-
* The element to listen on. A `null` target skips
|
|
5
|
-
* accessor such as `() => ({ target: element() })`
|
|
6
|
-
* after mount.
|
|
4
|
+
* The element to listen on. A `null` or `undefined` target skips
|
|
5
|
+
* registration, so pass an accessor such as `() => ({ target: element() })`
|
|
6
|
+
* for elements that attach after mount. Omit `target` for the document.
|
|
7
7
|
*/
|
|
8
8
|
export type CreateHotkeyTarget = Target | null;
|
|
9
9
|
/** Options shared by chords and sequences. */
|
package/dist/createHotkeys.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export type CreateHotkeyDefinition = AdapterHotkeyDefinition<CreateHotkeyTarget>
|
|
|
13
13
|
* commonOptions, per-hotkey options. Each option applies only to the kinds
|
|
14
14
|
* that support it. Unbound app hotkeys, empty sequences, and `undefined`,
|
|
15
15
|
* `null`, or `''` hotkeys register nothing.
|
|
16
|
-
* A `null` target skips registration until it is set.
|
|
16
|
+
* A `null` or `undefined` target skips registration until it is set.
|
|
17
17
|
*
|
|
18
18
|
* @example
|
|
19
19
|
* ```tsx
|
package/dist/createHotkeys.js
CHANGED
|
@@ -12,7 +12,7 @@ import { createEffect, onCleanup, untrack } from "solid-js";
|
|
|
12
12
|
* commonOptions, per-hotkey options. Each option applies only to the kinds
|
|
13
13
|
* that support it. Unbound app hotkeys, empty sequences, and `undefined`,
|
|
14
14
|
* `null`, or `''` hotkeys register nothing.
|
|
15
|
-
* A `null` target skips registration until it is set.
|
|
15
|
+
* A `null` or `undefined` target skips registration until it is set.
|
|
16
16
|
*
|
|
17
17
|
* @example
|
|
18
18
|
* ```tsx
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/solid-hotkeys",
|
|
3
|
-
"version": "0.21.
|
|
3
|
+
"version": "0.21.3",
|
|
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.26.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@solidjs/testing-library": "^0.8.10",
|
|
@@ -80,7 +80,7 @@ The state these return is accessors, including the recorder's fields. No provide
|
|
|
80
80
|
## Pitfalls
|
|
81
81
|
|
|
82
82
|
- **Pass options as an accessor.** `{ enabled: isDirty() }` is read once, during setup, so the hotkey never follows the signal. Use `() => ({ enabled: isDirty() })`. The hotkey and `createHotkeys`' definitions also accept accessors.
|
|
83
|
-
- **Keep element targets in a signal.** A `let el` variable is still `undefined` when the options are read, and
|
|
83
|
+
- **Keep element targets in a signal.** A `let el` variable is still `undefined` when the options are read, and nothing tracks it, so the hotkey waits and never registers. Use `ref={setEl}` and `() => ({ target: el() })`; a `null` or `undefined` target waits for the element.
|
|
84
84
|
- **Register hotkeys for removable elements in their `ref`.** Solid never calls a `ref` with `null`, so a signal keeps an element that `<Show>` or `<For>` removed, and the hotkey stays registered on it. Use `ref={(el) => createHotkey('K', cb, { target: el })}`; the hotkey unregisters when the element is removed.
|
|
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()}` ``.
|