tgui-core 2.0.3 → 2.0.4
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.
|
@@ -37,8 +37,6 @@ type Props = {
|
|
|
37
37
|
step: number;
|
|
38
38
|
/** The step size in pixels. */
|
|
39
39
|
stepPixelSize: number;
|
|
40
|
-
/** The number of milliseconds to suppress flickering. */
|
|
41
|
-
suppressFlicker: number;
|
|
42
40
|
/** Whether to unclamp the value. */
|
|
43
41
|
unclamped: boolean;
|
|
44
42
|
/** The unit of the value. */
|
|
@@ -1,132 +1,111 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useState as
|
|
3
|
-
import { KEY as
|
|
4
|
-
import { clamp as
|
|
5
|
-
import { AnimatedNumber as
|
|
6
|
-
const
|
|
7
|
-
function
|
|
8
|
-
return
|
|
1
|
+
import { jsxs as $, Fragment as q, jsx as D } from "react/jsx-runtime";
|
|
2
|
+
import { useState as F, useRef as i, useEffect as J } from "react";
|
|
3
|
+
import { KEY as Q, isEscape as W } from "../common/keys.js";
|
|
4
|
+
import { clamp as b } from "../common/math.js";
|
|
5
|
+
import { AnimatedNumber as Z } from "./AnimatedNumber.js";
|
|
6
|
+
const C = 400, x = -1;
|
|
7
|
+
function A(n, m) {
|
|
8
|
+
return n.screenX * m[0] + n.screenY * m[1];
|
|
9
9
|
}
|
|
10
|
-
function
|
|
10
|
+
function ie(n) {
|
|
11
11
|
const {
|
|
12
12
|
// Our props
|
|
13
|
-
animated:
|
|
14
|
-
children:
|
|
15
|
-
dragMatrix:
|
|
16
|
-
format:
|
|
17
|
-
maxValue:
|
|
18
|
-
minValue:
|
|
19
|
-
onChange:
|
|
20
|
-
onDrag:
|
|
21
|
-
step:
|
|
13
|
+
animated: m,
|
|
14
|
+
children: L,
|
|
15
|
+
dragMatrix: S = [1, 0],
|
|
16
|
+
format: g,
|
|
17
|
+
maxValue: N = Number.POSITIVE_INFINITY,
|
|
18
|
+
minValue: o = Number.NEGATIVE_INFINITY,
|
|
19
|
+
onChange: a,
|
|
20
|
+
onDrag: l,
|
|
21
|
+
step: s = 1,
|
|
22
22
|
stepPixelSize: O = 1,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
updateRate: w = te,
|
|
23
|
+
unclamped: Y,
|
|
24
|
+
unit: V,
|
|
25
|
+
updateRate: k = C,
|
|
27
26
|
// Box props
|
|
28
|
-
fontSize:
|
|
29
|
-
height:
|
|
27
|
+
fontSize: K,
|
|
28
|
+
height: P,
|
|
30
29
|
lineHeight: U
|
|
31
|
-
} =
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}, [
|
|
35
|
-
function
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
30
|
+
} = n, [ee, I] = F(n.value), [d, v] = F(!1), r = i(!1), u = i(n.value), c = i(0), E = i(x), y = i(null), T = i(null), p = i(null);
|
|
31
|
+
J(() => {
|
|
32
|
+
n.value !== u.current && (u.current = n.value, I(n.value));
|
|
33
|
+
}, [n.value]);
|
|
34
|
+
function j(e) {
|
|
35
|
+
d || (document.body.style["pointer-events"] = "none", E.current = A(e.nativeEvent, S), c.current = n.value, r.current = !0, document.addEventListener("mouseup", _), p.current = setTimeout(() => {
|
|
36
|
+
w(e.nativeEvent);
|
|
37
|
+
}, 100));
|
|
38
|
+
}
|
|
39
|
+
function w(e) {
|
|
40
|
+
if (r.current)
|
|
41
|
+
document.addEventListener("mousemove", h), T.current = setInterval(() => {
|
|
42
|
+
r.current && (l == null || l(e, n.value));
|
|
43
|
+
}, k);
|
|
44
|
+
else if (v(!0), y.current) {
|
|
45
|
+
const t = y.current;
|
|
46
|
+
t.value = c.current.toString(), setTimeout(() => {
|
|
39
47
|
t.focus(), t.select();
|
|
40
48
|
}, 10);
|
|
41
49
|
}
|
|
50
|
+
p.current && clearTimeout(p.current);
|
|
42
51
|
}
|
|
43
|
-
function
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
),
|
|
56
|
-
F(
|
|
57
|
-
n.current - n.current % o + Q,
|
|
58
|
-
l,
|
|
59
|
-
g
|
|
60
|
-
)
|
|
61
|
-
), m.current = t;
|
|
52
|
+
function h(e) {
|
|
53
|
+
const t = A(e, S), H = t - E.current, X = Number.isFinite(o) ? o % s : 0;
|
|
54
|
+
c.current = b(
|
|
55
|
+
c.current + H * s / O,
|
|
56
|
+
o - s,
|
|
57
|
+
N + s
|
|
58
|
+
);
|
|
59
|
+
const R = b(
|
|
60
|
+
c.current - c.current % s + X,
|
|
61
|
+
o,
|
|
62
|
+
N
|
|
63
|
+
);
|
|
64
|
+
u.current = R, I(R), E.current = t;
|
|
62
65
|
}
|
|
63
|
-
function
|
|
64
|
-
|
|
65
|
-
const t = e.nativeEvent;
|
|
66
|
-
document.body.style["pointer-events"] = "none", m.current = K(t, V), n.current = r.value, b.current = setTimeout(() => {
|
|
67
|
-
i.current = !0;
|
|
68
|
-
}, 250), I.current = setInterval(() => {
|
|
69
|
-
i && (a == null || a(t, r.value));
|
|
70
|
-
}, w), document.addEventListener("mousemove", x), document.addEventListener("mouseup", _);
|
|
66
|
+
function _(e) {
|
|
67
|
+
document.body.style["pointer-events"] = "auto", T.current && clearInterval(T.current), E.current = x, document.removeEventListener("mousemove", h), document.removeEventListener("mouseup", _), r.current && (a == null || a(e, u.current), l == null || l(e, u.current), r.current = !1);
|
|
71
68
|
}
|
|
72
|
-
function
|
|
73
|
-
|
|
74
|
-
e.preventDefault(), e.stopPropagation(), A(e.nativeEvent, e.currentTarget.value);
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
if (e.key === Y.Escape) {
|
|
78
|
-
f(!1);
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
69
|
+
function z(e) {
|
|
70
|
+
(e.key === Q.Enter || W(e.key)) && v(!1);
|
|
81
71
|
}
|
|
82
|
-
function
|
|
83
|
-
let
|
|
84
|
-
if (
|
|
85
|
-
|
|
72
|
+
function B(e) {
|
|
73
|
+
let t = Number.parseFloat(e.currentTarget.value);
|
|
74
|
+
if (Y || (t = b(t, o, N)), Number.isNaN(t)) {
|
|
75
|
+
v(!1);
|
|
86
76
|
return;
|
|
87
77
|
}
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
function L() {
|
|
91
|
-
if (S <= 0) return;
|
|
92
|
-
const e = R.current;
|
|
93
|
-
if (e)
|
|
94
|
-
return D(!0), clearTimeout(e), R.current = setTimeout(() => {
|
|
95
|
-
D(!1);
|
|
96
|
-
}, S), () => clearTimeout(e);
|
|
97
|
-
}
|
|
98
|
-
function $(e) {
|
|
99
|
-
v && f(!1), A(e.nativeEvent, e.currentTarget.value);
|
|
78
|
+
c.current = t, u.current = t, I(t), a == null || a(e.nativeEvent, t), d && v(!1);
|
|
100
79
|
}
|
|
101
|
-
let
|
|
102
|
-
|
|
103
|
-
const
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
] }),
|
|
80
|
+
let f = n.value;
|
|
81
|
+
r.current && (f = u.current);
|
|
82
|
+
const G = /* @__PURE__ */ $(q, { children: [
|
|
83
|
+
m && !r.current ? /* @__PURE__ */ D(Z, { value: f, format: g }) : g ? g(f) : f,
|
|
84
|
+
V ? ` ${V}` : ""
|
|
85
|
+
] }), M = /* @__PURE__ */ D(
|
|
107
86
|
"input",
|
|
108
87
|
{
|
|
109
|
-
ref:
|
|
88
|
+
ref: y,
|
|
110
89
|
className: "NumberInput__input",
|
|
111
90
|
style: {
|
|
112
|
-
display:
|
|
113
|
-
height:
|
|
91
|
+
display: d ? void 0 : "none",
|
|
92
|
+
height: P,
|
|
114
93
|
lineHeight: U,
|
|
115
|
-
fontSize:
|
|
94
|
+
fontSize: K
|
|
116
95
|
},
|
|
117
|
-
onBlur:
|
|
118
|
-
onKeyDown:
|
|
96
|
+
onBlur: B,
|
|
97
|
+
onKeyDown: z
|
|
119
98
|
}
|
|
120
99
|
);
|
|
121
|
-
return
|
|
122
|
-
displayElement:
|
|
123
|
-
displayValue:
|
|
124
|
-
dragging:
|
|
125
|
-
editing:
|
|
126
|
-
handleDragStart:
|
|
127
|
-
inputElement:
|
|
100
|
+
return L({
|
|
101
|
+
displayElement: G,
|
|
102
|
+
displayValue: f,
|
|
103
|
+
dragging: r.current,
|
|
104
|
+
editing: d,
|
|
105
|
+
handleDragStart: j,
|
|
106
|
+
inputElement: M
|
|
128
107
|
});
|
|
129
108
|
}
|
|
130
109
|
export {
|
|
131
|
-
|
|
110
|
+
ie as DraggableControl
|
|
132
111
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Component, HTMLAttributes, PropsWithChildren
|
|
1
|
+
import { Component, HTMLAttributes, PropsWithChildren } from 'react';
|
|
2
2
|
type Props = {
|
|
3
3
|
acceptableDifference?: number;
|
|
4
4
|
maxFontSize: number;
|
|
@@ -9,7 +9,7 @@ type State = {
|
|
|
9
9
|
fontSize: number;
|
|
10
10
|
};
|
|
11
11
|
export declare class FitText extends Component<Props, State> {
|
|
12
|
-
ref: RefObject<HTMLDivElement | null>;
|
|
12
|
+
ref: import('react').RefObject<HTMLDivElement | null>;
|
|
13
13
|
state: State;
|
|
14
14
|
constructor(props: Props);
|
|
15
15
|
componentDidUpdate(prevProps: any): void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CSSProperties, Component, FocusEventHandler, KeyboardEventHandler, MouseEventHandler
|
|
1
|
+
import { CSSProperties, Component, FocusEventHandler, KeyboardEventHandler, MouseEventHandler } from 'react';
|
|
2
2
|
import { BooleanLike } from '../common/react';
|
|
3
3
|
import { BoxProps } from './Box';
|
|
4
4
|
type Props = Required<{
|
|
@@ -51,7 +51,7 @@ type State = {
|
|
|
51
51
|
* to fine tune the value, or single click it to manually type a number.
|
|
52
52
|
*/
|
|
53
53
|
export declare class NumberInput extends Component<Props, State> {
|
|
54
|
-
inputRef: RefObject<HTMLInputElement | null>;
|
|
54
|
+
inputRef: import('react').RefObject<HTMLInputElement | null>;
|
|
55
55
|
dragTimeout: NodeJS.Timeout;
|
|
56
56
|
dragInterval: NodeJS.Timeout;
|
|
57
57
|
state: State;
|
package/package.json
CHANGED