tgui-core 1.7.6 → 1.8.0
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.
|
@@ -7,4 +7,11 @@ type Zip<T extends unknown[][]> = {
|
|
|
7
7
|
* the second elements of the given arrays, and so on.
|
|
8
8
|
*/
|
|
9
9
|
export declare function zip<T extends unknown[][]>(...arr: T): Zip<T>;
|
|
10
|
+
/**
|
|
11
|
+
* Helper function for string compares with native sorts
|
|
12
|
+
* @param a first string to compare
|
|
13
|
+
* @param b second string to compare
|
|
14
|
+
* @returns -1 for a < b, 1 for a > b and 0 otherwise
|
|
15
|
+
*/
|
|
16
|
+
export declare function stringCompare(a: string, b: string): 0 | 1 | -1;
|
|
10
17
|
export {};
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
function
|
|
2
|
-
return Array(Math.max(...
|
|
1
|
+
function p(...n) {
|
|
2
|
+
return Array(Math.max(...n.map((t) => t.length))).fill(void 0).map((t, r) => n.map((i) => i[r]));
|
|
3
|
+
}
|
|
4
|
+
function a(n, t) {
|
|
5
|
+
return n < t ? -1 : n > t ? 1 : 0;
|
|
3
6
|
}
|
|
4
7
|
export {
|
|
5
|
-
|
|
8
|
+
a as stringCompare,
|
|
9
|
+
p as zip
|
|
6
10
|
};
|
package/dist/components/Input.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useRef as
|
|
3
|
-
import { KEY as
|
|
4
|
-
import { classes as
|
|
5
|
-
import { debounce as
|
|
6
|
-
import { Box as
|
|
1
|
+
import { jsxs as S, jsx as p } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as j, useEffect as m } from "react";
|
|
3
|
+
import { KEY as k, isEscape as v } from "../common/keys.js";
|
|
4
|
+
import { classes as w } from "../common/react.js";
|
|
5
|
+
import { debounce as B } from "../common/timer.js";
|
|
6
|
+
import { Box as F } from "./Box.js";
|
|
7
7
|
function d(r) {
|
|
8
8
|
return typeof r != "number" && typeof r != "string" ? "" : String(r);
|
|
9
9
|
}
|
|
10
|
-
const
|
|
11
|
-
function
|
|
10
|
+
const O = B((r) => r(), 250);
|
|
11
|
+
function z(r) {
|
|
12
12
|
const {
|
|
13
13
|
autoFocus: g,
|
|
14
14
|
autoSelect: l,
|
|
@@ -19,55 +19,58 @@ function C(r) {
|
|
|
19
19
|
maxLength: x,
|
|
20
20
|
monospace: y,
|
|
21
21
|
onChange: n,
|
|
22
|
-
onEnter:
|
|
22
|
+
onEnter: o,
|
|
23
23
|
onEscape: s,
|
|
24
|
-
onInput:
|
|
25
|
-
placeholder:
|
|
26
|
-
selfClear:
|
|
27
|
-
updateOnPropsChange:
|
|
28
|
-
value:
|
|
29
|
-
...
|
|
30
|
-
} = r,
|
|
31
|
-
function
|
|
24
|
+
onInput: a,
|
|
25
|
+
placeholder: E,
|
|
26
|
+
selfClear: N,
|
|
27
|
+
updateOnPropsChange: _,
|
|
28
|
+
value: c,
|
|
29
|
+
...A
|
|
30
|
+
} = r, i = j(null);
|
|
31
|
+
function D(t) {
|
|
32
32
|
var u;
|
|
33
|
-
if (!
|
|
33
|
+
if (!a) return;
|
|
34
34
|
const e = (u = t.currentTarget) == null ? void 0 : u.value;
|
|
35
|
-
b ?
|
|
35
|
+
b ? O(() => a(t, e)) : a(t, e);
|
|
36
36
|
}
|
|
37
|
-
function
|
|
38
|
-
if (t.key ===
|
|
39
|
-
|
|
37
|
+
function K(t) {
|
|
38
|
+
if (t.key === k.Enter) {
|
|
39
|
+
o == null || o(t, t.currentTarget.value), N ? t.currentTarget.value = "" : (t.currentTarget.blur(), n == null || n(t, t.currentTarget.value));
|
|
40
40
|
return;
|
|
41
41
|
}
|
|
42
|
-
|
|
42
|
+
v(t.key) && (s == null || s(t), t.currentTarget.value = d(c), t.currentTarget.blur());
|
|
43
43
|
}
|
|
44
44
|
function f(t) {
|
|
45
|
-
const e =
|
|
45
|
+
const e = i.current;
|
|
46
46
|
if (!e) return;
|
|
47
47
|
const u = d(t);
|
|
48
48
|
e.value !== u && (e.value = u);
|
|
49
49
|
}
|
|
50
50
|
return m(() => {
|
|
51
|
-
const t =
|
|
51
|
+
const t = i.current;
|
|
52
52
|
if (t) {
|
|
53
|
-
f(
|
|
53
|
+
f(c);
|
|
54
54
|
const e = g || l, u = document.activeElement === t;
|
|
55
55
|
e && !u && setTimeout(() => {
|
|
56
56
|
t.focus(), l && t.select();
|
|
57
57
|
}, 1);
|
|
58
58
|
}
|
|
59
59
|
}, []), m(() => {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
if (_) {
|
|
61
|
+
const t = i.current;
|
|
62
|
+
t && (document.activeElement === t || f(c));
|
|
63
|
+
}
|
|
64
|
+
}, [c]), /* @__PURE__ */ S(
|
|
65
|
+
F,
|
|
63
66
|
{
|
|
64
|
-
className:
|
|
67
|
+
className: w([
|
|
65
68
|
"Input",
|
|
66
69
|
h && "Input--fluid",
|
|
67
70
|
y && "Input--monospace",
|
|
68
71
|
I
|
|
69
72
|
]),
|
|
70
|
-
...
|
|
73
|
+
...A,
|
|
71
74
|
children: [
|
|
72
75
|
/* @__PURE__ */ p("div", { className: "Input__baseline", children: "." }),
|
|
73
76
|
/* @__PURE__ */ p(
|
|
@@ -77,10 +80,10 @@ function C(r) {
|
|
|
77
80
|
disabled: T,
|
|
78
81
|
maxLength: x,
|
|
79
82
|
onBlur: (t) => n == null ? void 0 : n(t, t.target.value),
|
|
80
|
-
onChange:
|
|
81
|
-
onKeyDown:
|
|
82
|
-
placeholder:
|
|
83
|
-
ref:
|
|
83
|
+
onChange: D,
|
|
84
|
+
onKeyDown: K,
|
|
85
|
+
placeholder: E,
|
|
86
|
+
ref: i
|
|
84
87
|
}
|
|
85
88
|
)
|
|
86
89
|
]
|
|
@@ -88,6 +91,6 @@ function C(r) {
|
|
|
88
91
|
);
|
|
89
92
|
}
|
|
90
93
|
export {
|
|
91
|
-
|
|
94
|
+
z as Input,
|
|
92
95
|
d as toInputValue
|
|
93
96
|
};
|