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
package/dist/components/Table.js
CHANGED
|
@@ -1,57 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { classes as r } from "../common/react.js";
|
|
3
|
-
import { computeBoxProps as t, computeBoxClassName as n } from "../common/ui.js";
|
|
4
|
-
function m(e) {
|
|
5
|
-
const { className: l, collapsing: a, children: s, ...o } = e;
|
|
6
|
-
return /* @__PURE__ */ c(
|
|
7
|
-
"table",
|
|
8
|
-
{
|
|
9
|
-
className: r([
|
|
10
|
-
"Table",
|
|
11
|
-
a && "Table--collapsing",
|
|
12
|
-
l,
|
|
13
|
-
n(o)
|
|
14
|
-
]),
|
|
15
|
-
...t(o),
|
|
16
|
-
children: /* @__PURE__ */ c("tbody", { children: s })
|
|
17
|
-
}
|
|
18
|
-
);
|
|
19
|
-
}
|
|
20
|
-
function b(e) {
|
|
21
|
-
const { className: l, header: a, ...s } = e;
|
|
22
|
-
return /* @__PURE__ */ c(
|
|
23
|
-
"tr",
|
|
24
|
-
{
|
|
25
|
-
className: r([
|
|
26
|
-
"Table__row",
|
|
27
|
-
a && "Table__row--header",
|
|
28
|
-
l,
|
|
29
|
-
n(e)
|
|
30
|
-
]),
|
|
31
|
-
...t(s)
|
|
32
|
-
}
|
|
33
|
-
);
|
|
34
|
-
}
|
|
35
|
-
function _(e) {
|
|
36
|
-
const { className: l, collapsing: a, colSpan: s, header: o, ...i } = e;
|
|
37
|
-
return /* @__PURE__ */ c(
|
|
38
|
-
"td",
|
|
39
|
-
{
|
|
40
|
-
className: r([
|
|
41
|
-
"Table__cell",
|
|
42
|
-
a && "Table__cell--collapsing",
|
|
43
|
-
o && "Table__cell--header",
|
|
44
|
-
l,
|
|
45
|
-
n(e)
|
|
46
|
-
]),
|
|
47
|
-
colSpan: s,
|
|
48
|
-
...t(i)
|
|
49
|
-
}
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
((e) => {
|
|
53
|
-
e.Cell = _, e.Row = b;
|
|
54
|
-
})(m || (m = {}));
|
|
55
|
-
export {
|
|
56
|
-
m as Table
|
|
57
|
-
};
|
|
1
|
+
var e;import*as a from"react/jsx-runtime";import*as l from"../common/react.js";import*as s from"../common/ui.js";function o(e){let{className:o,collapsing:c,children:r,...t}=e;return(0,a.jsx)("table",{className:(0,l.classes)(["Table",c&&"Table--collapsing",o,(0,s.computeBoxClassName)(t)]),...(0,s.computeBoxProps)(t),children:(0,a.jsx)("tbody",{children:r})})}(e=o||(o={})).Cell=function(e){let{className:o,collapsing:c,colSpan:r,header:t,...m}=e;return(0,a.jsx)("td",{className:(0,l.classes)(["Table__cell",c&&"Table__cell--collapsing",t&&"Table__cell--header",o,(0,s.computeBoxClassName)(e)]),colSpan:r,...(0,s.computeBoxProps)(m)})},e.Row=function(e){let{className:o,header:c,...r}=e;return(0,a.jsx)("tr",{className:(0,l.classes)(["Table__row",c&&"Table__row--header",o,(0,s.computeBoxClassName)(e)]),...(0,s.computeBoxProps)(r)})};export{o as Table};
|
package/dist/components/Tabs.js
CHANGED
|
@@ -1,65 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { canRender as d, classes as f } from "../common/react.js";
|
|
3
|
-
import { computeBoxProps as h, computeBoxClassName as p } from "../common/ui.js";
|
|
4
|
-
import { Icon as v } from "./Icon.js";
|
|
5
|
-
function T(e) {
|
|
6
|
-
const { className: i, vertical: c, fill: o, fluid: s, children: r, ...l } = e;
|
|
7
|
-
return /* @__PURE__ */ a(
|
|
8
|
-
"div",
|
|
9
|
-
{
|
|
10
|
-
className: f([
|
|
11
|
-
"Tabs",
|
|
12
|
-
c ? "Tabs--vertical" : "Tabs--horizontal",
|
|
13
|
-
o && "Tabs--fill",
|
|
14
|
-
s && "Tabs--fluid",
|
|
15
|
-
i,
|
|
16
|
-
p(l)
|
|
17
|
-
]),
|
|
18
|
-
...h(l),
|
|
19
|
-
children: r
|
|
20
|
-
}
|
|
21
|
-
);
|
|
22
|
-
}
|
|
23
|
-
function x(e) {
|
|
24
|
-
const {
|
|
25
|
-
className: i,
|
|
26
|
-
selected: c,
|
|
27
|
-
color: o,
|
|
28
|
-
icon: s,
|
|
29
|
-
iconSpin: r,
|
|
30
|
-
leftSlot: l,
|
|
31
|
-
rightSlot: t,
|
|
32
|
-
children: u,
|
|
33
|
-
onClick: n,
|
|
34
|
-
...m
|
|
35
|
-
} = e;
|
|
36
|
-
function _(b) {
|
|
37
|
-
n && (n(b), b.target.blur());
|
|
38
|
-
}
|
|
39
|
-
return /* @__PURE__ */ N(
|
|
40
|
-
"div",
|
|
41
|
-
{
|
|
42
|
-
className: f([
|
|
43
|
-
"Tab",
|
|
44
|
-
"Tabs__Tab",
|
|
45
|
-
`Tab--color--${o}`,
|
|
46
|
-
c && "Tab--selected",
|
|
47
|
-
i,
|
|
48
|
-
p(m)
|
|
49
|
-
]),
|
|
50
|
-
onClick: _,
|
|
51
|
-
...h(m),
|
|
52
|
-
children: [
|
|
53
|
-
d(l) && /* @__PURE__ */ a("div", { className: "Tab__left", children: l }) || !!s && /* @__PURE__ */ a("div", { className: "Tab__left", children: /* @__PURE__ */ a(v, { name: s, spin: r }) }),
|
|
54
|
-
/* @__PURE__ */ a("div", { className: "Tab__text", children: u }),
|
|
55
|
-
d(t) && /* @__PURE__ */ a("div", { className: "Tab__right", children: t })
|
|
56
|
-
]
|
|
57
|
-
}
|
|
58
|
-
);
|
|
59
|
-
}
|
|
60
|
-
((e) => {
|
|
61
|
-
e.Tab = x;
|
|
62
|
-
})(T || (T = {}));
|
|
63
|
-
export {
|
|
64
|
-
T as Tabs
|
|
65
|
-
};
|
|
1
|
+
import*as s from"react/jsx-runtime";import*as a from"../common/react.js";import*as e from"../common/ui.js";import*as c from"./Icon.js";function o(c){let{className:o,vertical:r,fill:l,fluid:t,children:i,...n}=c;return(0,s.jsx)("div",{className:(0,a.classes)(["Tabs",r?"Tabs--vertical":"Tabs--horizontal",l&&"Tabs--fill",t&&"Tabs--fluid",o,(0,e.computeBoxClassName)(n)]),...(0,e.computeBoxProps)(n),children:i})}(o||(o={})).Tab=function(o){let{className:r,selected:l,color:t,icon:i,iconSpin:n,leftSlot:m,rightSlot:b,children:T,onClick:d,...x}=o;return(0,s.jsxs)("div",{className:(0,a.classes)(["Tab","Tabs__Tab",`Tab--color--${t}`,l&&"Tab--selected",r,(0,e.computeBoxClassName)(x)]),onClick:function(s){d&&(d(s),s.target.blur())},...(0,e.computeBoxProps)(x),children:[(0,a.canRender)(m)&&(0,s.jsx)("div",{className:"Tab__left",children:m})||!!i&&(0,s.jsx)("div",{className:"Tab__left",children:(0,s.jsx)(c.Icon,{name:i,spin:n})}),(0,s.jsx)("div",{className:"Tab__text",children:T}),(0,a.canRender)(b)&&(0,s.jsx)("div",{className:"Tab__right",children:b})]})};export{o as Tabs};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { RefObject, SyntheticEvent } from 'react';
|
|
2
|
-
import { BoxProps } from './Box';
|
|
1
|
+
import type { RefObject, SyntheticEvent } from 'react';
|
|
2
|
+
import { type BoxProps } from './Box';
|
|
3
3
|
type Props = Partial<{
|
|
4
4
|
/** Automatically focus the textarea on mount */
|
|
5
5
|
autoFocus: boolean;
|
|
@@ -1,126 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { useRef as R, useState as Y, useEffect as y } from "react";
|
|
3
|
-
import { KEY as A, isEscape as I } from "../common/keys.js";
|
|
4
|
-
import { classes as p } from "../common/react.js";
|
|
5
|
-
import { Box as L } from "./Box.js";
|
|
6
|
-
import { toInputValue as h } from "./Input.js";
|
|
7
|
-
function U(a, s, l, e) {
|
|
8
|
-
return `${a.substring(0, l)}${s}${a.substring(l, e)}${s}${a.substring(e)}`;
|
|
9
|
-
}
|
|
10
|
-
function Q(a) {
|
|
11
|
-
const {
|
|
12
|
-
autoFocus: s,
|
|
13
|
-
autoSelect: l,
|
|
14
|
-
displayedValue: e,
|
|
15
|
-
dontUseTabForIndent: k,
|
|
16
|
-
maxLength: S,
|
|
17
|
-
noborder: $,
|
|
18
|
-
onChange: n,
|
|
19
|
-
onEnter: i,
|
|
20
|
-
onEscape: f,
|
|
21
|
-
onInput: g,
|
|
22
|
-
placeholder: E,
|
|
23
|
-
ref: m,
|
|
24
|
-
scrollbar: K,
|
|
25
|
-
selfClear: b,
|
|
26
|
-
userMarkup: T,
|
|
27
|
-
value: x,
|
|
28
|
-
...w
|
|
29
|
-
} = a, { className: N, fluid: D, nowrap: C, ...V } = w, u = R((m == null ? void 0 : m.current) ?? null), [j, B] = Y(0);
|
|
30
|
-
function F(r) {
|
|
31
|
-
if (r.key === A.Enter) {
|
|
32
|
-
if (r.shiftKey) {
|
|
33
|
-
r.currentTarget.focus();
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
i == null || i(r, r.currentTarget.value), b && (r.currentTarget.value = ""), r.currentTarget.blur();
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
if (I(r.key)) {
|
|
40
|
-
f == null || f(r), b ? r.currentTarget.value = "" : (r.currentTarget.value = h(x), r.currentTarget.blur());
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
if (!k && r.key === A.Tab) {
|
|
44
|
-
r.preventDefault();
|
|
45
|
-
const { value: t, selectionStart: o, selectionEnd: c } = r.currentTarget;
|
|
46
|
-
r.currentTarget.value = `${t.substring(0, o)} ${t.substring(c)}`, r.currentTarget.selectionEnd = o + 1;
|
|
47
|
-
}
|
|
48
|
-
if (T && (r.ctrlKey || r.metaKey) && T[r.key]) {
|
|
49
|
-
r.preventDefault();
|
|
50
|
-
const { value: t, selectionStart: o, selectionEnd: c } = r.currentTarget, _ = T[r.key];
|
|
51
|
-
r.currentTarget.value = U(
|
|
52
|
-
t,
|
|
53
|
-
_,
|
|
54
|
-
o,
|
|
55
|
-
c
|
|
56
|
-
), r.currentTarget.selectionEnd = c + _.length * 2;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
return y(() => {
|
|
60
|
-
if (s || l) {
|
|
61
|
-
const r = u.current;
|
|
62
|
-
r && setTimeout(() => {
|
|
63
|
-
r.focus(), l && r.select();
|
|
64
|
-
}, 1);
|
|
65
|
-
}
|
|
66
|
-
}, []), y(() => {
|
|
67
|
-
const r = u.current;
|
|
68
|
-
if (r) {
|
|
69
|
-
const t = h(x);
|
|
70
|
-
r.value !== t && (r.value = t);
|
|
71
|
-
}
|
|
72
|
-
}, [x]), /* @__PURE__ */ M(
|
|
73
|
-
L,
|
|
74
|
-
{
|
|
75
|
-
className: p([
|
|
76
|
-
"TextArea",
|
|
77
|
-
D && "TextArea--fluid",
|
|
78
|
-
$ && "TextArea--noborder",
|
|
79
|
-
N
|
|
80
|
-
]),
|
|
81
|
-
...V,
|
|
82
|
-
children: [
|
|
83
|
-
!!e && /* @__PURE__ */ d("div", { className: "TextArea__value-container", children: /* @__PURE__ */ d(
|
|
84
|
-
"div",
|
|
85
|
-
{
|
|
86
|
-
className: p([
|
|
87
|
-
"TextArea__textarea",
|
|
88
|
-
"TextArea__textarea_custom"
|
|
89
|
-
]),
|
|
90
|
-
style: {
|
|
91
|
-
transform: `translateY(-${j}px)`
|
|
92
|
-
},
|
|
93
|
-
children: e
|
|
94
|
-
}
|
|
95
|
-
) }),
|
|
96
|
-
/* @__PURE__ */ d(
|
|
97
|
-
"textarea",
|
|
98
|
-
{
|
|
99
|
-
autoComplete: "off",
|
|
100
|
-
className: p([
|
|
101
|
-
"TextArea__textarea",
|
|
102
|
-
K && "TextArea__textarea--scrollable",
|
|
103
|
-
C && "TextArea__nowrap"
|
|
104
|
-
]),
|
|
105
|
-
maxLength: S,
|
|
106
|
-
onBlur: (r) => n == null ? void 0 : n(r, r.target.value),
|
|
107
|
-
onChange: (r) => g == null ? void 0 : g(r, r.target.value),
|
|
108
|
-
onKeyDown: F,
|
|
109
|
-
onScroll: () => {
|
|
110
|
-
e && u.current && B(u.current.scrollTop);
|
|
111
|
-
},
|
|
112
|
-
placeholder: E,
|
|
113
|
-
ref: u,
|
|
114
|
-
spellCheck: !1,
|
|
115
|
-
style: {
|
|
116
|
-
color: e ? "rgba(0, 0, 0, 0)" : "inherit"
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
)
|
|
120
|
-
]
|
|
121
|
-
}
|
|
122
|
-
);
|
|
123
|
-
}
|
|
124
|
-
export {
|
|
125
|
-
Q as TextArea
|
|
126
|
-
};
|
|
1
|
+
import*as e from"react/jsx-runtime";import*as r from"react";import*as t from"../common/keys.js";import*as a from"../common/react.js";import*as s from"./Box.js";import*as n from"./Input.js";function u(u){let{autoFocus:l,autoSelect:c,displayedValue:o,dontUseTabForIndent:i,maxLength:f,noborder:m,onChange:T,onEnter:x,onEscape:g,onInput:p,placeholder:v,ref:_,scrollbar:d,selfClear:y,userMarkup:b,value:h,...A}=u,{className:j,fluid:E,nowrap:$,...k}=A,K=(0,r.useRef)(null),N=_??K,[B,C]=(0,r.useState)(0);return(0,r.useEffect)(()=>{if(l||c){let e=N.current;e&&setTimeout(()=>{e.focus(),c&&e.select()},1)}},[]),(0,r.useEffect)(()=>{let e=N.current;if(e){let r=(0,n.toInputValue)(h);e.value!==r&&(e.value=r)}},[h]),(0,e.jsxs)(s.Box,{className:(0,a.classes)(["TextArea",E&&"TextArea--fluid",m&&"TextArea--noborder",j]),...k,children:[!!o&&(0,e.jsx)("div",{className:"TextArea__value-container",children:(0,e.jsx)("div",{className:(0,a.classes)(["TextArea__textarea","TextArea__textarea_custom"]),style:{transform:`translateY(-${B}px)`},children:o})}),(0,e.jsx)("textarea",{autoComplete:"off",className:(0,a.classes)(["TextArea__textarea",d&&"TextArea__textarea--scrollable",$&&"TextArea__nowrap"]),maxLength:f,onBlur:e=>T?.(e,e.target.value),onChange:e=>p?.(e,e.target.value),onKeyDown:function(e){if(e.key===t.KEY.Enter)return e.shiftKey?void e.currentTarget.focus():(x?.(e,e.currentTarget.value),y&&(e.currentTarget.value=""),void e.currentTarget.blur());if((0,t.isEscape)(e.key)){g?.(e),y?e.currentTarget.value="":(e.currentTarget.value=(0,n.toInputValue)(h),e.currentTarget.blur());return}if(!i&&e.key===t.KEY.Tab){e.preventDefault();let{value:r,selectionStart:t,selectionEnd:a}=e.currentTarget;e.currentTarget.value=`${r.substring(0,t)} ${r.substring(a)}`,e.currentTarget.selectionEnd=t+1}if(b&&(e.ctrlKey||e.metaKey)&&b[e.key]){e.preventDefault();let{value:r,selectionStart:t,selectionEnd:a}=e.currentTarget,s=b[e.key];e.currentTarget.value=`${r.substring(0,t)}${s}${r.substring(t,a)}${s}${r.substring(a)}`,e.currentTarget.selectionEnd=a+2*s.length}},onScroll:()=>{o&&N.current&&C(N.current.scrollTop)},placeholder:v,ref:N,spellCheck:!1,style:{color:o?"rgba(0, 0, 0, 0)":"inherit"}})]})}export{u as TextArea};
|
|
@@ -1,25 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { formatTime as d } from "../common/format.js";
|
|
3
|
-
import { isSafeNumber as u } from "../common/math.js";
|
|
4
|
-
function I(s) {
|
|
5
|
-
const {
|
|
6
|
-
value: e = 0,
|
|
7
|
-
auto: t = void 0,
|
|
8
|
-
format: n = void 0
|
|
9
|
-
} = s, [o, a] = l(
|
|
10
|
-
() => u(e) ? e : 0
|
|
11
|
-
), [i, m] = l(
|
|
12
|
-
u(e) ? e : void 0
|
|
13
|
-
), r = p(null);
|
|
14
|
-
return f(() => (t !== void 0 && (r.current = setInterval(() => {
|
|
15
|
-
const c = t === "up" ? 10 : -10;
|
|
16
|
-
a((v) => Math.max(0, v + c));
|
|
17
|
-
}, 1e3)), () => {
|
|
18
|
-
r.current && clearInterval(r.current);
|
|
19
|
-
}), [t]), f(() => {
|
|
20
|
-
e !== i && (m(e), a(e));
|
|
21
|
-
}, [e, i]), u(e) ? n ? n(o) : d(o) : e || null;
|
|
22
|
-
}
|
|
23
|
-
export {
|
|
24
|
-
I as TimeDisplay
|
|
25
|
-
};
|
|
1
|
+
import*as e from"react";import*as t from"../common/format.js";import*as r from"../common/math.js";function a(a){let{value:m=0,auto:u,format:o}=a,[s,f]=(0,e.useState)(()=>(0,r.isSafeNumber)(m)?m:0),[i,n]=(0,e.useState)((0,r.isSafeNumber)(m)?m:void 0),l=(0,e.useRef)(null);return((0,e.useEffect)(()=>(void 0!==u&&(l.current=setInterval(()=>{let e="up"===u?10:-10;f(t=>Math.max(0,t+e))},1e3)),()=>{l.current&&clearInterval(l.current)}),[u]),(0,e.useEffect)(()=>{m!==i&&(n(m),f(m))},[m,i]),(0,r.isSafeNumber)(m))?o?o(s):(0,t.formatTime)(s):m||null}export{a as TimeDisplay};
|
|
@@ -1,18 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Floating as i } from "./Floating.js";
|
|
3
|
-
function l(o) {
|
|
4
|
-
const { content: t, children: n, position: e } = o;
|
|
5
|
-
return /* @__PURE__ */ r(
|
|
6
|
-
i,
|
|
7
|
-
{
|
|
8
|
-
hoverOpen: !0,
|
|
9
|
-
content: t,
|
|
10
|
-
contentClasses: "Tooltip",
|
|
11
|
-
placement: e,
|
|
12
|
-
children: n
|
|
13
|
-
}
|
|
14
|
-
);
|
|
15
|
-
}
|
|
16
|
-
export {
|
|
17
|
-
l as Tooltip
|
|
18
|
-
};
|
|
1
|
+
import*as t from"react/jsx-runtime";import*as o from"./Floating.js";function e(e){let{content:n,children:r,position:i}=e;return(0,t.jsx)(o.Floating,{hoverOpen:!0,content:n,contentClasses:"Tooltip",placement:i,children:r})}export{e as Tooltip};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Component, PropsWithChildren } from 'react';
|
|
1
|
+
import { Component, type PropsWithChildren } from 'react';
|
|
2
2
|
type Props = {
|
|
3
3
|
onOutsideClick: () => void;
|
|
4
4
|
} & PropsWithChildren;
|
|
5
5
|
export declare class TrackOutsideClicks extends Component<Props> {
|
|
6
|
-
ref: import(
|
|
6
|
+
ref: import("react").RefObject<HTMLDivElement | null>;
|
|
7
7
|
constructor(props: any);
|
|
8
8
|
componentWillUnmount(): void;
|
|
9
9
|
handleOutsideClick(event: MouseEvent): void;
|
|
@@ -1,24 +1 @@
|
|
|
1
|
-
|
|
2
|
-
var s = (i, t, e) => t in i ? n(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e;
|
|
3
|
-
var r = (i, t, e) => s(i, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
-
import { jsx as c } from "react/jsx-runtime";
|
|
5
|
-
import { Component as d, createRef as o } from "react";
|
|
6
|
-
class a extends d {
|
|
7
|
-
constructor(e) {
|
|
8
|
-
super(e);
|
|
9
|
-
r(this, "ref", o());
|
|
10
|
-
this.handleOutsideClick = this.handleOutsideClick.bind(this), document.addEventListener("click", this.handleOutsideClick);
|
|
11
|
-
}
|
|
12
|
-
componentWillUnmount() {
|
|
13
|
-
document.removeEventListener("click", this.handleOutsideClick);
|
|
14
|
-
}
|
|
15
|
-
handleOutsideClick(e) {
|
|
16
|
-
e.target instanceof Node && this.ref.current && !this.ref.current.contains(e.target) && this.props.onOutsideClick();
|
|
17
|
-
}
|
|
18
|
-
render() {
|
|
19
|
-
return /* @__PURE__ */ c("div", { ref: this.ref, children: this.props.children });
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
export {
|
|
23
|
-
a as TrackOutsideClicks
|
|
24
|
-
};
|
|
1
|
+
import*as e from"react/jsx-runtime";import*as t from"react";class i extends t.Component{ref=(0,t.createRef)();constructor(e){super(e),this.handleOutsideClick=this.handleOutsideClick.bind(this),document.addEventListener("click",this.handleOutsideClick)}componentWillUnmount(){document.removeEventListener("click",this.handleOutsideClick)}handleOutsideClick(e){e.target instanceof Node&&this.ref.current&&!this.ref.current.contains(e.target)&&this.props.onOutsideClick()}render(){return(0,e.jsx)("div",{ref:this.ref,children:this.props.children})}}export{i as TrackOutsideClicks};
|
|
@@ -1,34 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { useRef as h, useState as o, useCallback as v, useEffect as b } from "react";
|
|
3
|
-
function y(u) {
|
|
4
|
-
const { children: t } = u, s = h(null), [e, d] = o(1), [m, f] = o(0), i = v(() => {
|
|
5
|
-
const { current: n } = s;
|
|
6
|
-
if (!t || !Array.isArray(t) || !n || e >= t.length)
|
|
7
|
-
return;
|
|
8
|
-
const r = document.body.offsetHeight - n.getBoundingClientRect().bottom, a = Math.ceil(n.offsetHeight / e);
|
|
9
|
-
if (r > 0) {
|
|
10
|
-
const l = Math.min(
|
|
11
|
-
t.length,
|
|
12
|
-
e + Math.max(1, Math.ceil(r / a))
|
|
13
|
-
);
|
|
14
|
-
d(l), f((t.length - l) * a);
|
|
15
|
-
}
|
|
16
|
-
}, [s, e, t]);
|
|
17
|
-
return b(() => {
|
|
18
|
-
i();
|
|
19
|
-
const n = setInterval(i, 100);
|
|
20
|
-
return () => clearInterval(n);
|
|
21
|
-
}, [i]), /* @__PURE__ */ g("div", { className: "VirtualList", children: [
|
|
22
|
-
/* @__PURE__ */ c("div", { className: "VirtualList__Container", ref: s, children: Array.isArray(t) ? t.slice(0, e) : null }),
|
|
23
|
-
/* @__PURE__ */ c(
|
|
24
|
-
"div",
|
|
25
|
-
{
|
|
26
|
-
className: "VirtualList__Padding",
|
|
27
|
-
style: { paddingBottom: `${m}px` }
|
|
28
|
-
}
|
|
29
|
-
)
|
|
30
|
-
] });
|
|
31
|
-
}
|
|
32
|
-
export {
|
|
33
|
-
y as VirtualList
|
|
34
|
-
};
|
|
1
|
+
import*as t from"react/jsx-runtime";import*as e from"react";function a(a){let{children:r}=a,i=(0,e.useRef)(null),[l,s]=(0,e.useState)(1),[n,u]=(0,e.useState)(0),c=(0,e.useCallback)(()=>{let{current:t}=i;if(!r||!Array.isArray(r)||!t||l>=r.length)return;let e=document.body.offsetHeight-t.getBoundingClientRect().bottom,a=Math.ceil(t.offsetHeight/l);if(e>0){let t=Math.min(r.length,l+Math.max(1,Math.ceil(e/a)));s(t),u((r.length-t)*a)}},[i,l,r]);return(0,e.useEffect)(()=>{c();let t=setInterval(c,100);return()=>clearInterval(t)},[c]),(0,t.jsxs)("div",{className:"VirtualList",children:[(0,t.jsx)("div",{className:"VirtualList__Container",ref:i,children:Array.isArray(r)?r.slice(0,l):null}),(0,t.jsx)("div",{className:"VirtualList__Padding",style:{paddingBottom:`${n}px`}})]})}export{a as VirtualList};
|
package/dist/components/index.js
CHANGED
|
@@ -1,96 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Autofocus as m } from "./Autofocus.js";
|
|
3
|
-
import { Blink as x } from "./Blink.js";
|
|
4
|
-
import { BlockQuote as i } from "./BlockQuote.js";
|
|
5
|
-
import { Box as l } from "./Box.js";
|
|
6
|
-
import { Button as u } from "./Button.js";
|
|
7
|
-
import { ByondUi as c } from "./ByondUi.js";
|
|
8
|
-
import { Chart as b } from "./Chart.js";
|
|
9
|
-
import { Collapsible as g } from "./Collapsible.js";
|
|
10
|
-
import { ColorBox as D } from "./ColorBox.js";
|
|
11
|
-
import { Dialog as C } from "./Dialog.js";
|
|
12
|
-
import { Dimmer as L } from "./Dimmer.js";
|
|
13
|
-
import { Divider as y } from "./Divider.js";
|
|
14
|
-
import { DmIcon as F } from "./DmIcon.js";
|
|
15
|
-
import { DraggableControl as P } from "./DraggableControl.js";
|
|
16
|
-
import { Dropdown as M } from "./Dropdown.js";
|
|
17
|
-
import { FitText as h } from "./FitText.js";
|
|
18
|
-
import { Flex as w } from "./Flex.js";
|
|
19
|
-
import { Floating as O } from "./Floating.js";
|
|
20
|
-
import { Icon as U } from "./Icon.js";
|
|
21
|
-
import { Image as j } from "./Image.js";
|
|
22
|
-
import { ImageButton as z } from "./ImageButton.js";
|
|
23
|
-
import { InfinitePlane as H } from "./InfinitePlane.js";
|
|
24
|
-
import { Input as W } from "./Input.js";
|
|
25
|
-
import { KeyListener as Y } from "./KeyListener.js";
|
|
26
|
-
import { Knob as _ } from "./Knob.js";
|
|
27
|
-
import { LabeledControls as oo } from "./LabeledControls.js";
|
|
28
|
-
import { LabeledList as eo } from "./LabeledList.js";
|
|
29
|
-
import { MenuBar as mo } from "./MenuBar.js";
|
|
30
|
-
import { Modal as xo } from "./Modal.js";
|
|
31
|
-
import { NoticeBox as io } from "./NoticeBox.js";
|
|
32
|
-
import { NumberInput as lo } from "./NumberInput.js";
|
|
33
|
-
import { Popper as uo } from "./Popper.js";
|
|
34
|
-
import { ProgressBar as co } from "./ProgressBar.js";
|
|
35
|
-
import { RestrictedInput as Bo } from "./RestrictedInput.js";
|
|
36
|
-
import { RoundGauge as Io } from "./RoundGauge.js";
|
|
37
|
-
import { Section as To } from "./Section.js";
|
|
38
|
-
import { Slider as ko } from "./Slider.js";
|
|
39
|
-
import { Stack as So } from "./Stack.js";
|
|
40
|
-
import { StyleableSection as Ao } from "./StyleableSection.js";
|
|
41
|
-
import { Table as No } from "./Table.js";
|
|
42
|
-
import { Tabs as Ko } from "./Tabs.js";
|
|
43
|
-
import { TextArea as Ro } from "./TextArea.js";
|
|
44
|
-
import { TimeDisplay as vo } from "./TimeDisplay.js";
|
|
45
|
-
import { Tooltip as Go } from "./Tooltip.js";
|
|
46
|
-
import { TrackOutsideClicks as Qo } from "./TrackOutsideClicks.js";
|
|
47
|
-
import { VirtualList as Vo } from "./VirtualList.js";
|
|
48
|
-
export {
|
|
49
|
-
e as AnimatedNumber,
|
|
50
|
-
m as Autofocus,
|
|
51
|
-
x as Blink,
|
|
52
|
-
i as BlockQuote,
|
|
53
|
-
l as Box,
|
|
54
|
-
u as Button,
|
|
55
|
-
c as ByondUi,
|
|
56
|
-
b as Chart,
|
|
57
|
-
g as Collapsible,
|
|
58
|
-
D as ColorBox,
|
|
59
|
-
C as Dialog,
|
|
60
|
-
L as Dimmer,
|
|
61
|
-
y as Divider,
|
|
62
|
-
F as DmIcon,
|
|
63
|
-
P as DraggableControl,
|
|
64
|
-
M as Dropdown,
|
|
65
|
-
h as FitText,
|
|
66
|
-
w as Flex,
|
|
67
|
-
O as Floating,
|
|
68
|
-
U as Icon,
|
|
69
|
-
j as Image,
|
|
70
|
-
z as ImageButton,
|
|
71
|
-
H as InfinitePlane,
|
|
72
|
-
W as Input,
|
|
73
|
-
Y as KeyListener,
|
|
74
|
-
_ as Knob,
|
|
75
|
-
oo as LabeledControls,
|
|
76
|
-
eo as LabeledList,
|
|
77
|
-
mo as MenuBar,
|
|
78
|
-
xo as Modal,
|
|
79
|
-
io as NoticeBox,
|
|
80
|
-
lo as NumberInput,
|
|
81
|
-
uo as Popper,
|
|
82
|
-
co as ProgressBar,
|
|
83
|
-
Bo as RestrictedInput,
|
|
84
|
-
Io as RoundGauge,
|
|
85
|
-
To as Section,
|
|
86
|
-
ko as Slider,
|
|
87
|
-
So as Stack,
|
|
88
|
-
Ao as StyleableSection,
|
|
89
|
-
No as Table,
|
|
90
|
-
Ko as Tabs,
|
|
91
|
-
Ro as TextArea,
|
|
92
|
-
vo as TimeDisplay,
|
|
93
|
-
Go as Tooltip,
|
|
94
|
-
Qo as TrackOutsideClicks,
|
|
95
|
-
Vo as VirtualList
|
|
96
|
-
};
|
|
1
|
+
import*as o from"./AnimatedNumber.js";import*as e from"./Autofocus.js";import*as s from"./Blink.js";import*as a from"./BlockQuote.js";import*as _ from"./Box.js";import*as r from"./Button.js";import*as t from"./ByondUi.js";import*as p from"./Chart.js";import*as i from"./Collapsible.js";import*as m from"./ColorBox.js";import*as l from"./Dialog.js";import*as n from"./Dimmer.js";import*as c from"./Divider.js";import*as b from"./DmIcon.js";import*as x from"./DraggableControl.js";import*as k from"./Dropdown.js";import*as u from"./FitText.js";import*as f from"./Flex.js";import*as w from"./Floating.js";import*as j from"./Icon.js";import*as d from"./Image.js";import*as B from"./ImageButton.js";import*as g from"./InfinitePlane.js";import*as I from"./Input.js";import*as D from"./KeyListener.js";import*as T from"./Knob.js";import*as C from"./LabeledControls.js";import*as L from"./LabeledList.js";import*as S from"./MenuBar.js";import*as y from"./Modal.js";import*as A from"./NoticeBox.js";import*as F from"./NumberInput.js";import*as N from"./Popper.js";import*as P from"./ProgressBar.js";import*as K from"./RestrictedInput.js";import*as M from"./RoundGauge.js";import*as R from"./Section.js";import*as v from"./Slider.js";import*as h from"./Stack.js";import*as G from"./StyleableSection.js";import*as O from"./Table.js";import*as Q from"./Tabs.js";import*as U from"./TextArea.js";import*as V from"./TimeDisplay.js";import*as q from"./Tooltip.js";import*as z from"./TrackOutsideClicks.js";import*as E from"./VirtualList.js";var H=o.AnimatedNumber,J=e.Autofocus,W=s.Blink,X=a.BlockQuote,Y=_.Box,Z=r.Button,$=t.ByondUi,oo=p.Chart,oe=i.Collapsible,os=m.ColorBox,oa=l.Dialog,o_=n.Dimmer,or=c.Divider,ot=b.DmIcon,op=x.DraggableControl,oi=k.Dropdown,om=u.FitText,ol=f.Flex,on=w.Floating,oc=j.Icon,ob=d.Image,ox=B.ImageButton,ok=g.InfinitePlane,ou=I.Input,of=D.KeyListener,ow=T.Knob,oj=C.LabeledControls,od=L.LabeledList,oB=S.MenuBar,og=y.Modal,oI=A.NoticeBox,oD=F.NumberInput,oT=N.Popper,oC=P.ProgressBar,oL=K.RestrictedInput,oS=M.RoundGauge,oy=R.Section,oA=v.Slider,oF=h.Stack,oN=G.StyleableSection,oP=O.Table,oK=Q.Tabs,oM=U.TextArea,oR=V.TimeDisplay,ov=q.Tooltip,oh=z.TrackOutsideClicks,oG=E.VirtualList;export{H as AnimatedNumber,J as Autofocus,W as Blink,X as BlockQuote,Y as Box,Z as Button,$ as ByondUi,oo as Chart,oe as Collapsible,os as ColorBox,oa as Dialog,o_ as Dimmer,or as Divider,ot as DmIcon,op as DraggableControl,oi as Dropdown,om as FitText,ol as Flex,on as Floating,oc as Icon,ob as Image,ox as ImageButton,ok as InfinitePlane,ou as Input,of as KeyListener,ow as Knob,oj as LabeledControls,od as LabeledList,oB as MenuBar,og as Modal,oI as NoticeBox,oD as NumberInput,oT as Popper,oC as ProgressBar,oL as RestrictedInput,oS as RoundGauge,oy as Section,oA as Slider,oF as Stack,oN as StyleableSection,oP as Table,oK as Tabs,oM as TextArea,oR as TimeDisplay,ov as Tooltip,oh as TrackOutsideClicks,oG as VirtualList};
|
package/license.txt
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tgui-core",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "TGUI core component library",
|
|
5
5
|
"keywords": ["TGUI", "library", "typescript"],
|
|
6
6
|
"files": ["dist", "styles"],
|
|
@@ -26,8 +26,7 @@
|
|
|
26
26
|
"url": "https://github.com/tgstation/tgui-core.git"
|
|
27
27
|
},
|
|
28
28
|
"scripts": {
|
|
29
|
-
"
|
|
30
|
-
"build": "tsc --noEmit && vite build",
|
|
29
|
+
"build": "rslib build",
|
|
31
30
|
"lint": "biome check lib",
|
|
32
31
|
"lint:fix": "prettier . --write && biome check . --fix",
|
|
33
32
|
"storybook": "storybook dev -p 6006",
|
|
@@ -37,33 +36,28 @@
|
|
|
37
36
|
"author": "jlsnow301",
|
|
38
37
|
"license": "MIT",
|
|
39
38
|
"type": "module",
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"@floating-ui/react": "^0.27.6"
|
|
41
|
+
},
|
|
40
42
|
"devDependencies": {
|
|
41
43
|
"@biomejs/biome": "1.9.4",
|
|
42
|
-
"@
|
|
43
|
-
"@
|
|
44
|
+
"@rsbuild/core": "^1.3.5",
|
|
45
|
+
"@rsbuild/plugin-react": "^1.2.0",
|
|
46
|
+
"@rsbuild/plugin-sass": "^1.3.1",
|
|
47
|
+
"@rslib/core": "^0.6.2",
|
|
44
48
|
"@storybook/addon-console": "^3.0.0",
|
|
45
49
|
"@storybook/addon-essentials": "^8.6.12",
|
|
46
|
-
"@storybook/addon-interactions": "^8.6.12",
|
|
47
|
-
"@storybook/addon-onboarding": "^8.6.12",
|
|
48
|
-
"@storybook/blocks": "^8.6.12",
|
|
49
50
|
"@storybook/react": "^8.6.12",
|
|
50
|
-
"@storybook/react-vite": "^8.6.12",
|
|
51
|
-
"@storybook/test": "^8.6.12",
|
|
52
51
|
"@storybook/theming": "^8.6.12",
|
|
53
52
|
"@types/node": "^22.14.0",
|
|
54
53
|
"@types/react": "^19.1.0",
|
|
55
54
|
"@types/react-dom": "^19.1.1",
|
|
56
|
-
"@types/webpack-env": "^1.18.8",
|
|
57
|
-
"@vitejs/plugin-react-swc": "^3.8.1",
|
|
58
|
-
"glob": "^11.0.1",
|
|
59
55
|
"prettier": "^3.5.3",
|
|
60
|
-
"react-popper": "^2.3.0",
|
|
61
56
|
"sass": "^1.81.0",
|
|
62
57
|
"storybook": "^8.6.12",
|
|
63
58
|
"storybook-addon-sass-postcss": "^0.3.2",
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"vite-plugin-dts": "^4.5.3"
|
|
59
|
+
"storybook-react-rsbuild": "^1.0.1",
|
|
60
|
+
"typescript": "^5.8.3"
|
|
67
61
|
},
|
|
68
62
|
"peerDependencies": {
|
|
69
63
|
"react": "^19.1.0",
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { jsx as r, jsxs as i } from "react/jsx-runtime";
|
|
2
|
-
import { Component as o, Fragment as c } from "react";
|
|
3
|
-
import { Box as m } from "./Box.js";
|
|
4
|
-
class h extends o {
|
|
5
|
-
constructor(e) {
|
|
6
|
-
super(e), this.timer = null, this.state = {
|
|
7
|
-
currentIndex: 0,
|
|
8
|
-
currentDisplay: []
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
tick() {
|
|
12
|
-
const { props: e, state: t } = this;
|
|
13
|
-
if (t.currentIndex <= e.allMessages.length) {
|
|
14
|
-
this.setState((n) => ({
|
|
15
|
-
currentIndex: n.currentIndex + 1
|
|
16
|
-
}));
|
|
17
|
-
const { currentDisplay: s } = t;
|
|
18
|
-
s.push(e.allMessages[t.currentIndex]);
|
|
19
|
-
} else
|
|
20
|
-
clearTimeout(this.timer), setTimeout(e.onFinished, e.finishedTimeout);
|
|
21
|
-
}
|
|
22
|
-
componentDidMount() {
|
|
23
|
-
const { linesPerSecond: e = 2.5 } = this.props;
|
|
24
|
-
this.timer = setInterval(() => this.tick(), 1e3 / e);
|
|
25
|
-
}
|
|
26
|
-
componentWillUnmount() {
|
|
27
|
-
clearTimeout(this.timer);
|
|
28
|
-
}
|
|
29
|
-
render() {
|
|
30
|
-
return /* @__PURE__ */ r(m, { m: 1, children: this.state.currentDisplay.map((e) => /* @__PURE__ */ i(c, { children: [
|
|
31
|
-
e,
|
|
32
|
-
/* @__PURE__ */ r("br", {})
|
|
33
|
-
] }, e)) });
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
export {
|
|
37
|
-
h as FakeTerminal
|
|
38
|
-
};
|