tgui-core 1.4.0 → 1.5.2
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/components/AnimatedNumber.d.ts +1 -0
- package/dist/components/BlockQuote.d.ts +5 -0
- package/dist/components/Box.d.ts +1 -2
- package/dist/components/Button.d.ts +4 -5
- package/dist/components/ByondUi.d.ts +50 -0
- package/dist/components/ByondUi.js +32 -44
- package/dist/components/Collapsible.d.ts +6 -0
- package/dist/components/ColorBox.d.ts +8 -0
- package/dist/components/Dialog.d.ts +3 -9
- package/dist/components/Dialog.js +19 -35
- package/dist/components/Dimmer.d.ts +6 -0
- package/dist/components/Divider.d.ts +9 -0
- package/dist/components/DmIcon.d.ts +5 -0
- package/dist/components/Dropdown.d.ts +6 -1
- package/dist/components/Flex.d.ts +32 -0
- package/dist/components/Icon.d.ts +11 -11
- package/dist/components/Icon.js +1 -2
- package/dist/components/Image.d.ts +8 -0
- package/dist/components/ImageButton.d.ts +5 -1
- package/dist/components/KeyListener.d.ts +5 -0
- package/dist/components/LabeledControls.d.ts +16 -0
- package/dist/components/LabeledList.d.ts +27 -0
- package/dist/components/MenuBar.js +102 -121
- package/dist/components/Modal.d.ts +7 -0
- package/dist/components/NoticeBox.d.ts +4 -0
- package/dist/components/NumberInput.d.ts +29 -6
- package/dist/components/ProgressBar.d.ts +4 -0
- package/dist/components/Slider.d.ts +2 -3
- package/dist/components/Stack.d.ts +51 -0
- package/dist/components/Table.d.ts +20 -2
- package/dist/components/Table.js +1 -3
- package/dist/components/Tabs.d.ts +79 -10
- package/dist/components/Tooltip.d.ts +16 -0
- package/package.json +18 -12
- package/dist/components/MenuBar.d.ts +0 -27
package/README.md
CHANGED
|
@@ -11,11 +11,11 @@ You can view the code on [GitHub](https://github.com/tgstation/tgui-core).
|
|
|
11
11
|
(assuming you have a tgui folder, navigate to the specific package)
|
|
12
12
|
|
|
13
13
|
```sh
|
|
14
|
-
cd tgui/packages/
|
|
14
|
+
cd tgui/packages/{package name}
|
|
15
15
|
yarn add tgui-core
|
|
16
16
|
```
|
|
17
17
|
|
|
18
|
-
##
|
|
18
|
+
## Using the components
|
|
19
19
|
|
|
20
20
|
Now, you can use them like normal TGUI components.
|
|
21
21
|
|
|
@@ -32,6 +32,28 @@ import { Button } from "tgui-core/components";
|
|
|
32
32
|
import { Box } from "../components";
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
+
## Using the styles
|
|
36
|
+
|
|
37
|
+
You have two options for importing styles:
|
|
38
|
+
|
|
39
|
+
### 1. Importing All Styles
|
|
40
|
+
|
|
41
|
+
To import all styles at once, add the following line to your main Sass file:
|
|
42
|
+
|
|
43
|
+
```scss
|
|
44
|
+
@use "pkg:tgui-core/styles";
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### 2. Importing Individual Styles
|
|
48
|
+
|
|
49
|
+
To import individual styles, add any of the exported styles to your main Sass file:
|
|
50
|
+
|
|
51
|
+
```scss
|
|
52
|
+
@use "pkg:tgui-core/styles/components/Button";
|
|
53
|
+
@use "pkg:tgui-core/styles/components/Dialog";
|
|
54
|
+
@use "pkg:tgui-core/styles/components/NoticeBox";
|
|
55
|
+
```
|
|
56
|
+
|
|
35
57
|
## License
|
|
36
58
|
|
|
37
59
|
MIT
|
package/dist/components/Box.d.ts
CHANGED
|
@@ -56,8 +56,7 @@ type DangerDoNotUse = {
|
|
|
56
56
|
};
|
|
57
57
|
};
|
|
58
58
|
/**
|
|
59
|
-
*
|
|
60
|
-
*
|
|
59
|
+
* ## Box
|
|
61
60
|
* The Box component serves as a wrapper component for most of the CSS utility
|
|
62
61
|
* needs. It creates a new DOM element, a `<div>` by default that can be changed
|
|
63
62
|
* with the `as` property. Let's say you want to use a `<span>` instead:
|
|
@@ -54,7 +54,10 @@ type Props = Partial<{
|
|
|
54
54
|
/** Align content vertically using flex. Use lineHeight if the height is static. */
|
|
55
55
|
verticalAlignContent: string;
|
|
56
56
|
}> & EllipsisUnion & BoxProps;
|
|
57
|
-
/**
|
|
57
|
+
/**
|
|
58
|
+
* ## Button
|
|
59
|
+
* Buttons allow users to take actions, and make choices, with a single click.
|
|
60
|
+
*/
|
|
58
61
|
export declare function Button(props: Props): import("react/jsx-runtime").JSX.Element;
|
|
59
62
|
export declare namespace Button {
|
|
60
63
|
var Checkbox: typeof ButtonCheckbox;
|
|
@@ -65,14 +68,12 @@ export declare namespace Button {
|
|
|
65
68
|
type CheckProps = Partial<{
|
|
66
69
|
checked: BooleanLike;
|
|
67
70
|
}> & Props;
|
|
68
|
-
/** Visually toggles between checked and unchecked states. */
|
|
69
71
|
export declare function ButtonCheckbox(props: CheckProps): import("react/jsx-runtime").JSX.Element;
|
|
70
72
|
type ConfirmProps = Partial<{
|
|
71
73
|
confirmColor: string;
|
|
72
74
|
confirmContent: ReactNode;
|
|
73
75
|
confirmIcon: string;
|
|
74
76
|
}> & Props;
|
|
75
|
-
/** Requires user confirmation before triggering its action. */
|
|
76
77
|
declare function ButtonConfirm(props: ConfirmProps): import("react/jsx-runtime").JSX.Element;
|
|
77
78
|
type InputProps = Partial<{
|
|
78
79
|
currentValue: string;
|
|
@@ -82,13 +83,11 @@ type InputProps = Partial<{
|
|
|
82
83
|
onCommit: (e: any, value: string) => void;
|
|
83
84
|
placeholder: string;
|
|
84
85
|
}> & Props;
|
|
85
|
-
/** Accepts and handles user input. */
|
|
86
86
|
declare function ButtonInput(props: InputProps): import("react/jsx-runtime").JSX.Element;
|
|
87
87
|
type FileProps = {
|
|
88
88
|
accept: string;
|
|
89
89
|
multiple?: boolean;
|
|
90
90
|
onSelectFiles: (files: string | string[]) => void;
|
|
91
91
|
} & Props;
|
|
92
|
-
/** Accepts file input */
|
|
93
92
|
declare function ButtonFile(props: FileProps): import("react/jsx-runtime").JSX.Element;
|
|
94
93
|
export {};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { BoxProps } from './Box';
|
|
2
|
+
type SampleByondParams = Partial<{
|
|
3
|
+
/** Can be auto-generated. */
|
|
4
|
+
id: string;
|
|
5
|
+
/** Defaults to the current window */
|
|
6
|
+
parent: string;
|
|
7
|
+
/** The type of control. Read-only. */
|
|
8
|
+
type: string;
|
|
9
|
+
/** Text shown in label/button/input. For input controls this setting is only available at runtime. */
|
|
10
|
+
text: string;
|
|
11
|
+
}>;
|
|
12
|
+
type Props = Partial<{
|
|
13
|
+
/** An object with parameters, which are directly passed to
|
|
14
|
+
* the `winset` proc call.
|
|
15
|
+
*
|
|
16
|
+
* You can find a full reference of these parameters
|
|
17
|
+
* in [BYOND controls and parameters guide](https://secure.byond.com/docs/ref/skinparams.html). */
|
|
18
|
+
params: SampleByondParams & Record<string, any>;
|
|
19
|
+
}> & BoxProps;
|
|
20
|
+
/**
|
|
21
|
+
* ## ByondUi
|
|
22
|
+
* Displays a BYOND UI element on top of the browser, and leverages browser's
|
|
23
|
+
* layout engine to position it just like any other HTML element. It is
|
|
24
|
+
* especially useful if you want to display a secondary game map in your
|
|
25
|
+
* interface.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```tsx
|
|
29
|
+
* <ByondUi
|
|
30
|
+
* params={{
|
|
31
|
+
* id: 'test_button', // optional, can be auto-generated
|
|
32
|
+
* parent: 'some_container', // optional, defaults to the current window
|
|
33
|
+
* type: 'button',
|
|
34
|
+
* text: 'Hello, world!',
|
|
35
|
+
* }} />
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```tsx
|
|
40
|
+
* <ByondUi
|
|
41
|
+
* params={{
|
|
42
|
+
* id: 'test_map',
|
|
43
|
+
* type: 'map',
|
|
44
|
+
* }} />
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* It supports a full set of `Box` properties for layout purposes.
|
|
48
|
+
*/
|
|
49
|
+
export declare function ByondUi(props: Props): import("react/jsx-runtime").JSX.Element;
|
|
50
|
+
export {};
|
|
@@ -1,19 +1,18 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import {
|
|
3
|
-
import { shallowDiffers as r } from "../common/react.js";
|
|
1
|
+
import { jsx as l } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as f, useEffect as p } from "react";
|
|
4
3
|
import { debounce as m } from "../common/timer.js";
|
|
5
|
-
import { computeBoxProps as
|
|
4
|
+
import { computeBoxProps as w } from "../common/ui.js";
|
|
6
5
|
const o = [];
|
|
7
|
-
function
|
|
8
|
-
const
|
|
6
|
+
function a(t) {
|
|
7
|
+
const e = o.length;
|
|
9
8
|
o.push(null);
|
|
10
|
-
const
|
|
9
|
+
const n = t || `byondui_${e}`;
|
|
11
10
|
return {
|
|
12
11
|
render: (i) => {
|
|
13
|
-
o[
|
|
12
|
+
o[e] = n, Byond.winset(n, i);
|
|
14
13
|
},
|
|
15
14
|
unmount: () => {
|
|
16
|
-
o[
|
|
15
|
+
o[e] = null, Byond.winset(n, {
|
|
17
16
|
parent: ""
|
|
18
17
|
});
|
|
19
18
|
}
|
|
@@ -21,53 +20,42 @@ function h(t) {
|
|
|
21
20
|
}
|
|
22
21
|
window.addEventListener("beforeunload", () => {
|
|
23
22
|
for (let t = 0; t < o.length; t++) {
|
|
24
|
-
const
|
|
25
|
-
typeof
|
|
23
|
+
const e = o[t];
|
|
24
|
+
typeof e == "string" && (o[t] = null, Byond.winset(e, {
|
|
26
25
|
parent: ""
|
|
27
26
|
}));
|
|
28
27
|
}
|
|
29
28
|
});
|
|
30
|
-
function
|
|
31
|
-
const
|
|
29
|
+
function x(t) {
|
|
30
|
+
const e = window.devicePixelRatio ?? 1, n = t.getBoundingClientRect();
|
|
32
31
|
return {
|
|
33
|
-
pos: [
|
|
32
|
+
pos: [n.left * e, n.top * e],
|
|
34
33
|
size: [
|
|
35
|
-
(
|
|
36
|
-
(
|
|
34
|
+
(n.right - n.left) * e,
|
|
35
|
+
(n.bottom - n.top) * e
|
|
37
36
|
]
|
|
38
37
|
};
|
|
39
38
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
shouldComponentUpdate(n) {
|
|
48
|
-
const { params: e = {}, ...i } = this.props, { params: d = {}, ...p } = n;
|
|
49
|
-
return r(e, d) || r(i, p);
|
|
50
|
-
}
|
|
51
|
-
componentDidMount() {
|
|
52
|
-
window.addEventListener("resize", this.handleResize), this.componentDidUpdate(), this.handleResize();
|
|
53
|
-
}
|
|
54
|
-
componentDidUpdate() {
|
|
55
|
-
const { params: n = {} } = this.props, e = u(this.containerRef.current);
|
|
56
|
-
this.byondUiElement.render({
|
|
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({
|
|
57
46
|
parent: Byond.windowId,
|
|
58
|
-
...
|
|
59
|
-
pos: `${
|
|
60
|
-
size: `${
|
|
47
|
+
...e,
|
|
48
|
+
pos: `${r.pos[0]},${r.pos[1]}`,
|
|
49
|
+
size: `${r.size[0]}x${r.size[1]}`
|
|
61
50
|
});
|
|
62
51
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
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" } }) });
|
|
70
58
|
}
|
|
71
59
|
export {
|
|
72
|
-
|
|
60
|
+
h as ByondUi
|
|
73
61
|
};
|
|
@@ -12,5 +12,11 @@ type Props = Partial<{
|
|
|
12
12
|
/** Text to display on the button for collapsing */
|
|
13
13
|
title: ReactNode;
|
|
14
14
|
}> & BoxProps;
|
|
15
|
+
/**
|
|
16
|
+
* ## Collapsible
|
|
17
|
+
* Displays contents when open, acts as a fluid button when closed.
|
|
18
|
+
*
|
|
19
|
+
* Click to toggle, closed by default.
|
|
20
|
+
*/
|
|
15
21
|
export declare function Collapsible(props: Props): import("react/jsx-runtime").JSX.Element;
|
|
16
22
|
export {};
|
|
@@ -3,5 +3,13 @@ import { BoxProps } from './Box';
|
|
|
3
3
|
type Props = {
|
|
4
4
|
content?: ReactNode;
|
|
5
5
|
} & BoxProps;
|
|
6
|
+
/**
|
|
7
|
+
* ## ColorBox
|
|
8
|
+
* Displays a 1-character wide colored square. Can be used as a status indicator,
|
|
9
|
+
* or for visually representing a color.
|
|
10
|
+
*
|
|
11
|
+
* If you want to set a background color on an element, use a plain
|
|
12
|
+
* [Box](https://github.com/tgstation/tgui-core/tree/main/lib/components/Box.tsx) instead.
|
|
13
|
+
*/
|
|
6
14
|
export declare function ColorBox(props: Props): import("react/jsx-runtime").JSX.Element;
|
|
7
15
|
export {};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
1
2
|
type DialogProps = {
|
|
2
|
-
children:
|
|
3
|
+
children: ReactNode;
|
|
3
4
|
height?: string;
|
|
4
5
|
onClose: () => void;
|
|
5
|
-
title:
|
|
6
|
+
title: ReactNode;
|
|
6
7
|
width?: string;
|
|
7
8
|
};
|
|
8
9
|
export declare function Dialog(props: DialogProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -14,11 +15,4 @@ type DialogButtonProps = {
|
|
|
14
15
|
onClick: () => void;
|
|
15
16
|
};
|
|
16
17
|
declare function DialogButton(props: DialogButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
17
|
-
type UnsavedChangesDialogProps = {
|
|
18
|
-
documentName: string;
|
|
19
|
-
onClose: () => void;
|
|
20
|
-
onDiscard: () => void;
|
|
21
|
-
onSave: () => void;
|
|
22
|
-
};
|
|
23
|
-
export declare function UnsavedChangesDialog(props: UnsavedChangesDialogProps): import("react/jsx-runtime").JSX.Element;
|
|
24
18
|
export {};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { Box as
|
|
3
|
-
import { Button as
|
|
4
|
-
function d(
|
|
5
|
-
const { title:
|
|
6
|
-
return /* @__PURE__ */
|
|
7
|
-
/* @__PURE__ */
|
|
8
|
-
/* @__PURE__ */
|
|
9
|
-
/* @__PURE__ */
|
|
10
|
-
|
|
1
|
+
import { jsx as t, jsxs as l } from "react/jsx-runtime";
|
|
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
11
|
{
|
|
12
12
|
mr: "-3px",
|
|
13
13
|
width: "26px",
|
|
@@ -17,42 +17,26 @@ function d(i) {
|
|
|
17
17
|
icon: "window-close-o",
|
|
18
18
|
tooltip: "Close",
|
|
19
19
|
tooltipPosition: "bottom-start",
|
|
20
|
-
onClick:
|
|
20
|
+
onClick: n
|
|
21
21
|
}
|
|
22
22
|
) })
|
|
23
23
|
] }),
|
|
24
24
|
c
|
|
25
25
|
] }) });
|
|
26
26
|
}
|
|
27
|
-
function
|
|
28
|
-
const { onClick:
|
|
29
|
-
return /* @__PURE__ */
|
|
30
|
-
|
|
27
|
+
function m(o) {
|
|
28
|
+
const { onClick: i, children: n } = o;
|
|
29
|
+
return /* @__PURE__ */ t(
|
|
30
|
+
r,
|
|
31
31
|
{
|
|
32
|
-
onClick:
|
|
32
|
+
onClick: i,
|
|
33
33
|
className: "Dialog__button",
|
|
34
34
|
verticalAlignContent: "middle",
|
|
35
|
-
children:
|
|
35
|
+
children: n
|
|
36
36
|
}
|
|
37
37
|
);
|
|
38
38
|
}
|
|
39
|
-
d.Button =
|
|
40
|
-
function p(i) {
|
|
41
|
-
const { documentName: n, onSave: t, onDiscard: c, onClose: l } = i;
|
|
42
|
-
return /* @__PURE__ */ e(d, { title: "Notepad", onClose: l, children: [
|
|
43
|
-
/* @__PURE__ */ e("div", { className: "Dialog__body", children: [
|
|
44
|
-
"Do you want to save changes to ",
|
|
45
|
-
n,
|
|
46
|
-
"?"
|
|
47
|
-
] }),
|
|
48
|
-
/* @__PURE__ */ e("div", { className: "Dialog__footer", children: [
|
|
49
|
-
/* @__PURE__ */ o(a, { onClick: t, children: "Save" }),
|
|
50
|
-
/* @__PURE__ */ o(a, { onClick: c, children: "Don't Save" }),
|
|
51
|
-
/* @__PURE__ */ o(a, { onClick: l, children: "Cancel" })
|
|
52
|
-
] })
|
|
53
|
-
] });
|
|
54
|
-
}
|
|
39
|
+
d.Button = m;
|
|
55
40
|
export {
|
|
56
|
-
d as Dialog
|
|
57
|
-
p as UnsavedChangesDialog
|
|
41
|
+
d as Dialog
|
|
58
42
|
};
|
|
@@ -1,2 +1,8 @@
|
|
|
1
1
|
import { BoxProps } from './Box';
|
|
2
|
+
/**
|
|
3
|
+
* ## Dimmer
|
|
4
|
+
* Dims surrounding area to emphasize content placed inside.
|
|
5
|
+
*
|
|
6
|
+
* Content is automatically centered inside the dimmer.
|
|
7
|
+
*/
|
|
2
8
|
export declare function Dimmer(props: BoxProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
type Props = Partial<{
|
|
2
|
+
/** Removes the line, simply adding a gap. */
|
|
2
3
|
hidden: boolean;
|
|
4
|
+
/** Rotate the divider to vertical. */
|
|
3
5
|
vertical: boolean;
|
|
4
6
|
}>;
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
* ## Dimmer
|
|
10
|
+
* Dims surrounding area to emphasize content placed inside.
|
|
11
|
+
*
|
|
12
|
+
* Content is automatically centered inside the dimmer.
|
|
13
|
+
*/
|
|
5
14
|
export declare function Divider(props: Props): import("react/jsx-runtime").JSX.Element;
|
|
6
15
|
export {};
|
|
@@ -25,5 +25,10 @@ type Props = {
|
|
|
25
25
|
/** Movement state. Default is false */
|
|
26
26
|
movement: any;
|
|
27
27
|
}> & BoxProps;
|
|
28
|
+
/**
|
|
29
|
+
* ## DmIcon
|
|
30
|
+
* Displays an icon from the BYOND icon reference map. Requires Byond 515+.
|
|
31
|
+
* A much faster alternative to base64 icons.
|
|
32
|
+
*/
|
|
28
33
|
export declare function DmIcon(props: Props): string | number | boolean | Iterable<ReactNode> | import("react/jsx-runtime").JSX.Element | null | undefined;
|
|
29
34
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import { BoxProps } from './Box';
|
|
3
|
-
|
|
3
|
+
type DropdownEntry = {
|
|
4
4
|
displayText: ReactNode;
|
|
5
5
|
value: string | number;
|
|
6
6
|
};
|
|
@@ -43,5 +43,10 @@ type Props = {
|
|
|
43
43
|
/** Text to show when nothing has been selected. */
|
|
44
44
|
placeholder: string;
|
|
45
45
|
}> & BoxProps;
|
|
46
|
+
/**
|
|
47
|
+
* ## Dropdown
|
|
48
|
+
* A simple dropdown box component. Lets the user select from a list of options
|
|
49
|
+
* and displays selected entry.
|
|
50
|
+
*/
|
|
46
51
|
export declare function Dropdown(props: Props): import("react/jsx-runtime").JSX.Element;
|
|
47
52
|
export {};
|
|
@@ -55,6 +55,38 @@ export type FlexProps = Partial<{
|
|
|
55
55
|
}> & BoxProps;
|
|
56
56
|
export declare function computeFlexClassName(props: FlexProps): string;
|
|
57
57
|
export declare function computeFlexProps(props: FlexProps): Record<string, any>;
|
|
58
|
+
/**
|
|
59
|
+
* ## Flex
|
|
60
|
+
* Quickly manage the layout, alignment, and sizing of grid columns, navigation,
|
|
61
|
+
* components, and more with a full suite of responsive flexbox utilities.
|
|
62
|
+
*
|
|
63
|
+
* If you are new to or unfamiliar with flexbox, we encourage you to read this
|
|
64
|
+
* [CSS-Tricks flexbox guide](https://css-tricks.com/snippets/css/a-guide-to-flexbox/).
|
|
65
|
+
*
|
|
66
|
+
* Consists of two elements: `<Flex>` and `<Flex.Item>`. Both of them provide
|
|
67
|
+
* the most straight-forward mapping to flex CSS properties as possible.
|
|
68
|
+
*
|
|
69
|
+
* One of the most basic usage of flex, is to align certain elements
|
|
70
|
+
* to the left, and certain elements to the right:
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```tsx
|
|
74
|
+
* <Flex>
|
|
75
|
+
* <Flex.Item grow>Button description</Flex.Item>
|
|
76
|
+
* <Flex.Item>
|
|
77
|
+
* <Button>Perform an action</Button>
|
|
78
|
+
* </Flex.Item>
|
|
79
|
+
* </Flex>
|
|
80
|
+
* ```
|
|
81
|
+
*
|
|
82
|
+
* Flex item with `grow` property will grow to take all available empty space,
|
|
83
|
+
* while flex items without grow will take the minimum amount of space. This
|
|
84
|
+
* effectively places the last flex item to the very end of the flex container.
|
|
85
|
+
*
|
|
86
|
+
* @deprecated - Use
|
|
87
|
+
* [Stack](https://github.com/tgstation/tgui-core/tree/main/lib/components/Stack.tsx)
|
|
88
|
+
* where possible.
|
|
89
|
+
*/
|
|
58
90
|
export declare function Flex(props: any): import("react/jsx-runtime").JSX.Element;
|
|
59
91
|
export declare namespace Flex {
|
|
60
92
|
var Item: typeof FlexItem;
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import { CSSProperties, ReactNode } from 'react';
|
|
2
1
|
import { BooleanLike } from '../common/react';
|
|
3
2
|
import { BoxProps } from './Box';
|
|
4
3
|
type Props = {
|
|
5
4
|
/** Icon name. See [icon list](https://fontawesome.com/v5/search?o=r&m=free) */
|
|
6
5
|
name: string;
|
|
7
6
|
} & Partial<{
|
|
8
|
-
/** Custom CSS class. */
|
|
9
|
-
className: string;
|
|
10
7
|
/** Icon rotation, in degrees. */
|
|
11
8
|
rotation: number;
|
|
12
9
|
/** Icon size. `1` is normal size, `2` is two times bigger. Fractional numbers are supported. */
|
|
13
10
|
size: number;
|
|
14
11
|
/** Whether an icon should be spinning. Good for load indicators. */
|
|
15
12
|
spin: BooleanLike;
|
|
16
|
-
/** Custom CSS. */
|
|
17
|
-
style: CSSProperties;
|
|
18
13
|
}> & Omit<BoxProps, 'children'>;
|
|
14
|
+
/**
|
|
15
|
+
* ## Icon
|
|
16
|
+
* Renders one of the FontAwesome icons of your choice.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```tsx
|
|
20
|
+
* <Icon name="plus" />
|
|
21
|
+
* ```
|
|
22
|
+
* @url https://fontawesome.com/v5/search?o=r&m=free
|
|
23
|
+
*/
|
|
19
24
|
export declare function Icon(props: Props): import("react/jsx-runtime").JSX.Element;
|
|
20
25
|
export declare namespace Icon {
|
|
21
26
|
var Stack: typeof IconStack;
|
|
22
27
|
}
|
|
23
|
-
|
|
24
|
-
children: ReactNode;
|
|
25
|
-
className?: string;
|
|
26
|
-
};
|
|
27
|
-
export type IconStackProps = IconStackUnique & BoxProps;
|
|
28
|
-
export declare function IconStack(props: IconStackProps): import("react/jsx-runtime").JSX.Element;
|
|
28
|
+
declare function IconStack(props: BoxProps): import("react/jsx-runtime").JSX.Element;
|
|
29
29
|
export {};
|
package/dist/components/Icon.js
CHANGED
|
@@ -9,5 +9,13 @@ type Props = Partial<{
|
|
|
9
9
|
objectFit: 'contain' | 'cover';
|
|
10
10
|
src: string;
|
|
11
11
|
}> & BoxProps;
|
|
12
|
+
/**
|
|
13
|
+
* ## Image
|
|
14
|
+
* A wrapper for the `<img>` element.
|
|
15
|
+
*
|
|
16
|
+
* By default, it will attempt to fix broken images by fetching them again.
|
|
17
|
+
*
|
|
18
|
+
* It will also try to fix blurry images by rendering them pixelated.
|
|
19
|
+
*/
|
|
12
20
|
export declare function Image(props: Props): import("react/jsx-runtime").JSX.Element;
|
|
13
21
|
export {};
|
|
@@ -24,7 +24,11 @@ type Props = Partial<{
|
|
|
24
24
|
children: ReactNode;
|
|
25
25
|
/** Applies a CSS class to the element. */
|
|
26
26
|
className: string;
|
|
27
|
-
/**
|
|
27
|
+
/**
|
|
28
|
+
* Color of the button. See
|
|
29
|
+
* [Button](https://github.com/tgstation/tgui-core/tree/main/lib/components/Button.tsx)
|
|
30
|
+
* but without `transparent`.
|
|
31
|
+
*/
|
|
28
32
|
color: string;
|
|
29
33
|
/** Makes button disabled and dark red if true. Also disables onClick. */
|
|
30
34
|
disabled: BooleanLike;
|
|
@@ -4,5 +4,10 @@ type Props = Partial<{
|
|
|
4
4
|
onKeyDown: (key: KeyEvent) => void;
|
|
5
5
|
onKeyUp: (key: KeyEvent) => void;
|
|
6
6
|
}>;
|
|
7
|
+
/**
|
|
8
|
+
* ## KeyListener
|
|
9
|
+
* A component that listens for keyboard events and calls the provided
|
|
10
|
+
* callbacks.
|
|
11
|
+
*/
|
|
7
12
|
export declare function KeyListener(props: Props): null;
|
|
8
13
|
export {};
|
|
@@ -1,4 +1,20 @@
|
|
|
1
1
|
import { FlexProps } from './Flex';
|
|
2
|
+
/**
|
|
3
|
+
* ## LabeledControls
|
|
4
|
+
* LabeledControls is a horizontal grid that is designed to hold various
|
|
5
|
+
* controls, like [Knobs](https://github.com/tgstation/tgui-core/tree/main/lib/components/Knob.tsx)
|
|
6
|
+
* or small [Buttons](https://github.com/tgstation/tgui-core/tree/main/lib/components/Button.tsx).
|
|
7
|
+
*
|
|
8
|
+
* Every item in this grid is labeled at the bottom.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```tsx
|
|
12
|
+
* <LabeledControls>
|
|
13
|
+
* <LabeledControls.Item label="Temperature"><Knob /></LabeledControls.Item>
|
|
14
|
+
* <LabeledControls.Item label="Submit"><Button /></LabeledControls.Item>
|
|
15
|
+
* </LabeledControls>
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
2
18
|
export declare function LabeledControls(props: FlexProps): import("react/jsx-runtime").JSX.Element;
|
|
3
19
|
export declare namespace LabeledControls {
|
|
4
20
|
var Item: typeof LabeledControlsItem;
|
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
import { PropsWithChildren, ReactNode } from 'react';
|
|
2
2
|
import { BooleanLike } from '../common/react';
|
|
3
|
+
/**
|
|
4
|
+
* ## LabeledList
|
|
5
|
+
* LabeledList is a continuous, vertical list of text and other content, where
|
|
6
|
+
* every item is labeled.
|
|
7
|
+
*
|
|
8
|
+
* It works just like a two column table, where first column is labels, and
|
|
9
|
+
* second column is content.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```tsx
|
|
13
|
+
* <LabeledList>
|
|
14
|
+
* <LabeledList.Item label="Item">Content</LabeledList.Item>
|
|
15
|
+
* </LabeledList>
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* If you want to have a button on the right side of an item (for example,
|
|
19
|
+
* to perform some sort of action), there is a way to do that:
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```tsx
|
|
23
|
+
* <LabeledList>
|
|
24
|
+
* <LabeledList.Item label="Item" buttons={<Button>Click me!</Button>}>
|
|
25
|
+
* Content
|
|
26
|
+
* </LabeledList.Item>
|
|
27
|
+
* </LabeledList>
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
3
30
|
export declare function LabeledList(props: PropsWithChildren): import("react/jsx-runtime").JSX.Element;
|
|
4
31
|
export declare namespace LabeledList {
|
|
5
32
|
var Item: typeof LabeledListItem;
|