@keybindy/react 1.1.10 → 1.1.12
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/Keybindy.js +2 -1
- package/dist/index.d.ts +3 -2
- package/package.json +2 -2
package/dist/Keybindy.js
CHANGED
|
@@ -2,11 +2,12 @@ import { jsx, Fragment } from 'react/jsx-runtime';
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { useKeybindy } from './useKeybindy.js';
|
|
4
4
|
|
|
5
|
-
const KeybindyComponent = ({ scope = 'global', shortcuts = [], children, disabled, onShortcutFired, logs = false, }) => {
|
|
5
|
+
const KeybindyComponent = ({ scope = 'global', shortcuts: shortcutsProp = [], children, disabled, onShortcutFired, logs = false, }) => {
|
|
6
6
|
const { register, unregister, manager, pushScope, popScope, getScopes, setScope } = useKeybindy({
|
|
7
7
|
onShortcutFired,
|
|
8
8
|
logs,
|
|
9
9
|
});
|
|
10
|
+
const shortcuts = React.useMemo(() => (typeof shortcutsProp === 'function' ? shortcutsProp() : shortcutsProp) || [], [shortcutsProp]);
|
|
10
11
|
// Memoize a stable representation of shortcuts, excluding the handler.
|
|
11
12
|
// This prevents the effect from re-running unnecessarily.
|
|
12
13
|
const stableShortcuts = React.useMemo(() => {
|
package/dist/index.d.ts
CHANGED
|
@@ -32,9 +32,10 @@ type KeybindyProps = {
|
|
|
32
32
|
*/
|
|
33
33
|
scope?: 'global' | string;
|
|
34
34
|
/**
|
|
35
|
-
*
|
|
35
|
+
* An array of shortcut definitions or a function that returns an array of shortcuts.
|
|
36
|
+
* Using a function can be useful for memoizing shortcuts or defining them conditionally.
|
|
36
37
|
*/
|
|
37
|
-
shortcuts?: KeybindyShortcut[];
|
|
38
|
+
shortcuts?: KeybindyShortcut[] | (() => KeybindyShortcut[]);
|
|
38
39
|
/**
|
|
39
40
|
* Whether the shortcuts should be disabled for this scope.
|
|
40
41
|
* Defaults to `false`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@keybindy/react",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.12",
|
|
4
4
|
"description": "Keybindy for React: Simple, scoped keyboard shortcuts that require little setup. designed to smoothly blend in with your React applications, allowing for robust keybinding functionality without the overhead.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "PRASSamin",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"react": "^19.1.0",
|
|
54
|
-
"@keybindy/core": "1.1.
|
|
54
|
+
"@keybindy/core": "1.1.7"
|
|
55
55
|
},
|
|
56
56
|
"scripts": {
|
|
57
57
|
"format": "prettier --write \"src/**/*.{ts,tsx}\"",
|