tgui-core 1.5.4 → 1.5.6
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/common/hotkeys.js +72 -72
- package/dist/components/Dropdown.js +14 -15
- package/package.json +1 -1
package/dist/common/hotkeys.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { globalEvents as l } from "./events.js";
|
|
2
|
-
import { KEY_ESCAPE as K, KEY_ENTER as E, KEY_SPACE as p, KEY_TAB as h, KEY_CTRL as d, KEY_SHIFT as g, KEY_UP as S, KEY_DOWN as Y, KEY_LEFT as _, KEY_RIGHT as
|
|
2
|
+
import { KEY_ESCAPE as K, KEY_ENTER as E, KEY_SPACE as p, KEY_TAB as h, KEY_CTRL as d, KEY_SHIFT as g, KEY_UP as S, KEY_DOWN as Y, KEY_LEFT as _, KEY_RIGHT as B, KEY_F5 as w } from "./keycodes.js";
|
|
3
3
|
const m = {}, c = [
|
|
4
4
|
K,
|
|
5
5
|
E,
|
|
@@ -10,103 +10,103 @@ const m = {}, c = [
|
|
|
10
10
|
S,
|
|
11
11
|
Y,
|
|
12
12
|
_,
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
B,
|
|
14
|
+
w
|
|
15
15
|
], o = {}, u = [];
|
|
16
|
-
function
|
|
17
|
-
if (
|
|
18
|
-
if (
|
|
19
|
-
if (
|
|
20
|
-
if (
|
|
21
|
-
if (
|
|
22
|
-
if (
|
|
23
|
-
if (
|
|
24
|
-
if (
|
|
25
|
-
if (
|
|
26
|
-
if (
|
|
27
|
-
if (
|
|
28
|
-
if (
|
|
29
|
-
if (
|
|
30
|
-
if (
|
|
31
|
-
return String.fromCharCode(
|
|
32
|
-
if (
|
|
33
|
-
return `Numpad${
|
|
34
|
-
if (
|
|
35
|
-
return `F${
|
|
36
|
-
if (
|
|
37
|
-
if (
|
|
38
|
-
if (
|
|
16
|
+
function F(n) {
|
|
17
|
+
if (n === 16) return "Shift";
|
|
18
|
+
if (n === 17) return "Ctrl";
|
|
19
|
+
if (n === 18) return "Alt";
|
|
20
|
+
if (n === 33) return "Northeast";
|
|
21
|
+
if (n === 34) return "Southeast";
|
|
22
|
+
if (n === 35) return "Southwest";
|
|
23
|
+
if (n === 36) return "Northwest";
|
|
24
|
+
if (n === 37) return "West";
|
|
25
|
+
if (n === 38) return "North";
|
|
26
|
+
if (n === 39) return "East";
|
|
27
|
+
if (n === 40) return "South";
|
|
28
|
+
if (n === 45) return "Insert";
|
|
29
|
+
if (n === 46) return "Delete";
|
|
30
|
+
if (n >= 48 && n <= 57 || n >= 65 && n <= 90)
|
|
31
|
+
return String.fromCharCode(n);
|
|
32
|
+
if (n >= 96 && n <= 105)
|
|
33
|
+
return `Numpad${n - 96}`;
|
|
34
|
+
if (n >= 112 && n <= 123)
|
|
35
|
+
return `F${n - 111}`;
|
|
36
|
+
if (n === 188) return ",";
|
|
37
|
+
if (n === 189) return "-";
|
|
38
|
+
if (n === 190) return ".";
|
|
39
39
|
}
|
|
40
|
-
function
|
|
41
|
-
const
|
|
42
|
-
if (
|
|
40
|
+
function N(n) {
|
|
41
|
+
const t = String(n);
|
|
42
|
+
if (t === "Ctrl+F5" || t === "Ctrl+R") {
|
|
43
43
|
location.reload();
|
|
44
44
|
return;
|
|
45
45
|
}
|
|
46
|
-
if (
|
|
46
|
+
if (t === "Ctrl+F" || n.event.defaultPrevented || n.isModifierKey() || c.includes(n.code))
|
|
47
47
|
return;
|
|
48
|
-
const
|
|
49
|
-
if (!
|
|
48
|
+
const i = F(n.code);
|
|
49
|
+
if (!i)
|
|
50
50
|
return;
|
|
51
|
-
const f = m[
|
|
51
|
+
const f = m[i];
|
|
52
52
|
if (f)
|
|
53
53
|
return Byond.command(f);
|
|
54
|
-
if (
|
|
55
|
-
o[
|
|
56
|
-
const r = `KeyDown "${
|
|
54
|
+
if (n.isDown() && !o[i]) {
|
|
55
|
+
o[i] = !0;
|
|
56
|
+
const r = `KeyDown "${i}"`;
|
|
57
57
|
return Byond.command(r);
|
|
58
58
|
}
|
|
59
|
-
if (
|
|
60
|
-
o[
|
|
61
|
-
const r = `KeyUp "${
|
|
59
|
+
if (n.isUp() && o[i]) {
|
|
60
|
+
o[i] = !1;
|
|
61
|
+
const r = `KeyUp "${i}"`;
|
|
62
62
|
return Byond.command(r);
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
|
-
function
|
|
66
|
-
c.push(
|
|
65
|
+
function P(n) {
|
|
66
|
+
c.push(n);
|
|
67
67
|
}
|
|
68
|
-
function
|
|
69
|
-
const
|
|
70
|
-
|
|
68
|
+
function R(n) {
|
|
69
|
+
const t = c.indexOf(n);
|
|
70
|
+
t >= 0 && c.splice(t, 1);
|
|
71
71
|
}
|
|
72
|
-
function
|
|
73
|
-
for (const
|
|
74
|
-
o[
|
|
72
|
+
function T() {
|
|
73
|
+
for (const n in o)
|
|
74
|
+
o[n] && (o[n] = !1, Byond.command(`KeyUp "${n}"`));
|
|
75
75
|
}
|
|
76
|
-
function
|
|
77
|
-
Byond.winget("default.*").then((
|
|
78
|
-
const
|
|
79
|
-
for (const r
|
|
80
|
-
const s = r.split("."),
|
|
81
|
-
|
|
76
|
+
function v() {
|
|
77
|
+
Byond.winget("default.*").then((n) => {
|
|
78
|
+
const t = {};
|
|
79
|
+
for (const r in n) {
|
|
80
|
+
const s = r.split("."), e = s[1], a = s[2];
|
|
81
|
+
e && a && (t[e] || (t[e] = {}), t[e][a] = n[r]);
|
|
82
82
|
}
|
|
83
|
-
const
|
|
83
|
+
const i = /\\"/g;
|
|
84
84
|
function f(r) {
|
|
85
|
-
return r.substring(1, r.length - 1).replace(
|
|
85
|
+
return r.substring(1, r.length - 1).replace(i, '"');
|
|
86
86
|
}
|
|
87
|
-
for (const r
|
|
88
|
-
const s =
|
|
89
|
-
m[
|
|
87
|
+
for (const r in t) {
|
|
88
|
+
const s = t[r], e = f(s.name);
|
|
89
|
+
m[e] = f(s.command);
|
|
90
90
|
}
|
|
91
91
|
}), l.on("window-blur", () => {
|
|
92
|
-
|
|
93
|
-
}), l.on("key", (
|
|
94
|
-
for (const
|
|
95
|
-
n
|
|
96
|
-
|
|
92
|
+
T();
|
|
93
|
+
}), l.on("key", (n) => {
|
|
94
|
+
for (const t of u)
|
|
95
|
+
t(n);
|
|
96
|
+
N(n);
|
|
97
97
|
});
|
|
98
98
|
}
|
|
99
|
-
function
|
|
100
|
-
u.push(
|
|
101
|
-
let
|
|
99
|
+
function x(n) {
|
|
100
|
+
u.push(n);
|
|
101
|
+
let t = !1;
|
|
102
102
|
return () => {
|
|
103
|
-
|
|
103
|
+
t || (t = !0, u.splice(u.indexOf(n), 1));
|
|
104
104
|
};
|
|
105
105
|
}
|
|
106
106
|
export {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
107
|
+
P as acquireHotKey,
|
|
108
|
+
x as listenForKeyEvents,
|
|
109
|
+
T as releaseHeldKeys,
|
|
110
|
+
R as releaseHotKey,
|
|
111
|
+
v as setupHotKeys
|
|
112
112
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { jsx as l, jsxs as p, Fragment as
|
|
2
|
-
import { useState as
|
|
1
|
+
import { jsx as l, jsxs as p, Fragment as F } from "react/jsx-runtime";
|
|
2
|
+
import { useState as L, useRef as S, useEffect as V } from "react";
|
|
3
3
|
import { classes as N } from "../common/react.js";
|
|
4
4
|
import { unit as $ } from "../common/ui.js";
|
|
5
5
|
import { Button as D } from "./Button.js";
|
|
@@ -9,17 +9,17 @@ const z = -1;
|
|
|
9
9
|
function h(u) {
|
|
10
10
|
return typeof u == "string" ? u : u.value;
|
|
11
11
|
}
|
|
12
|
-
function
|
|
12
|
+
function Y(u) {
|
|
13
13
|
const {
|
|
14
14
|
autoScroll: v = !0,
|
|
15
15
|
buttons: I,
|
|
16
16
|
className: O,
|
|
17
|
-
clipSelectedText:
|
|
17
|
+
clipSelectedText: T = !0,
|
|
18
18
|
color: B = "default",
|
|
19
19
|
disabled: d,
|
|
20
20
|
displayText: E,
|
|
21
21
|
icon: x,
|
|
22
|
-
iconRotation:
|
|
22
|
+
iconRotation: k,
|
|
23
23
|
iconSpin: j,
|
|
24
24
|
menuWidth: C = "15rem",
|
|
25
25
|
noChevron: R,
|
|
@@ -30,13 +30,12 @@ function X(u) {
|
|
|
30
30
|
placeholder: K = "Select...",
|
|
31
31
|
selected: m,
|
|
32
32
|
width: P = "15rem"
|
|
33
|
-
} = u, [r, f] =
|
|
33
|
+
} = u, [r, f] = L(!1), W = y ? !r : r, w = S(null), i = c.findIndex((e) => h(e) === m) || 0;
|
|
34
34
|
function g(e) {
|
|
35
|
-
var t;
|
|
36
35
|
let s = e;
|
|
37
36
|
e < i ? s = e < 2 ? 0 : e - 2 : s = e > c.length - 3 ? c.length - 1 : e - 2;
|
|
38
|
-
const n =
|
|
39
|
-
n
|
|
37
|
+
const n = w.current, t = n == null ? void 0 : n.children[s];
|
|
38
|
+
n && t && (n.scrollTop = t.offsetTop);
|
|
40
39
|
}
|
|
41
40
|
function _(e) {
|
|
42
41
|
if (c.length < 1 || d)
|
|
@@ -45,7 +44,7 @@ function X(u) {
|
|
|
45
44
|
let t;
|
|
46
45
|
i < 0 ? t = e === "next" ? n : s : e === "next" ? t = i === n ? s : i + 1 : t = i === s ? n : i - 1, r && v && g(t), o == null || o(h(c[t]));
|
|
47
46
|
}
|
|
48
|
-
return
|
|
47
|
+
return V(() => {
|
|
49
48
|
var e;
|
|
50
49
|
r && (v && i !== z && g(i), (e = w.current) == null || e.focus());
|
|
51
50
|
}, [r]), /* @__PURE__ */ l(
|
|
@@ -104,22 +103,22 @@ function X(u) {
|
|
|
104
103
|
e.key === "Enter" && !d && (f(!r), a == null || a(e));
|
|
105
104
|
},
|
|
106
105
|
children: [
|
|
107
|
-
x && /* @__PURE__ */ l(b, { mr: 1, name: x, rotation:
|
|
106
|
+
x && /* @__PURE__ */ l(b, { mr: 1, name: x, rotation: k, spin: j }),
|
|
108
107
|
/* @__PURE__ */ l(
|
|
109
108
|
"span",
|
|
110
109
|
{
|
|
111
110
|
className: "Dropdown__selected-text",
|
|
112
111
|
style: {
|
|
113
|
-
overflow:
|
|
112
|
+
overflow: T ? "hidden" : "visible"
|
|
114
113
|
},
|
|
115
114
|
children: E || m && h(m) || K
|
|
116
115
|
}
|
|
117
116
|
),
|
|
118
|
-
!R && /* @__PURE__ */ l("span", { className: "Dropdown__arrow-button", children: /* @__PURE__ */ l(b, { name:
|
|
117
|
+
!R && /* @__PURE__ */ l("span", { className: "Dropdown__arrow-button", children: /* @__PURE__ */ l(b, { name: W ? "chevron-up" : "chevron-down" }) })
|
|
119
118
|
]
|
|
120
119
|
}
|
|
121
120
|
),
|
|
122
|
-
I && /* @__PURE__ */ p(
|
|
121
|
+
I && /* @__PURE__ */ p(F, { children: [
|
|
123
122
|
/* @__PURE__ */ l(
|
|
124
123
|
D,
|
|
125
124
|
{
|
|
@@ -154,5 +153,5 @@ function X(u) {
|
|
|
154
153
|
);
|
|
155
154
|
}
|
|
156
155
|
export {
|
|
157
|
-
|
|
156
|
+
Y as Dropdown
|
|
158
157
|
};
|