@tanstack/preact-hotkeys 0.21.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.
|
@@ -29,7 +29,8 @@ export interface HotkeysProviderProps<T extends AppHotkeys = AppHotkeys> extends
|
|
|
29
29
|
children: ComponentChildren;
|
|
30
30
|
/**
|
|
31
31
|
* Every app hotkey, from `defineAppHotkeys`. Listed by `useAppHotkeyList`
|
|
32
|
-
* whether or not their components have mounted.
|
|
32
|
+
* whether or not their components have mounted. It can start as `undefined`
|
|
33
|
+
* and arrive later, such as from a lazy import.
|
|
33
34
|
*/
|
|
34
35
|
appHotkeys?: T;
|
|
35
36
|
/**
|
package/dist/HotkeysProvider.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { publishAppHotkeysStore } from "@tanstack/hotkeys";
|
|
2
2
|
import { activateHotkeysProviderScope, createAppHotkeysStore, getHotkeysProviderScopeKey, mergeHotkeysProviderDefaults } from "@tanstack/hotkeys/adapter";
|
|
3
3
|
import { createContext } from "preact";
|
|
4
|
-
import { useContext, useLayoutEffect, useMemo,
|
|
4
|
+
import { useContext, useLayoutEffect, useMemo, useRef } from "preact/hooks";
|
|
5
5
|
import { jsx } from "preact/jsx-runtime";
|
|
6
6
|
|
|
7
7
|
// src/HotkeysProvider.tsx
|
|
@@ -46,11 +46,13 @@ const NO_PARENT = {
|
|
|
46
46
|
function HotkeysProvider({ children, appHotkeys, customHotkeys, onCustomHotkeysChange, defaultOptions = DEFAULT_OPTIONS, scope, exclusive = false, enabled = true }) {
|
|
47
47
|
const parent = useContext(HotkeysContext) ?? NO_PARENT;
|
|
48
48
|
const platform = defaultOptions.platform ?? parent.defaultOptions.platform;
|
|
49
|
-
const
|
|
49
|
+
const storeRef = useRef(null);
|
|
50
|
+
if (!storeRef.current && appHotkeys) storeRef.current = createAppHotkeysStore(appHotkeys, {
|
|
50
51
|
customHotkeys,
|
|
51
52
|
onCustomHotkeysChange,
|
|
52
53
|
platform
|
|
53
|
-
})
|
|
54
|
+
});
|
|
55
|
+
const store = storeRef.current;
|
|
54
56
|
const active = parent.enabled && enabled;
|
|
55
57
|
const scopeKey = getHotkeysProviderScopeKey({
|
|
56
58
|
scope,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/preact-hotkeys",
|
|
3
|
-
"version": "0.21.
|
|
3
|
+
"version": "0.21.1",
|
|
4
4
|
"description": "Preact adapter for TanStack Hotkeys",
|
|
5
5
|
"author": "Tanner Linsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"skills"
|
|
36
36
|
],
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@tanstack/hotkeys": "0.27.
|
|
38
|
+
"@tanstack/hotkeys": "0.27.1"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@preact/preset-vite": "^2.10.6",
|