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
|
@@ -1,165 +1,146 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import { jsx as o, jsxs as f } from "react/jsx-runtime";
|
|
5
|
-
import { Component as B, createRef as N } from "react";
|
|
6
|
-
import { classes as M } from "../common/react.js";
|
|
1
|
+
import { jsx as t, jsxs as p } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as B, useEffect as h } from "react";
|
|
3
|
+
import { classes as _ } from "../common/react.js";
|
|
7
4
|
import { Box as l } from "./Box.js";
|
|
8
|
-
import { Icon as
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
this.props.menuRef.current && (this.props.menuRef.current.contains(t.target) || this.props.onOutsideClick());
|
|
15
|
-
};
|
|
5
|
+
import { Icon as v } from "./Icon.js";
|
|
6
|
+
function k(n) {
|
|
7
|
+
const { children: e, menuRef: o, onOutsideClick: r, width: a } = n;
|
|
8
|
+
function u(i) {
|
|
9
|
+
var c;
|
|
10
|
+
(c = o.current) != null && c.contains(i.target) || r();
|
|
16
11
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
12
|
+
return h(() => (document.addEventListener("click", u), () => {
|
|
13
|
+
document.removeEventListener("click", u);
|
|
14
|
+
}), []), /* @__PURE__ */ t(
|
|
15
|
+
"div",
|
|
16
|
+
{
|
|
17
|
+
className: "Menubar__menu",
|
|
18
|
+
style: {
|
|
19
|
+
width: a
|
|
20
|
+
},
|
|
21
|
+
children: e
|
|
22
|
+
}
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
function N(n) {
|
|
26
|
+
const {
|
|
27
|
+
children: e,
|
|
28
|
+
className: o,
|
|
29
|
+
disabled: r,
|
|
30
|
+
display: a,
|
|
31
|
+
onClick: u,
|
|
32
|
+
onMouseOver: i,
|
|
33
|
+
open: c,
|
|
34
|
+
openWidth: s,
|
|
35
|
+
onOutsideClick: m,
|
|
36
|
+
...M
|
|
37
|
+
} = n, f = B(null);
|
|
38
|
+
return /* @__PURE__ */ p("div", { ref: f, children: [
|
|
39
|
+
/* @__PURE__ */ t(
|
|
40
|
+
l,
|
|
27
41
|
{
|
|
28
|
-
className:
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
42
|
+
className: _([
|
|
43
|
+
"MenuBar__MenuBarButton",
|
|
44
|
+
"MenuBar__font",
|
|
45
|
+
"MenuBar__hover",
|
|
46
|
+
o
|
|
47
|
+
]),
|
|
48
|
+
...M,
|
|
49
|
+
onClick: r ? () => null : u,
|
|
50
|
+
onMouseOver: i,
|
|
51
|
+
children: /* @__PURE__ */ t("span", { className: "MenuBar__MenuBarButton-text", children: a })
|
|
33
52
|
}
|
|
34
|
-
)
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
open: t,
|
|
46
|
-
openWidth: s,
|
|
47
|
-
children: i,
|
|
48
|
-
disabled: c,
|
|
49
|
-
display: u,
|
|
50
|
-
onMouseOver: a,
|
|
51
|
-
onClick: m,
|
|
52
|
-
onOutsideClick: p,
|
|
53
|
-
..._
|
|
54
|
-
} = n, { className: k, ...v } = _;
|
|
55
|
-
return /* @__PURE__ */ f("div", { ref: this.menuRef, children: [
|
|
56
|
-
/* @__PURE__ */ o(
|
|
57
|
-
l,
|
|
58
|
-
{
|
|
59
|
-
className: M([
|
|
60
|
-
"MenuBar__MenuBarButton",
|
|
61
|
-
"MenuBar__font",
|
|
62
|
-
"MenuBar__hover",
|
|
63
|
-
k
|
|
64
|
-
]),
|
|
65
|
-
...v,
|
|
66
|
-
onClick: c ? () => null : m,
|
|
67
|
-
onMouseOver: a,
|
|
68
|
-
children: /* @__PURE__ */ o("span", { className: "MenuBar__MenuBarButton-text", children: u })
|
|
69
|
-
}
|
|
70
|
-
),
|
|
71
|
-
t && /* @__PURE__ */ o(
|
|
72
|
-
I,
|
|
73
|
-
{
|
|
74
|
-
width: s,
|
|
75
|
-
menuRef: this.menuRef,
|
|
76
|
-
onOutsideClick: p,
|
|
77
|
-
children: i
|
|
78
|
-
}
|
|
79
|
-
)
|
|
80
|
-
] });
|
|
81
|
-
}
|
|
53
|
+
),
|
|
54
|
+
c && /* @__PURE__ */ t(
|
|
55
|
+
k,
|
|
56
|
+
{
|
|
57
|
+
width: s,
|
|
58
|
+
menuRef: this.menuRef,
|
|
59
|
+
onOutsideClick: m,
|
|
60
|
+
children: e
|
|
61
|
+
}
|
|
62
|
+
)
|
|
63
|
+
] });
|
|
82
64
|
}
|
|
83
|
-
function d(
|
|
65
|
+
function d(n) {
|
|
84
66
|
const {
|
|
85
67
|
entry: e,
|
|
86
|
-
children:
|
|
87
|
-
openWidth:
|
|
88
|
-
display:
|
|
89
|
-
setOpenMenuBar:
|
|
90
|
-
openMenuBar:
|
|
91
|
-
setOpenOnHover:
|
|
92
|
-
openOnHover:
|
|
68
|
+
children: o,
|
|
69
|
+
openWidth: r,
|
|
70
|
+
display: a,
|
|
71
|
+
setOpenMenuBar: u,
|
|
72
|
+
openMenuBar: i,
|
|
73
|
+
setOpenOnHover: c,
|
|
74
|
+
openOnHover: s,
|
|
93
75
|
disabled: m,
|
|
94
|
-
className:
|
|
95
|
-
} =
|
|
96
|
-
return /* @__PURE__ */
|
|
97
|
-
|
|
76
|
+
className: M
|
|
77
|
+
} = n;
|
|
78
|
+
return /* @__PURE__ */ t(
|
|
79
|
+
N,
|
|
98
80
|
{
|
|
99
|
-
openWidth:
|
|
100
|
-
display:
|
|
81
|
+
openWidth: r,
|
|
82
|
+
display: a,
|
|
101
83
|
disabled: m,
|
|
102
|
-
open:
|
|
103
|
-
className:
|
|
84
|
+
open: i === e,
|
|
85
|
+
className: M,
|
|
104
86
|
onClick: () => {
|
|
105
|
-
i
|
|
87
|
+
u(i === e ? null : e), c(!s);
|
|
106
88
|
},
|
|
107
89
|
onOutsideClick: () => {
|
|
108
|
-
|
|
90
|
+
u(null), c(!1);
|
|
109
91
|
},
|
|
110
92
|
onMouseOver: () => {
|
|
111
|
-
|
|
93
|
+
s && u(e);
|
|
112
94
|
},
|
|
113
|
-
children:
|
|
95
|
+
children: o
|
|
114
96
|
}
|
|
115
97
|
);
|
|
116
98
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
99
|
+
O.Dropdown = d;
|
|
100
|
+
function g(n) {
|
|
101
|
+
const { value: e, displayText: o, onClick: r, checked: a } = n;
|
|
102
|
+
return /* @__PURE__ */ p(
|
|
120
103
|
l,
|
|
121
104
|
{
|
|
122
|
-
className:
|
|
105
|
+
className: _([
|
|
123
106
|
"MenuBar__font",
|
|
124
107
|
"MenuBar__MenuItem",
|
|
125
108
|
"MenuBar__MenuItemToggle",
|
|
126
109
|
"MenuBar__hover"
|
|
127
110
|
]),
|
|
128
|
-
onClick: () =>
|
|
111
|
+
onClick: () => r(e),
|
|
129
112
|
children: [
|
|
130
|
-
/* @__PURE__ */
|
|
131
|
-
|
|
113
|
+
/* @__PURE__ */ t("div", { className: "MenuBar__MenuItemToggle__check", children: a && /* @__PURE__ */ t(v, { size: 1.3, name: "check" }) }),
|
|
114
|
+
o
|
|
132
115
|
]
|
|
133
116
|
}
|
|
134
117
|
);
|
|
135
118
|
}
|
|
136
|
-
d.MenuItemToggle =
|
|
137
|
-
function
|
|
138
|
-
const { value: e, displayText:
|
|
139
|
-
return /* @__PURE__ */
|
|
119
|
+
d.MenuItemToggle = g;
|
|
120
|
+
function C(n) {
|
|
121
|
+
const { value: e, displayText: o, onClick: r } = n;
|
|
122
|
+
return /* @__PURE__ */ t(
|
|
140
123
|
l,
|
|
141
124
|
{
|
|
142
|
-
className:
|
|
125
|
+
className: _([
|
|
143
126
|
"MenuBar__font",
|
|
144
127
|
"MenuBar__MenuItem",
|
|
145
128
|
"MenuBar__hover"
|
|
146
129
|
]),
|
|
147
|
-
onClick: () =>
|
|
148
|
-
children:
|
|
130
|
+
onClick: () => r == null ? void 0 : r(e),
|
|
131
|
+
children: o
|
|
149
132
|
}
|
|
150
133
|
);
|
|
151
134
|
}
|
|
152
|
-
d.MenuItem =
|
|
153
|
-
function
|
|
154
|
-
return /* @__PURE__ */
|
|
135
|
+
d.MenuItem = C;
|
|
136
|
+
function I() {
|
|
137
|
+
return /* @__PURE__ */ t("div", { className: "MenuBar__Separator" });
|
|
155
138
|
}
|
|
156
|
-
d.Separator =
|
|
157
|
-
function
|
|
158
|
-
const { children: e } =
|
|
159
|
-
return /* @__PURE__ */
|
|
139
|
+
d.Separator = I;
|
|
140
|
+
function O(n) {
|
|
141
|
+
const { children: e } = n;
|
|
142
|
+
return /* @__PURE__ */ t(l, { className: "MenuBar", children: e });
|
|
160
143
|
}
|
|
161
|
-
T.Dropdown = d;
|
|
162
144
|
export {
|
|
163
|
-
|
|
164
|
-
T as MenuBar
|
|
145
|
+
O as MenuBar
|
|
165
146
|
};
|
|
@@ -1,2 +1,9 @@
|
|
|
1
1
|
import { BoxProps } from './Box';
|
|
2
|
+
/**
|
|
3
|
+
* ## Modal
|
|
4
|
+
* A modal window. Uses a [Dimmer](https://github.com/tgstation/tgui-core/tree/main/lib/components/Dimmer.tsx)
|
|
5
|
+
* under the hood, and dynamically adjusts its own size to fit the content you're trying to display.
|
|
6
|
+
*
|
|
7
|
+
* Must be a direct child of a layout component (e.g. `Window`).
|
|
8
|
+
*/
|
|
2
9
|
export declare function Modal(props: BoxProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -18,5 +18,9 @@ type ExclusiveProps = None | (Omit<None, 'info'> & {
|
|
|
18
18
|
/** Red notice */
|
|
19
19
|
danger: boolean;
|
|
20
20
|
});
|
|
21
|
+
/**
|
|
22
|
+
* ## NoticeBox
|
|
23
|
+
* A notice box which warns you about something very important.
|
|
24
|
+
*/
|
|
21
25
|
export declare function NoticeBox(props: Props): import("react/jsx-runtime").JSX.Element;
|
|
22
26
|
export {};
|
|
@@ -1,24 +1,42 @@
|
|
|
1
|
-
import { Component, FocusEventHandler, KeyboardEventHandler, MouseEventHandler, RefObject } from 'react';
|
|
1
|
+
import { CSSProperties, Component, FocusEventHandler, KeyboardEventHandler, MouseEventHandler, RefObject } from 'react';
|
|
2
2
|
import { BooleanLike } from '../common/react';
|
|
3
|
+
import { BoxProps } from './Box';
|
|
3
4
|
type Props = Required<{
|
|
5
|
+
/** Highest possible value. */
|
|
4
6
|
maxValue: number;
|
|
7
|
+
/** Lowest possible value. */
|
|
5
8
|
minValue: number;
|
|
9
|
+
/** Adjust value by this amount when dragging the input. */
|
|
6
10
|
step: number;
|
|
11
|
+
/** Value itself. */
|
|
7
12
|
value: number | string;
|
|
8
13
|
}> & Partial<{
|
|
14
|
+
/** Animates the value if it was changed externally. */
|
|
9
15
|
animated: BooleanLike;
|
|
10
|
-
|
|
16
|
+
/** Custom class name. */
|
|
17
|
+
className: BoxProps['className'];
|
|
18
|
+
/** Makes the input field uneditable & non draggable to prevent user changes */
|
|
11
19
|
disabled: BooleanLike;
|
|
20
|
+
/** Fill all available horizontal space. */
|
|
12
21
|
fluid: BooleanLike;
|
|
13
|
-
|
|
22
|
+
/** Input font size */
|
|
23
|
+
fontSize: CSSProperties['fontSize'];
|
|
24
|
+
/** Format value using this function before displaying it. */
|
|
14
25
|
format: (value: number) => string;
|
|
15
|
-
height
|
|
16
|
-
|
|
26
|
+
/** Input height */
|
|
27
|
+
height: CSSProperties['height'];
|
|
28
|
+
/** Input line height */
|
|
29
|
+
lineHeight: CSSProperties['lineHeight'];
|
|
30
|
+
/** An event which fires when you release the input or successfully enter a number. */
|
|
17
31
|
onChange: (value: number) => void;
|
|
32
|
+
/** An event which fires about every 500ms when you drag the input up and down, on release and on manual editing. */
|
|
18
33
|
onDrag: (value: number) => void;
|
|
34
|
+
/** Screen distance mouse needs to travel to adjust value by one `step`. */
|
|
19
35
|
stepPixelSize: number;
|
|
36
|
+
/** Unit to display to the right of value. */
|
|
20
37
|
unit: string;
|
|
21
|
-
|
|
38
|
+
/** Width in Box units */
|
|
39
|
+
width: BoxProps['width'];
|
|
22
40
|
}>;
|
|
23
41
|
type State = {
|
|
24
42
|
currentValue: number;
|
|
@@ -27,6 +45,11 @@ type State = {
|
|
|
27
45
|
origin: number;
|
|
28
46
|
previousValue: number;
|
|
29
47
|
};
|
|
48
|
+
/**
|
|
49
|
+
* ## NumberInput
|
|
50
|
+
* A fancy, interactive number input, which you can either drag up and down
|
|
51
|
+
* to fine tune the value, or single click it to manually type a number.
|
|
52
|
+
*/
|
|
30
53
|
export declare class NumberInput extends Component<Props, State> {
|
|
31
54
|
inputRef: RefObject<HTMLInputElement>;
|
|
32
55
|
dragTimeout: NodeJS.Timeout;
|
|
@@ -41,5 +41,9 @@ type Props = {
|
|
|
41
41
|
*/
|
|
42
42
|
ranges: Record<string, [number, number]>;
|
|
43
43
|
}> & BoxProps & PropsWithChildren;
|
|
44
|
+
/**
|
|
45
|
+
* ## ProgressBar
|
|
46
|
+
* Progress indicators inform users about the status of ongoing processes.
|
|
47
|
+
*/
|
|
44
48
|
export declare function ProgressBar(props: Props): import("react/jsx-runtime").JSX.Element;
|
|
45
49
|
export {};
|
|
@@ -37,11 +37,10 @@ type Props = {
|
|
|
37
37
|
}> & BoxProps & PropsWithChildren;
|
|
38
38
|
/**
|
|
39
39
|
* ## Slider
|
|
40
|
-
* A horizontal,
|
|
41
|
-
* in precise values by dragging it left and right.
|
|
40
|
+
* A horizontal, [ProgressBar](https://github.com/tgstation/tgui-core/tree/main/lib/components/Progressbar.tsx)-like
|
|
41
|
+
* control which allows dialing * in precise values by dragging it left and right.
|
|
42
42
|
*
|
|
43
43
|
* Single click opens an input box to manually type in a number.
|
|
44
|
-
*
|
|
45
44
|
*/
|
|
46
45
|
export declare function Slider(props: Props): import("react/jsx-runtime").JSX.Element;
|
|
47
46
|
export {};
|
|
@@ -10,6 +10,57 @@ type Props = Partial<{
|
|
|
10
10
|
/** Adds zebra striping to the stack. */
|
|
11
11
|
zebra: boolean;
|
|
12
12
|
}> & FlexProps;
|
|
13
|
+
/**
|
|
14
|
+
* ## Stack
|
|
15
|
+
* A higher-level component that is based on
|
|
16
|
+
* [Flex](https://github.com/tgstation/tgui-core/tree/main/lib/components/Flex.tsx).
|
|
17
|
+
*
|
|
18
|
+
* The main difference from `Flex`, is that this component automatically adds
|
|
19
|
+
* spacing between all stack items, reducing the boilerplate that you have to write!
|
|
20
|
+
*
|
|
21
|
+
* Consists of two elements: `<Stack>` and `<Stack.Item>`.
|
|
22
|
+
*
|
|
23
|
+
* Stacks can be vertical by adding a `vertical` property.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```tsx
|
|
27
|
+
* <Stack vertical>
|
|
28
|
+
* <Stack.Item grow>Button description</Stack.Item>
|
|
29
|
+
* <Stack.Item>
|
|
30
|
+
* <Button>Perform an action</Button>
|
|
31
|
+
* </Stack.Item>
|
|
32
|
+
* </Stack>
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* ### High level window layout
|
|
36
|
+
* Stacks can be used for high level window layout.
|
|
37
|
+
* Make sure to use the `fill` property.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```tsx
|
|
41
|
+
* <Window>
|
|
42
|
+
* <Window.Content>
|
|
43
|
+
* <Stack fill>
|
|
44
|
+
* <Stack.Item>
|
|
45
|
+
* <Section fill>Sidebar</Section>
|
|
46
|
+
* </Stack.Item>
|
|
47
|
+
* <Stack.Item grow>
|
|
48
|
+
* <Stack fill vertical>
|
|
49
|
+
* <Stack.Item grow>
|
|
50
|
+
* <Section fill scrollable>
|
|
51
|
+
* Main content
|
|
52
|
+
* </Section>
|
|
53
|
+
* </Stack.Item>
|
|
54
|
+
* <Stack.Item>
|
|
55
|
+
* <Section>Bottom pane</Section>
|
|
56
|
+
* </Stack.Item>
|
|
57
|
+
* </Stack>
|
|
58
|
+
* </Stack.Item>
|
|
59
|
+
* </Stack>
|
|
60
|
+
* </Window.Content>
|
|
61
|
+
* </Window>
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
13
64
|
export declare function Stack(props: Props): import("react/jsx-runtime").JSX.Element;
|
|
14
65
|
export declare namespace Stack {
|
|
15
66
|
var Item: typeof StackItem;
|
|
@@ -3,6 +3,24 @@ type Props = Partial<{
|
|
|
3
3
|
/** Collapses table to the smallest possible size. */
|
|
4
4
|
collapsing: boolean;
|
|
5
5
|
}> & BoxProps;
|
|
6
|
+
/**
|
|
7
|
+
* ## Table
|
|
8
|
+
* A straight forward mapping to a standard html table, which is slightly
|
|
9
|
+
* simplified (does not need a `<tbody>` tag) and with sane default styles
|
|
10
|
+
* (e.g. table width is 100% by default).
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```tsx
|
|
14
|
+
* <Table>
|
|
15
|
+
* <Table.Row>
|
|
16
|
+
* <Table.Cell bold>Hello world!</Table.Cell>
|
|
17
|
+
* <Table.Cell collapsing color="label">
|
|
18
|
+
* Label
|
|
19
|
+
* </Table.Cell>
|
|
20
|
+
* </Table.Row>
|
|
21
|
+
* </Table>
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
6
24
|
export declare function Table(props: Props): import("react/jsx-runtime").JSX.Element;
|
|
7
25
|
export declare namespace Table {
|
|
8
26
|
var Row: typeof TableRow;
|
|
@@ -12,7 +30,7 @@ type RowProps = Partial<{
|
|
|
12
30
|
/** Whether this is a header cell. */
|
|
13
31
|
header: boolean;
|
|
14
32
|
}> & BoxProps;
|
|
15
|
-
|
|
33
|
+
declare function TableRow(props: RowProps): import("react/jsx-runtime").JSX.Element;
|
|
16
34
|
type CellProps = Partial<{
|
|
17
35
|
/** Additional columns for this cell to expand, assuming there is room. */
|
|
18
36
|
colSpan: number;
|
|
@@ -24,5 +42,5 @@ type CellProps = Partial<{
|
|
|
24
42
|
/** Rows for this cell to expand, assuming there is room. */
|
|
25
43
|
rowSpan: number;
|
|
26
44
|
}> & BoxProps;
|
|
27
|
-
|
|
45
|
+
declare function TableCell(props: CellProps): import("react/jsx-runtime").JSX.Element;
|
|
28
46
|
export {};
|
package/dist/components/Table.js
CHANGED
|
@@ -1,23 +1,92 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
2
|
import { BoxProps } from './Box';
|
|
3
3
|
type Props = Partial<{
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Similarly to `fill` on
|
|
6
|
+
* [Section](https://github.com/tgstation/tgui-core/tree/main/lib/components/Section.tsx),
|
|
7
|
+
* tabs will fill all available vertical space. Only makes sense in a vertical
|
|
8
|
+
* configuration.
|
|
9
|
+
*/
|
|
5
10
|
fill: boolean;
|
|
11
|
+
/** If true, tabs will take all available horizontal space. */
|
|
6
12
|
fluid: boolean;
|
|
13
|
+
/** Use a vertical configuration, where tabs will be stacked vertically. */
|
|
7
14
|
vertical: boolean;
|
|
8
|
-
}> & BoxProps
|
|
15
|
+
}> & BoxProps;
|
|
16
|
+
/**
|
|
17
|
+
* ## Tabs
|
|
18
|
+
* Tabs make it easy to explore and switch between different views.
|
|
19
|
+
*
|
|
20
|
+
* Here is an example of how you would construct a simple tabbed view:
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```tsx
|
|
24
|
+
* <Tabs>
|
|
25
|
+
* <Tabs.Tab
|
|
26
|
+
* selected={tabIndex === 1}
|
|
27
|
+
* onClick={() => setTabIndex(1)}>
|
|
28
|
+
* Tab one
|
|
29
|
+
* </Tabs.Tab>
|
|
30
|
+
* <Tabs.Tab
|
|
31
|
+
* selected={tabIndex === 2}
|
|
32
|
+
* onClick={() => setTabIndex(2)}>
|
|
33
|
+
* Tab two
|
|
34
|
+
* </Tabs.Tab>
|
|
35
|
+
* </Tabs>
|
|
36
|
+
* <Box>
|
|
37
|
+
* Tab selected: {tabIndex}
|
|
38
|
+
* </Box>
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* Notice that tabs do not contain state. It is your job to track the selected
|
|
42
|
+
* tab, handle clicks and place tab content where you need it. In return, you get
|
|
43
|
+
* a lot of flexibility in regards to how you can layout your tabs.
|
|
44
|
+
*
|
|
45
|
+
* Tabs also support a vertical configuration. This is usually paired with
|
|
46
|
+
* [Stack](https://github.com/tgstation/tgui-core/tree/main/lib/components/Stack.tsx)
|
|
47
|
+
* to render tab content to the right.
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```tsx
|
|
51
|
+
* <Stack>
|
|
52
|
+
* <Stack.Item>
|
|
53
|
+
* <Tabs vertical>...</Tabs>
|
|
54
|
+
* </Stack.Item>
|
|
55
|
+
* <Stack.Item grow basis={0}>
|
|
56
|
+
* Tab content.
|
|
57
|
+
* </Stack.Item>
|
|
58
|
+
* </Stack>
|
|
59
|
+
* ```
|
|
60
|
+
*
|
|
61
|
+
* If you need to combine a tab section with other elements, or if you want to
|
|
62
|
+
* add scrollable functionality to tabs, pair them with the
|
|
63
|
+
* [Section](https://github.com/tgstation/tgui-core/tree/main/lib/components/Section.tsx)
|
|
64
|
+
* component:
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```tsx
|
|
68
|
+
* <Section fill fitted scrollable width="128px">
|
|
69
|
+
* <Tabs vertical>...</Tabs>
|
|
70
|
+
* ... other things ...
|
|
71
|
+
* </Section>
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
export declare function Tabs(props: Props): import("react/jsx-runtime").JSX.Element;
|
|
75
|
+
export declare namespace Tabs {
|
|
76
|
+
var Tab: (props: TabProps) => import("react/jsx-runtime").JSX.Element;
|
|
77
|
+
}
|
|
9
78
|
type TabProps = Partial<{
|
|
10
|
-
|
|
11
|
-
color: string;
|
|
79
|
+
/** Font awesome icon. */
|
|
12
80
|
icon: string;
|
|
81
|
+
/** Causes the icon to spin */
|
|
13
82
|
iconSpin: boolean;
|
|
83
|
+
/** Left slot content */
|
|
14
84
|
leftSlot: ReactNode;
|
|
85
|
+
/** Called when element is clicked */
|
|
15
86
|
onClick: (e?: any) => void;
|
|
87
|
+
/** Right slot content */
|
|
16
88
|
rightSlot: ReactNode;
|
|
89
|
+
/** Whether the tab is selected */
|
|
17
90
|
selected: boolean;
|
|
18
|
-
}> & BoxProps
|
|
19
|
-
export declare function Tabs(props: Props): import("react/jsx-runtime").JSX.Element;
|
|
20
|
-
export declare namespace Tabs {
|
|
21
|
-
var Tab: (props: TabProps) => import("react/jsx-runtime").JSX.Element;
|
|
22
|
-
}
|
|
91
|
+
}> & BoxProps;
|
|
23
92
|
export {};
|
|
@@ -12,6 +12,22 @@ type Props = {
|
|
|
12
12
|
type State = {
|
|
13
13
|
hovered: boolean;
|
|
14
14
|
};
|
|
15
|
+
/**
|
|
16
|
+
* ## Tooltip
|
|
17
|
+
* A boxy tooltip from tgui 1. It is very hacky in its current state, and
|
|
18
|
+
* requires setting `position: relative` on the container.
|
|
19
|
+
*
|
|
20
|
+
* Please note that
|
|
21
|
+
* [Button](https://github.com/tgstation/tgui-core/tree/main/lib/components/Button.tsx)
|
|
22
|
+
* component has a `tooltip` prop and it is recommended to use that prop instead.
|
|
23
|
+
*
|
|
24
|
+
* Usage:
|
|
25
|
+
* ```tsx
|
|
26
|
+
* <Tooltip position="bottom" content="Box tooltip">
|
|
27
|
+
* <Box position="relative">Sample text.</Box>
|
|
28
|
+
* </Tooltip>
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
15
31
|
export declare class Tooltip extends Component<Props, State> {
|
|
16
32
|
static renderedTooltip: HTMLDivElement | undefined;
|
|
17
33
|
static singletonPopper: ReturnType<typeof createPopper> | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tgui-core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.2",
|
|
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,16 +38,16 @@
|
|
|
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
43
|
"@storybook/addon-console": "^3.0.0",
|
|
37
|
-
"@storybook/addon-essentials": "8.4.
|
|
38
|
-
"@storybook/addon-interactions": "8.4.
|
|
39
|
-
"@storybook/addon-onboarding": "8.4.
|
|
40
|
-
"@storybook/blocks": "8.4.
|
|
41
|
-
"@storybook/react": "8.4.
|
|
42
|
-
"@storybook/react-vite": "8.4.
|
|
43
|
-
"@storybook/test": "8.4.
|
|
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",
|
|
44
51
|
"@types/node": "^22.9.0",
|
|
45
52
|
"@types/react": "^18.3.3",
|
|
46
53
|
"@types/react-dom": "^18.3.0",
|
|
@@ -51,9 +58,8 @@
|
|
|
51
58
|
"prettier": "^3.3.3",
|
|
52
59
|
"react-popper": "^2.3.0",
|
|
53
60
|
"sass": "^1.81.0",
|
|
54
|
-
"storybook": "8.4.
|
|
61
|
+
"storybook": "^8.4.7",
|
|
55
62
|
"storybook-addon-sass-postcss": "^0.3.2",
|
|
56
|
-
"tgui-styles": "^0.0.8",
|
|
57
63
|
"typescript": "^5.6.3",
|
|
58
64
|
"vite": "^5.4.11",
|
|
59
65
|
"vite-plugin-dts": "^4.3.0"
|
|
@@ -62,5 +68,5 @@
|
|
|
62
68
|
"react": "^18.2.0",
|
|
63
69
|
"react-dom": "^18.2.0"
|
|
64
70
|
},
|
|
65
|
-
"packageManager": "pnpm@9.
|
|
71
|
+
"packageManager": "pnpm@9.15.1+sha512.1acb565e6193efbebda772702950469150cf12bcc764262e7587e71d19dc98a423dff9536e57ea44c49bdf790ff694e83c27be5faa23d67e0c033b583be4bfcf"
|
|
66
72
|
}
|