tgui-core 1.5.6 → 1.6.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.
@@ -9,13 +9,13 @@ type Props = {
9
9
  * If provided, a function that formats the inner string. By default,
10
10
  * attempts to match the numeric precision of `value`.
11
11
  */
12
- format?: (value: number) => string;
12
+ format: (value: number) => string;
13
13
  /**
14
14
  * If provided, the initial value displayed. By default, the same as `value`.
15
15
  * If `initial` and `value` are different, the component immediately starts
16
16
  * animating.
17
17
  */
18
- initial?: number;
18
+ initial: number;
19
19
  }>;
20
20
  /**
21
21
  * ## AnimatedNumber
@@ -54,21 +54,11 @@ 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
- /**
58
- * ## Button
59
- * Buttons allow users to take actions, and make choices, with a single click.
60
- */
61
57
  export declare function Button(props: Props): import("react/jsx-runtime").JSX.Element;
62
- export declare namespace Button {
63
- var Checkbox: typeof ButtonCheckbox;
64
- var Confirm: typeof ButtonConfirm;
65
- var Input: typeof ButtonInput;
66
- var File: typeof ButtonFile;
67
- }
68
58
  type CheckProps = Partial<{
69
59
  checked: BooleanLike;
70
60
  }> & Props;
71
- export declare function ButtonCheckbox(props: CheckProps): import("react/jsx-runtime").JSX.Element;
61
+ declare function ButtonCheckbox(props: CheckProps): import("react/jsx-runtime").JSX.Element;
72
62
  type ConfirmProps = Partial<{
73
63
  confirmColor: string;
74
64
  confirmContent: ReactNode;
@@ -78,7 +68,6 @@ declare function ButtonConfirm(props: ConfirmProps): import("react/jsx-runtime")
78
68
  type InputProps = Partial<{
79
69
  currentValue: string;
80
70
  defaultValue: string;
81
- fluid: boolean;
82
71
  maxLength: number;
83
72
  onCommit: (e: any, value: string) => void;
84
73
  placeholder: string;
@@ -90,4 +79,32 @@ type FileProps = {
90
79
  onSelectFiles: (files: string | string[]) => void;
91
80
  } & Props;
92
81
  declare function ButtonFile(props: FileProps): import("react/jsx-runtime").JSX.Element;
82
+ /**
83
+ * ## Button
84
+ * Buttons allow users to take actions, and make choices, with a single click.
85
+ */
86
+ export declare namespace Button {
87
+ /**
88
+ * ## Button.Checkbox
89
+ * A ghetto checkbox, made entirely using existing Button API.
90
+ */
91
+ const Checkbox: typeof ButtonCheckbox;
92
+ /**
93
+ * ## Button.Confirm
94
+ * A button with an extra confirmation step, using native button component.
95
+ */
96
+ const Confirm: typeof ButtonConfirm;
97
+ /**
98
+ * ## Button.Input
99
+ * A button that turns into an input box after the first click.
100
+ *
101
+ * Turns back into a button after the user hits enter, defocuses, or hits escape. Enter and defocus commit, while escape cancels.
102
+ */
103
+ const Input: typeof ButtonInput;
104
+ /**
105
+ * ## Button.File
106
+ * Accepts file input, based on the native element.
107
+ */
108
+ const File: typeof ButtonFile;
109
+ }
93
110
  export {};
@@ -1,4 +1,4 @@
1
- import { jsx as i, jsxs as _, Fragment as K } from "react/jsx-runtime";
1
+ import { jsx as r, jsxs as _, Fragment as K } from "react/jsx-runtime";
2
2
  import { useState as A, createRef as V, useEffect as $, useRef as z } from "react";
3
3
  import { KEY as D, isEscape as E } from "../common/keys.js";
4
4
  import { classes as F } from "../common/react.js";
@@ -6,55 +6,55 @@ import { computeBoxClassName as j, computeBoxProps as q } from "../common/ui.js"
6
6
  import { Box as O } from "./Box.js";
7
7
  import { Icon as S } from "./Icon.js";
8
8
  import { Tooltip as v } from "./Tooltip.js";
9
- function x(u) {
9
+ function N(o) {
10
10
  const {
11
- captureKeys: l = !0,
12
- children: s,
11
+ captureKeys: s = !0,
12
+ children: u,
13
13
  circular: m,
14
14
  className: d,
15
- color: c,
15
+ color: l,
16
16
  compact: h,
17
17
  content: B,
18
18
  disabled: t,
19
- ellipsis: r,
20
- fluid: o,
21
- icon: e,
19
+ ellipsis: c,
20
+ fluid: e,
21
+ icon: i,
22
22
  iconColor: a,
23
23
  iconPosition: C,
24
- iconRotation: N,
24
+ iconRotation: I,
25
25
  iconSize: R,
26
26
  iconSpin: P,
27
27
  onClick: f,
28
- selected: g,
29
- tooltip: b,
28
+ selected: x,
29
+ tooltip: g,
30
30
  tooltipPosition: w,
31
31
  verticalAlignContent: y,
32
- ...I
33
- } = u, n = B || s;
34
- let k = /* @__PURE__ */ i(
32
+ ...b
33
+ } = o, n = B || u;
34
+ let k = /* @__PURE__ */ r(
35
35
  "div",
36
36
  {
37
37
  className: F([
38
38
  "Button",
39
- o && "Button--fluid",
39
+ e && "Button--fluid",
40
40
  t && "Button--disabled",
41
- g && "Button--selected",
41
+ x && "Button--selected",
42
42
  m && "Button--circular",
43
43
  h && "Button--compact",
44
44
  C && `Button--iconPosition--${C}`,
45
45
  y && "Button--flex",
46
- y && o && "Button--flex--fluid",
46
+ y && e && "Button--flex--fluid",
47
47
  y && `Button--verticalAlignContent--${y}`,
48
- c && typeof c == "string" ? `Button--color--${c}` : "Button--color--default",
48
+ l && typeof l == "string" ? `Button--color--${l}` : "Button--color--default",
49
49
  d,
50
- j(I)
50
+ j(b)
51
51
  ]),
52
52
  tabIndex: t ? void 0 : 0,
53
53
  onClick: (p) => {
54
54
  !t && f && f(p);
55
55
  },
56
56
  onKeyDown: (p) => {
57
- if (l) {
57
+ if (s) {
58
58
  if (p.key === D.Space || p.key === D.Enter) {
59
59
  p.preventDefault(), !t && f && f(p);
60
60
  return;
@@ -62,36 +62,36 @@ function x(u) {
62
62
  E(p.key) && p.preventDefault();
63
63
  }
64
64
  },
65
- ...q(I),
65
+ ...q(b),
66
66
  children: /* @__PURE__ */ _("div", { className: "Button__content", children: [
67
- e && C !== "right" && /* @__PURE__ */ i(
67
+ i && C !== "right" && /* @__PURE__ */ r(
68
68
  S,
69
69
  {
70
70
  mr: n ? 0.5 : 0,
71
- name: e,
71
+ name: i,
72
72
  color: a,
73
- rotation: N,
73
+ rotation: I,
74
74
  size: R,
75
75
  spin: P
76
76
  }
77
77
  ),
78
- r ? /* @__PURE__ */ i(
78
+ c ? /* @__PURE__ */ r(
79
79
  "span",
80
80
  {
81
81
  className: F([
82
82
  "Button--ellipsis",
83
- e && "Button__textMargin"
83
+ i && "Button__textMargin"
84
84
  ]),
85
85
  children: n
86
86
  }
87
87
  ) : n,
88
- e && C === "right" && /* @__PURE__ */ i(
88
+ i && C === "right" && /* @__PURE__ */ r(
89
89
  S,
90
90
  {
91
91
  ml: n ? 0.5 : 0,
92
- name: e,
92
+ name: i,
93
93
  color: a,
94
- rotation: N,
94
+ rotation: I,
95
95
  size: R,
96
96
  spin: P
97
97
  }
@@ -99,78 +99,76 @@ function x(u) {
99
99
  ] })
100
100
  }
101
101
  );
102
- return b && (k = /* @__PURE__ */ i(v, { content: b, position: w, children: k })), k;
102
+ return g && (k = /* @__PURE__ */ r(v, { content: g, position: w, children: k })), k;
103
103
  }
104
- function T(u) {
105
- const { checked: l, ...s } = u;
106
- return /* @__PURE__ */ i(
107
- x,
104
+ function T(o) {
105
+ const { checked: s, ...u } = o;
106
+ return /* @__PURE__ */ r(
107
+ N,
108
108
  {
109
109
  color: "transparent",
110
- icon: l ? "check-square-o" : "square-o",
111
- selected: l,
112
- ...s
110
+ icon: s ? "check-square-o" : "square-o",
111
+ selected: s,
112
+ ...u
113
113
  }
114
114
  );
115
115
  }
116
- x.Checkbox = T;
117
- function L(u) {
116
+ function L(o) {
118
117
  const {
119
- children: l,
120
- color: s,
118
+ children: s,
119
+ color: u,
121
120
  confirmColor: m = "bad",
122
121
  confirmContent: d = "Confirm?",
123
- confirmIcon: c,
122
+ confirmIcon: l,
124
123
  ellipsis: h = !0,
125
124
  icon: B,
126
125
  onClick: t,
127
- ...r
128
- } = u, [o, e] = A(!1);
126
+ ...c
127
+ } = o, [e, i] = A(!1);
129
128
  function a(C) {
130
- if (!o) {
131
- e(!0);
129
+ if (!e) {
130
+ i(!0);
132
131
  return;
133
132
  }
134
- t == null || t(C), e(!1);
133
+ t == null || t(C), i(!1);
135
134
  }
136
- return /* @__PURE__ */ i(
137
- x,
135
+ return /* @__PURE__ */ r(
136
+ N,
138
137
  {
139
- icon: o ? c : B,
140
- color: o ? m : s,
138
+ icon: e ? l : B,
139
+ color: e ? m : u,
141
140
  onClick: a,
142
- ...r,
143
- children: o ? d : l
141
+ ...c,
142
+ children: e ? d : s
144
143
  }
145
144
  );
146
145
  }
147
- x.Confirm = L;
148
- function M(u) {
146
+ function M(o) {
149
147
  const {
150
- children: l,
151
- color: s = "default",
148
+ children: s,
149
+ color: u = "default",
152
150
  content: m,
153
151
  currentValue: d,
154
- defaultValue: c,
152
+ defaultValue: l,
155
153
  disabled: h,
156
154
  fluid: B,
157
155
  icon: t,
158
- iconRotation: r,
159
- iconSpin: o,
160
- maxLength: e,
156
+ iconRotation: c,
157
+ iconSpin: e,
158
+ maxLength: i,
161
159
  onCommit: a = () => null,
162
160
  placeholder: C,
163
- tooltip: N,
161
+ tooltip: I,
164
162
  tooltipPosition: R,
165
163
  ...P
166
- } = u, [f, g] = A(!1), b = V(), w = m || l;
164
+ } = o, [f, x] = A(!1), g = V(), w = m || s;
167
165
  function y(n) {
168
- const k = b.current;
166
+ const k = g.current;
169
167
  if (!k) return;
170
- k.value !== "" ? a(n, k.value) : c && a(n, c);
168
+ k.value !== "" ? a(n, k.value) : l && a(n, l);
171
169
  }
172
170
  $(() => {
173
- const n = b.current;
171
+ const n = g.current;
174
172
  if (n && f) {
175
173
  n.value = d || "";
176
174
  try {
@@ -179,86 +177,86 @@ function M(u) {
179
177
  }
180
178
  }
181
179
  }, [f, d]);
182
- let I = /* @__PURE__ */ _(
180
+ let b = /* @__PURE__ */ _(
183
181
  O,
184
182
  {
185
183
  className: F([
186
184
  "Button",
187
185
  B && "Button--fluid",
188
186
  h && "Button--disabled",
189
- `Button--color--${s}`
187
+ `Button--color--${u}`
190
188
  ]),
191
189
  ...P,
192
- onClick: () => g(!0),
190
+ onClick: () => x(!0),
193
191
  children: [
194
- t && /* @__PURE__ */ i(S, { name: t, rotation: r, spin: o }),
195
- /* @__PURE__ */ i("div", { children: w }),
196
- /* @__PURE__ */ i(
192
+ t && /* @__PURE__ */ r(S, { name: t, rotation: c, spin: e }),
193
+ /* @__PURE__ */ r("div", { children: w }),
194
+ /* @__PURE__ */ r(
197
195
  "input",
198
196
  {
199
197
  disabled: !!h,
200
- ref: b,
198
+ ref: g,
201
199
  className: "NumberInput__input",
202
200
  style: {
203
201
  display: f ? "" : "none",
204
202
  textAlign: "left"
205
203
  },
206
204
  onBlur: (n) => {
207
- f && (g(!1), y(n));
205
+ f && (x(!1), y(n));
208
206
  },
209
207
  onKeyDown: (n) => {
210
208
  if (n.key === D.Enter) {
211
- g(!1), y(n);
209
+ x(!1), y(n);
212
210
  return;
213
211
  }
214
- E(n.key) && g(!1);
212
+ E(n.key) && x(!1);
215
213
  }
216
214
  }
217
215
  )
218
216
  ]
219
217
  }
220
218
  );
221
- return N && (I = /* @__PURE__ */ i(v, { content: N, position: R, children: I })), I;
219
+ return I && (b = /* @__PURE__ */ r(v, { content: I, position: R, children: b })), b;
222
220
  }
223
- x.Input = M;
224
- function Y(u) {
225
- const { accept: l, multiple: s, onSelectFiles: m, ...d } = u, c = z(null);
221
+ function Y(o) {
222
+ const { accept: s, multiple: u, onSelectFiles: m, ...d } = o, l = z(null);
226
223
  async function h(t) {
227
- const r = Array.from(t).map((o) => {
228
- const e = new FileReader();
224
+ const c = Array.from(t).map((e) => {
225
+ const i = new FileReader();
229
226
  return new Promise((a) => {
230
- e.onload = () => a(e.result), e.readAsText(o);
227
+ i.onload = () => a(i.result), i.readAsText(e);
231
228
  });
232
229
  });
233
- return await Promise.all(r);
230
+ return await Promise.all(c);
234
231
  }
235
232
  async function B(t) {
236
- const r = t.target.files;
237
- if (r != null && r.length) {
238
- const o = await h(r);
239
- m(s ? o : o[0]);
233
+ const c = t.target.files;
234
+ if (c != null && c.length) {
235
+ const e = await h(c);
236
+ m(u ? e : e[0]);
240
237
  }
241
238
  }
242
239
  return /* @__PURE__ */ _(K, { children: [
243
- /* @__PURE__ */ i(x, { onClick: () => {
240
+ /* @__PURE__ */ r(N, { onClick: () => {
244
241
  var t;
245
- return (t = c.current) == null ? void 0 : t.click();
242
+ return (t = l.current) == null ? void 0 : t.click();
246
243
  }, ...d }),
247
- /* @__PURE__ */ i(
244
+ /* @__PURE__ */ r(
248
245
  "input",
249
246
  {
250
247
  hidden: !0,
251
248
  type: "file",
252
- ref: c,
253
- accept: l,
254
- multiple: s,
249
+ ref: l,
250
+ accept: s,
251
+ multiple: u,
255
252
  onChange: B
256
253
  }
257
254
  )
258
255
  ] });
259
256
  }
260
- x.File = Y;
257
+ ((o) => {
258
+ o.Checkbox = T, o.Confirm = L, o.Input = M, o.File = Y;
259
+ })(N || (N = {}));
261
260
  export {
262
- x as Button,
263
- T as ButtonCheckbox
261
+ N as Button
264
262
  };
@@ -1,4 +1,4 @@
1
- import { ReactNode } from 'react';
1
+ import { CSSProperties, ReactNode } from 'react';
2
2
  import { BoxProps } from './Box';
3
3
  type Props = Partial<{
4
4
  /** Buttons or other content to render inline with the button */
@@ -11,6 +11,8 @@ type Props = Partial<{
11
11
  open: boolean;
12
12
  /** Text to display on the button for collapsing */
13
13
  title: ReactNode;
14
+ /** Custom styles for the child nodes */
15
+ childStyles: CSSProperties;
14
16
  }> & BoxProps;
15
17
  /**
16
18
  * ## Collapsible
@@ -1,35 +1,36 @@
1
- import { jsxs as n, jsx as e } from "react/jsx-runtime";
2
- import { useState as p } from "react";
3
- import { Box as t } from "./Box.js";
4
- import { Button as b } from "./Button.js";
5
- function x(o) {
1
+ import { jsxs as i, jsx as e } from "react/jsx-runtime";
2
+ import { useState as b } from "react";
3
+ import { Box as n } from "./Box.js";
4
+ import { Button as u } from "./Button.js";
5
+ function T(o) {
6
6
  const {
7
7
  children: r,
8
8
  child_mt: s = 1,
9
- color: m,
10
- title: a,
11
- buttons: c,
12
- icon: i,
13
- ...d
14
- } = o, [l, h] = p(o.open);
15
- return /* @__PURE__ */ n(t, { mb: 1, children: [
16
- /* @__PURE__ */ n("div", { className: "Table", children: [
9
+ childStyles: m,
10
+ color: a,
11
+ title: d,
12
+ buttons: t,
13
+ icon: c,
14
+ ...h
15
+ } = o, [l, p] = b(o.open);
16
+ return /* @__PURE__ */ i(n, { mb: 1, children: [
17
+ /* @__PURE__ */ i("div", { className: "Table", children: [
17
18
  /* @__PURE__ */ e("div", { className: "Table__cell", children: /* @__PURE__ */ e(
18
- b,
19
+ u,
19
20
  {
20
21
  fluid: !0,
21
- color: m,
22
- icon: i || (l ? "chevron-down" : "chevron-right"),
23
- onClick: () => h(!l),
24
- ...d,
25
- children: a
22
+ color: a,
23
+ icon: c || (l ? "chevron-down" : "chevron-right"),
24
+ onClick: () => p(!l),
25
+ ...h,
26
+ children: d
26
27
  }
27
28
  ) }),
28
- c && /* @__PURE__ */ e("div", { className: "Table__cell Table__cell--collapsing", children: c })
29
+ t && /* @__PURE__ */ e("div", { className: "Table__cell Table__cell--collapsing", children: t })
29
30
  ] }),
30
- l && /* @__PURE__ */ e(t, { mt: s, children: r })
31
+ l && /* @__PURE__ */ e(n, { mt: s, style: m, children: r })
31
32
  ] });
32
33
  }
33
34
  export {
34
- x as Collapsible
35
+ T as Collapsible
35
36
  };
@@ -1,6 +1,6 @@
1
1
  import { ReactNode } from 'react';
2
2
  import { BoxProps } from './Box';
3
- declare enum Direction {
3
+ export declare enum Direction {
4
4
  NORTH = 1,
5
5
  SOUTH = 2,
6
6
  EAST = 4,
@@ -1,21 +1,23 @@
1
- import { jsx as u } from "react/jsx-runtime";
2
- import { Image as $ } from "./Image.js";
3
- function x(o) {
4
- var r;
1
+ import { jsx as N } from "react/jsx-runtime";
2
+ import { Image as e } from "./Image.js";
3
+ var u = /* @__PURE__ */ ((T) => (T[T.NORTH = 1] = "NORTH", T[T.SOUTH = 2] = "SOUTH", T[T.EAST = 4] = "EAST", T[T.WEST = 8] = "WEST", T[T.NORTHEAST = 5] = "NORTHEAST", T[T.NORTHWEST = 9] = "NORTHWEST", T[T.SOUTHEAST = 6] = "SOUTHEAST", T[T.SOUTHWEST = 10] = "SOUTHWEST", T))(u || {});
4
+ function $(T) {
5
+ var m;
5
6
  const {
6
- className: l,
7
- direction: t = 2,
8
- fallback: n,
9
- frame: c = 1,
10
- icon_state: m,
11
- icon: i,
12
- movement: s = !1,
13
- ...a
14
- } = o, e = (r = Byond.iconRefMap) == null ? void 0 : r[i];
15
- if (!e) return n;
16
- const f = `${e}?state=${m}&dir=${t}&movement=${!!s}&frame=${c}`;
17
- return /* @__PURE__ */ u($, { fixErrors: !0, src: f, ...a });
7
+ className: A,
8
+ direction: E = 2,
9
+ fallback: a,
10
+ frame: s = 1,
11
+ icon_state: H,
12
+ icon: O,
13
+ movement: f = !1,
14
+ ...r
15
+ } = T, S = (m = Byond.iconRefMap) == null ? void 0 : m[O];
16
+ if (!S) return a;
17
+ const R = `${S}?state=${H}&dir=${E}&movement=${!!f}&frame=${s}`;
18
+ return /* @__PURE__ */ N(e, { fixErrors: !0, src: R, ...r });
18
19
  }
19
20
  export {
20
- x as DmIcon
21
+ u as Direction,
22
+ $ as DmIcon
21
23
  };
@@ -1,7 +1,7 @@
1
1
  import { BooleanLike } from '../common/react';
2
2
  import { BoxProps } from './Box';
3
3
  type Props = {
4
- /** Icon name. See [icon list](https://fontawesome.com/v5/search?o=r&m=free) */
4
+ /** Icon name. @see https://fontawesome.com/v6/search?o=r&m=free */
5
5
  name: string;
6
6
  } & Partial<{
7
7
  /** Icon rotation, in degrees. */
@@ -11,6 +11,8 @@ type Props = {
11
11
  /** Whether an icon should be spinning. Good for load indicators. */
12
12
  spin: BooleanLike;
13
13
  }> & Omit<BoxProps, 'children'>;
14
+ export declare function Icon(props: Props): import("react/jsx-runtime").JSX.Element;
15
+ declare function IconStack(props: BoxProps): import("react/jsx-runtime").JSX.Element;
14
16
  /**
15
17
  * ## Icon
16
18
  * Renders one of the FontAwesome icons of your choice.
@@ -19,11 +21,21 @@ type Props = {
19
21
  * ```tsx
20
22
  * <Icon name="plus" />
21
23
  * ```
22
- * @url https://fontawesome.com/v5/search?o=r&m=free
24
+ * @url https://fontawesome.com/v6/search?o=r&m=free
23
25
  */
24
- export declare function Icon(props: Props): import("react/jsx-runtime").JSX.Element;
25
26
  export declare namespace Icon {
26
- var Stack: typeof IconStack;
27
+ /**
28
+ * ## Icon.Stack
29
+ * Renders children icons on top of each other in order to make your own icon.
30
+ *
31
+ * @example
32
+ * ```tsx
33
+ * <Icon.Stack>
34
+ * <Icon name="pen" />
35
+ * <Icon name="slash" />
36
+ * </Icon.Stack>
37
+ * ```
38
+ */
39
+ const Stack: typeof IconStack;
27
40
  }
28
- declare function IconStack(props: BoxProps): import("react/jsx-runtime").JSX.Element;
29
41
  export {};