@tanstack/svelte-hotkeys 0.20.0 → 0.21.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/HotkeysCtx.d.ts +3 -3
- package/dist/HotkeysCtx.js +1 -1
- package/dist/HotkeysProvider.svelte +0 -1
- package/dist/createHotkey.svelte.d.ts +1 -1
- package/dist/createHotkeys.svelte.d.ts +2 -2
- package/dist/createHotkeys.svelte.js +1 -1
- package/dist/getAppHotkeys.svelte.js +2 -2
- package/dist/getHotkeyHint.svelte.js +1 -1
- package/dist/internal.svelte.js +1 -1
- package/package.json +8 -6
package/dist/HotkeysCtx.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { AppHotkeys, AppHotkeysStore, CustomHotkeys, HotkeyChordRecorderOptions, HotkeyPlatform, HotkeySequenceRecorderOptions } from '@tanstack/hotkeys';
|
|
2
2
|
import type { HotkeysProviderScopeProps } from '@tanstack/hotkeys/adapter';
|
|
3
|
-
import type { CreateHotkeyCommonOptions } from './createHotkey.svelte.js';
|
|
4
3
|
import type { Snippet } from 'svelte';
|
|
4
|
+
import type { CreateHotkeyCommonOptions } from './createHotkey.svelte.js';
|
|
5
5
|
export interface HotkeysProviderOptions {
|
|
6
6
|
/**
|
|
7
7
|
* The user's platform, for labels from `getFormatForDisplay`, hotkeys, and
|
|
@@ -29,8 +29,8 @@ export interface HotkeysContextOptions extends HotkeysProviderScopeProps {
|
|
|
29
29
|
/**
|
|
30
30
|
* The user's saved custom hotkeys. When the value changes, such as after
|
|
31
31
|
* saved data loads or the user signs in, it replaces the current custom
|
|
32
|
-
* hotkeys. `undefined` leaves them unchanged; `null` clears them.
|
|
33
|
-
* entries are ignored
|
|
32
|
+
* hotkeys. `undefined` leaves them unchanged; `null` clears them. Unknown
|
|
33
|
+
* ids and invalid entries are ignored.
|
|
34
34
|
*/
|
|
35
35
|
customHotkeys?: CustomHotkeys | null;
|
|
36
36
|
/** Called with the custom hotkeys after every change, ready to save. */
|
package/dist/HotkeysCtx.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { createContext, onMount } from 'svelte';
|
|
2
1
|
import { publishAppHotkeysStore } from '@tanstack/hotkeys';
|
|
3
2
|
import { createAppHotkeysStore, getHotkeysProviderScopeKey, mergeHotkeysProviderDefaults, } from '@tanstack/hotkeys/adapter';
|
|
3
|
+
import { createContext, onMount } from 'svelte';
|
|
4
4
|
import { activateScopeWhileMounted } from './internal.svelte.js';
|
|
5
5
|
export const DEFAULT_OPTIONS = {};
|
|
6
6
|
const [useHotkeysContext, setHotkeysContextValue] = createContext();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Attachment } from 'svelte/attachments';
|
|
2
1
|
import type { AppHotkey, HotkeyCallback, HotkeyCallbackContextFor, RegisterableHotkey } from '@tanstack/hotkeys';
|
|
3
2
|
import type { AdapterAppHotkeyOptions, AdapterChordOptions, AdapterCommonOptions, AdapterHotkeyOptions, AdapterOptionsFor, AdapterSequenceOptions } from '@tanstack/hotkeys/adapter';
|
|
3
|
+
import type { Attachment } from 'svelte/attachments';
|
|
4
4
|
import type { MaybeGetter } from './internal.svelte.js';
|
|
5
5
|
/** The document or window to listen on. Use an attachment for elements. */
|
|
6
6
|
export type CreateHotkeyTarget = Document | Window;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { Attachment } from 'svelte/attachments';
|
|
2
1
|
import type { AppHotkey, HotkeyCallback, RegisterableHotkey, RegisterableHotkeyChord, RegisterableHotkeySequence } from '@tanstack/hotkeys';
|
|
3
|
-
import type {
|
|
2
|
+
import type { Attachment } from 'svelte/attachments';
|
|
4
3
|
import type { CreateAppHotkeyOptions, CreateHotkeyChordOptions, CreateHotkeyCommonOptions, CreateHotkeyOptions, CreateHotkeySequenceOptions } from './createHotkey.svelte.js';
|
|
4
|
+
import type { MaybeGetter } from './internal.svelte.js';
|
|
5
5
|
/**
|
|
6
6
|
* One hotkey for `createHotkeys`. The hotkey and options may be getters.
|
|
7
7
|
* Chords accept `requireReset`; sequences accept `timeout`; hotkeys of unknown
|
|
@@ -8,7 +8,7 @@ import { createAppHotkeysSubscriber, resolveMaybeGetter, } from './internal.svel
|
|
|
8
8
|
function bindHotkeys(hotkeys, commonOptions, element) {
|
|
9
9
|
const context = getHotkeysContext();
|
|
10
10
|
const subscribeAppHotkeys = createAppHotkeysSubscriber(context?.appHotkeysStore ?? null);
|
|
11
|
-
const bindings = createHotkeyBindings();
|
|
11
|
+
const bindings = createHotkeyBindings({ afterDelegatedHandlers: true });
|
|
12
12
|
$effect(() => {
|
|
13
13
|
if (typeof document === 'undefined') {
|
|
14
14
|
return;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { getHotkeysContext } from './HotkeysCtx.js';
|
|
2
|
-
import { createStoreSubscriber } from './internal.svelte.js';
|
|
3
2
|
import { getHotkeyRegistrations } from './getHotkeyRegistrations.svelte.js';
|
|
3
|
+
import { createStoreSubscriber } from './internal.svelte.js';
|
|
4
4
|
function requireStore(name) {
|
|
5
5
|
const store = getHotkeysContext()?.appHotkeysStore;
|
|
6
6
|
if (!store) {
|
|
7
|
-
throw new Error(
|
|
7
|
+
throw new Error(`[hotkeys] ${name} requires a HotkeysProvider with appHotkeys`);
|
|
8
8
|
}
|
|
9
9
|
return {
|
|
10
10
|
store: store,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createSubscriber } from 'svelte/reactivity';
|
|
2
1
|
import { getHotkeyManager, getKeyStateTracker, isAppHotkey, matchesHeldModifiers, resolveAppHotkey, } from '@tanstack/hotkeys';
|
|
2
|
+
import { createSubscriber } from 'svelte/reactivity';
|
|
3
3
|
import { getHotkeysContext } from './HotkeysCtx.js';
|
|
4
4
|
import { resolveMaybeGetter } from './internal.svelte.js';
|
|
5
5
|
/**
|
package/dist/internal.svelte.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createSubscriber } from 'svelte/reactivity';
|
|
2
1
|
import { activateHotkeysProviderScope } from '@tanstack/hotkeys/adapter';
|
|
2
|
+
import { createSubscriber } from 'svelte/reactivity';
|
|
3
3
|
export function resolveMaybeGetter(value) {
|
|
4
4
|
return typeof value === 'function' ? value() : value;
|
|
5
5
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/svelte-hotkeys",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.1",
|
|
4
4
|
"description": "Svelte adapter for TanStack Hotkeys",
|
|
5
5
|
"author": "Kunal Rao",
|
|
6
6
|
"license": "MIT",
|
|
@@ -41,14 +41,15 @@
|
|
|
41
41
|
"skills"
|
|
42
42
|
],
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@tanstack/hotkeys": "0.
|
|
44
|
+
"@tanstack/hotkeys": "0.25.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@sveltejs/package": "^3.0.
|
|
47
|
+
"@sveltejs/package": "^3.0.2",
|
|
48
48
|
"@sveltejs/vite-plugin-svelte": "^7.3.1",
|
|
49
|
-
"@typescript-eslint/parser": "^8.
|
|
50
|
-
"eslint
|
|
51
|
-
"svelte": "^
|
|
49
|
+
"@typescript-eslint/parser": "^8.72.1",
|
|
50
|
+
"eslint": "^10.14.0",
|
|
51
|
+
"eslint-plugin-svelte": "^3.24.0",
|
|
52
|
+
"svelte": "^5.57.3"
|
|
52
53
|
},
|
|
53
54
|
"peerDependencies": {
|
|
54
55
|
"svelte": "^5.40.0"
|
|
@@ -58,6 +59,7 @@
|
|
|
58
59
|
},
|
|
59
60
|
"scripts": {
|
|
60
61
|
"clean": "premove ./dist ./coverage",
|
|
62
|
+
"test:oxlint": "oxlint ./src",
|
|
61
63
|
"test:eslint": "eslint ./src",
|
|
62
64
|
"test:lib": "vitest --passWithNoTests",
|
|
63
65
|
"test:lib:dev": "pnpm test:lib --watch",
|