tgui-core 1.5.1 → 1.5.3

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 CHANGED
@@ -41,7 +41,7 @@ You have two options for importing styles:
41
41
  To import all styles at once, add the following line to your main Sass file:
42
42
 
43
43
  ```scss
44
- @use "pkg:tgui-styles";
44
+ @use "pkg:tgui-core/styles";
45
45
  ```
46
46
 
47
47
  ### 2. Importing Individual Styles
@@ -49,9 +49,9 @@ To import all styles at once, add the following line to your main Sass file:
49
49
  To import individual styles, add any of the exported styles to your main Sass file:
50
50
 
51
51
  ```scss
52
- @use "pkg:tgui-styles/components/Button";
53
- @use "pkg:tgui-styles/components/Dialog";
54
- @use "pkg:tgui-styles/components/NoticeBox";
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
55
  ```
56
56
 
57
57
  ## License
@@ -68,20 +68,12 @@ export declare namespace Button {
68
68
  type CheckProps = Partial<{
69
69
  checked: BooleanLike;
70
70
  }> & Props;
71
- /**
72
- * ## Button.Checkbox
73
- * A ghetto checkbox, made entirely using existing Button API.
74
- */
75
71
  export declare function ButtonCheckbox(props: CheckProps): import("react/jsx-runtime").JSX.Element;
76
72
  type ConfirmProps = Partial<{
77
73
  confirmColor: string;
78
74
  confirmContent: ReactNode;
79
75
  confirmIcon: string;
80
76
  }> & Props;
81
- /**
82
- * ## Button.Confirm
83
- * A button with an extra confirmation step, using native button component.
84
- */
85
77
  declare function ButtonConfirm(props: ConfirmProps): import("react/jsx-runtime").JSX.Element;
86
78
  type InputProps = Partial<{
87
79
  currentValue: string;
@@ -91,21 +83,11 @@ type InputProps = Partial<{
91
83
  onCommit: (e: any, value: string) => void;
92
84
  placeholder: string;
93
85
  }> & Props;
94
- /**
95
- * ## Button.Input
96
- * A button that turns into an input box after the first click.
97
- *
98
- * Turns back into a button after the user hits enter, defocuses, or hits escape. Enter and defocus commit, while escape cancels.
99
- */
100
86
  declare function ButtonInput(props: InputProps): import("react/jsx-runtime").JSX.Element;
101
87
  type FileProps = {
102
88
  accept: string;
103
89
  multiple?: boolean;
104
90
  onSelectFiles: (files: string | string[]) => void;
105
91
  } & Props;
106
- /**
107
- * ## Button.File
108
- * Accepts file input, based on the native element.
109
- */
110
92
  declare function ButtonFile(props: FileProps): import("react/jsx-runtime").JSX.Element;
111
93
  export {};
@@ -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: any;
3
+ children: ReactNode;
3
4
  height?: string;
4
5
  onClose: () => void;
5
- title: any;
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 o, jsxs as e } from "react/jsx-runtime";
2
- import { Box as r } from "./Box.js";
3
- import { Button as s } from "./Button.js";
4
- function d(i) {
5
- const { title: n, onClose: t, children: c, width: l, height: h } = i;
6
- return /* @__PURE__ */ o("div", { className: "Dialog", children: /* @__PURE__ */ e(r, { className: "Dialog__content", width: l || "370px", height: h, children: [
7
- /* @__PURE__ */ e("div", { className: "Dialog__header", children: [
8
- /* @__PURE__ */ o("div", { className: "Dialog__title", children: n }),
9
- /* @__PURE__ */ o(r, { mr: 2, children: /* @__PURE__ */ o(
10
- s,
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: t
20
+ onClick: n
21
21
  }
22
22
  ) })
23
23
  ] }),
24
24
  c
25
25
  ] }) });
26
26
  }
27
- function a(i) {
28
- const { onClick: n, children: t } = i;
29
- return /* @__PURE__ */ o(
30
- s,
27
+ function m(o) {
28
+ const { onClick: i, children: n } = o;
29
+ return /* @__PURE__ */ t(
30
+ r,
31
31
  {
32
- onClick: n,
32
+ onClick: i,
33
33
  className: "Dialog__button",
34
34
  verticalAlignContent: "middle",
35
- children: t
35
+ children: n
36
36
  }
37
37
  );
38
38
  }
39
- d.Button = a;
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,14 @@
1
1
  type Props = Partial<{
2
+ /** Divider can divide content without creating a dividing line. */
2
3
  hidden: boolean;
4
+ /** Divide content vertically. */
3
5
  vertical: boolean;
4
6
  }>;
7
+ /**
8
+ *
9
+ * ## Divider
10
+ * Draws a horizontal or vertical line, dividing a section into groups.
11
+ * Works like the good old `<hr>` element, but it's fancier.
12
+ */
5
13
  export declare function Divider(props: Props): import("react/jsx-runtime").JSX.Element;
6
14
  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
- export type DropdownEntry = {
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
- type IconStackUnique = {
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 {};
@@ -39,6 +39,5 @@ function g(c) {
39
39
  }
40
40
  d.Stack = g;
41
41
  export {
42
- d as Icon,
43
- g as IconStack
42
+ d as Icon
44
43
  };
@@ -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
- /** Color of the button. See [Button](#button) but without `transparent`. */
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;
@@ -1,165 +1,146 @@
1
- var C = Object.defineProperty;
2
- var x = (r, e, n) => e in r ? C(r, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : r[e] = n;
3
- var h = (r, e, n) => x(r, typeof e != "symbol" ? e + "" : e, n);
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 g } from "./Icon.js";
9
- class I extends B {
10
- constructor(n) {
11
- super(n);
12
- h(this, "handleClick");
13
- this.handleClick = (t) => {
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
- componentWillMount() {
18
- window.addEventListener("click", this.handleClick);
19
- }
20
- componentWillUnmount() {
21
- window.removeEventListener("click", this.handleClick);
22
- }
23
- render() {
24
- const { width: n, children: t } = this.props;
25
- return /* @__PURE__ */ o(
26
- "div",
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: "Menubar__menu",
29
- style: {
30
- width: n
31
- },
32
- children: t
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
- class O extends B {
38
- constructor(n) {
39
- super(n);
40
- h(this, "menuRef");
41
- this.menuRef = N();
42
- }
43
- render() {
44
- const { props: n } = this, {
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(r) {
65
+ function d(n) {
84
66
  const {
85
67
  entry: e,
86
- children: n,
87
- openWidth: t,
88
- display: s,
89
- setOpenMenuBar: i,
90
- openMenuBar: c,
91
- setOpenOnHover: u,
92
- openOnHover: a,
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: p
95
- } = r;
96
- return /* @__PURE__ */ o(
97
- O,
76
+ className: M
77
+ } = n;
78
+ return /* @__PURE__ */ t(
79
+ N,
98
80
  {
99
- openWidth: t,
100
- display: s,
81
+ openWidth: r,
82
+ display: a,
101
83
  disabled: m,
102
- open: c === e,
103
- className: p,
84
+ open: i === e,
85
+ className: M,
104
86
  onClick: () => {
105
- i(c === e ? null : e), u(!a);
87
+ u(i === e ? null : e), c(!s);
106
88
  },
107
89
  onOutsideClick: () => {
108
- i(null), u(!1);
90
+ u(null), c(!1);
109
91
  },
110
92
  onMouseOver: () => {
111
- a && i(e);
93
+ s && u(e);
112
94
  },
113
- children: n
95
+ children: o
114
96
  }
115
97
  );
116
98
  }
117
- function w(r) {
118
- const { value: e, displayText: n, onClick: t, checked: s } = r;
119
- return /* @__PURE__ */ f(
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: M([
105
+ className: _([
123
106
  "MenuBar__font",
124
107
  "MenuBar__MenuItem",
125
108
  "MenuBar__MenuItemToggle",
126
109
  "MenuBar__hover"
127
110
  ]),
128
- onClick: () => t(e),
111
+ onClick: () => r(e),
129
112
  children: [
130
- /* @__PURE__ */ o("div", { className: "MenuBar__MenuItemToggle__check", children: s && /* @__PURE__ */ o(g, { size: 1.3, name: "check" }) }),
131
- n
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 = w;
137
- function R(r) {
138
- const { value: e, displayText: n, onClick: t } = r;
139
- return /* @__PURE__ */ o(
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: M([
125
+ className: _([
143
126
  "MenuBar__font",
144
127
  "MenuBar__MenuItem",
145
128
  "MenuBar__hover"
146
129
  ]),
147
- onClick: () => t(e),
148
- children: n
130
+ onClick: () => r == null ? void 0 : r(e),
131
+ children: o
149
132
  }
150
133
  );
151
134
  }
152
- d.MenuItem = R;
153
- function y() {
154
- return /* @__PURE__ */ o("div", { className: "MenuBar__Separator" });
135
+ d.MenuItem = C;
136
+ function I() {
137
+ return /* @__PURE__ */ t("div", { className: "MenuBar__Separator" });
155
138
  }
156
- d.Separator = y;
157
- function T(r) {
158
- const { children: e } = r;
159
- return /* @__PURE__ */ o(l, { className: "MenuBar", children: e });
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
- d as Dropdown,
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
- className: string;
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
- fontSize: string;
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: string;
16
- lineHeight: string;
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
- width: string;
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, progressbar-like control which allows dialing
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
- export declare function TableRow(props: RowProps): import("react/jsx-runtime").JSX.Element;
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
- export declare function TableCell(props: CellProps): import("react/jsx-runtime").JSX.Element;
45
+ declare function TableCell(props: CellProps): import("react/jsx-runtime").JSX.Element;
28
46
  export {};
@@ -52,7 +52,5 @@ function T(e) {
52
52
  }
53
53
  m.Cell = T;
54
54
  export {
55
- m as Table,
56
- T as TableCell,
57
- i as TableRow
55
+ m as Table
58
56
  };
@@ -1,23 +1,92 @@
1
- import { PropsWithChildren, ReactNode } from 'react';
1
+ import { ReactNode } from 'react';
2
2
  import { BoxProps } from './Box';
3
3
  type Props = Partial<{
4
- className: string;
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 & PropsWithChildren;
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
- className: string;
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 & PropsWithChildren;
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.5.1",
3
+ "version": "1.5.3",
4
4
  "description": "TGUI core component library",
5
5
  "keywords": ["TGUI", "library", "typescript"],
6
6
  "files": ["dist"],
@@ -1,27 +0,0 @@
1
- import { ReactNode } from 'react';
2
- type MenuBarItemProps = {
3
- children: any;
4
- className?: string;
5
- disabled?: boolean;
6
- display: ReactNode;
7
- entry: string;
8
- openMenuBar: string | null;
9
- openOnHover: boolean;
10
- openWidth: string;
11
- setOpenMenuBar: (entry: string | null) => void;
12
- setOpenOnHover: (flag: boolean) => void;
13
- };
14
- export declare function Dropdown(props: MenuBarItemProps): import("react/jsx-runtime").JSX.Element;
15
- export declare namespace Dropdown {
16
- var MenuItemToggle: (props: any) => import("react/jsx-runtime").JSX.Element;
17
- var MenuItem: (props: any) => import("react/jsx-runtime").JSX.Element;
18
- var Separator: () => import("react/jsx-runtime").JSX.Element;
19
- }
20
- type MenuBarProps = {
21
- children: any;
22
- };
23
- export declare function MenuBar(props: MenuBarProps): import("react/jsx-runtime").JSX.Element;
24
- export declare namespace MenuBar {
25
- var Dropdown: typeof import("./MenuBar").Dropdown;
26
- }
27
- export {};