react-better-hotkeys 0.6.0 → 0.6.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/HotkeyTextResolver.js +2 -2
- package/dist/hooks/useHotkey.js +24 -21
- package/package.json +1 -1
|
@@ -25,11 +25,11 @@ class p {
|
|
|
25
25
|
}
|
|
26
26
|
buildInitialMap() {
|
|
27
27
|
return {
|
|
28
|
-
...Object.entries(a).reduce((t, e) => (e[1].on === "code" && (t[e[0]] = e[1].value.length === 1 ? e[1].value.
|
|
28
|
+
...Object.entries(a).reduce((t, e) => (e[1].on === "code" && (t[e[0]] = e[1].value.length === 1 ? e[1].value.toLocaleUpperCase() : e[1].value), t), {}),
|
|
29
29
|
...Object.entries(a).reduce((t, e) => {
|
|
30
30
|
if (e[1].on === "key") {
|
|
31
31
|
const s = e[0].slice(3);
|
|
32
|
-
t[s] = e[1].value.length === 1 ? e[1].value.
|
|
32
|
+
t[s] = e[1].value.length === 1 ? e[1].value.toLocaleUpperCase() : e[1].value;
|
|
33
33
|
}
|
|
34
34
|
return t;
|
|
35
35
|
}, {})
|
package/dist/hooks/useHotkey.js
CHANGED
|
@@ -17,21 +17,24 @@ function q(o, d, v) {
|
|
|
17
17
|
}),
|
|
18
18
|
[v]
|
|
19
19
|
), a = p(
|
|
20
|
-
(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
(t) => {
|
|
21
|
+
let e = w(t) ? r?.textResolver.resolve(t) ?? [
|
|
22
|
+
x[`Key${t}`].value,
|
|
23
|
+
"unknown"
|
|
24
|
+
] : [x[t].value, "unknown"];
|
|
25
|
+
return e[0].length === 1 && (e = [e[0].toLocaleUpperCase(), e[1]]), e;
|
|
26
|
+
},
|
|
24
27
|
[r?.textResolver]
|
|
25
28
|
), c = p(
|
|
26
|
-
(
|
|
29
|
+
(t, e) => {
|
|
27
30
|
const i = {
|
|
28
|
-
...
|
|
31
|
+
...t,
|
|
29
32
|
options: l,
|
|
30
|
-
id:
|
|
33
|
+
id: e == null ? n : `${n}-${e}`,
|
|
31
34
|
callbackRef: f,
|
|
32
35
|
toParts: () => [
|
|
33
|
-
|
|
34
|
-
r?.textResolver.delimiterForType(
|
|
36
|
+
t.keys.map((u) => a(u)),
|
|
37
|
+
r?.textResolver.delimiterForType(t.type) ?? ""
|
|
35
38
|
],
|
|
36
39
|
toString: () => r?.textResolver.toString(i) ?? ""
|
|
37
40
|
};
|
|
@@ -39,25 +42,25 @@ function q(o, d, v) {
|
|
|
39
42
|
},
|
|
40
43
|
[l, r?.textResolver, n, a]
|
|
41
44
|
), y = p(
|
|
42
|
-
(
|
|
45
|
+
(t, e) => {
|
|
43
46
|
const i = {
|
|
44
|
-
...
|
|
47
|
+
...t,
|
|
45
48
|
options: l,
|
|
46
|
-
id:
|
|
49
|
+
id: e == null ? n : `${n}-${e}`,
|
|
47
50
|
callbackRef: f,
|
|
48
51
|
toParts: () => [
|
|
49
52
|
[
|
|
50
|
-
...Object.entries(
|
|
51
|
-
a(
|
|
53
|
+
...Object.entries(t.modifier).filter((u) => u[1]).map((u) => [u[0], "valid"]),
|
|
54
|
+
a(t.keyId)
|
|
52
55
|
],
|
|
53
|
-
r?.textResolver.delimiterForType(
|
|
56
|
+
r?.textResolver.delimiterForType(t.type) ?? ""
|
|
54
57
|
],
|
|
55
58
|
toString: () => r?.textResolver.toString(i) ?? ""
|
|
56
59
|
};
|
|
57
60
|
return i;
|
|
58
61
|
},
|
|
59
62
|
[l, r?.textResolver, n, a]
|
|
60
|
-
), s = m(() => o == null ? [] : Array.isArray(o) ? o.map((
|
|
63
|
+
), s = m(() => o == null ? [] : Array.isArray(o) ? o.map((t, e) => t.type === "chord" ? y(t, e) : c(t, e)) : o.type === "chord" ? y(o) : c(o), [y, c, o]);
|
|
61
64
|
return $(() => {
|
|
62
65
|
if (r == null) {
|
|
63
66
|
console.warn(
|
|
@@ -65,12 +68,12 @@ function q(o, d, v) {
|
|
|
65
68
|
);
|
|
66
69
|
return;
|
|
67
70
|
}
|
|
68
|
-
const
|
|
69
|
-
return
|
|
70
|
-
|
|
71
|
+
const t = Array.isArray(s) ? s : [s];
|
|
72
|
+
return t.forEach((e) => {
|
|
73
|
+
e.type === "chord" ? r.registry.addChordHotkey(e) : r.registry.addSequenceHotkey(e);
|
|
71
74
|
}), () => {
|
|
72
|
-
|
|
73
|
-
|
|
75
|
+
t.forEach((e) => {
|
|
76
|
+
e.type === "chord" ? r.registry.removeChordHotkey(e.id) : r.registry.removeSequenceHotkey(e.id);
|
|
74
77
|
});
|
|
75
78
|
};
|
|
76
79
|
}, [s]), o ? s : void 0;
|