@tanstack/lit-hotkeys 0.12.0 → 0.13.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/constants.js +1 -2
- package/dist/controllers/held-key-codes.d.ts +2 -5
- package/dist/controllers/held-key-codes.js +6 -3
- package/dist/controllers/held-keys.d.ts +2 -5
- package/dist/controllers/held-keys.js +6 -3
- package/dist/controllers/hotkey-hint.d.ts +2 -5
- package/dist/controllers/hotkey-hint.js +6 -3
- package/dist/controllers/hotkey-recorder.d.ts +2 -5
- package/dist/controllers/hotkey-recorder.js +11 -4
- package/dist/controllers/hotkey-registrations.d.ts +2 -5
- package/dist/controllers/hotkey-registrations.js +6 -4
- package/dist/controllers/hotkey-sequence-recorder.d.ts +2 -5
- package/dist/controllers/hotkey-sequence-recorder.js +13 -5
- package/dist/controllers/hotkey-sequence.d.ts +2 -5
- package/dist/controllers/hotkey-sequence.js +7 -2
- package/dist/controllers/hotkey.d.ts +2 -5
- package/dist/controllers/hotkey.js +7 -2
- package/dist/controllers/index.d.ts +2 -1
- package/dist/controllers/key-hold.d.ts +2 -5
- package/dist/controllers/key-hold.js +7 -3
- package/dist/decorators/hotkey-sequence.d.ts +2 -5
- package/dist/decorators/hotkey-sequence.js +1 -2
- package/dist/decorators/hotkey.d.ts +2 -5
- package/dist/decorators/hotkey.js +1 -2
- package/dist/decorators/index.d.ts +2 -1
- package/dist/index.d.ts +2 -0
- package/package.json +9 -14
- package/dist/constants.cjs +0 -27
- package/dist/constants.cjs.map +0 -1
- package/dist/constants.js.map +0 -1
- package/dist/controllers/held-key-codes.cjs +0 -61
- package/dist/controllers/held-key-codes.cjs.map +0 -1
- package/dist/controllers/held-key-codes.d.cts +0 -45
- package/dist/controllers/held-key-codes.js.map +0 -1
- package/dist/controllers/held-keys.cjs +0 -58
- package/dist/controllers/held-keys.cjs.map +0 -1
- package/dist/controllers/held-keys.d.cts +0 -44
- package/dist/controllers/held-keys.js.map +0 -1
- package/dist/controllers/hotkey-hint.cjs +0 -47
- package/dist/controllers/hotkey-hint.cjs.map +0 -1
- package/dist/controllers/hotkey-hint.d.cts +0 -27
- package/dist/controllers/hotkey-hint.js.map +0 -1
- package/dist/controllers/hotkey-recorder.cjs +0 -104
- package/dist/controllers/hotkey-recorder.cjs.map +0 -1
- package/dist/controllers/hotkey-recorder.d.cts +0 -75
- package/dist/controllers/hotkey-recorder.js.map +0 -1
- package/dist/controllers/hotkey-registrations.cjs +0 -70
- package/dist/controllers/hotkey-registrations.cjs.map +0 -1
- package/dist/controllers/hotkey-registrations.d.cts +0 -44
- package/dist/controllers/hotkey-registrations.js.map +0 -1
- package/dist/controllers/hotkey-sequence-recorder.cjs +0 -117
- package/dist/controllers/hotkey-sequence-recorder.cjs.map +0 -1
- package/dist/controllers/hotkey-sequence-recorder.d.cts +0 -83
- package/dist/controllers/hotkey-sequence-recorder.js.map +0 -1
- package/dist/controllers/hotkey-sequence.cjs +0 -58
- package/dist/controllers/hotkey-sequence.cjs.map +0 -1
- package/dist/controllers/hotkey-sequence.d.cts +0 -45
- package/dist/controllers/hotkey-sequence.js.map +0 -1
- package/dist/controllers/hotkey.cjs +0 -60
- package/dist/controllers/hotkey.cjs.map +0 -1
- package/dist/controllers/hotkey.d.cts +0 -45
- package/dist/controllers/hotkey.js.map +0 -1
- package/dist/controllers/index.d.cts +0 -9
- package/dist/controllers/key-hold.cjs +0 -78
- package/dist/controllers/key-hold.cjs.map +0 -1
- package/dist/controllers/key-hold.d.cts +0 -62
- package/dist/controllers/key-hold.js.map +0 -1
- package/dist/decorators/hotkey-sequence.cjs +0 -45
- package/dist/decorators/hotkey-sequence.cjs.map +0 -1
- package/dist/decorators/hotkey-sequence.d.cts +0 -28
- package/dist/decorators/hotkey-sequence.js.map +0 -1
- package/dist/decorators/hotkey.cjs +0 -44
- package/dist/decorators/hotkey.cjs.map +0 -1
- package/dist/decorators/hotkey.d.cts +0 -27
- package/dist/decorators/hotkey.js.map +0 -1
- package/dist/decorators/index.d.cts +0 -2
- package/dist/index.cjs +0 -31
- package/dist/index.d.cts +0 -13
- package/src/constants.ts +0 -23
- package/src/controllers/held-key-codes.ts +0 -67
- package/src/controllers/held-keys.ts +0 -64
- package/src/controllers/hotkey-hint.ts +0 -56
- package/src/controllers/hotkey-recorder.ts +0 -120
- package/src/controllers/hotkey-registrations.ts +0 -89
- package/src/controllers/hotkey-sequence-recorder.ts +0 -141
- package/src/controllers/hotkey-sequence.ts +0 -82
- package/src/controllers/hotkey.ts +0 -96
- package/src/controllers/index.ts +0 -9
- package/src/controllers/key-hold.ts +0 -88
- package/src/decorators/hotkey-sequence.ts +0 -68
- package/src/decorators/hotkey.ts +0 -70
- package/src/decorators/index.ts +0 -2
- package/src/index.ts +0 -6
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
let _tanstack_hotkeys = require("@tanstack/hotkeys");
|
|
2
|
-
|
|
3
|
-
//#region src/controllers/held-key-codes.ts
|
|
4
|
-
/**
|
|
5
|
-
* A Lit ReactiveController that tracks all currently held key names to their physical `event.code` values.
|
|
6
|
-
*
|
|
7
|
-
* Subscribes to the global KeyStateTracker and triggers host updates
|
|
8
|
-
* whenever keys are pressed or released.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```ts
|
|
12
|
-
* class KeyDisplay extends LitElement {
|
|
13
|
-
* private heldKeyCodes = new HeldKeyCodesController(this)
|
|
14
|
-
*
|
|
15
|
-
* render() {
|
|
16
|
-
* const heldCodes = Object.entries(this.heldKeyCodes.value).map(([key, code]) => `${key}: ${code}`).join(' + ')
|
|
17
|
-
* return html`
|
|
18
|
-
* <div>
|
|
19
|
-
* Currently pressed: ${heldCodes || 'None'}
|
|
20
|
-
* </div>
|
|
21
|
-
* `
|
|
22
|
-
* }
|
|
23
|
-
* }
|
|
24
|
-
* ```
|
|
25
|
-
*/
|
|
26
|
-
var HeldKeyCodesController = class {
|
|
27
|
-
/** Map of currently held key names to their physical `event.code` values. */
|
|
28
|
-
get value() {
|
|
29
|
-
return this._value;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* @param _host - The Lit component that owns this controller.
|
|
33
|
-
*/
|
|
34
|
-
constructor(_host) {
|
|
35
|
-
this._host = _host;
|
|
36
|
-
this._value = {};
|
|
37
|
-
this._host.addController(this);
|
|
38
|
-
}
|
|
39
|
-
/** Subscribes to the tracker store and updates the internal state when changes occur. */
|
|
40
|
-
hostConnected() {
|
|
41
|
-
const tracker = (0, _tanstack_hotkeys.getKeyStateTracker)();
|
|
42
|
-
this._value = tracker.store.state.heldCodes;
|
|
43
|
-
this._host.requestUpdate();
|
|
44
|
-
const subscription = tracker.store.subscribe(() => {
|
|
45
|
-
const { heldCodes } = tracker.store.state;
|
|
46
|
-
this._value = heldCodes;
|
|
47
|
-
this._host.requestUpdate();
|
|
48
|
-
});
|
|
49
|
-
this._unsubscribe = () => subscription.unsubscribe();
|
|
50
|
-
}
|
|
51
|
-
/** Unsubscribes from the tracker store and stops tracking the held key codes. */
|
|
52
|
-
hostDisconnected() {
|
|
53
|
-
this._unsubscribe?.();
|
|
54
|
-
this._unsubscribe = void 0;
|
|
55
|
-
this._value = {};
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
//#endregion
|
|
60
|
-
exports.HeldKeyCodesController = HeldKeyCodesController;
|
|
61
|
-
//# sourceMappingURL=held-key-codes.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"held-key-codes.cjs","names":[],"sources":["../../src/controllers/held-key-codes.ts"],"sourcesContent":["import { getKeyStateTracker } from '@tanstack/hotkeys'\nimport type { KeyStateTracker } from '@tanstack/hotkeys'\nimport type { ReactiveController, ReactiveControllerHost } from 'lit'\n\n/**\n * A Lit ReactiveController that tracks all currently held key names to their physical `event.code` values.\n *\n * Subscribes to the global KeyStateTracker and triggers host updates\n * whenever keys are pressed or released.\n *\n * @example\n * ```ts\n * class KeyDisplay extends LitElement {\n * private heldKeyCodes = new HeldKeyCodesController(this)\n *\n * render() {\n * const heldCodes = Object.entries(this.heldKeyCodes.value).map(([key, code]) => `${key}: ${code}`).join(' + ')\n * return html`\n * <div>\n * Currently pressed: ${heldCodes || 'None'}\n * </div>\n * `\n * }\n * }\n * ```\n */\nexport class HeldKeyCodesController implements ReactiveController {\n /** The unsubscribe function to unsubscribe from the tracker store. */\n private _unsubscribe: (() => void) | undefined\n /** The currently held key names to their physical `event.code` values. */\n private _value: Record<string, string> = {}\n\n /** Map of currently held key names to their physical `event.code` values. */\n public get value(): Record<string, string> {\n return this._value\n }\n\n /**\n * @param _host - The Lit component that owns this controller.\n */\n constructor(private _host: ReactiveControllerHost) {\n this._host.addController(this)\n }\n\n /** Subscribes to the tracker store and updates the internal state when changes occur. */\n public hostConnected(): void {\n const tracker: KeyStateTracker = getKeyStateTracker()\n this._value = tracker.store.state.heldCodes\n this._host.requestUpdate()\n\n const subscription = tracker.store.subscribe(() => {\n const { heldCodes } = tracker.store.state\n\n this._value = heldCodes\n this._host.requestUpdate()\n })\n\n this._unsubscribe = () => subscription.unsubscribe()\n }\n\n /** Unsubscribes from the tracker store and stops tracking the held key codes. */\n public hostDisconnected(): void {\n this._unsubscribe?.()\n this._unsubscribe = undefined\n this._value = {}\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,IAAa,yBAAb,MAAkE;;CAOhE,IAAW,QAAgC;AACzC,SAAO,KAAK;;;;;CAMd,YAAY,AAAQ,OAA+B;EAA/B;gBAVqB,EAAE;AAWzC,OAAK,MAAM,cAAc,KAAK;;;CAIhC,AAAO,gBAAsB;EAC3B,MAAM,qDAA+C;AACrD,OAAK,SAAS,QAAQ,MAAM,MAAM;AAClC,OAAK,MAAM,eAAe;EAE1B,MAAM,eAAe,QAAQ,MAAM,gBAAgB;GACjD,MAAM,EAAE,cAAc,QAAQ,MAAM;AAEpC,QAAK,SAAS;AACd,QAAK,MAAM,eAAe;IAC1B;AAEF,OAAK,qBAAqB,aAAa,aAAa;;;CAItD,AAAO,mBAAyB;AAC9B,OAAK,gBAAgB;AACrB,OAAK,eAAe;AACpB,OAAK,SAAS,EAAE"}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { ReactiveController, ReactiveControllerHost } from "lit";
|
|
2
|
-
|
|
3
|
-
//#region src/controllers/held-key-codes.d.ts
|
|
4
|
-
/**
|
|
5
|
-
* A Lit ReactiveController that tracks all currently held key names to their physical `event.code` values.
|
|
6
|
-
*
|
|
7
|
-
* Subscribes to the global KeyStateTracker and triggers host updates
|
|
8
|
-
* whenever keys are pressed or released.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```ts
|
|
12
|
-
* class KeyDisplay extends LitElement {
|
|
13
|
-
* private heldKeyCodes = new HeldKeyCodesController(this)
|
|
14
|
-
*
|
|
15
|
-
* render() {
|
|
16
|
-
* const heldCodes = Object.entries(this.heldKeyCodes.value).map(([key, code]) => `${key}: ${code}`).join(' + ')
|
|
17
|
-
* return html`
|
|
18
|
-
* <div>
|
|
19
|
-
* Currently pressed: ${heldCodes || 'None'}
|
|
20
|
-
* </div>
|
|
21
|
-
* `
|
|
22
|
-
* }
|
|
23
|
-
* }
|
|
24
|
-
* ```
|
|
25
|
-
*/
|
|
26
|
-
declare class HeldKeyCodesController implements ReactiveController {
|
|
27
|
-
private _host;
|
|
28
|
-
/** The unsubscribe function to unsubscribe from the tracker store. */
|
|
29
|
-
private _unsubscribe;
|
|
30
|
-
/** The currently held key names to their physical `event.code` values. */
|
|
31
|
-
private _value;
|
|
32
|
-
/** Map of currently held key names to their physical `event.code` values. */
|
|
33
|
-
get value(): Record<string, string>;
|
|
34
|
-
/**
|
|
35
|
-
* @param _host - The Lit component that owns this controller.
|
|
36
|
-
*/
|
|
37
|
-
constructor(_host: ReactiveControllerHost);
|
|
38
|
-
/** Subscribes to the tracker store and updates the internal state when changes occur. */
|
|
39
|
-
hostConnected(): void;
|
|
40
|
-
/** Unsubscribes from the tracker store and stops tracking the held key codes. */
|
|
41
|
-
hostDisconnected(): void;
|
|
42
|
-
}
|
|
43
|
-
//#endregion
|
|
44
|
-
export { HeldKeyCodesController };
|
|
45
|
-
//# sourceMappingURL=held-key-codes.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"held-key-codes.js","names":[],"sources":["../../src/controllers/held-key-codes.ts"],"sourcesContent":["import { getKeyStateTracker } from '@tanstack/hotkeys'\nimport type { KeyStateTracker } from '@tanstack/hotkeys'\nimport type { ReactiveController, ReactiveControllerHost } from 'lit'\n\n/**\n * A Lit ReactiveController that tracks all currently held key names to their physical `event.code` values.\n *\n * Subscribes to the global KeyStateTracker and triggers host updates\n * whenever keys are pressed or released.\n *\n * @example\n * ```ts\n * class KeyDisplay extends LitElement {\n * private heldKeyCodes = new HeldKeyCodesController(this)\n *\n * render() {\n * const heldCodes = Object.entries(this.heldKeyCodes.value).map(([key, code]) => `${key}: ${code}`).join(' + ')\n * return html`\n * <div>\n * Currently pressed: ${heldCodes || 'None'}\n * </div>\n * `\n * }\n * }\n * ```\n */\nexport class HeldKeyCodesController implements ReactiveController {\n /** The unsubscribe function to unsubscribe from the tracker store. */\n private _unsubscribe: (() => void) | undefined\n /** The currently held key names to their physical `event.code` values. */\n private _value: Record<string, string> = {}\n\n /** Map of currently held key names to their physical `event.code` values. */\n public get value(): Record<string, string> {\n return this._value\n }\n\n /**\n * @param _host - The Lit component that owns this controller.\n */\n constructor(private _host: ReactiveControllerHost) {\n this._host.addController(this)\n }\n\n /** Subscribes to the tracker store and updates the internal state when changes occur. */\n public hostConnected(): void {\n const tracker: KeyStateTracker = getKeyStateTracker()\n this._value = tracker.store.state.heldCodes\n this._host.requestUpdate()\n\n const subscription = tracker.store.subscribe(() => {\n const { heldCodes } = tracker.store.state\n\n this._value = heldCodes\n this._host.requestUpdate()\n })\n\n this._unsubscribe = () => subscription.unsubscribe()\n }\n\n /** Unsubscribes from the tracker store and stops tracking the held key codes. */\n public hostDisconnected(): void {\n this._unsubscribe?.()\n this._unsubscribe = undefined\n this._value = {}\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,IAAa,yBAAb,MAAkE;;CAOhE,IAAW,QAAgC;AACzC,SAAO,KAAK;;;;;CAMd,YAAY,AAAQ,OAA+B;EAA/B;gBAVqB,EAAE;AAWzC,OAAK,MAAM,cAAc,KAAK;;;CAIhC,AAAO,gBAAsB;EAC3B,MAAM,UAA2B,oBAAoB;AACrD,OAAK,SAAS,QAAQ,MAAM,MAAM;AAClC,OAAK,MAAM,eAAe;EAE1B,MAAM,eAAe,QAAQ,MAAM,gBAAgB;GACjD,MAAM,EAAE,cAAc,QAAQ,MAAM;AAEpC,QAAK,SAAS;AACd,QAAK,MAAM,eAAe;IAC1B;AAEF,OAAK,qBAAqB,aAAa,aAAa;;;CAItD,AAAO,mBAAyB;AAC9B,OAAK,gBAAgB;AACrB,OAAK,eAAe;AACpB,OAAK,SAAS,EAAE"}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
let _tanstack_hotkeys = require("@tanstack/hotkeys");
|
|
2
|
-
|
|
3
|
-
//#region src/controllers/held-keys.ts
|
|
4
|
-
/**
|
|
5
|
-
* A Lit ReactiveController that tracks all currently held keyboard keys.
|
|
6
|
-
*
|
|
7
|
-
* Subscribes to the global KeyStateTracker and triggers host updates
|
|
8
|
-
* whenever keys are pressed or released.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```ts
|
|
12
|
-
* class KeyDisplay extends LitElement {
|
|
13
|
-
* private heldKeys = new HeldKeysController(this)
|
|
14
|
-
*
|
|
15
|
-
* render() {
|
|
16
|
-
* return html`
|
|
17
|
-
* <div>
|
|
18
|
-
* Currently pressed: ${this.heldKeys.value.join(' + ') || 'None'}
|
|
19
|
-
* </div>
|
|
20
|
-
* `
|
|
21
|
-
* }
|
|
22
|
-
* }
|
|
23
|
-
* ```
|
|
24
|
-
*/
|
|
25
|
-
var HeldKeysController = class {
|
|
26
|
-
/** Array of currently held key names. */
|
|
27
|
-
get value() {
|
|
28
|
-
return this._value;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* @param _host - The Lit component that owns this controller.
|
|
32
|
-
*/
|
|
33
|
-
constructor(_host) {
|
|
34
|
-
this._host = _host;
|
|
35
|
-
this._value = [];
|
|
36
|
-
this._host.addController(this);
|
|
37
|
-
}
|
|
38
|
-
/** Subscribes to the tracker store and updates the internal state when changes occur. */
|
|
39
|
-
hostConnected() {
|
|
40
|
-
const tracker = (0, _tanstack_hotkeys.getKeyStateTracker)();
|
|
41
|
-
const subscription = tracker.store.subscribe(() => {
|
|
42
|
-
const { heldKeys } = tracker.store.state;
|
|
43
|
-
this._value = heldKeys;
|
|
44
|
-
this._host.requestUpdate();
|
|
45
|
-
});
|
|
46
|
-
this._unsubscribe = () => subscription.unsubscribe();
|
|
47
|
-
}
|
|
48
|
-
/** Unsubscribes from the tracker store and stops tracking the held keys. */
|
|
49
|
-
hostDisconnected() {
|
|
50
|
-
this._unsubscribe?.();
|
|
51
|
-
this._unsubscribe = void 0;
|
|
52
|
-
this._value = [];
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
//#endregion
|
|
57
|
-
exports.HeldKeysController = HeldKeysController;
|
|
58
|
-
//# sourceMappingURL=held-keys.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"held-keys.cjs","names":[],"sources":["../../src/controllers/held-keys.ts"],"sourcesContent":["import { getKeyStateTracker } from '@tanstack/hotkeys'\nimport type { KeyStateTracker } from '@tanstack/hotkeys'\nimport type { ReactiveController, ReactiveControllerHost } from 'lit'\n\n/**\n * A Lit ReactiveController that tracks all currently held keyboard keys.\n *\n * Subscribes to the global KeyStateTracker and triggers host updates\n * whenever keys are pressed or released.\n *\n * @example\n * ```ts\n * class KeyDisplay extends LitElement {\n * private heldKeys = new HeldKeysController(this)\n *\n * render() {\n * return html`\n * <div>\n * Currently pressed: ${this.heldKeys.value.join(' + ') || 'None'}\n * </div>\n * `\n * }\n * }\n * ```\n */\nexport class HeldKeysController implements ReactiveController {\n /** The unsubscribe function to unsubscribe from the tracker store. */\n private _unsubscribe: (() => void) | undefined\n /** The currently held key names. */\n private _value: Array<string> = []\n\n /** Array of currently held key names. */\n public get value(): Array<string> {\n return this._value\n }\n\n /**\n * @param _host - The Lit component that owns this controller.\n */\n constructor(private _host: ReactiveControllerHost) {\n this._host.addController(this)\n }\n\n /** Subscribes to the tracker store and updates the internal state when changes occur. */\n public hostConnected(): void {\n const tracker: KeyStateTracker = getKeyStateTracker()\n\n const subscription = tracker.store.subscribe(() => {\n const { heldKeys } = tracker.store.state\n\n this._value = heldKeys\n this._host.requestUpdate()\n })\n\n this._unsubscribe = () => subscription.unsubscribe()\n }\n\n /** Unsubscribes from the tracker store and stops tracking the held keys. */\n public hostDisconnected(): void {\n this._unsubscribe?.()\n this._unsubscribe = undefined\n this._value = []\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAyBA,IAAa,qBAAb,MAA8D;;CAO5D,IAAW,QAAuB;AAChC,SAAO,KAAK;;;;;CAMd,YAAY,AAAQ,OAA+B;EAA/B;gBAVY,EAAE;AAWhC,OAAK,MAAM,cAAc,KAAK;;;CAIhC,AAAO,gBAAsB;EAC3B,MAAM,qDAA+C;EAErD,MAAM,eAAe,QAAQ,MAAM,gBAAgB;GACjD,MAAM,EAAE,aAAa,QAAQ,MAAM;AAEnC,QAAK,SAAS;AACd,QAAK,MAAM,eAAe;IAC1B;AAEF,OAAK,qBAAqB,aAAa,aAAa;;;CAItD,AAAO,mBAAyB;AAC9B,OAAK,gBAAgB;AACrB,OAAK,eAAe;AACpB,OAAK,SAAS,EAAE"}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { ReactiveController, ReactiveControllerHost } from "lit";
|
|
2
|
-
|
|
3
|
-
//#region src/controllers/held-keys.d.ts
|
|
4
|
-
/**
|
|
5
|
-
* A Lit ReactiveController that tracks all currently held keyboard keys.
|
|
6
|
-
*
|
|
7
|
-
* Subscribes to the global KeyStateTracker and triggers host updates
|
|
8
|
-
* whenever keys are pressed or released.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```ts
|
|
12
|
-
* class KeyDisplay extends LitElement {
|
|
13
|
-
* private heldKeys = new HeldKeysController(this)
|
|
14
|
-
*
|
|
15
|
-
* render() {
|
|
16
|
-
* return html`
|
|
17
|
-
* <div>
|
|
18
|
-
* Currently pressed: ${this.heldKeys.value.join(' + ') || 'None'}
|
|
19
|
-
* </div>
|
|
20
|
-
* `
|
|
21
|
-
* }
|
|
22
|
-
* }
|
|
23
|
-
* ```
|
|
24
|
-
*/
|
|
25
|
-
declare class HeldKeysController implements ReactiveController {
|
|
26
|
-
private _host;
|
|
27
|
-
/** The unsubscribe function to unsubscribe from the tracker store. */
|
|
28
|
-
private _unsubscribe;
|
|
29
|
-
/** The currently held key names. */
|
|
30
|
-
private _value;
|
|
31
|
-
/** Array of currently held key names. */
|
|
32
|
-
get value(): Array<string>;
|
|
33
|
-
/**
|
|
34
|
-
* @param _host - The Lit component that owns this controller.
|
|
35
|
-
*/
|
|
36
|
-
constructor(_host: ReactiveControllerHost);
|
|
37
|
-
/** Subscribes to the tracker store and updates the internal state when changes occur. */
|
|
38
|
-
hostConnected(): void;
|
|
39
|
-
/** Unsubscribes from the tracker store and stops tracking the held keys. */
|
|
40
|
-
hostDisconnected(): void;
|
|
41
|
-
}
|
|
42
|
-
//#endregion
|
|
43
|
-
export { HeldKeysController };
|
|
44
|
-
//# sourceMappingURL=held-keys.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"held-keys.js","names":[],"sources":["../../src/controllers/held-keys.ts"],"sourcesContent":["import { getKeyStateTracker } from '@tanstack/hotkeys'\nimport type { KeyStateTracker } from '@tanstack/hotkeys'\nimport type { ReactiveController, ReactiveControllerHost } from 'lit'\n\n/**\n * A Lit ReactiveController that tracks all currently held keyboard keys.\n *\n * Subscribes to the global KeyStateTracker and triggers host updates\n * whenever keys are pressed or released.\n *\n * @example\n * ```ts\n * class KeyDisplay extends LitElement {\n * private heldKeys = new HeldKeysController(this)\n *\n * render() {\n * return html`\n * <div>\n * Currently pressed: ${this.heldKeys.value.join(' + ') || 'None'}\n * </div>\n * `\n * }\n * }\n * ```\n */\nexport class HeldKeysController implements ReactiveController {\n /** The unsubscribe function to unsubscribe from the tracker store. */\n private _unsubscribe: (() => void) | undefined\n /** The currently held key names. */\n private _value: Array<string> = []\n\n /** Array of currently held key names. */\n public get value(): Array<string> {\n return this._value\n }\n\n /**\n * @param _host - The Lit component that owns this controller.\n */\n constructor(private _host: ReactiveControllerHost) {\n this._host.addController(this)\n }\n\n /** Subscribes to the tracker store and updates the internal state when changes occur. */\n public hostConnected(): void {\n const tracker: KeyStateTracker = getKeyStateTracker()\n\n const subscription = tracker.store.subscribe(() => {\n const { heldKeys } = tracker.store.state\n\n this._value = heldKeys\n this._host.requestUpdate()\n })\n\n this._unsubscribe = () => subscription.unsubscribe()\n }\n\n /** Unsubscribes from the tracker store and stops tracking the held keys. */\n public hostDisconnected(): void {\n this._unsubscribe?.()\n this._unsubscribe = undefined\n this._value = []\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAyBA,IAAa,qBAAb,MAA8D;;CAO5D,IAAW,QAAuB;AAChC,SAAO,KAAK;;;;;CAMd,YAAY,AAAQ,OAA+B;EAA/B;gBAVY,EAAE;AAWhC,OAAK,MAAM,cAAc,KAAK;;;CAIhC,AAAO,gBAAsB;EAC3B,MAAM,UAA2B,oBAAoB;EAErD,MAAM,eAAe,QAAQ,MAAM,gBAAgB;GACjD,MAAM,EAAE,aAAa,QAAQ,MAAM;AAEnC,QAAK,SAAS;AACd,QAAK,MAAM,eAAe;IAC1B;AAEF,OAAK,qBAAqB,aAAa,aAAa;;;CAItD,AAAO,mBAAyB;AAC9B,OAAK,gBAAgB;AACrB,OAAK,eAAe;AACpB,OAAK,SAAS,EAAE"}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
let _tanstack_hotkeys = require("@tanstack/hotkeys");
|
|
2
|
-
|
|
3
|
-
//#region src/controllers/hotkey-hint.ts
|
|
4
|
-
/** Modifier hint controller. Getter arguments can read reactive host properties. */
|
|
5
|
-
var HotkeyHintController = class {
|
|
6
|
-
/** Attaches to the host; getter arguments can read changing reactive properties. */
|
|
7
|
-
constructor(host, hotkey, options = {}) {
|
|
8
|
-
this.host = host;
|
|
9
|
-
this.hotkey = hotkey;
|
|
10
|
-
this.options = options;
|
|
11
|
-
this.visible = false;
|
|
12
|
-
host.addController(this);
|
|
13
|
-
}
|
|
14
|
-
/** Current visibility; combine with the action’s enabled state when rendering. */
|
|
15
|
-
get value() {
|
|
16
|
-
return this.visible;
|
|
17
|
-
}
|
|
18
|
-
/** Subscribes on connection and requests renders only when hint visibility changes. */
|
|
19
|
-
hostConnected() {
|
|
20
|
-
this.update();
|
|
21
|
-
const subscription = (0, _tanstack_hotkeys.getKeyStateTracker)().store.subscribe(() => {
|
|
22
|
-
if (this.update()) this.host.requestUpdate();
|
|
23
|
-
});
|
|
24
|
-
this.unsubscribe = () => subscription.unsubscribe();
|
|
25
|
-
}
|
|
26
|
-
/** Re-evaluates getter arguments when host properties trigger an update. */
|
|
27
|
-
hostUpdate() {
|
|
28
|
-
this.update();
|
|
29
|
-
}
|
|
30
|
-
/** Releases the subscription and clears cached visibility while disconnected. */
|
|
31
|
-
hostDisconnected() {
|
|
32
|
-
this.unsubscribe?.();
|
|
33
|
-
this.unsubscribe = void 0;
|
|
34
|
-
this.visible = false;
|
|
35
|
-
}
|
|
36
|
-
/** Recomputes visibility and reports whether the host needs another render. */
|
|
37
|
-
update() {
|
|
38
|
-
const next = (0, _tanstack_hotkeys.matchesHeldModifiers)(typeof this.hotkey === "function" ? this.hotkey() : this.hotkey, (0, _tanstack_hotkeys.getKeyStateTracker)().store.state.heldKeys, typeof this.options === "function" ? this.options() : this.options);
|
|
39
|
-
const changed = next !== this.visible;
|
|
40
|
-
this.visible = next;
|
|
41
|
-
return changed;
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
//#endregion
|
|
46
|
-
exports.HotkeyHintController = HotkeyHintController;
|
|
47
|
-
//# sourceMappingURL=hotkey-hint.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hotkey-hint.cjs","names":[],"sources":["../../src/controllers/hotkey-hint.ts"],"sourcesContent":["import { getKeyStateTracker, matchesHeldModifiers } from '@tanstack/hotkeys'\nimport type { ReactiveController, ReactiveControllerHost } from 'lit'\nimport type { HeldModifierOptions, RegisterableHotkey } from '@tanstack/hotkeys'\n\n/** Modifier hint controller. Getter arguments can read reactive host properties. */\nexport class HotkeyHintController implements ReactiveController {\n private unsubscribe?: () => void\n private visible = false\n\n /** Attaches to the host; getter arguments can read changing reactive properties. */\n constructor(\n private host: ReactiveControllerHost,\n private hotkey: RegisterableHotkey | (() => RegisterableHotkey),\n private options: HeldModifierOptions | (() => HeldModifierOptions) = {},\n ) {\n host.addController(this)\n }\n\n /** Current visibility; combine with the action’s enabled state when rendering. */\n get value(): boolean {\n return this.visible\n }\n\n /** Subscribes on connection and requests renders only when hint visibility changes. */\n hostConnected(): void {\n this.update()\n const subscription = getKeyStateTracker().store.subscribe(() => {\n if (this.update()) this.host.requestUpdate()\n })\n this.unsubscribe = () => subscription.unsubscribe()\n }\n\n /** Re-evaluates getter arguments when host properties trigger an update. */\n hostUpdate(): void {\n this.update()\n }\n\n /** Releases the subscription and clears cached visibility while disconnected. */\n hostDisconnected(): void {\n this.unsubscribe?.()\n this.unsubscribe = undefined\n this.visible = false\n }\n\n /** Recomputes visibility and reports whether the host needs another render. */\n private update(): boolean {\n const next = matchesHeldModifiers(\n typeof this.hotkey === 'function' ? this.hotkey() : this.hotkey,\n getKeyStateTracker().store.state.heldKeys,\n typeof this.options === 'function' ? this.options() : this.options,\n )\n const changed = next !== this.visible\n this.visible = next\n return changed\n }\n}\n"],"mappings":";;;;AAKA,IAAa,uBAAb,MAAgE;;CAK9D,YACE,AAAQ,MACR,AAAQ,QACR,AAAQ,UAA6D,EAAE,EACvE;EAHQ;EACA;EACA;iBANQ;AAQhB,OAAK,cAAc,KAAK;;;CAI1B,IAAI,QAAiB;AACnB,SAAO,KAAK;;;CAId,gBAAsB;AACpB,OAAK,QAAQ;EACb,MAAM,0DAAmC,CAAC,MAAM,gBAAgB;AAC9D,OAAI,KAAK,QAAQ,CAAE,MAAK,KAAK,eAAe;IAC5C;AACF,OAAK,oBAAoB,aAAa,aAAa;;;CAIrD,aAAmB;AACjB,OAAK,QAAQ;;;CAIf,mBAAyB;AACvB,OAAK,eAAe;AACpB,OAAK,cAAc;AACnB,OAAK,UAAU;;;CAIjB,AAAQ,SAAkB;EACxB,MAAM,mDACJ,OAAO,KAAK,WAAW,aAAa,KAAK,QAAQ,GAAG,KAAK,mDACrC,CAAC,MAAM,MAAM,UACjC,OAAO,KAAK,YAAY,aAAa,KAAK,SAAS,GAAG,KAAK,QAC5D;EACD,MAAM,UAAU,SAAS,KAAK;AAC9B,OAAK,UAAU;AACf,SAAO"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { HeldModifierOptions, RegisterableHotkey } from "@tanstack/hotkeys";
|
|
2
|
-
import { ReactiveController, ReactiveControllerHost } from "lit";
|
|
3
|
-
|
|
4
|
-
//#region src/controllers/hotkey-hint.d.ts
|
|
5
|
-
/** Modifier hint controller. Getter arguments can read reactive host properties. */
|
|
6
|
-
declare class HotkeyHintController implements ReactiveController {
|
|
7
|
-
private host;
|
|
8
|
-
private hotkey;
|
|
9
|
-
private options;
|
|
10
|
-
private unsubscribe?;
|
|
11
|
-
private visible;
|
|
12
|
-
/** Attaches to the host; getter arguments can read changing reactive properties. */
|
|
13
|
-
constructor(host: ReactiveControllerHost, hotkey: RegisterableHotkey | (() => RegisterableHotkey), options?: HeldModifierOptions | (() => HeldModifierOptions));
|
|
14
|
-
/** Current visibility; combine with the action’s enabled state when rendering. */
|
|
15
|
-
get value(): boolean;
|
|
16
|
-
/** Subscribes on connection and requests renders only when hint visibility changes. */
|
|
17
|
-
hostConnected(): void;
|
|
18
|
-
/** Re-evaluates getter arguments when host properties trigger an update. */
|
|
19
|
-
hostUpdate(): void;
|
|
20
|
-
/** Releases the subscription and clears cached visibility while disconnected. */
|
|
21
|
-
hostDisconnected(): void;
|
|
22
|
-
/** Recomputes visibility and reports whether the host needs another render. */
|
|
23
|
-
private update;
|
|
24
|
-
}
|
|
25
|
-
//#endregion
|
|
26
|
-
export { HotkeyHintController };
|
|
27
|
-
//# sourceMappingURL=hotkey-hint.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hotkey-hint.js","names":[],"sources":["../../src/controllers/hotkey-hint.ts"],"sourcesContent":["import { getKeyStateTracker, matchesHeldModifiers } from '@tanstack/hotkeys'\nimport type { ReactiveController, ReactiveControllerHost } from 'lit'\nimport type { HeldModifierOptions, RegisterableHotkey } from '@tanstack/hotkeys'\n\n/** Modifier hint controller. Getter arguments can read reactive host properties. */\nexport class HotkeyHintController implements ReactiveController {\n private unsubscribe?: () => void\n private visible = false\n\n /** Attaches to the host; getter arguments can read changing reactive properties. */\n constructor(\n private host: ReactiveControllerHost,\n private hotkey: RegisterableHotkey | (() => RegisterableHotkey),\n private options: HeldModifierOptions | (() => HeldModifierOptions) = {},\n ) {\n host.addController(this)\n }\n\n /** Current visibility; combine with the action’s enabled state when rendering. */\n get value(): boolean {\n return this.visible\n }\n\n /** Subscribes on connection and requests renders only when hint visibility changes. */\n hostConnected(): void {\n this.update()\n const subscription = getKeyStateTracker().store.subscribe(() => {\n if (this.update()) this.host.requestUpdate()\n })\n this.unsubscribe = () => subscription.unsubscribe()\n }\n\n /** Re-evaluates getter arguments when host properties trigger an update. */\n hostUpdate(): void {\n this.update()\n }\n\n /** Releases the subscription and clears cached visibility while disconnected. */\n hostDisconnected(): void {\n this.unsubscribe?.()\n this.unsubscribe = undefined\n this.visible = false\n }\n\n /** Recomputes visibility and reports whether the host needs another render. */\n private update(): boolean {\n const next = matchesHeldModifiers(\n typeof this.hotkey === 'function' ? this.hotkey() : this.hotkey,\n getKeyStateTracker().store.state.heldKeys,\n typeof this.options === 'function' ? this.options() : this.options,\n )\n const changed = next !== this.visible\n this.visible = next\n return changed\n }\n}\n"],"mappings":";;;;AAKA,IAAa,uBAAb,MAAgE;;CAK9D,YACE,AAAQ,MACR,AAAQ,QACR,AAAQ,UAA6D,EAAE,EACvE;EAHQ;EACA;EACA;iBANQ;AAQhB,OAAK,cAAc,KAAK;;;CAI1B,IAAI,QAAiB;AACnB,SAAO,KAAK;;;CAId,gBAAsB;AACpB,OAAK,QAAQ;EACb,MAAM,eAAe,oBAAoB,CAAC,MAAM,gBAAgB;AAC9D,OAAI,KAAK,QAAQ,CAAE,MAAK,KAAK,eAAe;IAC5C;AACF,OAAK,oBAAoB,aAAa,aAAa;;;CAIrD,aAAmB;AACjB,OAAK,QAAQ;;;CAIf,mBAAyB;AACvB,OAAK,eAAe;AACpB,OAAK,cAAc;AACnB,OAAK,UAAU;;;CAIjB,AAAQ,SAAkB;EACxB,MAAM,OAAO,qBACX,OAAO,KAAK,WAAW,aAAa,KAAK,QAAQ,GAAG,KAAK,QACzD,oBAAoB,CAAC,MAAM,MAAM,UACjC,OAAO,KAAK,YAAY,aAAa,KAAK,SAAS,GAAG,KAAK,QAC5D;EACD,MAAM,UAAU,SAAS,KAAK;AAC9B,OAAK,UAAU;AACf,SAAO"}
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
let _tanstack_hotkeys = require("@tanstack/hotkeys");
|
|
2
|
-
|
|
3
|
-
//#region src/controllers/hotkey-recorder.ts
|
|
4
|
-
/**
|
|
5
|
-
* A Lit ReactiveController that records keyboard shortcuts.
|
|
6
|
-
*
|
|
7
|
-
* Wraps the framework-agnostic `HotkeyRecorder` class, managing all the
|
|
8
|
-
* complexity of capturing keyboard events, converting them to hotkey strings,
|
|
9
|
-
* and handling edge cases like Escape to cancel or Backspace/Delete to clear.
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```ts
|
|
13
|
-
* class ShortcutSettings extends LitElement {
|
|
14
|
-
* private recorder = new HotkeyRecorderController(this, {
|
|
15
|
-
* onRecord: (hotkey) => {
|
|
16
|
-
* this.shortcut = hotkey
|
|
17
|
-
* this.requestUpdate()
|
|
18
|
-
* },
|
|
19
|
-
* onCancel: () => {
|
|
20
|
-
* console.log('Recording cancelled')
|
|
21
|
-
* },
|
|
22
|
-
* })
|
|
23
|
-
*
|
|
24
|
-
* private shortcut: Hotkey | null = null
|
|
25
|
-
*
|
|
26
|
-
* render() {
|
|
27
|
-
* return html`
|
|
28
|
-
* <button @click=${() => this.recorder.startRecording()}>
|
|
29
|
-
* ${this.recorder.isRecording ? 'Recording...' : 'Edit Shortcut'}
|
|
30
|
-
* </button>
|
|
31
|
-
* ${this.recorder.recordedHotkey
|
|
32
|
-
* ? html`<div>Recording: ${this.recorder.recordedHotkey}</div>`
|
|
33
|
-
* : nothing}
|
|
34
|
-
* `
|
|
35
|
-
* }
|
|
36
|
-
* }
|
|
37
|
-
* ```
|
|
38
|
-
*/
|
|
39
|
-
var HotkeyRecorderController = class {
|
|
40
|
-
/** Whether recording is currently active. */
|
|
41
|
-
get isRecording() {
|
|
42
|
-
return this._isRecording;
|
|
43
|
-
}
|
|
44
|
-
/** The currently recorded hotkey (for live preview). */
|
|
45
|
-
get recordedHotkey() {
|
|
46
|
-
return this._recordedHotkey;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* @param _host - The Lit component that owns this controller.
|
|
50
|
-
* @param _options - Configuration options for the recorder.
|
|
51
|
-
*/
|
|
52
|
-
constructor(_host, _options) {
|
|
53
|
-
this._host = _host;
|
|
54
|
-
this._options = _options;
|
|
55
|
-
this._isRecording = false;
|
|
56
|
-
this._recordedHotkey = null;
|
|
57
|
-
this._recorder = new _tanstack_hotkeys.HotkeyRecorder(_options);
|
|
58
|
-
this._host.addController(this);
|
|
59
|
-
}
|
|
60
|
-
/** Subscribes to the recorder store and updates the internal state when changes occur. */
|
|
61
|
-
hostConnected() {
|
|
62
|
-
const subscription = this._recorder.store.subscribe(() => {
|
|
63
|
-
const { isRecording, recordedHotkey } = this._recorder.store.state;
|
|
64
|
-
if (isRecording !== this._isRecording || recordedHotkey !== this._recordedHotkey) {
|
|
65
|
-
this._isRecording = isRecording;
|
|
66
|
-
this._recordedHotkey = recordedHotkey;
|
|
67
|
-
this._host.requestUpdate();
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
this._unsubscribe = () => subscription.unsubscribe();
|
|
71
|
-
}
|
|
72
|
-
/** Unsubscribes from the recorder store and destroys the recorder instance to prevent memory leaks. */
|
|
73
|
-
hostDisconnected() {
|
|
74
|
-
this._unsubscribe?.();
|
|
75
|
-
this._unsubscribe = void 0;
|
|
76
|
-
this._recorder.stop();
|
|
77
|
-
this._isRecording = false;
|
|
78
|
-
this._recordedHotkey = null;
|
|
79
|
-
}
|
|
80
|
-
/** Updates the recorder options (e.g. callbacks). */
|
|
81
|
-
setOptions(options) {
|
|
82
|
-
this._options = {
|
|
83
|
-
...this._options,
|
|
84
|
-
...options
|
|
85
|
-
};
|
|
86
|
-
this._recorder.setOptions(this._options);
|
|
87
|
-
}
|
|
88
|
-
/** Start recording a new hotkey. */
|
|
89
|
-
startRecording() {
|
|
90
|
-
this._recorder.start();
|
|
91
|
-
}
|
|
92
|
-
/** Stop recording (same as cancel but without calling onCancel). */
|
|
93
|
-
stopRecording() {
|
|
94
|
-
this._recorder.stop();
|
|
95
|
-
}
|
|
96
|
-
/** Cancel recording without saving. */
|
|
97
|
-
cancelRecording() {
|
|
98
|
-
this._recorder.cancel();
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
//#endregion
|
|
103
|
-
exports.HotkeyRecorderController = HotkeyRecorderController;
|
|
104
|
-
//# sourceMappingURL=hotkey-recorder.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hotkey-recorder.cjs","names":["HotkeyRecorder"],"sources":["../../src/controllers/hotkey-recorder.ts"],"sourcesContent":["import { HotkeyRecorder } from '@tanstack/hotkeys'\nimport type { ReactiveController, ReactiveControllerHost } from 'lit'\nimport type { Hotkey, HotkeyRecorderOptions } from '@tanstack/hotkeys'\n\n/**\n * A Lit ReactiveController that records keyboard shortcuts.\n *\n * Wraps the framework-agnostic `HotkeyRecorder` class, managing all the\n * complexity of capturing keyboard events, converting them to hotkey strings,\n * and handling edge cases like Escape to cancel or Backspace/Delete to clear.\n *\n * @example\n * ```ts\n * class ShortcutSettings extends LitElement {\n * private recorder = new HotkeyRecorderController(this, {\n * onRecord: (hotkey) => {\n * this.shortcut = hotkey\n * this.requestUpdate()\n * },\n * onCancel: () => {\n * console.log('Recording cancelled')\n * },\n * })\n *\n * private shortcut: Hotkey | null = null\n *\n * render() {\n * return html`\n * <button @click=${() => this.recorder.startRecording()}>\n * ${this.recorder.isRecording ? 'Recording...' : 'Edit Shortcut'}\n * </button>\n * ${this.recorder.recordedHotkey\n * ? html`<div>Recording: ${this.recorder.recordedHotkey}</div>`\n * : nothing}\n * `\n * }\n * }\n * ```\n */\nexport class HotkeyRecorderController implements ReactiveController {\n /** The recorder instance. */\n private _recorder: HotkeyRecorder\n /** The unsubscribe function to unsubscribe from the recorder store. */\n private _unsubscribe: (() => void) | undefined\n /** Whether recording is currently active. */\n private _isRecording = false\n /** The currently recorded hotkey (for live preview). */\n private _recordedHotkey: Hotkey | null = null\n\n /** Whether recording is currently active. */\n public get isRecording(): boolean {\n return this._isRecording\n }\n\n /** The currently recorded hotkey (for live preview). */\n public get recordedHotkey(): Hotkey | null {\n return this._recordedHotkey\n }\n\n /**\n * @param _host - The Lit component that owns this controller.\n * @param _options - Configuration options for the recorder.\n */\n constructor(\n private _host: ReactiveControllerHost,\n private _options: HotkeyRecorderOptions,\n ) {\n this._recorder = new HotkeyRecorder(_options)\n this._host.addController(this)\n }\n\n /** Subscribes to the recorder store and updates the internal state when changes occur. */\n public hostConnected(): void {\n const subscription = this._recorder.store.subscribe(() => {\n const { isRecording, recordedHotkey } = this._recorder.store.state\n\n const hasChanged: boolean =\n isRecording !== this._isRecording ||\n recordedHotkey !== this._recordedHotkey\n\n if (hasChanged) {\n this._isRecording = isRecording\n this._recordedHotkey = recordedHotkey\n this._host.requestUpdate()\n }\n })\n\n this._unsubscribe = () => subscription.unsubscribe()\n }\n\n /** Unsubscribes from the recorder store and destroys the recorder instance to prevent memory leaks. */\n public hostDisconnected(): void {\n this._unsubscribe?.()\n this._unsubscribe = undefined\n this._recorder.stop()\n this._isRecording = false\n this._recordedHotkey = null\n }\n\n /** Updates the recorder options (e.g. callbacks). */\n public setOptions(options: Partial<HotkeyRecorderOptions>): void {\n this._options = { ...this._options, ...options }\n this._recorder.setOptions(this._options)\n }\n\n /** Start recording a new hotkey. */\n public startRecording(): void {\n this._recorder.start()\n }\n\n /** Stop recording (same as cancel but without calling onCancel). */\n public stopRecording(): void {\n this._recorder.stop()\n }\n\n /** Cancel recording without saving. */\n public cancelRecording(): void {\n this._recorder.cancel()\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,IAAa,2BAAb,MAAoE;;CAWlE,IAAW,cAAuB;AAChC,SAAO,KAAK;;;CAId,IAAW,iBAAgC;AACzC,SAAO,KAAK;;;;;;CAOd,YACE,AAAQ,OACR,AAAQ,UACR;EAFQ;EACA;sBApBa;yBAEkB;AAoBvC,OAAK,YAAY,IAAIA,iCAAe,SAAS;AAC7C,OAAK,MAAM,cAAc,KAAK;;;CAIhC,AAAO,gBAAsB;EAC3B,MAAM,eAAe,KAAK,UAAU,MAAM,gBAAgB;GACxD,MAAM,EAAE,aAAa,mBAAmB,KAAK,UAAU,MAAM;AAM7D,OAHE,gBAAgB,KAAK,gBACrB,mBAAmB,KAAK,iBAEV;AACd,SAAK,eAAe;AACpB,SAAK,kBAAkB;AACvB,SAAK,MAAM,eAAe;;IAE5B;AAEF,OAAK,qBAAqB,aAAa,aAAa;;;CAItD,AAAO,mBAAyB;AAC9B,OAAK,gBAAgB;AACrB,OAAK,eAAe;AACpB,OAAK,UAAU,MAAM;AACrB,OAAK,eAAe;AACpB,OAAK,kBAAkB;;;CAIzB,AAAO,WAAW,SAA+C;AAC/D,OAAK,WAAW;GAAE,GAAG,KAAK;GAAU,GAAG;GAAS;AAChD,OAAK,UAAU,WAAW,KAAK,SAAS;;;CAI1C,AAAO,iBAAuB;AAC5B,OAAK,UAAU,OAAO;;;CAIxB,AAAO,gBAAsB;AAC3B,OAAK,UAAU,MAAM;;;CAIvB,AAAO,kBAAwB;AAC7B,OAAK,UAAU,QAAQ"}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { Hotkey, HotkeyRecorderOptions } from "@tanstack/hotkeys";
|
|
2
|
-
import { ReactiveController, ReactiveControllerHost } from "lit";
|
|
3
|
-
|
|
4
|
-
//#region src/controllers/hotkey-recorder.d.ts
|
|
5
|
-
/**
|
|
6
|
-
* A Lit ReactiveController that records keyboard shortcuts.
|
|
7
|
-
*
|
|
8
|
-
* Wraps the framework-agnostic `HotkeyRecorder` class, managing all the
|
|
9
|
-
* complexity of capturing keyboard events, converting them to hotkey strings,
|
|
10
|
-
* and handling edge cases like Escape to cancel or Backspace/Delete to clear.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```ts
|
|
14
|
-
* class ShortcutSettings extends LitElement {
|
|
15
|
-
* private recorder = new HotkeyRecorderController(this, {
|
|
16
|
-
* onRecord: (hotkey) => {
|
|
17
|
-
* this.shortcut = hotkey
|
|
18
|
-
* this.requestUpdate()
|
|
19
|
-
* },
|
|
20
|
-
* onCancel: () => {
|
|
21
|
-
* console.log('Recording cancelled')
|
|
22
|
-
* },
|
|
23
|
-
* })
|
|
24
|
-
*
|
|
25
|
-
* private shortcut: Hotkey | null = null
|
|
26
|
-
*
|
|
27
|
-
* render() {
|
|
28
|
-
* return html`
|
|
29
|
-
* <button @click=${() => this.recorder.startRecording()}>
|
|
30
|
-
* ${this.recorder.isRecording ? 'Recording...' : 'Edit Shortcut'}
|
|
31
|
-
* </button>
|
|
32
|
-
* ${this.recorder.recordedHotkey
|
|
33
|
-
* ? html`<div>Recording: ${this.recorder.recordedHotkey}</div>`
|
|
34
|
-
* : nothing}
|
|
35
|
-
* `
|
|
36
|
-
* }
|
|
37
|
-
* }
|
|
38
|
-
* ```
|
|
39
|
-
*/
|
|
40
|
-
declare class HotkeyRecorderController implements ReactiveController {
|
|
41
|
-
private _host;
|
|
42
|
-
private _options;
|
|
43
|
-
/** The recorder instance. */
|
|
44
|
-
private _recorder;
|
|
45
|
-
/** The unsubscribe function to unsubscribe from the recorder store. */
|
|
46
|
-
private _unsubscribe;
|
|
47
|
-
/** Whether recording is currently active. */
|
|
48
|
-
private _isRecording;
|
|
49
|
-
/** The currently recorded hotkey (for live preview). */
|
|
50
|
-
private _recordedHotkey;
|
|
51
|
-
/** Whether recording is currently active. */
|
|
52
|
-
get isRecording(): boolean;
|
|
53
|
-
/** The currently recorded hotkey (for live preview). */
|
|
54
|
-
get recordedHotkey(): Hotkey | null;
|
|
55
|
-
/**
|
|
56
|
-
* @param _host - The Lit component that owns this controller.
|
|
57
|
-
* @param _options - Configuration options for the recorder.
|
|
58
|
-
*/
|
|
59
|
-
constructor(_host: ReactiveControllerHost, _options: HotkeyRecorderOptions);
|
|
60
|
-
/** Subscribes to the recorder store and updates the internal state when changes occur. */
|
|
61
|
-
hostConnected(): void;
|
|
62
|
-
/** Unsubscribes from the recorder store and destroys the recorder instance to prevent memory leaks. */
|
|
63
|
-
hostDisconnected(): void;
|
|
64
|
-
/** Updates the recorder options (e.g. callbacks). */
|
|
65
|
-
setOptions(options: Partial<HotkeyRecorderOptions>): void;
|
|
66
|
-
/** Start recording a new hotkey. */
|
|
67
|
-
startRecording(): void;
|
|
68
|
-
/** Stop recording (same as cancel but without calling onCancel). */
|
|
69
|
-
stopRecording(): void;
|
|
70
|
-
/** Cancel recording without saving. */
|
|
71
|
-
cancelRecording(): void;
|
|
72
|
-
}
|
|
73
|
-
//#endregion
|
|
74
|
-
export { HotkeyRecorderController };
|
|
75
|
-
//# sourceMappingURL=hotkey-recorder.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hotkey-recorder.js","names":[],"sources":["../../src/controllers/hotkey-recorder.ts"],"sourcesContent":["import { HotkeyRecorder } from '@tanstack/hotkeys'\nimport type { ReactiveController, ReactiveControllerHost } from 'lit'\nimport type { Hotkey, HotkeyRecorderOptions } from '@tanstack/hotkeys'\n\n/**\n * A Lit ReactiveController that records keyboard shortcuts.\n *\n * Wraps the framework-agnostic `HotkeyRecorder` class, managing all the\n * complexity of capturing keyboard events, converting them to hotkey strings,\n * and handling edge cases like Escape to cancel or Backspace/Delete to clear.\n *\n * @example\n * ```ts\n * class ShortcutSettings extends LitElement {\n * private recorder = new HotkeyRecorderController(this, {\n * onRecord: (hotkey) => {\n * this.shortcut = hotkey\n * this.requestUpdate()\n * },\n * onCancel: () => {\n * console.log('Recording cancelled')\n * },\n * })\n *\n * private shortcut: Hotkey | null = null\n *\n * render() {\n * return html`\n * <button @click=${() => this.recorder.startRecording()}>\n * ${this.recorder.isRecording ? 'Recording...' : 'Edit Shortcut'}\n * </button>\n * ${this.recorder.recordedHotkey\n * ? html`<div>Recording: ${this.recorder.recordedHotkey}</div>`\n * : nothing}\n * `\n * }\n * }\n * ```\n */\nexport class HotkeyRecorderController implements ReactiveController {\n /** The recorder instance. */\n private _recorder: HotkeyRecorder\n /** The unsubscribe function to unsubscribe from the recorder store. */\n private _unsubscribe: (() => void) | undefined\n /** Whether recording is currently active. */\n private _isRecording = false\n /** The currently recorded hotkey (for live preview). */\n private _recordedHotkey: Hotkey | null = null\n\n /** Whether recording is currently active. */\n public get isRecording(): boolean {\n return this._isRecording\n }\n\n /** The currently recorded hotkey (for live preview). */\n public get recordedHotkey(): Hotkey | null {\n return this._recordedHotkey\n }\n\n /**\n * @param _host - The Lit component that owns this controller.\n * @param _options - Configuration options for the recorder.\n */\n constructor(\n private _host: ReactiveControllerHost,\n private _options: HotkeyRecorderOptions,\n ) {\n this._recorder = new HotkeyRecorder(_options)\n this._host.addController(this)\n }\n\n /** Subscribes to the recorder store and updates the internal state when changes occur. */\n public hostConnected(): void {\n const subscription = this._recorder.store.subscribe(() => {\n const { isRecording, recordedHotkey } = this._recorder.store.state\n\n const hasChanged: boolean =\n isRecording !== this._isRecording ||\n recordedHotkey !== this._recordedHotkey\n\n if (hasChanged) {\n this._isRecording = isRecording\n this._recordedHotkey = recordedHotkey\n this._host.requestUpdate()\n }\n })\n\n this._unsubscribe = () => subscription.unsubscribe()\n }\n\n /** Unsubscribes from the recorder store and destroys the recorder instance to prevent memory leaks. */\n public hostDisconnected(): void {\n this._unsubscribe?.()\n this._unsubscribe = undefined\n this._recorder.stop()\n this._isRecording = false\n this._recordedHotkey = null\n }\n\n /** Updates the recorder options (e.g. callbacks). */\n public setOptions(options: Partial<HotkeyRecorderOptions>): void {\n this._options = { ...this._options, ...options }\n this._recorder.setOptions(this._options)\n }\n\n /** Start recording a new hotkey. */\n public startRecording(): void {\n this._recorder.start()\n }\n\n /** Stop recording (same as cancel but without calling onCancel). */\n public stopRecording(): void {\n this._recorder.stop()\n }\n\n /** Cancel recording without saving. */\n public cancelRecording(): void {\n this._recorder.cancel()\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,IAAa,2BAAb,MAAoE;;CAWlE,IAAW,cAAuB;AAChC,SAAO,KAAK;;;CAId,IAAW,iBAAgC;AACzC,SAAO,KAAK;;;;;;CAOd,YACE,AAAQ,OACR,AAAQ,UACR;EAFQ;EACA;sBApBa;yBAEkB;AAoBvC,OAAK,YAAY,IAAI,eAAe,SAAS;AAC7C,OAAK,MAAM,cAAc,KAAK;;;CAIhC,AAAO,gBAAsB;EAC3B,MAAM,eAAe,KAAK,UAAU,MAAM,gBAAgB;GACxD,MAAM,EAAE,aAAa,mBAAmB,KAAK,UAAU,MAAM;AAM7D,OAHE,gBAAgB,KAAK,gBACrB,mBAAmB,KAAK,iBAEV;AACd,SAAK,eAAe;AACpB,SAAK,kBAAkB;AACvB,SAAK,MAAM,eAAe;;IAE5B;AAEF,OAAK,qBAAqB,aAAa,aAAa;;;CAItD,AAAO,mBAAyB;AAC9B,OAAK,gBAAgB;AACrB,OAAK,eAAe;AACpB,OAAK,UAAU,MAAM;AACrB,OAAK,eAAe;AACpB,OAAK,kBAAkB;;;CAIzB,AAAO,WAAW,SAA+C;AAC/D,OAAK,WAAW;GAAE,GAAG,KAAK;GAAU,GAAG;GAAS;AAChD,OAAK,UAAU,WAAW,KAAK,SAAS;;;CAI1C,AAAO,iBAAuB;AAC5B,OAAK,UAAU,OAAO;;;CAIxB,AAAO,gBAAsB;AAC3B,OAAK,UAAU,MAAM;;;CAIvB,AAAO,kBAAwB;AAC7B,OAAK,UAAU,QAAQ"}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
let _tanstack_hotkeys = require("@tanstack/hotkeys");
|
|
2
|
-
|
|
3
|
-
//#region src/controllers/hotkey-registrations.ts
|
|
4
|
-
/**
|
|
5
|
-
* A Lit ReactiveController that tracks all hotkey and sequence registrations.
|
|
6
|
-
*
|
|
7
|
-
* Subscribes to the singleton HotkeyManager and SequenceManager stores and
|
|
8
|
-
* triggers host updates whenever registrations change.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```ts
|
|
12
|
-
* class ShortcutPalette extends LitElement {
|
|
13
|
-
* private registrations = new HotkeyRegistrationsController(this)
|
|
14
|
-
*
|
|
15
|
-
* render() {
|
|
16
|
-
* return html`
|
|
17
|
-
* <ul>
|
|
18
|
-
* ${this.registrations.hotkeys.map(
|
|
19
|
-
* (reg) => html`<li>${reg.options.meta?.name ?? reg.hotkey}</li>`,
|
|
20
|
-
* )}
|
|
21
|
-
* </ul>
|
|
22
|
-
* `
|
|
23
|
-
* }
|
|
24
|
-
* }
|
|
25
|
-
* ```
|
|
26
|
-
*/
|
|
27
|
-
var HotkeyRegistrationsController = class {
|
|
28
|
-
/** All registered hotkeys (public view, no callbacks). */
|
|
29
|
-
get hotkeys() {
|
|
30
|
-
return this._hotkeys;
|
|
31
|
-
}
|
|
32
|
-
/** All registered sequences. */
|
|
33
|
-
get sequences() {
|
|
34
|
-
return this._sequences;
|
|
35
|
-
}
|
|
36
|
-
constructor(_host) {
|
|
37
|
-
this._host = _host;
|
|
38
|
-
this._hotkeys = [];
|
|
39
|
-
this._sequences = [];
|
|
40
|
-
this._host.addController(this);
|
|
41
|
-
}
|
|
42
|
-
hostConnected() {
|
|
43
|
-
const hotkeyManager = (0, _tanstack_hotkeys.getHotkeyManager)();
|
|
44
|
-
const sequenceManager = (0, _tanstack_hotkeys.getSequenceManager)();
|
|
45
|
-
const hotkeysSub = hotkeyManager.registrations.subscribe(() => {
|
|
46
|
-
this._hotkeys = Array.from(hotkeyManager.registrations.state.values()).map(_tanstack_hotkeys.toHotkeyRegistrationView);
|
|
47
|
-
this._host.requestUpdate();
|
|
48
|
-
});
|
|
49
|
-
const sequencesSub = sequenceManager.registrations.subscribe(() => {
|
|
50
|
-
this._sequences = Array.from(sequenceManager.registrations.state.values());
|
|
51
|
-
this._host.requestUpdate();
|
|
52
|
-
});
|
|
53
|
-
this._unsubscribeHotkeys = () => hotkeysSub.unsubscribe();
|
|
54
|
-
this._unsubscribeSequences = () => sequencesSub.unsubscribe();
|
|
55
|
-
this._hotkeys = Array.from(hotkeyManager.registrations.state.values()).map(_tanstack_hotkeys.toHotkeyRegistrationView);
|
|
56
|
-
this._sequences = Array.from(sequenceManager.registrations.state.values());
|
|
57
|
-
}
|
|
58
|
-
hostDisconnected() {
|
|
59
|
-
this._unsubscribeHotkeys?.();
|
|
60
|
-
this._unsubscribeSequences?.();
|
|
61
|
-
this._unsubscribeHotkeys = void 0;
|
|
62
|
-
this._unsubscribeSequences = void 0;
|
|
63
|
-
this._hotkeys = [];
|
|
64
|
-
this._sequences = [];
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
//#endregion
|
|
69
|
-
exports.HotkeyRegistrationsController = HotkeyRegistrationsController;
|
|
70
|
-
//# sourceMappingURL=hotkey-registrations.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hotkey-registrations.cjs","names":["toHotkeyRegistrationView"],"sources":["../../src/controllers/hotkey-registrations.ts"],"sourcesContent":["import {\n getHotkeyManager,\n getSequenceManager,\n toHotkeyRegistrationView,\n} from '@tanstack/hotkeys'\nimport type {\n HotkeyRegistrationView,\n SequenceRegistrationView,\n} from '@tanstack/hotkeys'\nimport type { ReactiveController, ReactiveControllerHost } from 'lit'\n\n/**\n * A Lit ReactiveController that tracks all hotkey and sequence registrations.\n *\n * Subscribes to the singleton HotkeyManager and SequenceManager stores and\n * triggers host updates whenever registrations change.\n *\n * @example\n * ```ts\n * class ShortcutPalette extends LitElement {\n * private registrations = new HotkeyRegistrationsController(this)\n *\n * render() {\n * return html`\n * <ul>\n * ${this.registrations.hotkeys.map(\n * (reg) => html`<li>${reg.options.meta?.name ?? reg.hotkey}</li>`,\n * )}\n * </ul>\n * `\n * }\n * }\n * ```\n */\nexport class HotkeyRegistrationsController implements ReactiveController {\n private _unsubscribeHotkeys: (() => void) | undefined\n private _unsubscribeSequences: (() => void) | undefined\n private _hotkeys: Array<HotkeyRegistrationView> = []\n private _sequences: Array<SequenceRegistrationView> = []\n\n /** All registered hotkeys (public view, no callbacks). */\n public get hotkeys(): Array<HotkeyRegistrationView> {\n return this._hotkeys\n }\n\n /** All registered sequences. */\n public get sequences(): Array<SequenceRegistrationView> {\n return this._sequences\n }\n\n constructor(private _host: ReactiveControllerHost) {\n this._host.addController(this)\n }\n\n public hostConnected(): void {\n const hotkeyManager = getHotkeyManager()\n const sequenceManager = getSequenceManager()\n\n const hotkeysSub = hotkeyManager.registrations.subscribe(() => {\n this._hotkeys = Array.from(\n hotkeyManager.registrations.state.values(),\n ).map(toHotkeyRegistrationView)\n this._host.requestUpdate()\n })\n\n const sequencesSub = sequenceManager.registrations.subscribe(() => {\n this._sequences = Array.from(sequenceManager.registrations.state.values())\n this._host.requestUpdate()\n })\n\n this._unsubscribeHotkeys = () => hotkeysSub.unsubscribe()\n this._unsubscribeSequences = () => sequencesSub.unsubscribe()\n\n // Sync initial state\n this._hotkeys = Array.from(hotkeyManager.registrations.state.values()).map(\n toHotkeyRegistrationView,\n )\n this._sequences = Array.from(sequenceManager.registrations.state.values())\n }\n\n public hostDisconnected(): void {\n this._unsubscribeHotkeys?.()\n this._unsubscribeSequences?.()\n this._unsubscribeHotkeys = undefined\n this._unsubscribeSequences = undefined\n this._hotkeys = []\n this._sequences = []\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,IAAa,gCAAb,MAAyE;;CAOvE,IAAW,UAAyC;AAClD,SAAO,KAAK;;;CAId,IAAW,YAA6C;AACtD,SAAO,KAAK;;CAGd,YAAY,AAAQ,OAA+B;EAA/B;kBAb8B,EAAE;oBACE,EAAE;AAatD,OAAK,MAAM,cAAc,KAAK;;CAGhC,AAAO,gBAAsB;EAC3B,MAAM,yDAAkC;EACxC,MAAM,6DAAsC;EAE5C,MAAM,aAAa,cAAc,cAAc,gBAAgB;AAC7D,QAAK,WAAW,MAAM,KACpB,cAAc,cAAc,MAAM,QAAQ,CAC3C,CAAC,IAAIA,2CAAyB;AAC/B,QAAK,MAAM,eAAe;IAC1B;EAEF,MAAM,eAAe,gBAAgB,cAAc,gBAAgB;AACjE,QAAK,aAAa,MAAM,KAAK,gBAAgB,cAAc,MAAM,QAAQ,CAAC;AAC1E,QAAK,MAAM,eAAe;IAC1B;AAEF,OAAK,4BAA4B,WAAW,aAAa;AACzD,OAAK,8BAA8B,aAAa,aAAa;AAG7D,OAAK,WAAW,MAAM,KAAK,cAAc,cAAc,MAAM,QAAQ,CAAC,CAAC,IACrEA,2CACD;AACD,OAAK,aAAa,MAAM,KAAK,gBAAgB,cAAc,MAAM,QAAQ,CAAC;;CAG5E,AAAO,mBAAyB;AAC9B,OAAK,uBAAuB;AAC5B,OAAK,yBAAyB;AAC9B,OAAK,sBAAsB;AAC3B,OAAK,wBAAwB;AAC7B,OAAK,WAAW,EAAE;AAClB,OAAK,aAAa,EAAE"}
|