@tanstack/hotkeys-devtools 1.6.1 → 1.7.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/_trigger.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { HotkeyManager } from "@tanstack/hotkeys";
|
|
2
|
+
|
|
3
|
+
//#region src/_trigger.ts
|
|
4
|
+
/**
|
|
5
|
+
* Runs a registration's callback as if its hotkey, or a sequence's last step,
|
|
6
|
+
* was pressed, and counts it like a real press. The event names the physical
|
|
7
|
+
* code for physical bindings and the key otherwise.
|
|
8
|
+
*
|
|
9
|
+
* @returns False when no registration has the id
|
|
10
|
+
*/
|
|
11
|
+
function triggerRegistration(id, manager = HotkeyManager.getInstance()) {
|
|
12
|
+
const registration = manager.registrations.state.get(id);
|
|
13
|
+
if (!registration) return false;
|
|
14
|
+
const context = registration.kind === "chord" ? {
|
|
15
|
+
kind: "chord",
|
|
16
|
+
hotkey: registration.hotkey,
|
|
17
|
+
parsedChord: registration.parsedChord
|
|
18
|
+
} : {
|
|
19
|
+
kind: "sequence",
|
|
20
|
+
hotkey: registration.hotkey,
|
|
21
|
+
parsedSequence: registration.parsedSequence
|
|
22
|
+
};
|
|
23
|
+
const parsed = registration.kind === "chord" ? registration.parsedChord : registration.parsedSequence[registration.parsedSequence.length - 1];
|
|
24
|
+
const event = new KeyboardEvent(registration.options.eventType ?? "keydown", {
|
|
25
|
+
...parsed.code !== void 0 ? { code: parsed.code } : { key: parsed.key },
|
|
26
|
+
ctrlKey: parsed.ctrl,
|
|
27
|
+
shiftKey: parsed.shift,
|
|
28
|
+
altKey: parsed.alt,
|
|
29
|
+
metaKey: parsed.meta,
|
|
30
|
+
bubbles: true,
|
|
31
|
+
cancelable: true
|
|
32
|
+
});
|
|
33
|
+
registration.triggerCount++;
|
|
34
|
+
if (registration.kind === "sequence") registration.hasFired = true;
|
|
35
|
+
manager.registrations.setState((prev) => new Map(prev));
|
|
36
|
+
registration.callback(event, context);
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
//#endregion
|
|
41
|
+
export { triggerRegistration };
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { useStyles } from "../styles/use-styles.js";
|
|
2
|
+
import { triggerRegistration } from "../_trigger.js";
|
|
2
3
|
import { className, delegateEvents, effect, template } from "solid-js/web";
|
|
3
|
-
import { HotkeyManager } from "@tanstack/hotkeys";
|
|
4
4
|
|
|
5
5
|
//#region src/components/ActionButtons.tsx
|
|
6
6
|
var _tmpl$ = /*#__PURE__*/ template(`<div><button><span></span>Trigger`);
|
|
7
7
|
function ActionButtons(props) {
|
|
8
8
|
const styles = useStyles();
|
|
9
9
|
const handleTrigger = () => {
|
|
10
|
-
|
|
10
|
+
triggerRegistration(props.registration.id);
|
|
11
11
|
};
|
|
12
12
|
return (() => {
|
|
13
13
|
var _el$ = _tmpl$(), _el$2 = _el$.firstChild, _el$3 = _el$2.firstChild;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/hotkeys-devtools",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.1",
|
|
4
4
|
"description": "Devtools for TanStack Hotkeys",
|
|
5
5
|
"author": "Tanner Linsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -36,11 +36,11 @@
|
|
|
36
36
|
"dist"
|
|
37
37
|
],
|
|
38
38
|
"peerDependencies": {
|
|
39
|
-
"@tanstack/hotkeys": "0.
|
|
39
|
+
"@tanstack/hotkeys": "0.21.0"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@tanstack/devtools-ui": "^0.7.
|
|
43
|
-
"@tanstack/devtools-utils": "^0.7.
|
|
42
|
+
"@tanstack/devtools-ui": "^0.7.2",
|
|
43
|
+
"@tanstack/devtools-utils": "^0.7.2",
|
|
44
44
|
"clsx": "^2.1.1",
|
|
45
45
|
"goober": "^2.1.19",
|
|
46
46
|
"match-sorter": "^8.3.0",
|