tgui-core 2.0.5 → 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 +30 -44
- package/dist/components/Section.js +1 -66
- 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 +14 -28
- package/dist/components/TextArea.js +1 -139
- 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/styles/components/TextArea.scss +7 -0
- package/dist/components/FakeTerminal.js +0 -38
|
@@ -1,258 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { useState as A, createRef as $, useEffect as j, useRef as q } from "react";
|
|
3
|
-
import { KEY as P, isEscape as E } from "../common/keys.js";
|
|
4
|
-
import { classes as S } from "../common/react.js";
|
|
5
|
-
import { computeBoxProps as z, computeBoxClassName as O } from "../common/ui.js";
|
|
6
|
-
import { Box as T } from "./Box.js";
|
|
7
|
-
import { Icon as v } from "./Icon.js";
|
|
8
|
-
import { Tooltip as K } from "./Tooltip.js";
|
|
9
|
-
function R(e) {
|
|
10
|
-
const {
|
|
11
|
-
captureKeys: s = !0,
|
|
12
|
-
children: u,
|
|
13
|
-
circular: m,
|
|
14
|
-
className: p,
|
|
15
|
-
color: r,
|
|
16
|
-
compact: h,
|
|
17
|
-
content: B,
|
|
18
|
-
disabled: t,
|
|
19
|
-
ellipsis: o,
|
|
20
|
-
fluid: l,
|
|
21
|
-
icon: i,
|
|
22
|
-
iconColor: a,
|
|
23
|
-
iconPosition: C,
|
|
24
|
-
iconRotation: x,
|
|
25
|
-
iconSize: y,
|
|
26
|
-
iconSpin: D,
|
|
27
|
-
onClick: f,
|
|
28
|
-
selected: b,
|
|
29
|
-
tooltip: g,
|
|
30
|
-
tooltipPosition: F,
|
|
31
|
-
verticalAlignContent: k,
|
|
32
|
-
...I
|
|
33
|
-
} = e, n = B || u, N = /* @__PURE__ */ c(
|
|
34
|
-
v,
|
|
35
|
-
{
|
|
36
|
-
className: "Button--icon",
|
|
37
|
-
name: i || "",
|
|
38
|
-
color: a,
|
|
39
|
-
rotation: x,
|
|
40
|
-
size: y,
|
|
41
|
-
spin: D
|
|
42
|
-
}
|
|
43
|
-
);
|
|
44
|
-
let w = /* @__PURE__ */ c(
|
|
45
|
-
"div",
|
|
46
|
-
{
|
|
47
|
-
className: S([
|
|
48
|
-
"Button",
|
|
49
|
-
l && "Button--fluid",
|
|
50
|
-
t && "Button--disabled",
|
|
51
|
-
b && "Button--selected",
|
|
52
|
-
m && "Button--circular",
|
|
53
|
-
h && "Button--compact",
|
|
54
|
-
!n && "Button--empty",
|
|
55
|
-
C && `Button--icon-${C}`,
|
|
56
|
-
k && "Button--flex",
|
|
57
|
-
k && l && "Button--flex--fluid",
|
|
58
|
-
k && `Button--verticalAlignContent--${k}`,
|
|
59
|
-
r && typeof r == "string" ? `Button--color--${r}` : "Button--color--default",
|
|
60
|
-
p,
|
|
61
|
-
O(I)
|
|
62
|
-
]),
|
|
63
|
-
tabIndex: t ? void 0 : 0,
|
|
64
|
-
onClick: (d) => {
|
|
65
|
-
!t && f && f(d);
|
|
66
|
-
},
|
|
67
|
-
onKeyDown: (d) => {
|
|
68
|
-
if (s) {
|
|
69
|
-
if (d.key === P.Space || d.key === P.Enter) {
|
|
70
|
-
d.preventDefault(), !t && f && f(d);
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
E(d.key) && d.preventDefault();
|
|
74
|
-
}
|
|
75
|
-
},
|
|
76
|
-
...z(I),
|
|
77
|
-
children: /* @__PURE__ */ _(
|
|
78
|
-
"div",
|
|
79
|
-
{
|
|
80
|
-
className: S([
|
|
81
|
-
"Button__content",
|
|
82
|
-
o && "Button__content--ellipsis"
|
|
83
|
-
]),
|
|
84
|
-
children: [
|
|
85
|
-
i && C !== "right" && N,
|
|
86
|
-
o ? /* @__PURE__ */ c("span", { className: "Button--ellipsis", children: n }) : n,
|
|
87
|
-
i && C === "right" && N
|
|
88
|
-
]
|
|
89
|
-
}
|
|
90
|
-
)
|
|
91
|
-
}
|
|
92
|
-
);
|
|
93
|
-
return g && (w = /* @__PURE__ */ c(K, { content: g, position: F, children: w })), w;
|
|
94
|
-
}
|
|
95
|
-
function L(e) {
|
|
96
|
-
const { checked: s, ...u } = e;
|
|
97
|
-
return /* @__PURE__ */ c(
|
|
98
|
-
R,
|
|
99
|
-
{
|
|
100
|
-
color: "transparent",
|
|
101
|
-
icon: s ? "check-square-o" : "square-o",
|
|
102
|
-
selected: s,
|
|
103
|
-
...u
|
|
104
|
-
}
|
|
105
|
-
);
|
|
106
|
-
}
|
|
107
|
-
function Y(e) {
|
|
108
|
-
const {
|
|
109
|
-
children: s,
|
|
110
|
-
color: u,
|
|
111
|
-
confirmColor: m = "bad",
|
|
112
|
-
confirmContent: p = "Confirm?",
|
|
113
|
-
confirmIcon: r,
|
|
114
|
-
ellipsis: h = !0,
|
|
115
|
-
icon: B,
|
|
116
|
-
onBlur: t,
|
|
117
|
-
onClick: o,
|
|
118
|
-
...l
|
|
119
|
-
} = e, [i, a] = A(!1);
|
|
120
|
-
function C(y) {
|
|
121
|
-
a(!1), t == null || t(y);
|
|
122
|
-
}
|
|
123
|
-
function x(y) {
|
|
124
|
-
if (!i) {
|
|
125
|
-
a(!0);
|
|
126
|
-
return;
|
|
127
|
-
}
|
|
128
|
-
o == null || o(y), a(!1);
|
|
129
|
-
}
|
|
130
|
-
return /* @__PURE__ */ c(
|
|
131
|
-
R,
|
|
132
|
-
{
|
|
133
|
-
icon: i ? r : B,
|
|
134
|
-
color: i ? m : u,
|
|
135
|
-
onBlur: C,
|
|
136
|
-
onClick: x,
|
|
137
|
-
...l,
|
|
138
|
-
children: i ? p : s
|
|
139
|
-
}
|
|
140
|
-
);
|
|
141
|
-
}
|
|
142
|
-
function G(e) {
|
|
143
|
-
const {
|
|
144
|
-
children: s,
|
|
145
|
-
color: u = "default",
|
|
146
|
-
content: m,
|
|
147
|
-
currentValue: p,
|
|
148
|
-
defaultValue: r,
|
|
149
|
-
disabled: h,
|
|
150
|
-
fluid: B,
|
|
151
|
-
icon: t,
|
|
152
|
-
iconRotation: o,
|
|
153
|
-
iconSpin: l,
|
|
154
|
-
maxLength: i,
|
|
155
|
-
onCommit: a = () => null,
|
|
156
|
-
placeholder: C,
|
|
157
|
-
tooltip: x,
|
|
158
|
-
tooltipPosition: y,
|
|
159
|
-
...D
|
|
160
|
-
} = e, [f, b] = A(!1), g = $(), F = m || s;
|
|
161
|
-
function k(n) {
|
|
162
|
-
const N = g.current;
|
|
163
|
-
if (!N) return;
|
|
164
|
-
N.value !== "" ? a(n, N.value) : r && a(n, r);
|
|
165
|
-
}
|
|
166
|
-
j(() => {
|
|
167
|
-
const n = g.current;
|
|
168
|
-
if (n && f) {
|
|
169
|
-
n.value = p || "";
|
|
170
|
-
try {
|
|
171
|
-
n.focus(), n.select();
|
|
172
|
-
} catch {
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
}, [f, p]);
|
|
176
|
-
let I = /* @__PURE__ */ _(
|
|
177
|
-
T,
|
|
178
|
-
{
|
|
179
|
-
className: S([
|
|
180
|
-
"Button",
|
|
181
|
-
B && "Button--fluid",
|
|
182
|
-
h && "Button--disabled",
|
|
183
|
-
`Button--color--${u}`
|
|
184
|
-
]),
|
|
185
|
-
...D,
|
|
186
|
-
onClick: () => b(!0),
|
|
187
|
-
children: [
|
|
188
|
-
t && /* @__PURE__ */ c(v, { name: t, rotation: o, spin: l }),
|
|
189
|
-
/* @__PURE__ */ c("div", { children: F }),
|
|
190
|
-
/* @__PURE__ */ c(
|
|
191
|
-
"input",
|
|
192
|
-
{
|
|
193
|
-
disabled: !!h,
|
|
194
|
-
ref: g,
|
|
195
|
-
className: "NumberInput__input",
|
|
196
|
-
style: {
|
|
197
|
-
display: f ? "" : "none",
|
|
198
|
-
textAlign: "left"
|
|
199
|
-
},
|
|
200
|
-
onBlur: (n) => {
|
|
201
|
-
f && (b(!1), k(n));
|
|
202
|
-
},
|
|
203
|
-
onKeyDown: (n) => {
|
|
204
|
-
if (n.key === P.Enter) {
|
|
205
|
-
b(!1), k(n);
|
|
206
|
-
return;
|
|
207
|
-
}
|
|
208
|
-
E(n.key) && b(!1);
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
)
|
|
212
|
-
]
|
|
213
|
-
}
|
|
214
|
-
);
|
|
215
|
-
return x && (I = /* @__PURE__ */ c(K, { content: x, position: y, children: I })), I;
|
|
216
|
-
}
|
|
217
|
-
function H(e) {
|
|
218
|
-
const { accept: s, multiple: u, onSelectFiles: m, ...p } = e, r = q(null);
|
|
219
|
-
async function h(t) {
|
|
220
|
-
const o = Array.from(t).map((l) => {
|
|
221
|
-
const i = new FileReader();
|
|
222
|
-
return new Promise((a) => {
|
|
223
|
-
i.onload = () => a(i.result), i.readAsText(l);
|
|
224
|
-
});
|
|
225
|
-
});
|
|
226
|
-
return await Promise.all(o);
|
|
227
|
-
}
|
|
228
|
-
async function B(t) {
|
|
229
|
-
const o = t.target.files;
|
|
230
|
-
if (o != null && o.length) {
|
|
231
|
-
const l = await h(o);
|
|
232
|
-
m(u ? l : l[0]);
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
return /* @__PURE__ */ _(V, { children: [
|
|
236
|
-
/* @__PURE__ */ c(R, { onClick: () => {
|
|
237
|
-
var t;
|
|
238
|
-
return (t = r.current) == null ? void 0 : t.click();
|
|
239
|
-
}, ...p }),
|
|
240
|
-
/* @__PURE__ */ c(
|
|
241
|
-
"input",
|
|
242
|
-
{
|
|
243
|
-
hidden: !0,
|
|
244
|
-
type: "file",
|
|
245
|
-
ref: r,
|
|
246
|
-
accept: s,
|
|
247
|
-
multiple: u,
|
|
248
|
-
onChange: B
|
|
249
|
-
}
|
|
250
|
-
)
|
|
251
|
-
] });
|
|
252
|
-
}
|
|
253
|
-
((e) => {
|
|
254
|
-
e.Checkbox = L, e.Confirm = Y, e.Input = G, e.File = H;
|
|
255
|
-
})(R || (R = {}));
|
|
256
|
-
export {
|
|
257
|
-
R as Button
|
|
258
|
-
};
|
|
1
|
+
var t;import*as e from"react/jsx-runtime";import*as n from"react";import*as o from"../common/keys.js";import*as r from"../common/react.js";import*as s from"../common/ui.js";import*as i from"./Box.js";import*as l from"./Icon.js";import*as c from"./Tooltip.js";function u(t){let{captureKeys:n=!0,children:i,circular:u,className:a,color:f,compact:m,content:p,disabled:d,ellipsis:B,fluid:x,icon:j,iconColor:h,iconPosition:y,iconRotation:k,iconSize:v,iconSpin:C,onClick:g,selected:E,tooltip:N,tooltipPosition:b,verticalAlignContent:_,...w}=t,I=p||i,K=(0,e.jsx)(l.Icon,{className:"Button--icon",name:j||"",color:h,rotation:k,size:v,spin:C}),A=(0,e.jsx)("div",{className:(0,r.classes)(["Button",x&&"Button--fluid",d&&"Button--disabled",E&&"Button--selected",u&&"Button--circular",m&&"Button--compact",!I&&"Button--empty",y&&`Button--icon-${y}`,_&&"Button--flex",_&&x&&"Button--flex--fluid",_&&`Button--verticalAlignContent--${_}`,f&&"string"==typeof f?`Button--color--${f}`:"Button--color--default",a,(0,s.computeBoxClassName)(w)]),tabIndex:d?void 0:0,onClick:t=>{!d&&g&&g(t)},onKeyDown:t=>{if(n){if(t.key===o.KEY.Space||t.key===o.KEY.Enter){t.preventDefault(),!d&&g&&g(t);return}(0,o.isEscape)(t.key)&&t.preventDefault()}},...(0,s.computeBoxProps)(w),children:(0,e.jsxs)("div",{className:(0,r.classes)(["Button__content",B&&"Button__content--ellipsis"]),children:[j&&"right"!==y&&K,B?(0,e.jsx)("span",{className:"Button--ellipsis",children:I}):I,j&&"right"===y&&K]})});return N&&(A=(0,e.jsx)(c.Tooltip,{content:N,position:b,children:A})),A}(t=u||(u={})).Checkbox=function(t){let{checked:n,...o}=t;return(0,e.jsx)(u,{color:"transparent",icon:n?"check-square-o":"square-o",selected:n,...o})},t.Confirm=function(t){let{children:o,color:r,confirmColor:s="bad",confirmContent:i="Confirm?",confirmIcon:l,ellipsis:c=!0,icon:a,onBlur:f,onClick:m,...p}=t,[d,B]=(0,n.useState)(!1);return(0,e.jsx)(u,{icon:d?l:a,color:d?s:r,onBlur:function(t){B(!1),f?.(t)},onClick:function(t){if(!d)return void B(!0);m?.(t),B(!1)},...p,children:d?i:o})},t.Input=function(t){let{children:s,color:u="default",content:a,currentValue:f,defaultValue:m,disabled:p,fluid:d,icon:B,iconRotation:x,iconSpin:j,maxLength:h,onCommit:y=()=>null,placeholder:k,tooltip:v,tooltipPosition:C,...g}=t,[E,N]=(0,n.useState)(!1),b=(0,n.createRef)();function _(t){let e=b.current;e&&(""!==e.value?y(t,e.value):m&&y(t,m))}(0,n.useEffect)(()=>{let t=b.current;if(t&&E){t.value=f||"";try{t.focus(),t.select()}catch{}}},[E,f]);let w=(0,e.jsxs)(i.Box,{className:(0,r.classes)(["Button",d&&"Button--fluid",p&&"Button--disabled",`Button--color--${u}`]),...g,onClick:()=>N(!0),children:[B&&(0,e.jsx)(l.Icon,{name:B,rotation:x,spin:j}),(0,e.jsx)("div",{children:a||s}),(0,e.jsx)("input",{disabled:!!p,ref:b,className:"NumberInput__input",style:{display:E?"":"none",textAlign:"left"},onBlur:t=>{E&&(N(!1),_(t))},onKeyDown:t=>{if(t.key===o.KEY.Enter){N(!1),_(t);return}(0,o.isEscape)(t.key)&&N(!1)}})]});return v&&(w=(0,e.jsx)(c.Tooltip,{content:v,position:C,children:w})),w},t.File=function(t){let{accept:o,multiple:r,onSelectFiles:s,...i}=t,l=(0,n.useRef)(null);async function c(t){let e=Array.from(t).map(t=>{let e=new FileReader;return new Promise(n=>{e.onload=()=>n(e.result),e.readAsText(t)})});return await Promise.all(e)}async function a(t){let e=t.target.files;if(e?.length){let t=await c(e);s(r?t:t[0])}}return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(u,{onClick:()=>l.current?.click(),...i}),(0,e.jsx)("input",{hidden:!0,type:"file",ref:l,accept:o,multiple:r,onChange:a})]})};export{u as Button};
|
|
@@ -1,61 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { useRef as f, useEffect as p } from "react";
|
|
3
|
-
import { debounce as m } from "../common/timer.js";
|
|
4
|
-
import { computeBoxProps as w } from "../common/ui.js";
|
|
5
|
-
const o = [];
|
|
6
|
-
function a(t) {
|
|
7
|
-
const e = o.length;
|
|
8
|
-
o.push(null);
|
|
9
|
-
const n = t || `byondui_${e}`;
|
|
10
|
-
return {
|
|
11
|
-
render: (i) => {
|
|
12
|
-
o[e] = n, Byond.winset(n, i);
|
|
13
|
-
},
|
|
14
|
-
unmount: () => {
|
|
15
|
-
o[e] = null, Byond.winset(n, {
|
|
16
|
-
parent: ""
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
window.addEventListener("beforeunload", () => {
|
|
22
|
-
for (let t = 0; t < o.length; t++) {
|
|
23
|
-
const e = o[t];
|
|
24
|
-
typeof e == "string" && (o[t] = null, Byond.winset(e, {
|
|
25
|
-
parent: ""
|
|
26
|
-
}));
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
function x(t) {
|
|
30
|
-
const e = window.devicePixelRatio ?? 1, n = t.getBoundingClientRect();
|
|
31
|
-
return {
|
|
32
|
-
pos: [n.left * e, n.top * e],
|
|
33
|
-
size: [
|
|
34
|
-
(n.right - n.left) * e,
|
|
35
|
-
(n.bottom - n.top) * e
|
|
36
|
-
]
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
function h(t) {
|
|
40
|
-
const { params: e, ...n } = t, i = f(null), d = f(a(e == null ? void 0 : e.id));
|
|
41
|
-
function s() {
|
|
42
|
-
const c = i.current;
|
|
43
|
-
if (!c) return;
|
|
44
|
-
const r = x(c);
|
|
45
|
-
d.current.render({
|
|
46
|
-
parent: Byond.windowId,
|
|
47
|
-
...e,
|
|
48
|
-
pos: `${r.pos[0]},${r.pos[1]}`,
|
|
49
|
-
size: `${r.size[0]}x${r.size[1]}`
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
const u = m(() => {
|
|
53
|
-
s();
|
|
54
|
-
}, 100);
|
|
55
|
-
return p(() => (window.addEventListener("resize", u), s(), () => {
|
|
56
|
-
window.removeEventListener("resize", u), d.current.unmount();
|
|
57
|
-
}), []), /* @__PURE__ */ l("div", { ref: i, ...w(n), children: /* @__PURE__ */ l("div", { style: { minHeight: "22px" } }) });
|
|
58
|
-
}
|
|
59
|
-
export {
|
|
60
|
-
h as ByondUi
|
|
61
|
-
};
|
|
1
|
+
import*as e from"react/jsx-runtime";import*as t from"react";import*as n from"../common/timer.js";import*as o from"../common/ui.js";let r=[];function i(i){let{params:s,...u}=i,l=(0,t.useRef)(null),d=(0,t.useRef)(function(e){let t=r.length;r.push(null);let n=e||`byondui_${t}`;return{render:e=>{r[t]=n,Byond.winset(n,e)},unmount:()=>{r[t]=null,Byond.winset(n,{parent:""})}}}(s?.id));function m(){let e=l.current;if(!e)return;let t=function(e){let t=window.devicePixelRatio??1,n=e.getBoundingClientRect();return{pos:[n.left*t,n.top*t],size:[(n.right-n.left)*t,(n.bottom-n.top)*t]}}(e);d.current.render({parent:Byond.windowId,...s,pos:`${t.pos[0]},${t.pos[1]}`,size:`${t.size[0]}x${t.size[1]}`})}let f=(0,n.debounce)(()=>{m()},100);return(0,t.useEffect)(()=>(window.addEventListener("resize",f),m(),()=>{window.removeEventListener("resize",f),d.current.unmount()}),[]),(0,e.jsx)("div",{ref:l,...(0,o.computeBoxProps)(u),children:(0,e.jsx)("div",{style:{minHeight:"22px"}})})}window.addEventListener("beforeunload",()=>{for(let e=0;e<r.length;e++){let t=r[e];"string"==typeof t&&(r[e]=null,Byond.winset(t,{parent:""}))}});export{i as ByondUi};
|
package/dist/components/Chart.js
CHANGED
|
@@ -1,80 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { useRef as y, useState as B, useEffect as R } from "react";
|
|
3
|
-
import { zip as w } from "../common/collections.js";
|
|
4
|
-
import { Box as $ } from "./Box.js";
|
|
5
|
-
function C(n, l, o, i) {
|
|
6
|
-
if (n.length === 0)
|
|
7
|
-
return [];
|
|
8
|
-
const f = w(...n), c = f.map((r) => Math.min(...r)), t = f.map((r) => Math.max(...r));
|
|
9
|
-
return o !== void 0 && (c[0] = o[0], t[0] = o[1]), i !== void 0 && (c[1] = i[0], t[1] = i[1]), n.map(
|
|
10
|
-
(r) => w(r, c, t, l).map(
|
|
11
|
-
([s, p, e, u]) => (s - p) / (e - p) * u
|
|
12
|
-
)
|
|
13
|
-
);
|
|
14
|
-
}
|
|
15
|
-
function k(n) {
|
|
16
|
-
let l = "";
|
|
17
|
-
for (let o = 0; o < n.length; o++) {
|
|
18
|
-
const i = n[o];
|
|
19
|
-
l += `${i[0]},${i[1]} `;
|
|
20
|
-
}
|
|
21
|
-
return l;
|
|
22
|
-
}
|
|
23
|
-
const x = {
|
|
24
|
-
position: "absolute",
|
|
25
|
-
top: 0,
|
|
26
|
-
left: 0,
|
|
27
|
-
right: 0,
|
|
28
|
-
bottom: 0,
|
|
29
|
-
overflow: "hidden"
|
|
30
|
-
};
|
|
31
|
-
function z(n) {
|
|
32
|
-
const {
|
|
33
|
-
data: l = [],
|
|
34
|
-
rangeX: o,
|
|
35
|
-
rangeY: i,
|
|
36
|
-
fillColor: f = "none",
|
|
37
|
-
strokeColor: c = "#ffffff",
|
|
38
|
-
strokeWidth: t = 2,
|
|
39
|
-
...v
|
|
40
|
-
} = n, r = y(null), [s, p] = B([600, 200]), e = C(l, s, o, i);
|
|
41
|
-
if (e.length > 0) {
|
|
42
|
-
const m = e[0], a = e[e.length - 1];
|
|
43
|
-
e.push([s[0] + t, a[1]]), e.push([s[0] + t, -t]), e.push([-t, -t]), e.push([-t, m[1]]);
|
|
44
|
-
}
|
|
45
|
-
const u = k(e);
|
|
46
|
-
function d() {
|
|
47
|
-
const m = r.current;
|
|
48
|
-
if (!m)
|
|
49
|
-
return;
|
|
50
|
-
const a = m.getBoundingClientRect();
|
|
51
|
-
p([a.width, a.height]);
|
|
52
|
-
}
|
|
53
|
-
return R(() => (window.addEventListener("resize", d), d(), () => {
|
|
54
|
-
window.removeEventListener("resize", d);
|
|
55
|
-
}), []), /* @__PURE__ */ h($, { position: "relative", ...v, children: /* @__PURE__ */ h("div", { ref: r, style: x, children: /* @__PURE__ */ g(
|
|
56
|
-
"svg",
|
|
57
|
-
{
|
|
58
|
-
viewBox: `0 0 ${s[0]} ${s[1]}`,
|
|
59
|
-
preserveAspectRatio: "none",
|
|
60
|
-
style: x,
|
|
61
|
-
children: [
|
|
62
|
-
/* @__PURE__ */ h("title", { children: "chart" }),
|
|
63
|
-
/* @__PURE__ */ h(
|
|
64
|
-
"polyline",
|
|
65
|
-
{
|
|
66
|
-
transform: `scale(1, -1) translate(0, -${s[1]})`,
|
|
67
|
-
fill: f,
|
|
68
|
-
stroke: c,
|
|
69
|
-
strokeWidth: t,
|
|
70
|
-
points: u
|
|
71
|
-
}
|
|
72
|
-
)
|
|
73
|
-
]
|
|
74
|
-
}
|
|
75
|
-
) }) });
|
|
76
|
-
}
|
|
77
|
-
z.Line = z;
|
|
78
|
-
export {
|
|
79
|
-
z as Chart
|
|
80
|
-
};
|
|
1
|
+
import*as e from"react/jsx-runtime";import*as t from"react";import*as i from"../common/collections.js";import*as n from"./Box.js";let r={position:"absolute",top:0,left:0,right:0,bottom:0,overflow:"hidden"};function o(o){let{data:s=[],rangeX:l,rangeY:f,fillColor:a="none",strokeColor:h="#ffffff",strokeWidth:p=2,...u}=o,m=(0,t.useRef)(null),[c,d]=(0,t.useState)([600,200]),v=function(e,t,n,r){if(0===e.length)return[];let o=(0,i.zip)(...e),s=o.map(e=>Math.min(...e)),l=o.map(e=>Math.max(...e));return void 0!==n&&(s[0]=n[0],l[0]=n[1]),void 0!==r&&(s[1]=r[0],l[1]=r[1]),e.map(e=>(0,i.zip)(e,s,l,t).map(([e,t,i,n])=>(e-t)/(i-t)*n))}(s,c,l,f);if(v.length>0){let e=v[0],t=v[v.length-1];v.push([c[0]+p,t[1]]),v.push([c[0]+p,-p]),v.push([-p,-p]),v.push([-p,e[1]])}let x=function(e){let t="";for(let i=0;i<e.length;i++){let n=e[i];t+=`${n[0]},${n[1]} `}return t}(v);function g(){let e=m.current;if(!e)return;let t=e.getBoundingClientRect();d([t.width,t.height])}return(0,t.useEffect)(()=>(window.addEventListener("resize",g),g(),()=>{window.removeEventListener("resize",g)}),[]),(0,e.jsx)(n.Box,{position:"relative",...u,children:(0,e.jsx)("div",{ref:m,style:r,children:(0,e.jsxs)("svg",{viewBox:`0 0 ${c[0]} ${c[1]}`,preserveAspectRatio:"none",style:r,children:[(0,e.jsx)("title",{children:"chart"}),(0,e.jsx)("polyline",{transform:`scale(1, -1) translate(0, -${c[1]})`,fill:a,stroke:h,strokeWidth:p,points:x})]})})})}o.Line=o;export{o as Chart};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CSSProperties, ReactNode } from 'react';
|
|
2
|
-
import { BoxProps } from './Box';
|
|
1
|
+
import { type CSSProperties, type ReactNode } from 'react';
|
|
2
|
+
import { type BoxProps } from './Box';
|
|
3
3
|
type Props = Partial<{
|
|
4
4
|
/** Buttons or other content to render inline with the button */
|
|
5
5
|
buttons: ReactNode;
|
|
@@ -1,36 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { useState as b } from "react";
|
|
3
|
-
import { Box as n } from "./Box.js";
|
|
4
|
-
import { Button as u } from "./Button.js";
|
|
5
|
-
function T(o) {
|
|
6
|
-
const {
|
|
7
|
-
children: r,
|
|
8
|
-
child_mt: s = 1,
|
|
9
|
-
childStyles: m,
|
|
10
|
-
color: a,
|
|
11
|
-
title: d,
|
|
12
|
-
buttons: t,
|
|
13
|
-
icon: c,
|
|
14
|
-
...h
|
|
15
|
-
} = o, [l, p] = b(o.open);
|
|
16
|
-
return /* @__PURE__ */ i(n, { mb: 1, children: [
|
|
17
|
-
/* @__PURE__ */ i("div", { className: "Table", children: [
|
|
18
|
-
/* @__PURE__ */ e("div", { className: "Table__cell", children: /* @__PURE__ */ e(
|
|
19
|
-
u,
|
|
20
|
-
{
|
|
21
|
-
fluid: !0,
|
|
22
|
-
color: a,
|
|
23
|
-
icon: c || (l ? "chevron-down" : "chevron-right"),
|
|
24
|
-
onClick: () => p(!l),
|
|
25
|
-
...h,
|
|
26
|
-
children: d
|
|
27
|
-
}
|
|
28
|
-
) }),
|
|
29
|
-
t && /* @__PURE__ */ e("div", { className: "Table__cell Table__cell--collapsing", children: t })
|
|
30
|
-
] }),
|
|
31
|
-
l && /* @__PURE__ */ e(n, { mt: s, style: m, children: r })
|
|
32
|
-
] });
|
|
33
|
-
}
|
|
34
|
-
export {
|
|
35
|
-
T as Collapsible
|
|
36
|
-
};
|
|
1
|
+
import*as e from"react/jsx-runtime";import*as l from"react";import*as o from"./Box.js";import*as s from"./Button.js";function r(r){let{children:c,child_mt:i=1,childStyles:t,color:a,title:n,buttons:m,icon:d,...x}=r,[h,j]=(0,l.useState)(r.open);return(0,e.jsxs)(o.Box,{mb:1,children:[(0,e.jsxs)("div",{className:"Table",children:[(0,e.jsx)("div",{className:"Table__cell",children:(0,e.jsx)(s.Button,{fluid:!0,color:a,icon:d||(h?"chevron-down":"chevron-right"),onClick:()=>j(!h),...x,children:n})}),m&&(0,e.jsx)("div",{className:"Table__cell Table__cell--collapsing",children:m})]}),h&&(0,e.jsx)(o.Box,{mt:i,style:t,children:c})]})}export{r as Collapsible};
|
|
@@ -1,17 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { classes as c } from "../common/react.js";
|
|
3
|
-
import { computeBoxProps as s, computeBoxClassName as m } from "../common/ui.js";
|
|
4
|
-
function d(r) {
|
|
5
|
-
const { content: l, children: a, className: e, ...o } = r;
|
|
6
|
-
return o.color = l ? null : "default", o.backgroundColor = r.color || "default", /* @__PURE__ */ t(
|
|
7
|
-
"div",
|
|
8
|
-
{
|
|
9
|
-
className: c(["ColorBox", e, m(o)]),
|
|
10
|
-
...s(o),
|
|
11
|
-
children: l || ""
|
|
12
|
-
}
|
|
13
|
-
);
|
|
14
|
-
}
|
|
15
|
-
export {
|
|
16
|
-
d as ColorBox
|
|
17
|
-
};
|
|
1
|
+
import*as o from"react/jsx-runtime";import*as r from"../common/react.js";import*as m from"../common/ui.js";function s(s){let{content:e,children:l,className:t,...a}=s;return a.color=e?null:"default",a.backgroundColor=s.color||"default",(0,o.jsx)("div",{className:(0,r.classes)(["ColorBox",t,(0,m.computeBoxClassName)(a)]),...(0,m.computeBoxProps)(a),children:e||""})}export{s as ColorBox};
|
|
@@ -1,42 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Box as e } from "./Box.js";
|
|
3
|
-
import { Button as r } from "./Button.js";
|
|
4
|
-
function d(o) {
|
|
5
|
-
const { title: i, onClose: n, children: c, width: a, height: s } = o;
|
|
6
|
-
return /* @__PURE__ */ t("div", { className: "Dialog", children: /* @__PURE__ */ l(e, { className: "Dialog__content", width: a || "370px", height: s, children: [
|
|
7
|
-
/* @__PURE__ */ l("div", { className: "Dialog__header", children: [
|
|
8
|
-
/* @__PURE__ */ t("div", { className: "Dialog__title", children: i }),
|
|
9
|
-
/* @__PURE__ */ t(e, { mr: 2, children: /* @__PURE__ */ t(
|
|
10
|
-
r,
|
|
11
|
-
{
|
|
12
|
-
color: "transparent",
|
|
13
|
-
icon: "window-close-o",
|
|
14
|
-
lineHeight: "22px",
|
|
15
|
-
mr: "-3px",
|
|
16
|
-
onClick: n,
|
|
17
|
-
textAlign: "center",
|
|
18
|
-
tooltip: "Close",
|
|
19
|
-
tooltipPosition: "bottom-start",
|
|
20
|
-
width: "26px"
|
|
21
|
-
}
|
|
22
|
-
) })
|
|
23
|
-
] }),
|
|
24
|
-
c
|
|
25
|
-
] }) });
|
|
26
|
-
}
|
|
27
|
-
function m(o) {
|
|
28
|
-
const { onClick: i, children: n } = o;
|
|
29
|
-
return /* @__PURE__ */ t(
|
|
30
|
-
r,
|
|
31
|
-
{
|
|
32
|
-
onClick: i,
|
|
33
|
-
className: "Dialog__button",
|
|
34
|
-
verticalAlignContent: "middle",
|
|
35
|
-
children: n
|
|
36
|
-
}
|
|
37
|
-
);
|
|
38
|
-
}
|
|
39
|
-
d.Button = m;
|
|
40
|
-
export {
|
|
41
|
-
d as Dialog
|
|
42
|
-
};
|
|
1
|
+
import*as t from"react/jsx-runtime";import*as o from"./Box.js";import*as i from"./Button.js";function e(e){let{title:n,onClose:l,children:s,width:r,height:a}=e;return(0,t.jsx)("div",{className:"Dialog",children:(0,t.jsxs)(o.Box,{className:"Dialog__content",width:r||"370px",height:a,children:[(0,t.jsxs)("div",{className:"Dialog__header",children:[(0,t.jsx)("div",{className:"Dialog__title",children:n}),(0,t.jsx)(o.Box,{mr:2,children:(0,t.jsx)(i.Button,{color:"transparent",icon:"window-close-o",lineHeight:"22px",mr:"-3px",onClick:l,textAlign:"center",tooltip:"Close",tooltipPosition:"bottom-start",width:"26px"})})]}),s]})})}e.Button=function(o){let{onClick:e,children:n}=o;return(0,t.jsx)(i.Button,{onClick:e,className:"Dialog__button",verticalAlignContent:"middle",children:n})};export{e as Dialog};
|
|
@@ -1,10 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { classes as o } from "../common/react.js";
|
|
3
|
-
import { Box as c } from "./Box.js";
|
|
4
|
-
function l(m) {
|
|
5
|
-
const { className: e, children: s, ...i } = m;
|
|
6
|
-
return /* @__PURE__ */ r(c, { className: o(["Dimmer", e]), ...i, children: /* @__PURE__ */ r("div", { className: "Dimmer__inner", children: s }) });
|
|
7
|
-
}
|
|
8
|
-
export {
|
|
9
|
-
l as Dimmer
|
|
10
|
-
};
|
|
1
|
+
import*as r from"react/jsx-runtime";import*as m from"../common/react.js";import*as e from"./Box.js";function s(s){let{className:i,children:o,...a}=s;return(0,r.jsx)(e.Box,{className:(0,m.classes)(["Dimmer",i]),...a,children:(0,r.jsx)("div",{className:"Dimmer__inner",children:o})})}export{s as Dimmer};
|
|
@@ -1,18 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { classes as o } from "../common/react.js";
|
|
3
|
-
function n(i) {
|
|
4
|
-
const { hidden: r, vertical: e } = i;
|
|
5
|
-
return /* @__PURE__ */ d(
|
|
6
|
-
"div",
|
|
7
|
-
{
|
|
8
|
-
className: o([
|
|
9
|
-
"Divider",
|
|
10
|
-
r && "Divider--hidden",
|
|
11
|
-
e ? "Divider--vertical" : "Divider--horizontal"
|
|
12
|
-
])
|
|
13
|
-
}
|
|
14
|
-
);
|
|
15
|
-
}
|
|
16
|
-
export {
|
|
17
|
-
n as Divider
|
|
18
|
-
};
|
|
1
|
+
import*as i from"react/jsx-runtime";import*as r from"../common/react.js";function e(e){let{hidden:t,vertical:o}=e;return(0,i.jsx)("div",{className:(0,r.classes)(["Divider",t&&"Divider--hidden",o?"Divider--vertical":"Divider--horizontal"])})}export{e as Divider};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
import { BoxProps } from './Box';
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { BoxProps } from './Box';
|
|
3
3
|
export declare enum Direction {
|
|
4
4
|
NORTH = 1,
|
|
5
5
|
SOUTH = 2,
|
|
@@ -30,5 +30,5 @@ type Props = {
|
|
|
30
30
|
* Displays an icon from the BYOND icon reference map. Requires Byond 515+.
|
|
31
31
|
* A much faster alternative to base64 icons.
|
|
32
32
|
*/
|
|
33
|
-
export declare function DmIcon(props: Props): string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean | import(
|
|
33
|
+
export declare function DmIcon(props: Props): string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | import("react/jsx-runtime").JSX.Element | null | undefined;
|
|
34
34
|
export {};
|
|
@@ -1,23 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Image as e } from "./Image.js";
|
|
3
|
-
var u = /* @__PURE__ */ ((T) => (T[T.NORTH = 1] = "NORTH", T[T.SOUTH = 2] = "SOUTH", T[T.EAST = 4] = "EAST", T[T.WEST = 8] = "WEST", T[T.NORTHEAST = 5] = "NORTHEAST", T[T.NORTHWEST = 9] = "NORTHWEST", T[T.SOUTHEAST = 6] = "SOUTHEAST", T[T.SOUTHWEST = 10] = "SOUTHWEST", T))(u || {});
|
|
4
|
-
function $(T) {
|
|
5
|
-
var m;
|
|
6
|
-
const {
|
|
7
|
-
className: A,
|
|
8
|
-
direction: E = 2,
|
|
9
|
-
fallback: a,
|
|
10
|
-
frame: s = 1,
|
|
11
|
-
icon_state: H,
|
|
12
|
-
icon: O,
|
|
13
|
-
movement: f = !1,
|
|
14
|
-
...r
|
|
15
|
-
} = T, S = (m = Byond.iconRefMap) == null ? void 0 : m[O];
|
|
16
|
-
if (!S) return a;
|
|
17
|
-
const R = `${S}?state=${H}&dir=${E}&movement=${!!f}&frame=${s}`;
|
|
18
|
-
return /* @__PURE__ */ N(e, { fixErrors: !0, src: R, ...r });
|
|
19
|
-
}
|
|
20
|
-
export {
|
|
21
|
-
u as Direction,
|
|
22
|
-
$ as DmIcon
|
|
23
|
-
};
|
|
1
|
+
import*as T from"react/jsx-runtime";import*as r from"./Image.js";var S,e=((S={})[S.NORTH=1]="NORTH",S[S.SOUTH=2]="SOUTH",S[S.EAST=4]="EAST",S[S.WEST=8]="WEST",S[S.NORTHEAST=5]="NORTHEAST",S[S.NORTHWEST=9]="NORTHWEST",S[S.SOUTHEAST=6]="SOUTHEAST",S[S.SOUTHWEST=10]="SOUTHWEST",S);function t(S){let{className:e,direction:t=2,fallback:o,frame:E=1,icon_state:i,icon:m,movement:n=!1,...H}=S,O=Byond.iconRefMap?.[m];if(!O)return o;let a=`${O}?state=${i}&dir=${t}&movement=${!!n}&frame=${E}`;return(0,T.jsx)(r.Image,{fixErrors:!0,src:a,...H})}export{e as Direction,t as DmIcon};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { MouseEventHandler, ReactNode } from 'react';
|
|
2
|
-
import { BoxProps } from './Box';
|
|
1
|
+
import { type MouseEventHandler, type ReactNode } from 'react';
|
|
2
|
+
import type { BoxProps } from './Box';
|
|
3
3
|
type Control = {
|
|
4
4
|
/** Tooltip-like node to display. */
|
|
5
5
|
displayElement: ReactNode;
|