tgui-core 1.3.2 → 1.5.1
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/README.md +24 -2
- package/dist/common/ui.d.ts +113 -0
- package/dist/common/ui.js +137 -0
- package/dist/components/AnimatedNumber.d.ts +1 -0
- package/dist/components/BlockQuote.d.ts +5 -0
- package/dist/components/Box.d.ts +74 -63
- package/dist/components/Box.js +13 -127
- package/dist/components/Button.d.ts +22 -5
- package/dist/components/Button.js +2 -1
- package/dist/components/ByondUi.d.ts +50 -0
- package/dist/components/ByondUi.js +32 -44
- package/dist/components/ColorBox.js +1 -1
- package/dist/components/Dropdown.js +1 -1
- package/dist/components/Flex.js +1 -1
- package/dist/components/Icon.d.ts +1 -1
- package/dist/components/Icon.js +2 -2
- package/dist/components/Image.js +22 -21
- package/dist/components/ImageButton.js +1 -1
- package/dist/components/InfinitePlane.js +1 -1
- package/dist/components/Input.d.ts +6 -3
- package/dist/components/Input.js +60 -55
- package/dist/components/KeyListener.d.ts +2 -8
- package/dist/components/KeyListener.js +11 -19
- package/dist/components/Knob.js +1 -1
- package/dist/components/LabeledList.js +16 -15
- package/dist/components/Modal.js +1 -1
- package/dist/components/ProgressBar.js +1 -1
- package/dist/components/RoundGauge.d.ts +2 -1
- package/dist/components/RoundGauge.js +19 -18
- package/dist/components/Section.d.ts +43 -27
- package/dist/components/Section.js +64 -66
- package/dist/components/Slider.js +1 -1
- package/dist/components/Stack.js +1 -1
- package/dist/components/Table.js +1 -1
- package/dist/components/Tabs.js +1 -1
- package/dist/components/TextArea.d.ts +2 -1
- package/package.json +20 -12
|
@@ -1,43 +1,44 @@
|
|
|
1
1
|
import { jsxs as m, jsx as e } from "react/jsx-runtime";
|
|
2
2
|
import { scale as d, keyOfMatchingRange as M, clamp01 as k } from "../common/math.js";
|
|
3
|
-
import { classes as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
3
|
+
import { classes as p } from "../common/react.js";
|
|
4
|
+
import { computeBoxClassName as v, computeBoxProps as B } from "../common/ui.js";
|
|
5
|
+
import { AnimatedNumber as $ } from "./AnimatedNumber.js";
|
|
6
|
+
import { Box as j } from "./Box.js";
|
|
7
|
+
function z(h) {
|
|
7
8
|
const {
|
|
8
9
|
alertAfter: a,
|
|
9
10
|
alertBefore: t,
|
|
10
11
|
className: _,
|
|
11
12
|
format: R,
|
|
12
13
|
maxValue: c = 1,
|
|
13
|
-
minValue:
|
|
14
|
+
minValue: i = 1,
|
|
14
15
|
ranges: n,
|
|
15
16
|
size: y = 1,
|
|
16
17
|
style: x,
|
|
17
18
|
value: r,
|
|
18
19
|
...g
|
|
19
|
-
} =
|
|
20
|
+
} = h, G = d(r, i, c), f = k(G), l = n ? {} : { primary: [0, 1] };
|
|
20
21
|
n && Object.keys(n).forEach((o) => {
|
|
21
22
|
const s = n[o];
|
|
22
23
|
l[o] = [
|
|
23
|
-
d(s[0],
|
|
24
|
-
d(s[1],
|
|
24
|
+
d(s[0], i, c),
|
|
25
|
+
d(s[1], i, c)
|
|
25
26
|
];
|
|
26
27
|
});
|
|
27
28
|
function N() {
|
|
28
29
|
return !!(a && t && r > a && r < t || a && r > a || t && r < t);
|
|
29
30
|
}
|
|
30
31
|
const C = N() && M(f, l);
|
|
31
|
-
return /* @__PURE__ */ m(
|
|
32
|
+
return /* @__PURE__ */ m(j, { inline: !0, children: [
|
|
32
33
|
/* @__PURE__ */ e(
|
|
33
34
|
"div",
|
|
34
35
|
{
|
|
35
|
-
className:
|
|
36
|
+
className: p([
|
|
36
37
|
"RoundGauge",
|
|
37
38
|
_,
|
|
38
|
-
|
|
39
|
+
v(g)
|
|
39
40
|
]),
|
|
40
|
-
...
|
|
41
|
+
...B({
|
|
41
42
|
style: {
|
|
42
43
|
fontSize: `${y}em`,
|
|
43
44
|
...x
|
|
@@ -48,7 +49,7 @@ function w(p) {
|
|
|
48
49
|
(a || t) && /* @__PURE__ */ e(
|
|
49
50
|
"g",
|
|
50
51
|
{
|
|
51
|
-
className:
|
|
52
|
+
className: p([
|
|
52
53
|
"RoundGauge__alert",
|
|
53
54
|
C ? `active RoundGauge__alert--${C}` : ""
|
|
54
55
|
]),
|
|
@@ -57,18 +58,18 @@ function w(p) {
|
|
|
57
58
|
),
|
|
58
59
|
/* @__PURE__ */ e("g", { children: /* @__PURE__ */ e("circle", { className: "RoundGauge__ringTrack", cx: "50", cy: "50", r: "45" }) }),
|
|
59
60
|
/* @__PURE__ */ e("g", { children: Object.keys(l).map((o, s) => {
|
|
60
|
-
const
|
|
61
|
+
const u = l[o];
|
|
61
62
|
return /* @__PURE__ */ e(
|
|
62
63
|
"circle",
|
|
63
64
|
{
|
|
64
65
|
className: `RoundGauge__ringFill RoundGauge--color--${o}`,
|
|
65
66
|
style: {
|
|
66
67
|
strokeDashoffset: Math.max(
|
|
67
|
-
(2 - (
|
|
68
|
+
(2 - (u[1] - u[0])) * Math.PI * 50,
|
|
68
69
|
0
|
|
69
70
|
)
|
|
70
71
|
},
|
|
71
|
-
transform: `rotate(${180 + 180 *
|
|
72
|
+
transform: `rotate(${180 + 180 * u[0]} 50 50)`,
|
|
72
73
|
cx: "50",
|
|
73
74
|
cy: "50",
|
|
74
75
|
r: "45"
|
|
@@ -105,9 +106,9 @@ function w(p) {
|
|
|
105
106
|
] })
|
|
106
107
|
}
|
|
107
108
|
),
|
|
108
|
-
/* @__PURE__ */ e(
|
|
109
|
+
/* @__PURE__ */ e($, { value: r, format: R })
|
|
109
110
|
] });
|
|
110
111
|
}
|
|
111
112
|
export {
|
|
112
|
-
|
|
113
|
+
z as RoundGauge
|
|
113
114
|
};
|
|
@@ -1,29 +1,4 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
import { BoxProps } from './Box';
|
|
3
|
-
type Props = Partial<{
|
|
4
|
-
/** Buttons to render aside the section title. */
|
|
5
|
-
buttons: ReactNode;
|
|
6
|
-
/** id to assosiate with the parent div element used by this section, for uses with procs like getElementByID */
|
|
7
|
-
container_id: string;
|
|
8
|
-
/** If true, fills all available vertical space. */
|
|
9
|
-
fill: boolean;
|
|
10
|
-
/** If true, removes all section padding. */
|
|
11
|
-
fitted: boolean;
|
|
12
|
-
/** If true, fills the area without forcing height to 100% */
|
|
13
|
-
flexGrow: boolean;
|
|
14
|
-
/** If true, removes the section top padding */
|
|
15
|
-
noTopPadding: boolean;
|
|
16
|
-
/** @member Callback function for the `scroll` event */
|
|
17
|
-
onScroll: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
18
|
-
/** Shows or hides the scrollbar. */
|
|
19
|
-
scrollable: boolean;
|
|
20
|
-
/** Shows or hides the horizontal scrollbar. */
|
|
21
|
-
scrollableHorizontal: boolean;
|
|
22
|
-
/** If true, filly the area except for -3rem */
|
|
23
|
-
stretchContents: boolean;
|
|
24
|
-
/** Title of the section. */
|
|
25
|
-
title: ReactNode;
|
|
26
|
-
}> & BoxProps;
|
|
27
2
|
/**
|
|
28
3
|
* ## Section
|
|
29
4
|
* Section is a surface that displays content and actions on a single topic.
|
|
@@ -51,5 +26,46 @@ type Props = Partial<{
|
|
|
51
26
|
* </Section>
|
|
52
27
|
* ```
|
|
53
28
|
*/
|
|
54
|
-
export declare
|
|
55
|
-
|
|
29
|
+
export declare const Section: import('react').ForwardRefExoticComponent<Partial<{
|
|
30
|
+
/** Buttons to render aside the section title. */
|
|
31
|
+
buttons: ReactNode;
|
|
32
|
+
/** id to assosiate with the parent div element used by this section, for uses with procs like getElementByID */
|
|
33
|
+
container_id: string;
|
|
34
|
+
/** If true, fills all available vertical space. */
|
|
35
|
+
fill: boolean;
|
|
36
|
+
/** If true, removes all section padding. */
|
|
37
|
+
fitted: boolean;
|
|
38
|
+
/** If true, fills the area without forcing height to 100% */
|
|
39
|
+
flexGrow: boolean;
|
|
40
|
+
/** If true, removes the section top padding */
|
|
41
|
+
noTopPadding: boolean;
|
|
42
|
+
/** @member Callback function for the `scroll` event */
|
|
43
|
+
onScroll: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
44
|
+
/** Shows or hides the scrollbar. */
|
|
45
|
+
scrollable: boolean;
|
|
46
|
+
/** Shows or hides the horizontal scrollbar. */
|
|
47
|
+
scrollableHorizontal: boolean;
|
|
48
|
+
/** If true, filly the area except for -3rem */
|
|
49
|
+
stretchContents: boolean;
|
|
50
|
+
/** Title of the section. */
|
|
51
|
+
title: ReactNode;
|
|
52
|
+
}> & Partial<{
|
|
53
|
+
as: string;
|
|
54
|
+
children: ReactNode;
|
|
55
|
+
className: string | import('../common/react').BooleanLike;
|
|
56
|
+
id: string;
|
|
57
|
+
style: import('react').CSSProperties;
|
|
58
|
+
tw: string;
|
|
59
|
+
} & import('../common/ui').BooleanStyleMap & import('../common/ui').StringStyleMap & {
|
|
60
|
+
onClick: import('react').MouseEventHandler<HTMLDivElement>;
|
|
61
|
+
onContextMenu: import('react').MouseEventHandler<HTMLDivElement>;
|
|
62
|
+
onDoubleClick: import('react').MouseEventHandler<HTMLDivElement>;
|
|
63
|
+
onKeyDown: import('react').KeyboardEventHandler<HTMLDivElement>;
|
|
64
|
+
onKeyUp: import('react').KeyboardEventHandler<HTMLDivElement>;
|
|
65
|
+
onMouseDown: import('react').MouseEventHandler<HTMLDivElement>;
|
|
66
|
+
onMouseLeave: import('react').MouseEventHandler<HTMLDivElement>;
|
|
67
|
+
onMouseMove: import('react').MouseEventHandler<HTMLDivElement>;
|
|
68
|
+
onMouseOver: import('react').MouseEventHandler<HTMLDivElement>;
|
|
69
|
+
onMouseUp: import('react').MouseEventHandler<HTMLDivElement>;
|
|
70
|
+
onScroll: import('react').UIEventHandler<HTMLDivElement>;
|
|
71
|
+
}> & import('react').RefAttributes<HTMLDivElement>>;
|
|
@@ -1,68 +1,66 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useRef as
|
|
3
|
-
import { addScrollableNode as
|
|
4
|
-
import { classes as
|
|
5
|
-
import { computeBoxClassName as
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
/* @__PURE__ */ t("
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
b
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
);
|
|
65
|
-
}
|
|
1
|
+
import { jsxs as i, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as C, useRef as P, useEffect as g } from "react";
|
|
3
|
+
import { addScrollableNode as j, removeScrollableNode as w } from "../common/events.js";
|
|
4
|
+
import { classes as s, canRender as a } from "../common/react.js";
|
|
5
|
+
import { computeBoxClassName as z, computeBoxProps as B } from "../common/ui.js";
|
|
6
|
+
const q = C(
|
|
7
|
+
(d, m) => {
|
|
8
|
+
const {
|
|
9
|
+
buttons: o,
|
|
10
|
+
children: f,
|
|
11
|
+
className: S,
|
|
12
|
+
container_id: _ = "",
|
|
13
|
+
fill: u,
|
|
14
|
+
fitted: p,
|
|
15
|
+
flexGrow: N,
|
|
16
|
+
noTopPadding: h,
|
|
17
|
+
onScroll: b,
|
|
18
|
+
scrollable: n,
|
|
19
|
+
scrollableHorizontal: c,
|
|
20
|
+
stretchContents: x,
|
|
21
|
+
title: r,
|
|
22
|
+
...l
|
|
23
|
+
} = d, v = P(null), e = m || v, T = a(r) || a(o);
|
|
24
|
+
return g(() => (e != null && e.current && (n || c) && j(e.current), () => {
|
|
25
|
+
e != null && e.current && w(e.current);
|
|
26
|
+
}), []), /* @__PURE__ */ i(
|
|
27
|
+
"div",
|
|
28
|
+
{
|
|
29
|
+
id: _,
|
|
30
|
+
className: s([
|
|
31
|
+
"Section",
|
|
32
|
+
u && "Section--fill",
|
|
33
|
+
p && "Section--fitted",
|
|
34
|
+
n && "Section--scrollable",
|
|
35
|
+
c && "Section--scrollableHorizontal",
|
|
36
|
+
N && "Section--flex",
|
|
37
|
+
S,
|
|
38
|
+
z(l)
|
|
39
|
+
]),
|
|
40
|
+
...B(l),
|
|
41
|
+
children: [
|
|
42
|
+
T && /* @__PURE__ */ i("div", { className: "Section__title", children: [
|
|
43
|
+
/* @__PURE__ */ t("span", { className: "Section__titleText", children: r }),
|
|
44
|
+
/* @__PURE__ */ t("div", { className: "Section__buttons", children: o })
|
|
45
|
+
] }),
|
|
46
|
+
/* @__PURE__ */ t("div", { className: "Section__rest", children: /* @__PURE__ */ t(
|
|
47
|
+
"div",
|
|
48
|
+
{
|
|
49
|
+
className: s([
|
|
50
|
+
"Section__content",
|
|
51
|
+
x && "Section__content--stretchContents",
|
|
52
|
+
h && "Section__content--noTopPadding"
|
|
53
|
+
]),
|
|
54
|
+
onScroll: b,
|
|
55
|
+
ref: e,
|
|
56
|
+
children: f
|
|
57
|
+
}
|
|
58
|
+
) })
|
|
59
|
+
]
|
|
60
|
+
}
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
);
|
|
66
64
|
export {
|
|
67
|
-
|
|
65
|
+
q as Section
|
|
68
66
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as e, jsxs as m } from "react/jsx-runtime";
|
|
2
2
|
import { keyOfMatchingRange as O, clamp01 as r, scale as u } from "../common/math.js";
|
|
3
3
|
import { classes as p } from "../common/react.js";
|
|
4
|
-
import { computeBoxClassName as b, computeBoxProps as z } from "
|
|
4
|
+
import { computeBoxClassName as b, computeBoxProps as z } from "../common/ui.js";
|
|
5
5
|
import { DraggableControl as R } from "./DraggableControl.js";
|
|
6
6
|
function J(g) {
|
|
7
7
|
const {
|
package/dist/components/Stack.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as i } from "react/jsx-runtime";
|
|
2
2
|
import { classes as a } from "../common/react.js";
|
|
3
|
-
import { computeBoxClassName as o } from "
|
|
3
|
+
import { computeBoxClassName as o } from "../common/ui.js";
|
|
4
4
|
import { computeFlexClassName as k, computeFlexProps as v, computeFlexItemProps as m } from "./Flex.js";
|
|
5
5
|
function n(r) {
|
|
6
6
|
const { className: c, vertical: e, fill: t, reverse: s, zebra: l, ...d } = r, f = e ? "column" : "row", S = s ? "-reverse" : "";
|
package/dist/components/Table.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as c } from "react/jsx-runtime";
|
|
2
2
|
import { classes as r } from "../common/react.js";
|
|
3
|
-
import { computeBoxClassName as t, computeBoxProps as n } from "
|
|
3
|
+
import { computeBoxClassName as t, computeBoxProps as n } from "../common/ui.js";
|
|
4
4
|
function m(e) {
|
|
5
5
|
const { className: l, collapsing: a, children: s, ...o } = e;
|
|
6
6
|
return /* @__PURE__ */ c(
|
package/dist/components/Tabs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as a, jsxs as u } from "react/jsx-runtime";
|
|
2
2
|
import { classes as T, canRender as d } from "../common/react.js";
|
|
3
|
-
import { computeBoxClassName as f, computeBoxProps as h } from "
|
|
3
|
+
import { computeBoxClassName as f, computeBoxProps as h } from "../common/ui.js";
|
|
4
4
|
import { Icon as N } from "./Icon.js";
|
|
5
5
|
function v(l) {
|
|
6
6
|
const { className: c, vertical: i, fill: o, fluid: e, children: r, ...s } = l;
|
|
@@ -25,7 +25,8 @@ export declare const TextArea: import('react').ForwardRefExoticComponent<Partial
|
|
|
25
25
|
className: string | import('../common/react').BooleanLike;
|
|
26
26
|
id: string;
|
|
27
27
|
style: import('react').CSSProperties;
|
|
28
|
-
|
|
28
|
+
tw: string;
|
|
29
|
+
} & import('../common/ui').BooleanStyleMap & import('../common/ui').StringStyleMap & {
|
|
29
30
|
onClick: import('react').MouseEventHandler<HTMLDivElement>;
|
|
30
31
|
onContextMenu: import('react').MouseEventHandler<HTMLDivElement>;
|
|
31
32
|
onDoubleClick: import('react').MouseEventHandler<HTMLDivElement>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tgui-core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.1",
|
|
4
4
|
"description": "TGUI core component library",
|
|
5
5
|
"keywords": ["TGUI", "library", "typescript"],
|
|
6
6
|
"files": ["dist"],
|
|
@@ -12,6 +12,13 @@
|
|
|
12
12
|
"./*": {
|
|
13
13
|
"import": "./dist/common/*.js",
|
|
14
14
|
"require": "./dist/common/*.cjs"
|
|
15
|
+
},
|
|
16
|
+
"./styles": {
|
|
17
|
+
"default": "./lib/styles/main.scss",
|
|
18
|
+
"sass": "./lib/styles/main.scss"
|
|
19
|
+
},
|
|
20
|
+
"./styles/components/*": {
|
|
21
|
+
"sass": "./lib/styles/components/*"
|
|
15
22
|
}
|
|
16
23
|
},
|
|
17
24
|
"repository": {
|
|
@@ -31,27 +38,28 @@
|
|
|
31
38
|
"type": "module",
|
|
32
39
|
"devDependencies": {
|
|
33
40
|
"@biomejs/biome": "1.9.4",
|
|
34
|
-
"@chromatic-com/storybook": "3.2.
|
|
41
|
+
"@chromatic-com/storybook": "^3.2.3",
|
|
35
42
|
"@popperjs/core": "^2.11.8",
|
|
36
|
-
"@storybook/addon-
|
|
37
|
-
"@storybook/addon-
|
|
38
|
-
"@storybook/addon-
|
|
39
|
-
"@storybook/
|
|
40
|
-
"@storybook/
|
|
41
|
-
"@storybook/react
|
|
42
|
-
"@storybook/
|
|
43
|
+
"@storybook/addon-console": "^3.0.0",
|
|
44
|
+
"@storybook/addon-essentials": "^8.4.7",
|
|
45
|
+
"@storybook/addon-interactions": "^8.4.7",
|
|
46
|
+
"@storybook/addon-onboarding": "^8.4.7",
|
|
47
|
+
"@storybook/blocks": "^8.4.7",
|
|
48
|
+
"@storybook/react": "^8.4.7",
|
|
49
|
+
"@storybook/react-vite": "^8.4.7",
|
|
50
|
+
"@storybook/test": "^8.4.7",
|
|
43
51
|
"@types/node": "^22.9.0",
|
|
44
52
|
"@types/react": "^18.3.3",
|
|
45
53
|
"@types/react-dom": "^18.3.0",
|
|
46
54
|
"@types/webpack-env": "^1.18.5",
|
|
47
55
|
"@vitejs/plugin-react-swc": "^3.7.1",
|
|
56
|
+
"chromatic": "^11.18.1",
|
|
48
57
|
"glob": "^11.0.0",
|
|
49
58
|
"prettier": "^3.3.3",
|
|
50
59
|
"react-popper": "^2.3.0",
|
|
51
60
|
"sass": "^1.81.0",
|
|
52
|
-
"storybook": "8.4.
|
|
61
|
+
"storybook": "^8.4.7",
|
|
53
62
|
"storybook-addon-sass-postcss": "^0.3.2",
|
|
54
|
-
"tgui-styles": "^0.0.8",
|
|
55
63
|
"typescript": "^5.6.3",
|
|
56
64
|
"vite": "^5.4.11",
|
|
57
65
|
"vite-plugin-dts": "^4.3.0"
|
|
@@ -60,5 +68,5 @@
|
|
|
60
68
|
"react": "^18.2.0",
|
|
61
69
|
"react-dom": "^18.2.0"
|
|
62
70
|
},
|
|
63
|
-
"packageManager": "pnpm@9.
|
|
71
|
+
"packageManager": "pnpm@9.15.1+sha512.1acb565e6193efbebda772702950469150cf12bcc764262e7587e71d19dc98a423dff9536e57ea44c49bdf790ff694e83c27be5faa23d67e0c033b583be4bfcf"
|
|
64
72
|
}
|