tgui-core 2.0.6 → 2.1.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.
- package/dist/common/collections.d.ts +1 -1
- package/dist/common/collections.js +1 -10
- package/dist/common/color.js +1 -70
- package/dist/common/constants.js +1 -329
- package/dist/common/events.js +1 -147
- package/dist/common/exhaustive.js +1 -6
- package/dist/common/format.js +1 -117
- package/dist/common/fp.js +1 -9
- package/dist/common/hotkeys.d.ts +1 -1
- package/dist/common/hotkeys.js +1 -112
- package/dist/common/http.js +1 -10
- package/dist/common/keycodes.js +1 -88
- package/dist/common/keys.js +1 -32
- package/dist/common/math.js +1 -45
- package/dist/common/random.js +1 -21
- package/dist/common/react.js +1 -30
- package/dist/common/string.js +1 -88
- package/dist/common/timer.js +1 -28
- package/dist/common/type-utils.js +1 -25
- package/dist/common/ui.d.ts +2 -2
- package/dist/common/ui.js +1 -141
- package/dist/common/uuid.js +1 -10
- package/dist/common/vector.js +1 -48
- package/dist/components/AnimatedNumber.d.ts +1 -1
- package/dist/components/AnimatedNumber.js +1 -73
- package/dist/components/Autofocus.d.ts +1 -1
- package/dist/components/Autofocus.js +1 -17
- package/dist/components/Blink.d.ts +1 -1
- package/dist/components/Blink.js +1 -56
- package/dist/components/BlockQuote.d.ts +1 -1
- package/dist/components/BlockQuote.js +1 -10
- package/dist/components/Box.d.ts +5 -5
- package/dist/components/Box.js +1 -19
- package/dist/components/Button.d.ts +4 -4
- package/dist/components/Button.js +1 -258
- package/dist/components/ByondUi.d.ts +1 -1
- package/dist/components/ByondUi.js +1 -61
- package/dist/components/Chart.d.ts +1 -1
- package/dist/components/Chart.js +1 -80
- package/dist/components/Collapsible.d.ts +2 -2
- package/dist/components/Collapsible.js +1 -36
- package/dist/components/ColorBox.d.ts +2 -2
- package/dist/components/ColorBox.js +1 -17
- package/dist/components/Dialog.d.ts +1 -1
- package/dist/components/Dialog.js +1 -42
- package/dist/components/Dimmer.d.ts +1 -1
- package/dist/components/Dimmer.js +1 -10
- package/dist/components/Divider.js +1 -18
- package/dist/components/DmIcon.d.ts +3 -3
- package/dist/components/DmIcon.js +1 -23
- package/dist/components/DraggableControl.d.ts +2 -2
- package/dist/components/DraggableControl.js +1 -111
- package/dist/components/Dropdown.d.ts +2 -2
- package/dist/components/Dropdown.js +1 -165
- package/dist/components/FitText.d.ts +2 -2
- package/dist/components/FitText.js +1 -63
- package/dist/components/Flex.d.ts +1 -1
- package/dist/components/Flex.js +1 -70
- package/dist/components/Floating.d.ts +3 -3
- package/dist/components/Floating.js +1 -2235
- package/dist/components/Icon.d.ts +2 -2
- package/dist/components/Icon.js +1 -45
- package/dist/components/Image.d.ts +1 -1
- package/dist/components/Image.js +1 -38
- package/dist/components/ImageButton.d.ts +10 -5
- package/dist/components/ImageButton.js +1 -154
- package/dist/components/InfinitePlane.d.ts +2 -2
- package/dist/components/InfinitePlane.js +1 -133
- package/dist/components/Input.d.ts +2 -2
- package/dist/components/Input.js +1 -96
- package/dist/components/KeyListener.d.ts +1 -1
- package/dist/components/KeyListener.js +1 -15
- package/dist/components/Knob.d.ts +2 -2
- package/dist/components/Knob.js +1 -133
- package/dist/components/LabeledControls.d.ts +1 -1
- package/dist/components/LabeledControls.js +1 -39
- package/dist/components/LabeledList.d.ts +2 -2
- package/dist/components/LabeledList.js +1 -89
- package/dist/components/MenuBar.d.ts +32 -0
- package/dist/components/MenuBar.js +1 -133
- package/dist/components/Modal.d.ts +2 -2
- package/dist/components/Modal.js +1 -22
- package/dist/components/NoticeBox.d.ts +1 -1
- package/dist/components/NoticeBox.js +1 -23
- package/dist/components/NumberInput.d.ts +9 -19
- package/dist/components/NumberInput.js +1 -213
- package/dist/components/Popper.d.ts +8 -9
- package/dist/components/Popper.js +1 -1082
- package/dist/components/ProgressBar.d.ts +2 -2
- package/dist/components/ProgressBar.js +1 -33
- package/dist/components/RestrictedInput.d.ts +29 -0
- package/dist/components/RestrictedInput.js +1 -161
- package/dist/components/RoundGauge.d.ts +2 -2
- package/dist/components/RoundGauge.js +1 -114
- package/dist/components/Section.d.ts +2 -2
- package/dist/components/Section.js +1 -65
- package/dist/components/Slider.d.ts +2 -2
- package/dist/components/Slider.js +1 -113
- package/dist/components/Stack.d.ts +2 -2
- package/dist/components/Stack.js +1 -58
- package/dist/components/StyleableSection.d.ts +1 -1
- package/dist/components/StyleableSection.js +1 -16
- package/dist/components/Table.d.ts +1 -1
- package/dist/components/Table.js +1 -57
- package/dist/components/Tabs.d.ts +2 -2
- package/dist/components/Tabs.js +1 -65
- package/dist/components/TextArea.d.ts +2 -2
- package/dist/components/TextArea.js +1 -126
- package/dist/components/TimeDisplay.js +1 -25
- package/dist/components/Tooltip.d.ts +2 -2
- package/dist/components/Tooltip.js +1 -18
- package/dist/components/TrackOutsideClicks.d.ts +2 -2
- package/dist/components/TrackOutsideClicks.js +1 -24
- package/dist/components/VirtualList.d.ts +1 -1
- package/dist/components/VirtualList.js +1 -34
- package/dist/components/index.js +1 -96
- package/license.txt +1 -1
- package/package.json +11 -17
- package/styles/components/Button.scss +1 -1
- package/dist/components/FakeTerminal.js +0 -38
|
@@ -1,213 +1 @@
|
|
|
1
|
-
|
|
2
|
-
var E = (m, d, e) => d in m ? I(m, d, { enumerable: !0, configurable: !0, writable: !0, value: e }) : m[d] = e;
|
|
3
|
-
var o = (m, d, e) => E(m, typeof d != "symbol" ? d + "" : d, e);
|
|
4
|
-
import { jsxs as N, jsx as f } from "react/jsx-runtime";
|
|
5
|
-
import { Component as x, createRef as D } from "react";
|
|
6
|
-
import { KEY as _, isEscape as M } from "../common/keys.js";
|
|
7
|
-
import { clamp as h, round as T } from "../common/math.js";
|
|
8
|
-
import { classes as w } from "../common/react.js";
|
|
9
|
-
import { AnimatedNumber as F } from "./AnimatedNumber.js";
|
|
10
|
-
import { Box as R } from "./Box.js";
|
|
11
|
-
class H extends x {
|
|
12
|
-
constructor() {
|
|
13
|
-
super(...arguments);
|
|
14
|
-
// Ref to the input field to set focus & highlight
|
|
15
|
-
o(this, "inputRef", D());
|
|
16
|
-
// After this time has elapsed we are in drag mode so no editing when dragging ends
|
|
17
|
-
o(this, "dragTimeout");
|
|
18
|
-
// Call onDrag at this interval
|
|
19
|
-
o(this, "dragInterval");
|
|
20
|
-
// default values for the number input state
|
|
21
|
-
o(this, "state", {
|
|
22
|
-
editing: !1,
|
|
23
|
-
dragging: !1,
|
|
24
|
-
currentValue: 0,
|
|
25
|
-
previousValue: 0,
|
|
26
|
-
origin: 0
|
|
27
|
-
});
|
|
28
|
-
o(this, "handleDragStart", (e) => {
|
|
29
|
-
const { value: u, disabled: n } = this.props, { editing: s } = this.state;
|
|
30
|
-
if (n || s)
|
|
31
|
-
return;
|
|
32
|
-
document.body.style["pointer-events"] = "none";
|
|
33
|
-
const r = Number.parseFloat(u.toString());
|
|
34
|
-
this.setState({
|
|
35
|
-
dragging: !1,
|
|
36
|
-
origin: e.screenY,
|
|
37
|
-
currentValue: r,
|
|
38
|
-
previousValue: r
|
|
39
|
-
}), this.dragTimeout = setTimeout(() => {
|
|
40
|
-
this.setState({
|
|
41
|
-
dragging: !0
|
|
42
|
-
});
|
|
43
|
-
}, 250), this.dragInterval = setInterval(() => {
|
|
44
|
-
const { dragging: l, currentValue: i, previousValue: t } = this.state, { onDrag: a } = this.props;
|
|
45
|
-
l && i !== t && (this.setState({
|
|
46
|
-
previousValue: i
|
|
47
|
-
}), a == null || a(i));
|
|
48
|
-
}, 400), document.addEventListener("mousemove", this.handleDragMove), document.addEventListener("mouseup", this.handleDragEnd);
|
|
49
|
-
});
|
|
50
|
-
o(this, "handleDragMove", (e) => {
|
|
51
|
-
const { minValue: u, maxValue: n, step: s, stepPixelSize: r, disabled: l } = this.props;
|
|
52
|
-
l || this.setState((i) => {
|
|
53
|
-
const t = { ...i }, a = t.origin - e.screenY;
|
|
54
|
-
if (i.dragging) {
|
|
55
|
-
const g = r || 1, c = h(
|
|
56
|
-
t.currentValue + a * s / g,
|
|
57
|
-
u - s,
|
|
58
|
-
n + s
|
|
59
|
-
);
|
|
60
|
-
Math.abs(c - t.currentValue) >= s ? (t.currentValue = h(
|
|
61
|
-
T(c / s, 0) * s,
|
|
62
|
-
u,
|
|
63
|
-
n
|
|
64
|
-
), t.origin = e.screenY) : Math.abs(a) > g && (t.origin = e.screenY);
|
|
65
|
-
} else Math.abs(a) > 4 && (t.dragging = !0);
|
|
66
|
-
return t;
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
o(this, "handleDragEnd", (e) => {
|
|
70
|
-
const { dragging: u, currentValue: n } = this.state, { onDrag: s, onChange: r, disabled: l } = this.props;
|
|
71
|
-
if (!l) {
|
|
72
|
-
if (document.body.style["pointer-events"] = "auto", clearInterval(this.dragInterval), clearTimeout(this.dragTimeout), this.setState({
|
|
73
|
-
dragging: !1,
|
|
74
|
-
editing: !u,
|
|
75
|
-
previousValue: n
|
|
76
|
-
}), u)
|
|
77
|
-
r == null || r(n), s == null || s(n);
|
|
78
|
-
else if (this.inputRef) {
|
|
79
|
-
const i = this.inputRef.current;
|
|
80
|
-
i && (i.value = `${n}`, setTimeout(() => {
|
|
81
|
-
i.focus(), i.select();
|
|
82
|
-
}, 10));
|
|
83
|
-
}
|
|
84
|
-
document.removeEventListener("mousemove", this.handleDragMove), document.removeEventListener("mouseup", this.handleDragEnd);
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
o(this, "handleBlur", (e) => {
|
|
88
|
-
const { editing: u, previousValue: n } = this.state, { minValue: s, maxValue: r, onChange: l, onDrag: i, disabled: t } = this.props;
|
|
89
|
-
if (t || !u)
|
|
90
|
-
return;
|
|
91
|
-
const a = h(
|
|
92
|
-
Number.parseFloat(e.target.value),
|
|
93
|
-
s,
|
|
94
|
-
r
|
|
95
|
-
);
|
|
96
|
-
if (Number.isNaN(a)) {
|
|
97
|
-
this.setState({
|
|
98
|
-
editing: !1
|
|
99
|
-
});
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
this.setState({
|
|
103
|
-
editing: !1,
|
|
104
|
-
currentValue: a,
|
|
105
|
-
previousValue: a
|
|
106
|
-
}), n !== a && (l == null || l(a), i == null || i(a));
|
|
107
|
-
});
|
|
108
|
-
o(this, "handleKeyDown", (e) => {
|
|
109
|
-
const { minValue: u, maxValue: n, onChange: s, onDrag: r, disabled: l } = this.props;
|
|
110
|
-
if (l)
|
|
111
|
-
return;
|
|
112
|
-
const { previousValue: i } = this.state;
|
|
113
|
-
if (e.key === _.Enter) {
|
|
114
|
-
const t = h(
|
|
115
|
-
Number.parseFloat(e.currentTarget.value),
|
|
116
|
-
u,
|
|
117
|
-
n
|
|
118
|
-
);
|
|
119
|
-
if (Number.isNaN(t)) {
|
|
120
|
-
this.setState({
|
|
121
|
-
editing: !1
|
|
122
|
-
});
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
this.setState({
|
|
126
|
-
editing: !1,
|
|
127
|
-
currentValue: t,
|
|
128
|
-
previousValue: t
|
|
129
|
-
}), i !== t && (s == null || s(t), r == null || r(t));
|
|
130
|
-
} else M(e.key) && this.setState({
|
|
131
|
-
editing: !1
|
|
132
|
-
});
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
componentDidMount() {
|
|
136
|
-
const e = Number.parseFloat(this.props.value.toString());
|
|
137
|
-
this.setState({
|
|
138
|
-
currentValue: e,
|
|
139
|
-
previousValue: e
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
render() {
|
|
143
|
-
const { dragging: e, editing: u, currentValue: n } = this.state, {
|
|
144
|
-
className: s,
|
|
145
|
-
fluid: r,
|
|
146
|
-
animated: l,
|
|
147
|
-
unit: i,
|
|
148
|
-
value: t,
|
|
149
|
-
minValue: a,
|
|
150
|
-
maxValue: g,
|
|
151
|
-
height: c,
|
|
152
|
-
width: S,
|
|
153
|
-
lineHeight: v,
|
|
154
|
-
fontSize: b,
|
|
155
|
-
format: V
|
|
156
|
-
} = this.props;
|
|
157
|
-
let p = Number.parseFloat(t.toString());
|
|
158
|
-
e && (p = n);
|
|
159
|
-
const y = /* @__PURE__ */ N("div", { className: "NumberInput__content", children: [
|
|
160
|
-
l && !e ? /* @__PURE__ */ f(F, { value: p, format: V }) : V ? V(p) : p,
|
|
161
|
-
i ? ` ${i}` : ""
|
|
162
|
-
] });
|
|
163
|
-
return /* @__PURE__ */ N(
|
|
164
|
-
R,
|
|
165
|
-
{
|
|
166
|
-
className: w([
|
|
167
|
-
"NumberInput",
|
|
168
|
-
r && "NumberInput--fluid",
|
|
169
|
-
s
|
|
170
|
-
]),
|
|
171
|
-
minWidth: S,
|
|
172
|
-
minHeight: c,
|
|
173
|
-
lineHeight: v,
|
|
174
|
-
fontSize: b,
|
|
175
|
-
onMouseDown: this.handleDragStart,
|
|
176
|
-
children: [
|
|
177
|
-
/* @__PURE__ */ f("div", { className: "NumberInput__barContainer", children: /* @__PURE__ */ f(
|
|
178
|
-
"div",
|
|
179
|
-
{
|
|
180
|
-
className: "NumberInput__bar",
|
|
181
|
-
style: {
|
|
182
|
-
height: `${h(
|
|
183
|
-
(p - a) / (g - a) * 100,
|
|
184
|
-
0,
|
|
185
|
-
100
|
|
186
|
-
)}%`
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
) }),
|
|
190
|
-
y,
|
|
191
|
-
/* @__PURE__ */ f(
|
|
192
|
-
"input",
|
|
193
|
-
{
|
|
194
|
-
ref: this.inputRef,
|
|
195
|
-
className: "NumberInput__input",
|
|
196
|
-
style: {
|
|
197
|
-
display: u ? "inline" : "none",
|
|
198
|
-
height: c,
|
|
199
|
-
lineHeight: v,
|
|
200
|
-
fontSize: b
|
|
201
|
-
},
|
|
202
|
-
onBlur: this.handleBlur,
|
|
203
|
-
onKeyDown: this.handleKeyDown
|
|
204
|
-
}
|
|
205
|
-
)
|
|
206
|
-
]
|
|
207
|
-
}
|
|
208
|
-
);
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
export {
|
|
212
|
-
H as NumberInput
|
|
213
|
-
};
|
|
1
|
+
import*as e from"react/jsx-runtime";import*as t from"react";import*as r from"../common/keys.js";import*as s from"../common/math.js";import*as i from"../common/react.js";import*as a from"./AnimatedNumber.js";import*as n from"./Box.js";class o extends t.Component{inputRef=(0,t.createRef)();dragTimeout;dragInterval;state={editing:!1,dragging:!1,currentValue:0,previousValue:0,origin:0};componentDidMount(){let e=Number.parseFloat(this.props.value.toString());this.setState({currentValue:e,previousValue:e})}handleDragStart=e=>{let{value:t,disabled:r}=this.props,{editing:s}=this.state;if(r||s)return;document.body.style["pointer-events"]="none";let i=Number.parseFloat(t.toString());this.setState({dragging:!1,origin:e.screenY,currentValue:i,previousValue:i}),this.dragTimeout=setTimeout(()=>{this.setState({dragging:!0})},250),this.dragInterval=setInterval(()=>{let{dragging:e,currentValue:t,previousValue:r}=this.state,{onDrag:s}=this.props;e&&t!==r&&(this.setState({previousValue:t}),s?.(t))},400),document.addEventListener("mousemove",this.handleDragMove),document.addEventListener("mouseup",this.handleDragEnd)};handleDragMove=e=>{let{minValue:t,maxValue:r,step:i,stepPixelSize:a,disabled:n}=this.props;n||this.setState(n=>{let o={...n},u=o.origin-e.screenY;if(n.dragging){let n=a||1,l=(0,s.clamp)(o.currentValue+u*i/n,t-i,r+i);Math.abs(l-o.currentValue)>=i?(o.currentValue=(0,s.clamp)((0,s.round)(l/i,0)*i,t,r),o.origin=e.screenY):Math.abs(u)>n&&(o.origin=e.screenY)}else Math.abs(u)>4&&(o.dragging=!0);return o})};handleDragEnd=e=>{let{dragging:t,currentValue:r}=this.state,{onDrag:s,onChange:i,disabled:a}=this.props;if(!a){if(document.body.style["pointer-events"]="auto",clearInterval(this.dragInterval),clearTimeout(this.dragTimeout),this.setState({dragging:!1,editing:!t,previousValue:r}),t)i?.(r),s?.(r);else if(this.inputRef){let e=this.inputRef.current;e&&(e.value=`${r}`,setTimeout(()=>{e.focus(),e.select()},10))}document.removeEventListener("mousemove",this.handleDragMove),document.removeEventListener("mouseup",this.handleDragEnd)}};handleBlur=e=>{let{editing:t,previousValue:r}=this.state,{minValue:i,maxValue:a,onChange:n,onDrag:o,disabled:u}=this.props;if(u||!t)return;let l=(0,s.clamp)(Number.parseFloat(e.target.value),i,a);if(Number.isNaN(l))return void this.setState({editing:!1});this.setState({editing:!1,currentValue:l,previousValue:l}),r!==l&&(n?.(l),o?.(l))};handleKeyDown=e=>{let{minValue:t,maxValue:i,onChange:a,onDrag:n,disabled:o}=this.props;if(o)return;let{previousValue:u}=this.state;if(e.key===r.KEY.Enter){let r=(0,s.clamp)(Number.parseFloat(e.currentTarget.value),t,i);if(Number.isNaN(r))return void this.setState({editing:!1});this.setState({editing:!1,currentValue:r,previousValue:r}),u!==r&&(a?.(r),n?.(r))}else(0,r.isEscape)(e.key)&&this.setState({editing:!1})};render(){let{dragging:t,editing:r,currentValue:o}=this.state,{className:u,fluid:l,animated:m,unit:h,value:d,minValue:p,maxValue:g,height:c,width:v,lineHeight:f,fontSize:N,format:b}=this.props,S=Number.parseFloat(d.toString());t&&(S=o);let V=(0,e.jsxs)("div",{className:"NumberInput__content",children:[m&&!t?(0,e.jsx)(a.AnimatedNumber,{value:S,format:b}):b?b(S):S,h?` ${h}`:""]});return(0,e.jsxs)(n.Box,{className:(0,i.classes)(["NumberInput",l&&"NumberInput--fluid",u]),minWidth:v,minHeight:c,lineHeight:f,fontSize:N,onMouseDown:this.handleDragStart,children:[(0,e.jsx)("div",{className:"NumberInput__barContainer",children:(0,e.jsx)("div",{className:"NumberInput__bar",style:{height:`${(0,s.clamp)((S-p)/(g-p)*100,0,100)}%`}})}),V,(0,e.jsx)("input",{ref:this.inputRef,className:"NumberInput__input",style:{display:r?"inline":"none",height:c,lineHeight:f,fontSize:N},onBlur:this.handleBlur,onKeyDown:this.handleKeyDown})]})}}export{o as NumberInput};
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { Placement } from '@
|
|
2
|
-
import { PropsWithChildren, ReactNode } from 'react';
|
|
3
|
-
type
|
|
1
|
+
import type { Placement } from '@floating-ui/react';
|
|
2
|
+
import type { PropsWithChildren, ReactNode } from 'react';
|
|
3
|
+
type Props = {
|
|
4
4
|
/** The content to display in the popper */
|
|
5
5
|
content: ReactNode;
|
|
6
6
|
/** Whether the popper is open */
|
|
7
7
|
isOpen: boolean;
|
|
8
|
-
}
|
|
9
|
-
type OptionalProps = Partial<{
|
|
8
|
+
} & Partial<{
|
|
10
9
|
/** Base z-index of the popper div
|
|
11
10
|
* @default 5
|
|
12
11
|
*/
|
|
@@ -15,16 +14,16 @@ type OptionalProps = Partial<{
|
|
|
15
14
|
onClickOutside: () => void;
|
|
16
15
|
/** Where to place the popper relative to the reference element */
|
|
17
16
|
placement: Placement;
|
|
18
|
-
}
|
|
19
|
-
type Props = RequiredProps & OptionalProps;
|
|
17
|
+
}> & PropsWithChildren;
|
|
20
18
|
/**
|
|
21
19
|
* ## Popper
|
|
22
20
|
* Popper lets you position elements so that they don't go out of the bounds of the window.
|
|
23
|
-
* @url https://popper.js.org/react-popper/ for more information.
|
|
24
21
|
*
|
|
25
22
|
* @deprecated - Use
|
|
26
23
|
* [Floating](https://github.com/tgstation/tgui-core/tree/main/lib/components/Floating.tsx)
|
|
27
24
|
* instead.
|
|
25
|
+
*
|
|
26
|
+
* This will serve as a wrapper for floating ui until replaced.
|
|
28
27
|
*/
|
|
29
|
-
export declare function Popper(props:
|
|
28
|
+
export declare function Popper(props: Props): import("react/jsx-runtime").JSX.Element;
|
|
30
29
|
export {};
|