@tanstack/vue-hotkeys 0.0.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/README.md +122 -0
- package/dist/HotkeysProvider.cjs +31 -0
- package/dist/HotkeysProvider.cjs.map +1 -0
- package/dist/HotkeysProvider.d.cts +34 -0
- package/dist/HotkeysProvider.d.ts +34 -0
- package/dist/HotkeysProvider.js +31 -0
- package/dist/HotkeysProvider.js.map +1 -0
- package/dist/HotkeysProviderContext.cjs +20 -0
- package/dist/HotkeysProviderContext.cjs.map +1 -0
- package/dist/HotkeysProviderContext.d.cts +19 -0
- package/dist/HotkeysProviderContext.d.ts +19 -0
- package/dist/HotkeysProviderContext.js +18 -0
- package/dist/HotkeysProviderContext.js.map +1 -0
- package/dist/index.cjs +27 -0
- package/dist/index.d.cts +10 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +12 -0
- package/dist/useHeldKeyCodes.cjs +37 -0
- package/dist/useHeldKeyCodes.cjs.map +1 -0
- package/dist/useHeldKeyCodes.d.cts +33 -0
- package/dist/useHeldKeyCodes.d.ts +33 -0
- package/dist/useHeldKeyCodes.js +37 -0
- package/dist/useHeldKeyCodes.js.map +1 -0
- package/dist/useHeldKeys.cjs +35 -0
- package/dist/useHeldKeys.cjs.map +1 -0
- package/dist/useHeldKeys.d.cts +31 -0
- package/dist/useHeldKeys.d.ts +31 -0
- package/dist/useHeldKeys.js +35 -0
- package/dist/useHeldKeys.js.map +1 -0
- package/dist/useHotkey.cjs +124 -0
- package/dist/useHotkey.cjs.map +1 -0
- package/dist/useHotkey.d.cts +86 -0
- package/dist/useHotkey.d.ts +86 -0
- package/dist/useHotkey.js +124 -0
- package/dist/useHotkey.js.map +1 -0
- package/dist/useHotkeyRecorder.cjs +80 -0
- package/dist/useHotkeyRecorder.cjs.map +1 -0
- package/dist/useHotkeyRecorder.d.cts +61 -0
- package/dist/useHotkeyRecorder.d.ts +61 -0
- package/dist/useHotkeyRecorder.js +80 -0
- package/dist/useHotkeyRecorder.js.map +1 -0
- package/dist/useHotkeySequence.cjs +95 -0
- package/dist/useHotkeySequence.cjs.map +1 -0
- package/dist/useHotkeySequence.d.cts +58 -0
- package/dist/useHotkeySequence.d.ts +58 -0
- package/dist/useHotkeySequence.js +95 -0
- package/dist/useHotkeySequence.js.map +1 -0
- package/dist/useKeyHold.cjs +60 -0
- package/dist/useKeyHold.cjs.map +1 -0
- package/dist/useKeyHold.d.cts +52 -0
- package/dist/useKeyHold.d.ts +52 -0
- package/dist/useKeyHold.js +60 -0
- package/dist/useKeyHold.js.map +1 -0
- package/package.json +66 -0
- package/src/HotkeysProvider.tsx +29 -0
- package/src/HotkeysProviderContext.ts +37 -0
- package/src/index.ts +14 -0
- package/src/useHeldKeyCodes.ts +34 -0
- package/src/useHeldKeys.ts +32 -0
- package/src/useHotkey.ts +197 -0
- package/src/useHotkeyRecorder.ts +112 -0
- package/src/useHotkeySequence.ts +158 -0
- package/src/useKeyHold.ts +65 -0
- package/src/vue.d.ts +6 -0
package/README.md
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<img src="./media/header_hotkeys.png" alt="TanStack Hotkeys" />
|
|
3
|
+
</div>
|
|
4
|
+
|
|
5
|
+
<br />
|
|
6
|
+
|
|
7
|
+
<div align="center">
|
|
8
|
+
<a href="https://www.npmjs.com/package/@tanstack/hotkeys" target="\_parent">
|
|
9
|
+
<img alt="" src="https://img.shields.io/npm/dm/@tanstack/hotkeys.svg" alt="npm downloads" />
|
|
10
|
+
</a>
|
|
11
|
+
<a href="https://github.com/TanStack/hotkeys" target="\_parent">
|
|
12
|
+
<img alt="" src="https://img.shields.io/github/stars/TanStack/hotkeys.svg?style=social&label=Star" alt="GitHub stars" />
|
|
13
|
+
</a>
|
|
14
|
+
<a href="https://bundlephobia.com/result?p=@tanstack/react-hotkeys@latest" target="\_parent">
|
|
15
|
+
<img alt="" src="https://badgen.net/bundlephobia/minzip/@tanstack/react-hotkeys@latest" alt="Bundle size" />
|
|
16
|
+
</a>
|
|
17
|
+
</div>
|
|
18
|
+
|
|
19
|
+
<div align="center">
|
|
20
|
+
<a href="#badge">
|
|
21
|
+
<img alt="semantic-release" src="https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg">
|
|
22
|
+
</a>
|
|
23
|
+
<a href="#badge">
|
|
24
|
+
<img src="https://img.shields.io/github/v/release/tanstack/hotkeys" alt="Release"/>
|
|
25
|
+
</a>
|
|
26
|
+
<a href="https://twitter.com/tan_stack">
|
|
27
|
+
<img src="https://img.shields.io/twitter/follow/tan_stack.svg?style=social" alt="Follow @TanStack"/>
|
|
28
|
+
</a>
|
|
29
|
+
</div>
|
|
30
|
+
|
|
31
|
+
<div align="center">
|
|
32
|
+
|
|
33
|
+
### [Become a Sponsor!](https://github.com/sponsors/tannerlinsley/)
|
|
34
|
+
|
|
35
|
+
</div>
|
|
36
|
+
|
|
37
|
+
# TanStack Hotkeys
|
|
38
|
+
|
|
39
|
+
> [!NOTE]
|
|
40
|
+
> TanStack Hotkeys is pre-alpha (prototyping phase). We are actively developing the library and are open to feedback and contributions.
|
|
41
|
+
|
|
42
|
+
Type-safe keyboard shortcuts for the web. Template-string bindings, parsed objects, a cross-platform `Mod` key, a singleton Hotkey Manager, and utilities for cheatsheet UIs—built to stay SSR-friendly.
|
|
43
|
+
|
|
44
|
+
- Type-safe bindings — template strings (`Mod+Shift+S`, `Escape`) or parsed objects for full control
|
|
45
|
+
- Flexible options — `keydown`/`keyup`, `preventDefault`, `stopPropagation`, conditional enabled, `requireReset`
|
|
46
|
+
- Cross-platform Mod — maps to Cmd on macOS and Ctrl on Windows/Linux
|
|
47
|
+
- Batteries included — validation + matching, sequences (Vim-style), key-state tracking, recorder UI helpers, framework adapters, and devtools
|
|
48
|
+
|
|
49
|
+
### <a href="https://tanstack.com/hotkeys">Read the docs →</a>
|
|
50
|
+
|
|
51
|
+
<br />
|
|
52
|
+
|
|
53
|
+
> [!NOTE]
|
|
54
|
+
> You may know **TanStack Hotkeys** by our adapter names, too!
|
|
55
|
+
>
|
|
56
|
+
> - [**React Hotkeys**](https://tanstack.com/hotkeys/latest/docs/framework/react/react-hotkeys)
|
|
57
|
+
> - [**Preact Hotkeys**](https://tanstack.com/hotkeys/latest/docs/framework/preact/preact-hotkeys)
|
|
58
|
+
> - [**Solid Hotkeys**](https://tanstack.com/hotkeys/latest/docs/framework/solid/reference)
|
|
59
|
+
> - [**Angular Hotkeys**](https://tanstack.com/hotkeys/latest/docs/framework/angular/reference)
|
|
60
|
+
> - [**Vue Hotkeys**](https://tanstack.com/hotkeys/latest/docs/framework/vue/reference)
|
|
61
|
+
> - Svelte Hotkeys – needs a contributor!
|
|
62
|
+
|
|
63
|
+
## Get Involved
|
|
64
|
+
|
|
65
|
+
- We welcome issues and pull requests!
|
|
66
|
+
- Participate in [GitHub discussions](https://github.com/TanStack/hotkeys/discussions)
|
|
67
|
+
- Chat with the community on [Discord](https://discord.com/invite/WrRKjPJ)
|
|
68
|
+
- See [CONTRIBUTING.md](./CONTRIBUTING.md) for setup instructions
|
|
69
|
+
|
|
70
|
+
## Partners
|
|
71
|
+
|
|
72
|
+
<div align="center">
|
|
73
|
+
|
|
74
|
+
<table align="center">
|
|
75
|
+
<tr>
|
|
76
|
+
<td>
|
|
77
|
+
<a href="https://www.coderabbit.ai/?via=tanstack&dub_id=aCcEEdAOqqutX6OS" >
|
|
78
|
+
<picture>
|
|
79
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://tanstack.com/assets/coderabbit-dark-D643Zkrv.svg" height="40" />
|
|
80
|
+
<source media="(prefers-color-scheme: light)" srcset="https://tanstack.com/assets/coderabbit-light-CIzGLYU_.svg" height="40" />
|
|
81
|
+
<img src="https://tanstack.com/assets/coderabbit-light-DVMJ2jHi.svg" height="40" alt="CodeRabbit" />
|
|
82
|
+
</picture>
|
|
83
|
+
</a>
|
|
84
|
+
</td>
|
|
85
|
+
<td>
|
|
86
|
+
<a href="https://www.cloudflare.com?utm_source=tanstack">
|
|
87
|
+
<picture>
|
|
88
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://tanstack.com/assets/cloudflare-white-Co-Tyjbl.svg" height="60" />
|
|
89
|
+
<source media="(prefers-color-scheme: light)" srcset="https://tanstack.com/assets/cloudflare-black-6Ojsn8yh.svg" height="60" />
|
|
90
|
+
<img src="https://tanstack.com/assets/cloudflare-black-CPufaW0B.svg" height="60" alt="Cloudflare" />
|
|
91
|
+
</picture>
|
|
92
|
+
</a>
|
|
93
|
+
</td>
|
|
94
|
+
</tr>
|
|
95
|
+
</table>
|
|
96
|
+
|
|
97
|
+
<div align="center">
|
|
98
|
+
<img src="media/partner_logo.svg" alt="Keys & you?" height="65">
|
|
99
|
+
<p>
|
|
100
|
+
We're looking for TanStack Hotkeys Partners to join our mission! Partner with us to push the boundaries of TanStack Hotkeys and build amazing things together.
|
|
101
|
+
</p>
|
|
102
|
+
<a href="mailto:partners@tanstack.com?subject=TanStack Hotkeys Partnership"><b>LET'S CHAT</b></a>
|
|
103
|
+
</div>
|
|
104
|
+
|
|
105
|
+
</div>
|
|
106
|
+
|
|
107
|
+
## Explore the TanStack Ecosystem
|
|
108
|
+
|
|
109
|
+
- <a href="https://github.com/tanstack/config"><b>TanStack Config</b></a> – Tooling for JS/TS packages
|
|
110
|
+
- <a href="https://github.com/tanstack/db"><b>TanStack DB</b></a> – Reactive sync client store
|
|
111
|
+
- <a href="https://github.com/tanstack/devtools"><b>TanStack DevTools</b></a> – Unified devtools panel
|
|
112
|
+
- <a href="https://github.com/tanstack/form"><b>TanStack Form</b></a> – Type‑safe form state
|
|
113
|
+
- <a href="https://github.com/tanstack/hotkeys"><b>TanStack Hotkeys</b></a> – Type‑safe keyboard shortcuts
|
|
114
|
+
- <a href="https://github.com/tanstack/query"><b>TanStack Query</b></a> – Async state & caching
|
|
115
|
+
- <a href="https://github.com/tanstack/ranger"><b>TanStack Ranger</b></a> – Range & slider primitives
|
|
116
|
+
- <a href="https://github.com/tanstack/router"><b>TanStack Router</b></a> – Type‑safe routing, caching & URL state
|
|
117
|
+
- <a href="https://github.com/tanstack/start"><b>TanStack Start</b></a> – Full‑stack SSR & streaming
|
|
118
|
+
- <a href="https://github.com/tanstack/store"><b>TanStack Store</b></a> – Reactive data store
|
|
119
|
+
- <a href="https://github.com/tanstack/table"><b>TanStack Table</b></a> – Headless datagrids
|
|
120
|
+
- <a href="https://github.com/tanstack/virtual"><b>TanStack Virtual</b></a> – Virtualized rendering
|
|
121
|
+
|
|
122
|
+
… and more at <a href="https://tanstack.com"><b>TanStack.com »</b></a>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const require_HotkeysProviderContext = require('./HotkeysProviderContext.cjs');
|
|
2
|
+
let vue = require("vue");
|
|
3
|
+
|
|
4
|
+
//#region src/HotkeysProvider.tsx
|
|
5
|
+
/**
|
|
6
|
+
* Vue component that provides default options for hotkeys context.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```vue
|
|
10
|
+
* <template>
|
|
11
|
+
* <HotkeysProvider :defaultOptions="{ hotkey: { enabled: true } }">
|
|
12
|
+
* <App />
|
|
13
|
+
* </HotkeysProvider>
|
|
14
|
+
* </template>
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
const HotkeysProvider = (0, vue.defineComponent)({
|
|
18
|
+
name: "HotkeysProvider",
|
|
19
|
+
props: { defaultOptions: {
|
|
20
|
+
type: Object,
|
|
21
|
+
default: void 0
|
|
22
|
+
} },
|
|
23
|
+
setup(props, { slots }) {
|
|
24
|
+
require_HotkeysProviderContext.provideHotkeysContext(props.defaultOptions);
|
|
25
|
+
return () => slots.default?.();
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
//#endregion
|
|
30
|
+
exports.HotkeysProvider = HotkeysProvider;
|
|
31
|
+
//# sourceMappingURL=HotkeysProvider.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HotkeysProvider.cjs","names":[],"sources":["../src/HotkeysProvider.tsx"],"sourcesContent":["import { defineComponent } from 'vue'\nimport { provideHotkeysContext } from './HotkeysProviderContext'\nimport type { HotkeysProviderOptions } from './HotkeysProviderContext'\n\n/**\n * Vue component that provides default options for hotkeys context.\n *\n * @example\n * ```vue\n * <template>\n * <HotkeysProvider :defaultOptions=\"{ hotkey: { enabled: true } }\">\n * <App />\n * </HotkeysProvider>\n * </template>\n * ```\n */\nexport const HotkeysProvider = defineComponent({\n name: 'HotkeysProvider',\n props: {\n defaultOptions: {\n type: Object as () => HotkeysProviderOptions,\n default: undefined,\n },\n },\n setup(props, { slots }) {\n provideHotkeysContext(props.defaultOptions)\n return () => slots.default?.()\n },\n})\n"],"mappings":";;;;;;;;;;;;;;;;AAgBA,MAAa,2CAAkC;CAC7C,MAAM;CACN,OAAO,EACL,gBAAgB;EACd,MAAM;EACN,SAAS;EACV,EACF;CACD,MAAM,OAAO,EAAE,SAAS;AACtB,uDAAsB,MAAM,eAAe;AAC3C,eAAa,MAAM,WAAW;;CAEjC,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { HotkeysProviderOptions } from "./HotkeysProviderContext.cjs";
|
|
2
|
+
import * as vue from "vue";
|
|
3
|
+
|
|
4
|
+
//#region src/HotkeysProvider.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Vue component that provides default options for hotkeys context.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```vue
|
|
10
|
+
* <template>
|
|
11
|
+
* <HotkeysProvider :defaultOptions="{ hotkey: { enabled: true } }">
|
|
12
|
+
* <App />
|
|
13
|
+
* </HotkeysProvider>
|
|
14
|
+
* </template>
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
declare const HotkeysProvider: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
18
|
+
defaultOptions: {
|
|
19
|
+
type: () => HotkeysProviderOptions;
|
|
20
|
+
default: undefined;
|
|
21
|
+
};
|
|
22
|
+
}>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
23
|
+
[key: string]: any;
|
|
24
|
+
}>[] | undefined, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
25
|
+
defaultOptions: {
|
|
26
|
+
type: () => HotkeysProviderOptions;
|
|
27
|
+
default: undefined;
|
|
28
|
+
};
|
|
29
|
+
}>> & Readonly<{}>, {
|
|
30
|
+
defaultOptions: HotkeysProviderOptions;
|
|
31
|
+
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
32
|
+
//#endregion
|
|
33
|
+
export { HotkeysProvider };
|
|
34
|
+
//# sourceMappingURL=HotkeysProvider.d.cts.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { HotkeysProviderOptions } from "./HotkeysProviderContext.js";
|
|
2
|
+
import * as vue from "vue";
|
|
3
|
+
|
|
4
|
+
//#region src/HotkeysProvider.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Vue component that provides default options for hotkeys context.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```vue
|
|
10
|
+
* <template>
|
|
11
|
+
* <HotkeysProvider :defaultOptions="{ hotkey: { enabled: true } }">
|
|
12
|
+
* <App />
|
|
13
|
+
* </HotkeysProvider>
|
|
14
|
+
* </template>
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
declare const HotkeysProvider: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
18
|
+
defaultOptions: {
|
|
19
|
+
type: () => HotkeysProviderOptions;
|
|
20
|
+
default: undefined;
|
|
21
|
+
};
|
|
22
|
+
}>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
23
|
+
[key: string]: any;
|
|
24
|
+
}>[] | undefined, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
25
|
+
defaultOptions: {
|
|
26
|
+
type: () => HotkeysProviderOptions;
|
|
27
|
+
default: undefined;
|
|
28
|
+
};
|
|
29
|
+
}>> & Readonly<{}>, {
|
|
30
|
+
defaultOptions: HotkeysProviderOptions;
|
|
31
|
+
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
32
|
+
//#endregion
|
|
33
|
+
export { HotkeysProvider };
|
|
34
|
+
//# sourceMappingURL=HotkeysProvider.d.ts.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { provideHotkeysContext } from "./HotkeysProviderContext.js";
|
|
2
|
+
import { defineComponent } from "vue";
|
|
3
|
+
|
|
4
|
+
//#region src/HotkeysProvider.tsx
|
|
5
|
+
/**
|
|
6
|
+
* Vue component that provides default options for hotkeys context.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```vue
|
|
10
|
+
* <template>
|
|
11
|
+
* <HotkeysProvider :defaultOptions="{ hotkey: { enabled: true } }">
|
|
12
|
+
* <App />
|
|
13
|
+
* </HotkeysProvider>
|
|
14
|
+
* </template>
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
const HotkeysProvider = defineComponent({
|
|
18
|
+
name: "HotkeysProvider",
|
|
19
|
+
props: { defaultOptions: {
|
|
20
|
+
type: Object,
|
|
21
|
+
default: void 0
|
|
22
|
+
} },
|
|
23
|
+
setup(props, { slots }) {
|
|
24
|
+
provideHotkeysContext(props.defaultOptions);
|
|
25
|
+
return () => slots.default?.();
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
//#endregion
|
|
30
|
+
export { HotkeysProvider };
|
|
31
|
+
//# sourceMappingURL=HotkeysProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HotkeysProvider.js","names":[],"sources":["../src/HotkeysProvider.tsx"],"sourcesContent":["import { defineComponent } from 'vue'\nimport { provideHotkeysContext } from './HotkeysProviderContext'\nimport type { HotkeysProviderOptions } from './HotkeysProviderContext'\n\n/**\n * Vue component that provides default options for hotkeys context.\n *\n * @example\n * ```vue\n * <template>\n * <HotkeysProvider :defaultOptions=\"{ hotkey: { enabled: true } }\">\n * <App />\n * </HotkeysProvider>\n * </template>\n * ```\n */\nexport const HotkeysProvider = defineComponent({\n name: 'HotkeysProvider',\n props: {\n defaultOptions: {\n type: Object as () => HotkeysProviderOptions,\n default: undefined,\n },\n },\n setup(props, { slots }) {\n provideHotkeysContext(props.defaultOptions)\n return () => slots.default?.()\n },\n})\n"],"mappings":";;;;;;;;;;;;;;;;AAgBA,MAAa,kBAAkB,gBAAgB;CAC7C,MAAM;CACN,OAAO,EACL,gBAAgB;EACd,MAAM;EACN,SAAS;EACV,EACF;CACD,MAAM,OAAO,EAAE,SAAS;AACtB,wBAAsB,MAAM,eAAe;AAC3C,eAAa,MAAM,WAAW;;CAEjC,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
let vue = require("vue");
|
|
2
|
+
|
|
3
|
+
//#region src/HotkeysProviderContext.ts
|
|
4
|
+
const HotkeysContext = Symbol("HotkeysContext");
|
|
5
|
+
const DEFAULT_OPTIONS = {};
|
|
6
|
+
function provideHotkeysContext(defaultOptions) {
|
|
7
|
+
(0, vue.provide)(HotkeysContext, { defaultOptions: defaultOptions ?? DEFAULT_OPTIONS });
|
|
8
|
+
}
|
|
9
|
+
function useHotkeysContext() {
|
|
10
|
+
return (0, vue.inject)(HotkeysContext, null);
|
|
11
|
+
}
|
|
12
|
+
function useDefaultHotkeysOptions() {
|
|
13
|
+
return (0, vue.inject)(HotkeysContext, null)?.defaultOptions ?? {};
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
exports.provideHotkeysContext = provideHotkeysContext;
|
|
18
|
+
exports.useDefaultHotkeysOptions = useDefaultHotkeysOptions;
|
|
19
|
+
exports.useHotkeysContext = useHotkeysContext;
|
|
20
|
+
//# sourceMappingURL=HotkeysProviderContext.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HotkeysProviderContext.cjs","names":[],"sources":["../src/HotkeysProviderContext.ts"],"sourcesContent":["import { inject, provide } from 'vue'\nimport type { InjectionKey } from 'vue'\nimport type { HotkeyRecorderOptions } from '@tanstack/hotkeys'\nimport type { UseHotkeyOptions } from './useHotkey'\nimport type { UseHotkeySequenceOptions } from './useHotkeySequence'\n\nexport interface HotkeysProviderOptions {\n hotkey?: Partial<UseHotkeyOptions>\n hotkeyRecorder?: Partial<HotkeyRecorderOptions>\n hotkeySequence?: Partial<UseHotkeySequenceOptions>\n}\n\ninterface HotkeysContextValue {\n defaultOptions: HotkeysProviderOptions\n}\n\nconst HotkeysContext: InjectionKey<HotkeysContextValue> =\n Symbol('HotkeysContext')\n\nconst DEFAULT_OPTIONS: HotkeysProviderOptions = {}\n\nexport function provideHotkeysContext(defaultOptions?: HotkeysProviderOptions) {\n const contextValue: HotkeysContextValue = {\n defaultOptions: defaultOptions ?? DEFAULT_OPTIONS,\n }\n\n provide(HotkeysContext, contextValue)\n}\n\nexport function useHotkeysContext() {\n return inject(HotkeysContext, null)\n}\n\nexport function useDefaultHotkeysOptions() {\n const context = inject(HotkeysContext, null)\n return context?.defaultOptions ?? {}\n}\n"],"mappings":";;;AAgBA,MAAM,iBACJ,OAAO,iBAAiB;AAE1B,MAAM,kBAA0C,EAAE;AAElD,SAAgB,sBAAsB,gBAAyC;AAK7E,kBAAQ,gBAJkC,EACxC,gBAAgB,kBAAkB,iBACnC,CAEoC;;AAGvC,SAAgB,oBAAoB;AAClC,wBAAc,gBAAgB,KAAK;;AAGrC,SAAgB,2BAA2B;AAEzC,wBADuB,gBAAgB,KAAK,EAC5B,kBAAkB,EAAE"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { UseHotkeyOptions } from "./useHotkey.cjs";
|
|
2
|
+
import { UseHotkeySequenceOptions } from "./useHotkeySequence.cjs";
|
|
3
|
+
import { HotkeyRecorderOptions } from "@tanstack/hotkeys";
|
|
4
|
+
|
|
5
|
+
//#region src/HotkeysProviderContext.d.ts
|
|
6
|
+
interface HotkeysProviderOptions {
|
|
7
|
+
hotkey?: Partial<UseHotkeyOptions>;
|
|
8
|
+
hotkeyRecorder?: Partial<HotkeyRecorderOptions>;
|
|
9
|
+
hotkeySequence?: Partial<UseHotkeySequenceOptions>;
|
|
10
|
+
}
|
|
11
|
+
interface HotkeysContextValue {
|
|
12
|
+
defaultOptions: HotkeysProviderOptions;
|
|
13
|
+
}
|
|
14
|
+
declare function provideHotkeysContext(defaultOptions?: HotkeysProviderOptions): void;
|
|
15
|
+
declare function useHotkeysContext(): HotkeysContextValue | null;
|
|
16
|
+
declare function useDefaultHotkeysOptions(): HotkeysProviderOptions;
|
|
17
|
+
//#endregion
|
|
18
|
+
export { HotkeysProviderOptions, provideHotkeysContext, useDefaultHotkeysOptions, useHotkeysContext };
|
|
19
|
+
//# sourceMappingURL=HotkeysProviderContext.d.cts.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { UseHotkeyOptions } from "./useHotkey.js";
|
|
2
|
+
import { UseHotkeySequenceOptions } from "./useHotkeySequence.js";
|
|
3
|
+
import { HotkeyRecorderOptions } from "@tanstack/hotkeys";
|
|
4
|
+
|
|
5
|
+
//#region src/HotkeysProviderContext.d.ts
|
|
6
|
+
interface HotkeysProviderOptions {
|
|
7
|
+
hotkey?: Partial<UseHotkeyOptions>;
|
|
8
|
+
hotkeyRecorder?: Partial<HotkeyRecorderOptions>;
|
|
9
|
+
hotkeySequence?: Partial<UseHotkeySequenceOptions>;
|
|
10
|
+
}
|
|
11
|
+
interface HotkeysContextValue {
|
|
12
|
+
defaultOptions: HotkeysProviderOptions;
|
|
13
|
+
}
|
|
14
|
+
declare function provideHotkeysContext(defaultOptions?: HotkeysProviderOptions): void;
|
|
15
|
+
declare function useHotkeysContext(): HotkeysContextValue | null;
|
|
16
|
+
declare function useDefaultHotkeysOptions(): HotkeysProviderOptions;
|
|
17
|
+
//#endregion
|
|
18
|
+
export { HotkeysProviderOptions, provideHotkeysContext, useDefaultHotkeysOptions, useHotkeysContext };
|
|
19
|
+
//# sourceMappingURL=HotkeysProviderContext.d.ts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { inject, provide } from "vue";
|
|
2
|
+
|
|
3
|
+
//#region src/HotkeysProviderContext.ts
|
|
4
|
+
const HotkeysContext = Symbol("HotkeysContext");
|
|
5
|
+
const DEFAULT_OPTIONS = {};
|
|
6
|
+
function provideHotkeysContext(defaultOptions) {
|
|
7
|
+
provide(HotkeysContext, { defaultOptions: defaultOptions ?? DEFAULT_OPTIONS });
|
|
8
|
+
}
|
|
9
|
+
function useHotkeysContext() {
|
|
10
|
+
return inject(HotkeysContext, null);
|
|
11
|
+
}
|
|
12
|
+
function useDefaultHotkeysOptions() {
|
|
13
|
+
return inject(HotkeysContext, null)?.defaultOptions ?? {};
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
export { provideHotkeysContext, useDefaultHotkeysOptions, useHotkeysContext };
|
|
18
|
+
//# sourceMappingURL=HotkeysProviderContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HotkeysProviderContext.js","names":[],"sources":["../src/HotkeysProviderContext.ts"],"sourcesContent":["import { inject, provide } from 'vue'\nimport type { InjectionKey } from 'vue'\nimport type { HotkeyRecorderOptions } from '@tanstack/hotkeys'\nimport type { UseHotkeyOptions } from './useHotkey'\nimport type { UseHotkeySequenceOptions } from './useHotkeySequence'\n\nexport interface HotkeysProviderOptions {\n hotkey?: Partial<UseHotkeyOptions>\n hotkeyRecorder?: Partial<HotkeyRecorderOptions>\n hotkeySequence?: Partial<UseHotkeySequenceOptions>\n}\n\ninterface HotkeysContextValue {\n defaultOptions: HotkeysProviderOptions\n}\n\nconst HotkeysContext: InjectionKey<HotkeysContextValue> =\n Symbol('HotkeysContext')\n\nconst DEFAULT_OPTIONS: HotkeysProviderOptions = {}\n\nexport function provideHotkeysContext(defaultOptions?: HotkeysProviderOptions) {\n const contextValue: HotkeysContextValue = {\n defaultOptions: defaultOptions ?? DEFAULT_OPTIONS,\n }\n\n provide(HotkeysContext, contextValue)\n}\n\nexport function useHotkeysContext() {\n return inject(HotkeysContext, null)\n}\n\nexport function useDefaultHotkeysOptions() {\n const context = inject(HotkeysContext, null)\n return context?.defaultOptions ?? {}\n}\n"],"mappings":";;;AAgBA,MAAM,iBACJ,OAAO,iBAAiB;AAE1B,MAAM,kBAA0C,EAAE;AAElD,SAAgB,sBAAsB,gBAAyC;AAK7E,SAAQ,gBAJkC,EACxC,gBAAgB,kBAAkB,iBACnC,CAEoC;;AAGvC,SAAgB,oBAAoB;AAClC,QAAO,OAAO,gBAAgB,KAAK;;AAGrC,SAAgB,2BAA2B;AAEzC,QADgB,OAAO,gBAAgB,KAAK,EAC5B,kBAAkB,EAAE"}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_HotkeysProviderContext = require('./HotkeysProviderContext.cjs');
|
|
3
|
+
const require_HotkeysProvider = require('./HotkeysProvider.cjs');
|
|
4
|
+
const require_useHotkey = require('./useHotkey.cjs');
|
|
5
|
+
const require_useHeldKeys = require('./useHeldKeys.cjs');
|
|
6
|
+
const require_useHeldKeyCodes = require('./useHeldKeyCodes.cjs');
|
|
7
|
+
const require_useKeyHold = require('./useKeyHold.cjs');
|
|
8
|
+
const require_useHotkeySequence = require('./useHotkeySequence.cjs');
|
|
9
|
+
const require_useHotkeyRecorder = require('./useHotkeyRecorder.cjs');
|
|
10
|
+
|
|
11
|
+
exports.HotkeysProvider = require_HotkeysProvider.HotkeysProvider;
|
|
12
|
+
exports.provideHotkeysContext = require_HotkeysProviderContext.provideHotkeysContext;
|
|
13
|
+
exports.useDefaultHotkeysOptions = require_HotkeysProviderContext.useDefaultHotkeysOptions;
|
|
14
|
+
exports.useHeldKeyCodes = require_useHeldKeyCodes.useHeldKeyCodes;
|
|
15
|
+
exports.useHeldKeys = require_useHeldKeys.useHeldKeys;
|
|
16
|
+
exports.useHotkey = require_useHotkey.useHotkey;
|
|
17
|
+
exports.useHotkeyRecorder = require_useHotkeyRecorder.useHotkeyRecorder;
|
|
18
|
+
exports.useHotkeySequence = require_useHotkeySequence.useHotkeySequence;
|
|
19
|
+
exports.useHotkeysContext = require_HotkeysProviderContext.useHotkeysContext;
|
|
20
|
+
exports.useKeyHold = require_useKeyHold.useKeyHold;
|
|
21
|
+
var _tanstack_hotkeys = require("@tanstack/hotkeys");
|
|
22
|
+
Object.keys(_tanstack_hotkeys).forEach(function (k) {
|
|
23
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
get: function () { return _tanstack_hotkeys[k]; }
|
|
26
|
+
});
|
|
27
|
+
});
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { UseHotkeyOptions, useHotkey } from "./useHotkey.cjs";
|
|
2
|
+
import { UseHotkeySequenceOptions, useHotkeySequence } from "./useHotkeySequence.cjs";
|
|
3
|
+
import { HotkeysProviderOptions, provideHotkeysContext, useDefaultHotkeysOptions, useHotkeysContext } from "./HotkeysProviderContext.cjs";
|
|
4
|
+
import { HotkeysProvider } from "./HotkeysProvider.cjs";
|
|
5
|
+
import { useHeldKeys } from "./useHeldKeys.cjs";
|
|
6
|
+
import { useHeldKeyCodes } from "./useHeldKeyCodes.cjs";
|
|
7
|
+
import { useKeyHold } from "./useKeyHold.cjs";
|
|
8
|
+
import { VueHotkeyRecorder, useHotkeyRecorder } from "./useHotkeyRecorder.cjs";
|
|
9
|
+
export * from "@tanstack/hotkeys";
|
|
10
|
+
export { HotkeysProvider, HotkeysProviderOptions, UseHotkeyOptions, UseHotkeySequenceOptions, VueHotkeyRecorder, provideHotkeysContext, useDefaultHotkeysOptions, useHeldKeyCodes, useHeldKeys, useHotkey, useHotkeyRecorder, useHotkeySequence, useHotkeysContext, useKeyHold };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { UseHotkeyOptions, useHotkey } from "./useHotkey.js";
|
|
2
|
+
import { UseHotkeySequenceOptions, useHotkeySequence } from "./useHotkeySequence.js";
|
|
3
|
+
import { HotkeysProviderOptions, provideHotkeysContext, useDefaultHotkeysOptions, useHotkeysContext } from "./HotkeysProviderContext.js";
|
|
4
|
+
import { HotkeysProvider } from "./HotkeysProvider.js";
|
|
5
|
+
import { useHeldKeys } from "./useHeldKeys.js";
|
|
6
|
+
import { useHeldKeyCodes } from "./useHeldKeyCodes.js";
|
|
7
|
+
import { useKeyHold } from "./useKeyHold.js";
|
|
8
|
+
import { VueHotkeyRecorder, useHotkeyRecorder } from "./useHotkeyRecorder.js";
|
|
9
|
+
export * from "@tanstack/hotkeys";
|
|
10
|
+
export { HotkeysProvider, HotkeysProviderOptions, UseHotkeyOptions, UseHotkeySequenceOptions, VueHotkeyRecorder, provideHotkeysContext, useDefaultHotkeysOptions, useHeldKeyCodes, useHeldKeys, useHotkey, useHotkeyRecorder, useHotkeySequence, useHotkeysContext, useKeyHold };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { provideHotkeysContext, useDefaultHotkeysOptions, useHotkeysContext } from "./HotkeysProviderContext.js";
|
|
2
|
+
import { HotkeysProvider } from "./HotkeysProvider.js";
|
|
3
|
+
import { useHotkey } from "./useHotkey.js";
|
|
4
|
+
import { useHeldKeys } from "./useHeldKeys.js";
|
|
5
|
+
import { useHeldKeyCodes } from "./useHeldKeyCodes.js";
|
|
6
|
+
import { useKeyHold } from "./useKeyHold.js";
|
|
7
|
+
import { useHotkeySequence } from "./useHotkeySequence.js";
|
|
8
|
+
import { useHotkeyRecorder } from "./useHotkeyRecorder.js";
|
|
9
|
+
|
|
10
|
+
export * from "@tanstack/hotkeys"
|
|
11
|
+
|
|
12
|
+
export { HotkeysProvider, provideHotkeysContext, useDefaultHotkeysOptions, useHeldKeyCodes, useHeldKeys, useHotkey, useHotkeyRecorder, useHotkeySequence, useHotkeysContext, useKeyHold };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
let _tanstack_hotkeys = require("@tanstack/hotkeys");
|
|
2
|
+
let _tanstack_vue_store = require("@tanstack/vue-store");
|
|
3
|
+
|
|
4
|
+
//#region src/useHeldKeyCodes.ts
|
|
5
|
+
/**
|
|
6
|
+
* Vue composable that returns a reactive ref mapping currently held key names to their physical `event.code` values.
|
|
7
|
+
*
|
|
8
|
+
* This is useful for debugging which physical key was pressed (e.g. distinguishing
|
|
9
|
+
* left vs right Shift via "ShiftLeft" / "ShiftRight").
|
|
10
|
+
*
|
|
11
|
+
* @returns Reactive ref containing record mapping normalized key names to their `event.code` values
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```vue
|
|
15
|
+
* <script setup>
|
|
16
|
+
* import { useHeldKeys, useHeldKeyCodes } from '@tanstack/vue-hotkeys'
|
|
17
|
+
*
|
|
18
|
+
* const heldKeys = useHeldKeys()
|
|
19
|
+
* const heldCodes = useHeldKeyCodes()
|
|
20
|
+
* <\/script>
|
|
21
|
+
*
|
|
22
|
+
* <template>
|
|
23
|
+
* <div>
|
|
24
|
+
* <kbd v-for="key in heldKeys" :key="key">
|
|
25
|
+
* {{ key }} <small>{{ heldCodes[key] }}</small>
|
|
26
|
+
* </kbd>
|
|
27
|
+
* </div>
|
|
28
|
+
* </template>
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
function useHeldKeyCodes() {
|
|
32
|
+
return (0, _tanstack_vue_store.useStore)((0, _tanstack_hotkeys.getKeyStateTracker)().store, (state) => state.heldCodes);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
//#endregion
|
|
36
|
+
exports.useHeldKeyCodes = useHeldKeyCodes;
|
|
37
|
+
//# sourceMappingURL=useHeldKeyCodes.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useHeldKeyCodes.cjs","names":[],"sources":["../src/useHeldKeyCodes.ts"],"sourcesContent":["import { useStore } from '@tanstack/vue-store'\nimport { getKeyStateTracker } from '@tanstack/hotkeys'\nimport type { Ref } from 'vue'\n\n/**\n * Vue composable that returns a reactive ref mapping currently held key names to their physical `event.code` values.\n *\n * This is useful for debugging which physical key was pressed (e.g. distinguishing\n * left vs right Shift via \"ShiftLeft\" / \"ShiftRight\").\n *\n * @returns Reactive ref containing record mapping normalized key names to their `event.code` values\n *\n * @example\n * ```vue\n * <script setup>\n * import { useHeldKeys, useHeldKeyCodes } from '@tanstack/vue-hotkeys'\n *\n * const heldKeys = useHeldKeys()\n * const heldCodes = useHeldKeyCodes()\n * </script>\n *\n * <template>\n * <div>\n * <kbd v-for=\"key in heldKeys\" :key=\"key\">\n * {{ key }} <small>{{ heldCodes[key] }}</small>\n * </kbd>\n * </div>\n * </template>\n * ```\n */\nexport function useHeldKeyCodes(): Ref<Record<string, string>> {\n const tracker = getKeyStateTracker()\n return useStore(tracker.store, (state) => state.heldCodes)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,SAAgB,kBAA+C;AAE7D,qFADoC,CACZ,QAAQ,UAAU,MAAM,UAAU"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Ref } from "vue";
|
|
2
|
+
|
|
3
|
+
//#region src/useHeldKeyCodes.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Vue composable that returns a reactive ref mapping currently held key names to their physical `event.code` values.
|
|
6
|
+
*
|
|
7
|
+
* This is useful for debugging which physical key was pressed (e.g. distinguishing
|
|
8
|
+
* left vs right Shift via "ShiftLeft" / "ShiftRight").
|
|
9
|
+
*
|
|
10
|
+
* @returns Reactive ref containing record mapping normalized key names to their `event.code` values
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```vue
|
|
14
|
+
* <script setup>
|
|
15
|
+
* import { useHeldKeys, useHeldKeyCodes } from '@tanstack/vue-hotkeys'
|
|
16
|
+
*
|
|
17
|
+
* const heldKeys = useHeldKeys()
|
|
18
|
+
* const heldCodes = useHeldKeyCodes()
|
|
19
|
+
* </script>
|
|
20
|
+
*
|
|
21
|
+
* <template>
|
|
22
|
+
* <div>
|
|
23
|
+
* <kbd v-for="key in heldKeys" :key="key">
|
|
24
|
+
* {{ key }} <small>{{ heldCodes[key] }}</small>
|
|
25
|
+
* </kbd>
|
|
26
|
+
* </div>
|
|
27
|
+
* </template>
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
declare function useHeldKeyCodes(): Ref<Record<string, string>>;
|
|
31
|
+
//#endregion
|
|
32
|
+
export { useHeldKeyCodes };
|
|
33
|
+
//# sourceMappingURL=useHeldKeyCodes.d.cts.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Ref } from "vue";
|
|
2
|
+
|
|
3
|
+
//#region src/useHeldKeyCodes.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Vue composable that returns a reactive ref mapping currently held key names to their physical `event.code` values.
|
|
6
|
+
*
|
|
7
|
+
* This is useful for debugging which physical key was pressed (e.g. distinguishing
|
|
8
|
+
* left vs right Shift via "ShiftLeft" / "ShiftRight").
|
|
9
|
+
*
|
|
10
|
+
* @returns Reactive ref containing record mapping normalized key names to their `event.code` values
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```vue
|
|
14
|
+
* <script setup>
|
|
15
|
+
* import { useHeldKeys, useHeldKeyCodes } from '@tanstack/vue-hotkeys'
|
|
16
|
+
*
|
|
17
|
+
* const heldKeys = useHeldKeys()
|
|
18
|
+
* const heldCodes = useHeldKeyCodes()
|
|
19
|
+
* </script>
|
|
20
|
+
*
|
|
21
|
+
* <template>
|
|
22
|
+
* <div>
|
|
23
|
+
* <kbd v-for="key in heldKeys" :key="key">
|
|
24
|
+
* {{ key }} <small>{{ heldCodes[key] }}</small>
|
|
25
|
+
* </kbd>
|
|
26
|
+
* </div>
|
|
27
|
+
* </template>
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
declare function useHeldKeyCodes(): Ref<Record<string, string>>;
|
|
31
|
+
//#endregion
|
|
32
|
+
export { useHeldKeyCodes };
|
|
33
|
+
//# sourceMappingURL=useHeldKeyCodes.d.ts.map
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { getKeyStateTracker } from "@tanstack/hotkeys";
|
|
2
|
+
import { useStore } from "@tanstack/vue-store";
|
|
3
|
+
|
|
4
|
+
//#region src/useHeldKeyCodes.ts
|
|
5
|
+
/**
|
|
6
|
+
* Vue composable that returns a reactive ref mapping currently held key names to their physical `event.code` values.
|
|
7
|
+
*
|
|
8
|
+
* This is useful for debugging which physical key was pressed (e.g. distinguishing
|
|
9
|
+
* left vs right Shift via "ShiftLeft" / "ShiftRight").
|
|
10
|
+
*
|
|
11
|
+
* @returns Reactive ref containing record mapping normalized key names to their `event.code` values
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```vue
|
|
15
|
+
* <script setup>
|
|
16
|
+
* import { useHeldKeys, useHeldKeyCodes } from '@tanstack/vue-hotkeys'
|
|
17
|
+
*
|
|
18
|
+
* const heldKeys = useHeldKeys()
|
|
19
|
+
* const heldCodes = useHeldKeyCodes()
|
|
20
|
+
* <\/script>
|
|
21
|
+
*
|
|
22
|
+
* <template>
|
|
23
|
+
* <div>
|
|
24
|
+
* <kbd v-for="key in heldKeys" :key="key">
|
|
25
|
+
* {{ key }} <small>{{ heldCodes[key] }}</small>
|
|
26
|
+
* </kbd>
|
|
27
|
+
* </div>
|
|
28
|
+
* </template>
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
function useHeldKeyCodes() {
|
|
32
|
+
return useStore(getKeyStateTracker().store, (state) => state.heldCodes);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
//#endregion
|
|
36
|
+
export { useHeldKeyCodes };
|
|
37
|
+
//# sourceMappingURL=useHeldKeyCodes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useHeldKeyCodes.js","names":[],"sources":["../src/useHeldKeyCodes.ts"],"sourcesContent":["import { useStore } from '@tanstack/vue-store'\nimport { getKeyStateTracker } from '@tanstack/hotkeys'\nimport type { Ref } from 'vue'\n\n/**\n * Vue composable that returns a reactive ref mapping currently held key names to their physical `event.code` values.\n *\n * This is useful for debugging which physical key was pressed (e.g. distinguishing\n * left vs right Shift via \"ShiftLeft\" / \"ShiftRight\").\n *\n * @returns Reactive ref containing record mapping normalized key names to their `event.code` values\n *\n * @example\n * ```vue\n * <script setup>\n * import { useHeldKeys, useHeldKeyCodes } from '@tanstack/vue-hotkeys'\n *\n * const heldKeys = useHeldKeys()\n * const heldCodes = useHeldKeyCodes()\n * </script>\n *\n * <template>\n * <div>\n * <kbd v-for=\"key in heldKeys\" :key=\"key\">\n * {{ key }} <small>{{ heldCodes[key] }}</small>\n * </kbd>\n * </div>\n * </template>\n * ```\n */\nexport function useHeldKeyCodes(): Ref<Record<string, string>> {\n const tracker = getKeyStateTracker()\n return useStore(tracker.store, (state) => state.heldCodes)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,SAAgB,kBAA+C;AAE7D,QAAO,SADS,oBAAoB,CACZ,QAAQ,UAAU,MAAM,UAAU"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
let _tanstack_hotkeys = require("@tanstack/hotkeys");
|
|
2
|
+
let _tanstack_vue_store = require("@tanstack/vue-store");
|
|
3
|
+
|
|
4
|
+
//#region src/useHeldKeys.ts
|
|
5
|
+
/**
|
|
6
|
+
* Vue composable that returns a reactive ref of currently held keyboard keys.
|
|
7
|
+
*
|
|
8
|
+
* This composable uses `useStore` from `@tanstack/vue-store` to subscribe
|
|
9
|
+
* to the global KeyStateTracker and updates whenever keys are pressed
|
|
10
|
+
* or released.
|
|
11
|
+
*
|
|
12
|
+
* @returns Reactive ref containing array of currently held key names
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```vue
|
|
16
|
+
* <script setup>
|
|
17
|
+
* import { useHeldKeys } from '@tanstack/vue-hotkeys'
|
|
18
|
+
*
|
|
19
|
+
* const heldKeys = useHeldKeys()
|
|
20
|
+
* <\/script>
|
|
21
|
+
*
|
|
22
|
+
* <template>
|
|
23
|
+
* <div>
|
|
24
|
+
* Currently pressed: {{ heldKeys.join(' + ') || 'None' }}
|
|
25
|
+
* </div>
|
|
26
|
+
* </template>
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
function useHeldKeys() {
|
|
30
|
+
return (0, _tanstack_vue_store.useStore)((0, _tanstack_hotkeys.getKeyStateTracker)().store, (state) => state.heldKeys);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
//#endregion
|
|
34
|
+
exports.useHeldKeys = useHeldKeys;
|
|
35
|
+
//# sourceMappingURL=useHeldKeys.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useHeldKeys.cjs","names":[],"sources":["../src/useHeldKeys.ts"],"sourcesContent":["import { useStore } from '@tanstack/vue-store'\nimport { getKeyStateTracker } from '@tanstack/hotkeys'\nimport type { Ref } from 'vue'\n\n/**\n * Vue composable that returns a reactive ref of currently held keyboard keys.\n *\n * This composable uses `useStore` from `@tanstack/vue-store` to subscribe\n * to the global KeyStateTracker and updates whenever keys are pressed\n * or released.\n *\n * @returns Reactive ref containing array of currently held key names\n *\n * @example\n * ```vue\n * <script setup>\n * import { useHeldKeys } from '@tanstack/vue-hotkeys'\n *\n * const heldKeys = useHeldKeys()\n * </script>\n *\n * <template>\n * <div>\n * Currently pressed: {{ heldKeys.join(' + ') || 'None' }}\n * </div>\n * </template>\n * ```\n */\nexport function useHeldKeys(): Ref<Array<string>> {\n const tracker = getKeyStateTracker()\n return useStore(tracker.store, (state) => state.heldKeys)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,SAAgB,cAAkC;AAEhD,qFADoC,CACZ,QAAQ,UAAU,MAAM,SAAS"}
|