@tanstack/solid-hotkeys 0.10.0 → 0.11.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/README.md +15 -1
- package/dist/createHotkeyHint.cjs +20 -0
- package/dist/createHotkeyHint.cjs.map +1 -0
- package/dist/createHotkeyHint.d.cts +14 -0
- package/dist/createHotkeyHint.d.ts +14 -0
- package/dist/createHotkeyHint.js +20 -0
- package/dist/createHotkeyHint.js.map +1 -0
- package/dist/index.cjs +2 -0
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/package.json +2 -2
- package/src/createHotkeyHint.ts +28 -0
- package/src/index.ts +1 -0
package/README.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
<div align="center">
|
|
2
|
-
<
|
|
2
|
+
<picture>
|
|
3
|
+
<source
|
|
4
|
+
media="(prefers-color-scheme: dark)"
|
|
5
|
+
srcset="https://tanstack.com/api/readme/hotkeys.png?theme=dark"
|
|
6
|
+
/>
|
|
7
|
+
<source
|
|
8
|
+
media="(prefers-color-scheme: light)"
|
|
9
|
+
srcset="https://tanstack.com/api/readme/hotkeys.png"
|
|
10
|
+
/>
|
|
11
|
+
<img
|
|
12
|
+
src="https://tanstack.com/api/readme/hotkeys.png"
|
|
13
|
+
alt="TanStack Hotkeys"
|
|
14
|
+
width="900"
|
|
15
|
+
/>
|
|
16
|
+
</picture>
|
|
3
17
|
</div>
|
|
4
18
|
|
|
5
19
|
<br />
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
let _tanstack_hotkeys = require("@tanstack/hotkeys");
|
|
2
|
+
let solid_js = require("solid-js");
|
|
3
|
+
let _tanstack_solid_store = require("@tanstack/solid-store");
|
|
4
|
+
|
|
5
|
+
//#region src/createHotkeyHint.ts
|
|
6
|
+
/**
|
|
7
|
+
* Returns a boolean accessor indicating whether held modifiers reveal this shortcut.
|
|
8
|
+
* Pass accessors to track changing bindings and options.
|
|
9
|
+
* Uses the nonempty-subset/AltGr rules of `matchesHeldModifiers`; `exact` requires
|
|
10
|
+
* every modifier. Combine with the action's enabled state before showing a badge.
|
|
11
|
+
* This helper does not register a shortcut or check whether its target is focused.
|
|
12
|
+
*/
|
|
13
|
+
function createHotkeyHint(hotkey, options = {}) {
|
|
14
|
+
const held = (0, _tanstack_solid_store.useSelector)((0, _tanstack_hotkeys.getKeyStateTracker)().store, (state) => state.heldKeys);
|
|
15
|
+
return (0, solid_js.createMemo)(() => (0, _tanstack_hotkeys.matchesHeldModifiers)(typeof hotkey === "function" ? hotkey() : hotkey, held(), typeof options === "function" ? options() : options));
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
exports.createHotkeyHint = createHotkeyHint;
|
|
20
|
+
//# sourceMappingURL=createHotkeyHint.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createHotkeyHint.cjs","names":[],"sources":["../src/createHotkeyHint.ts"],"sourcesContent":["import { createMemo } from 'solid-js'\nimport { useSelector } from '@tanstack/solid-store'\nimport { getKeyStateTracker, matchesHeldModifiers } from '@tanstack/hotkeys'\nimport type { HeldModifierOptions, RegisterableHotkey } from '@tanstack/hotkeys'\n\n/**\n * Returns a boolean accessor indicating whether held modifiers reveal this shortcut.\n * Pass accessors to track changing bindings and options.\n * Uses the nonempty-subset/AltGr rules of `matchesHeldModifiers`; `exact` requires\n * every modifier. Combine with the action's enabled state before showing a badge.\n * This helper does not register a shortcut or check whether its target is focused.\n */\nexport function createHotkeyHint(\n hotkey: RegisterableHotkey | (() => RegisterableHotkey),\n options: HeldModifierOptions | (() => HeldModifierOptions) = {},\n): () => boolean {\n const held = useSelector(\n getKeyStateTracker().store,\n (state) => state.heldKeys,\n )\n return createMemo(() =>\n matchesHeldModifiers(\n typeof hotkey === 'function' ? hotkey() : hotkey,\n held(),\n typeof options === 'function' ? options() : options,\n ),\n )\n}\n"],"mappings":";;;;;;;;;;;;AAYA,SAAgB,iBACd,QACA,UAA6D,EAAE,EAChD;CACf,MAAM,yFACgB,CAAC,QACpB,UAAU,MAAM,SAClB;AACD,mFAEI,OAAO,WAAW,aAAa,QAAQ,GAAG,QAC1C,MAAM,EACN,OAAO,YAAY,aAAa,SAAS,GAAG,QAC7C,CACF"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { HeldModifierOptions, RegisterableHotkey } from "@tanstack/hotkeys";
|
|
2
|
+
|
|
3
|
+
//#region src/createHotkeyHint.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Returns a boolean accessor indicating whether held modifiers reveal this shortcut.
|
|
6
|
+
* Pass accessors to track changing bindings and options.
|
|
7
|
+
* Uses the nonempty-subset/AltGr rules of `matchesHeldModifiers`; `exact` requires
|
|
8
|
+
* every modifier. Combine with the action's enabled state before showing a badge.
|
|
9
|
+
* This helper does not register a shortcut or check whether its target is focused.
|
|
10
|
+
*/
|
|
11
|
+
declare function createHotkeyHint(hotkey: RegisterableHotkey | (() => RegisterableHotkey), options?: HeldModifierOptions | (() => HeldModifierOptions)): () => boolean;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { createHotkeyHint };
|
|
14
|
+
//# sourceMappingURL=createHotkeyHint.d.cts.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { HeldModifierOptions, RegisterableHotkey } from "@tanstack/hotkeys";
|
|
2
|
+
|
|
3
|
+
//#region src/createHotkeyHint.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Returns a boolean accessor indicating whether held modifiers reveal this shortcut.
|
|
6
|
+
* Pass accessors to track changing bindings and options.
|
|
7
|
+
* Uses the nonempty-subset/AltGr rules of `matchesHeldModifiers`; `exact` requires
|
|
8
|
+
* every modifier. Combine with the action's enabled state before showing a badge.
|
|
9
|
+
* This helper does not register a shortcut or check whether its target is focused.
|
|
10
|
+
*/
|
|
11
|
+
declare function createHotkeyHint(hotkey: RegisterableHotkey | (() => RegisterableHotkey), options?: HeldModifierOptions | (() => HeldModifierOptions)): () => boolean;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { createHotkeyHint };
|
|
14
|
+
//# sourceMappingURL=createHotkeyHint.d.ts.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { getKeyStateTracker, matchesHeldModifiers } from "@tanstack/hotkeys";
|
|
2
|
+
import { createMemo } from "solid-js";
|
|
3
|
+
import { useSelector } from "@tanstack/solid-store";
|
|
4
|
+
|
|
5
|
+
//#region src/createHotkeyHint.ts
|
|
6
|
+
/**
|
|
7
|
+
* Returns a boolean accessor indicating whether held modifiers reveal this shortcut.
|
|
8
|
+
* Pass accessors to track changing bindings and options.
|
|
9
|
+
* Uses the nonempty-subset/AltGr rules of `matchesHeldModifiers`; `exact` requires
|
|
10
|
+
* every modifier. Combine with the action's enabled state before showing a badge.
|
|
11
|
+
* This helper does not register a shortcut or check whether its target is focused.
|
|
12
|
+
*/
|
|
13
|
+
function createHotkeyHint(hotkey, options = {}) {
|
|
14
|
+
const held = useSelector(getKeyStateTracker().store, (state) => state.heldKeys);
|
|
15
|
+
return createMemo(() => matchesHeldModifiers(typeof hotkey === "function" ? hotkey() : hotkey, held(), typeof options === "function" ? options() : options));
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
export { createHotkeyHint };
|
|
20
|
+
//# sourceMappingURL=createHotkeyHint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createHotkeyHint.js","names":[],"sources":["../src/createHotkeyHint.ts"],"sourcesContent":["import { createMemo } from 'solid-js'\nimport { useSelector } from '@tanstack/solid-store'\nimport { getKeyStateTracker, matchesHeldModifiers } from '@tanstack/hotkeys'\nimport type { HeldModifierOptions, RegisterableHotkey } from '@tanstack/hotkeys'\n\n/**\n * Returns a boolean accessor indicating whether held modifiers reveal this shortcut.\n * Pass accessors to track changing bindings and options.\n * Uses the nonempty-subset/AltGr rules of `matchesHeldModifiers`; `exact` requires\n * every modifier. Combine with the action's enabled state before showing a badge.\n * This helper does not register a shortcut or check whether its target is focused.\n */\nexport function createHotkeyHint(\n hotkey: RegisterableHotkey | (() => RegisterableHotkey),\n options: HeldModifierOptions | (() => HeldModifierOptions) = {},\n): () => boolean {\n const held = useSelector(\n getKeyStateTracker().store,\n (state) => state.heldKeys,\n )\n return createMemo(() =>\n matchesHeldModifiers(\n typeof hotkey === 'function' ? hotkey() : hotkey,\n held(),\n typeof options === 'function' ? options() : options,\n ),\n )\n}\n"],"mappings":";;;;;;;;;;;;AAYA,SAAgB,iBACd,QACA,UAA6D,EAAE,EAChD;CACf,MAAM,OAAO,YACX,oBAAoB,CAAC,QACpB,UAAU,MAAM,SAClB;AACD,QAAO,iBACL,qBACE,OAAO,WAAW,aAAa,QAAQ,GAAG,QAC1C,MAAM,EACN,OAAO,YAAY,aAAa,SAAS,GAAG,QAC7C,CACF"}
|
package/dist/index.cjs
CHANGED
|
@@ -10,11 +10,13 @@ const require_createHotkeySequences = require('./createHotkeySequences.cjs');
|
|
|
10
10
|
const require_createHotkeyRecorder = require('./createHotkeyRecorder.cjs');
|
|
11
11
|
const require_createHotkeyRegistrations = require('./createHotkeyRegistrations.cjs');
|
|
12
12
|
const require_createHotkeySequenceRecorder = require('./createHotkeySequenceRecorder.cjs');
|
|
13
|
+
const require_createHotkeyHint = require('./createHotkeyHint.cjs');
|
|
13
14
|
|
|
14
15
|
exports.HotkeysProvider = require_HotkeysProvider.HotkeysProvider;
|
|
15
16
|
exports.createHeldKeyCodes = require_createHeldKeyCodes.createHeldKeyCodes;
|
|
16
17
|
exports.createHeldKeys = require_createHeldKeys.createHeldKeys;
|
|
17
18
|
exports.createHotkey = require_createHotkey.createHotkey;
|
|
19
|
+
exports.createHotkeyHint = require_createHotkeyHint.createHotkeyHint;
|
|
18
20
|
exports.createHotkeyRecorder = require_createHotkeyRecorder.createHotkeyRecorder;
|
|
19
21
|
exports.createHotkeyRegistrations = require_createHotkeyRegistrations.createHotkeyRegistrations;
|
|
20
22
|
exports.createHotkeySequence = require_createHotkeySequence.createHotkeySequence;
|
package/dist/index.d.cts
CHANGED
|
@@ -9,5 +9,6 @@ import { CreateHotkeySequenceDefinition, createHotkeySequences } from "./createH
|
|
|
9
9
|
import { SolidHotkeyRecorder, createHotkeyRecorder } from "./createHotkeyRecorder.cjs";
|
|
10
10
|
import { HotkeyRegistrationsResult, createHotkeyRegistrations } from "./createHotkeyRegistrations.cjs";
|
|
11
11
|
import { SolidHotkeySequenceRecorder, createHotkeySequenceRecorder } from "./createHotkeySequenceRecorder.cjs";
|
|
12
|
+
import { createHotkeyHint } from "./createHotkeyHint.cjs";
|
|
12
13
|
export * from "@tanstack/hotkeys";
|
|
13
|
-
export { CreateHotkeyDefinition, CreateHotkeyOptions, CreateHotkeySequenceDefinition, CreateHotkeySequenceOptions, HotkeyRegistrationsResult, HotkeysProvider, HotkeysProviderOptions, HotkeysProviderProps, SolidHotkeyRecorder, SolidHotkeySequenceRecorder, createHeldKeyCodes, createHeldKeys, createHotkey, createHotkeyRecorder, createHotkeyRegistrations, createHotkeySequence, createHotkeySequenceRecorder, createHotkeySequences, createHotkeys, createKeyHold, useDefaultHotkeysOptions, useHotkeysContext };
|
|
14
|
+
export { CreateHotkeyDefinition, CreateHotkeyOptions, CreateHotkeySequenceDefinition, CreateHotkeySequenceOptions, HotkeyRegistrationsResult, HotkeysProvider, HotkeysProviderOptions, HotkeysProviderProps, SolidHotkeyRecorder, SolidHotkeySequenceRecorder, createHeldKeyCodes, createHeldKeys, createHotkey, createHotkeyHint, createHotkeyRecorder, createHotkeyRegistrations, createHotkeySequence, createHotkeySequenceRecorder, createHotkeySequences, createHotkeys, createKeyHold, useDefaultHotkeysOptions, useHotkeysContext };
|
package/dist/index.d.ts
CHANGED
|
@@ -9,5 +9,6 @@ import { CreateHotkeySequenceDefinition, createHotkeySequences } from "./createH
|
|
|
9
9
|
import { SolidHotkeyRecorder, createHotkeyRecorder } from "./createHotkeyRecorder.js";
|
|
10
10
|
import { HotkeyRegistrationsResult, createHotkeyRegistrations } from "./createHotkeyRegistrations.js";
|
|
11
11
|
import { SolidHotkeySequenceRecorder, createHotkeySequenceRecorder } from "./createHotkeySequenceRecorder.js";
|
|
12
|
+
import { createHotkeyHint } from "./createHotkeyHint.js";
|
|
12
13
|
export * from "@tanstack/hotkeys";
|
|
13
|
-
export { CreateHotkeyDefinition, CreateHotkeyOptions, CreateHotkeySequenceDefinition, CreateHotkeySequenceOptions, HotkeyRegistrationsResult, HotkeysProvider, HotkeysProviderOptions, HotkeysProviderProps, SolidHotkeyRecorder, SolidHotkeySequenceRecorder, createHeldKeyCodes, createHeldKeys, createHotkey, createHotkeyRecorder, createHotkeyRegistrations, createHotkeySequence, createHotkeySequenceRecorder, createHotkeySequences, createHotkeys, createKeyHold, useDefaultHotkeysOptions, useHotkeysContext };
|
|
14
|
+
export { CreateHotkeyDefinition, CreateHotkeyOptions, CreateHotkeySequenceDefinition, CreateHotkeySequenceOptions, HotkeyRegistrationsResult, HotkeysProvider, HotkeysProviderOptions, HotkeysProviderProps, SolidHotkeyRecorder, SolidHotkeySequenceRecorder, createHeldKeyCodes, createHeldKeys, createHotkey, createHotkeyHint, createHotkeyRecorder, createHotkeyRegistrations, createHotkeySequence, createHotkeySequenceRecorder, createHotkeySequences, createHotkeys, createKeyHold, useDefaultHotkeysOptions, useHotkeysContext };
|
package/dist/index.js
CHANGED
|
@@ -9,7 +9,8 @@ import { createHotkeySequences } from "./createHotkeySequences.js";
|
|
|
9
9
|
import { createHotkeyRecorder } from "./createHotkeyRecorder.js";
|
|
10
10
|
import { createHotkeyRegistrations } from "./createHotkeyRegistrations.js";
|
|
11
11
|
import { createHotkeySequenceRecorder } from "./createHotkeySequenceRecorder.js";
|
|
12
|
+
import { createHotkeyHint } from "./createHotkeyHint.js";
|
|
12
13
|
|
|
13
14
|
export * from "@tanstack/hotkeys"
|
|
14
15
|
|
|
15
|
-
export { HotkeysProvider, createHeldKeyCodes, createHeldKeys, createHotkey, createHotkeyRecorder, createHotkeyRegistrations, createHotkeySequence, createHotkeySequenceRecorder, createHotkeySequences, createHotkeys, createKeyHold, useDefaultHotkeysOptions, useHotkeysContext };
|
|
16
|
+
export { HotkeysProvider, createHeldKeyCodes, createHeldKeys, createHotkey, createHotkeyHint, createHotkeyRecorder, createHotkeyRegistrations, createHotkeySequence, createHotkeySequenceRecorder, createHotkeySequences, createHotkeys, createKeyHold, useDefaultHotkeysOptions, useHotkeysContext };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/solid-hotkeys",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "SolidJS adapter for TanStack Hotkeys",
|
|
5
5
|
"author": "Tanner Linsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
],
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@tanstack/solid-store": "^0.11.0",
|
|
46
|
-
"@tanstack/hotkeys": "0.
|
|
46
|
+
"@tanstack/hotkeys": "0.9.0"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@solidjs/testing-library": "^0.8.10",
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { createMemo } from 'solid-js'
|
|
2
|
+
import { useSelector } from '@tanstack/solid-store'
|
|
3
|
+
import { getKeyStateTracker, matchesHeldModifiers } from '@tanstack/hotkeys'
|
|
4
|
+
import type { HeldModifierOptions, RegisterableHotkey } from '@tanstack/hotkeys'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Returns a boolean accessor indicating whether held modifiers reveal this shortcut.
|
|
8
|
+
* Pass accessors to track changing bindings and options.
|
|
9
|
+
* Uses the nonempty-subset/AltGr rules of `matchesHeldModifiers`; `exact` requires
|
|
10
|
+
* every modifier. Combine with the action's enabled state before showing a badge.
|
|
11
|
+
* This helper does not register a shortcut or check whether its target is focused.
|
|
12
|
+
*/
|
|
13
|
+
export function createHotkeyHint(
|
|
14
|
+
hotkey: RegisterableHotkey | (() => RegisterableHotkey),
|
|
15
|
+
options: HeldModifierOptions | (() => HeldModifierOptions) = {},
|
|
16
|
+
): () => boolean {
|
|
17
|
+
const held = useSelector(
|
|
18
|
+
getKeyStateTracker().store,
|
|
19
|
+
(state) => state.heldKeys,
|
|
20
|
+
)
|
|
21
|
+
return createMemo(() =>
|
|
22
|
+
matchesHeldModifiers(
|
|
23
|
+
typeof hotkey === 'function' ? hotkey() : hotkey,
|
|
24
|
+
held(),
|
|
25
|
+
typeof options === 'function' ? options() : options,
|
|
26
|
+
),
|
|
27
|
+
)
|
|
28
|
+
}
|
package/src/index.ts
CHANGED