tgui-core 2.0.4 → 2.0.5

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
@@ -66,7 +66,7 @@ Contributions are welcome. Please open an issue or a pull request. I am availabl
66
66
 
67
67
  To automagically release a new version of the tgui-core package, simply create a [new release](https://github.com/tgstation/tgui-core/releases/new) with the tag set to the new version you want to publish. Set the tag to be the commit you want to base the version off of (likely the latest, being the default).
68
68
 
69
- The release workflow will take care of setting the `package.json` version, building, generating a release changelog, and publishing to npm.
69
+ The release workflow will take care of setting the `package.json` version, building, and publishing to npm.
70
70
 
71
71
  ### Development
72
72
 
@@ -42,12 +42,6 @@ type Props = {
42
42
  step: number;
43
43
  /** Screen distance mouse needs to travel to adjust value by one `step`. */
44
44
  stepPixelSize: number;
45
- /**
46
- * A number in milliseconds, for which the input will hold off from updating
47
- * while events propagate through the backend. Default is about 250ms,
48
- * increase it if you still see flickering.
49
- */
50
- suppressFlicker: number;
51
45
  /** Whether to clamp the value to the range. */
52
46
  unclamped: boolean;
53
47
  /** Unit to display to the right of value. */
@@ -1,79 +1,77 @@
1
- import { jsx as e, jsxs as o } from "react/jsx-runtime";
2
- import { keyOfMatchingRange as S, scale as c } from "../common/math.js";
3
- import { classes as $ } from "../common/react.js";
4
- import { computeBoxProps as j, computeBoxClassName as E } from "../common/ui.js";
5
- import { DraggableControl as T } from "./DraggableControl.js";
6
- function G(m) {
1
+ import { jsx as e, jsxs as l } from "react/jsx-runtime";
2
+ import { keyOfMatchingRange as F, scale as c } from "../common/math.js";
3
+ import { classes as S } from "../common/react.js";
4
+ import { computeBoxProps as $, computeBoxClassName as j } from "../common/ui.js";
5
+ import { DraggableControl as E } from "./DraggableControl.js";
6
+ function A(m) {
7
7
  const {
8
8
  // Draggable props (passthrough)
9
9
  animated: d,
10
- format: p,
10
+ format: g,
11
11
  maxValue: a,
12
- minValue: l,
13
- onChange: u,
14
- onDrag: g,
12
+ minValue: o,
13
+ onChange: p,
14
+ onDrag: u,
15
15
  step: _,
16
16
  stepPixelSize: b,
17
- suppressFlicker: f,
18
- unclamped: h,
19
- unit: x,
17
+ unclamped: f,
18
+ unit: h,
20
19
  value: r,
21
20
  // Own props
22
- bipolar: s,
23
- className: K,
24
- color: v,
25
- fillValue: n,
26
- ranges: N = {},
27
- size: y = 1,
28
- style: V,
29
- ...i
21
+ bipolar: n,
22
+ className: x,
23
+ color: K,
24
+ fillValue: i,
25
+ ranges: v = {},
26
+ size: N = 1,
27
+ style: y,
28
+ ...s
30
29
  } = m;
31
30
  return /* @__PURE__ */ e(
32
- T,
31
+ E,
33
32
  {
34
33
  dragMatrix: [0, -1],
35
34
  animated: d,
36
- format: p,
35
+ format: g,
37
36
  maxValue: a,
38
- minValue: l,
39
- onChange: u,
40
- onDrag: g,
37
+ minValue: o,
38
+ onChange: p,
39
+ onDrag: u,
41
40
  step: _,
42
41
  stepPixelSize: b,
43
- suppressFlicker: f,
44
- unclamped: h,
45
- unit: x,
42
+ unclamped: f,
43
+ unit: h,
46
44
  value: r,
47
- children: (k) => {
45
+ children: (V) => {
48
46
  const {
49
47
  displayElement: D,
50
48
  displayValue: t,
51
49
  dragging: M,
52
- handleDragStart: B,
53
- inputElement: P
54
- } = k, C = c(
55
- n ?? t,
56
- l,
50
+ handleDragStart: k,
51
+ inputElement: B
52
+ } = V, P = c(
53
+ i ?? t,
54
+ o,
57
55
  a
58
- ), F = c(t, l, a), w = v || S(n ?? r, N) || "default", z = Math.min((F - 0.5) * 270, 225);
59
- return /* @__PURE__ */ o(
56
+ ), C = c(t, o, a), w = K || F(i ?? r, v) || "default", z = Math.min((C - 0.5) * 270, 225);
57
+ return /* @__PURE__ */ l(
60
58
  "div",
61
59
  {
62
- className: $([
60
+ className: S([
63
61
  "Knob",
64
62
  `Knob--color--${w}`,
65
- s && "Knob--bipolar",
66
- K,
67
- E(i)
63
+ n && "Knob--bipolar",
64
+ x,
65
+ j(s)
68
66
  ]),
69
- ...j({
67
+ ...$({
70
68
  style: {
71
- fontSize: `${y}em`,
72
- ...V
69
+ fontSize: `${N}em`,
70
+ ...y
73
71
  },
74
- ...i
72
+ ...s
75
73
  }),
76
- onMouseDown: B,
74
+ onMouseDown: k,
77
75
  children: [
78
76
  /* @__PURE__ */ e("div", { className: "Knob__circle", children: /* @__PURE__ */ e(
79
77
  "div",
@@ -86,7 +84,7 @@ function G(m) {
86
84
  }
87
85
  ) }),
88
86
  M && /* @__PURE__ */ e("div", { className: "Knob__popupValue", children: D }),
89
- /* @__PURE__ */ o(
87
+ /* @__PURE__ */ l(
90
88
  "svg",
91
89
  {
92
90
  className: "Knob__ring Knob__ringTrackPivot",
@@ -97,7 +95,7 @@ function G(m) {
97
95
  ]
98
96
  }
99
97
  ),
100
- /* @__PURE__ */ o(
98
+ /* @__PURE__ */ l(
101
99
  "svg",
102
100
  {
103
101
  className: "Knob__ring Knob__ringFillPivot",
@@ -110,7 +108,7 @@ function G(m) {
110
108
  className: "Knob__ringFill",
111
109
  style: {
112
110
  strokeDashoffset: Math.max(
113
- ((s ? 2.75 : 2) - C * 1.5) * Math.PI * 50,
111
+ ((n ? 2.75 : 2) - P * 1.5) * Math.PI * 50,
114
112
  0
115
113
  )
116
114
  },
@@ -122,7 +120,7 @@ function G(m) {
122
120
  ]
123
121
  }
124
122
  ),
125
- P
123
+ B
126
124
  ]
127
125
  }
128
126
  );
@@ -131,5 +129,5 @@ function G(m) {
131
129
  );
132
130
  }
133
131
  export {
134
- G as Knob
132
+ A as Knob
135
133
  };
@@ -40,6 +40,8 @@ type Props = {
40
40
  *
41
41
  */
42
42
  ranges: Record<string, [number, number]>;
43
+ /** Removes progress percentage text, makes no sense if children are present */
44
+ empty: boolean;
43
45
  }> & BoxProps & PropsWithChildren;
44
46
  /**
45
47
  * ## ProgressBar
@@ -1,9 +1,9 @@
1
- import { jsxs as B, jsx as i } from "react/jsx-runtime";
2
- import { CSS_COLORS as C } from "../common/constants.js";
3
- import { keyOfMatchingRange as P, toFixed as h, clamp01 as x, scale as _ } from "../common/math.js";
4
- import { classes as v } from "../common/react.js";
5
- import { computeBoxProps as y, computeBoxClassName as N } from "../common/ui.js";
6
- function j(n) {
1
+ import { jsxs as C, jsx as i } from "react/jsx-runtime";
2
+ import { CSS_COLORS as P } from "../common/constants.js";
3
+ import { keyOfMatchingRange as h, toFixed as x, clamp01 as _, scale as v } from "../common/math.js";
4
+ import { classes as y } from "../common/react.js";
5
+ import { computeBoxProps as N, computeBoxClassName as S } from "../common/ui.js";
6
+ function k(n) {
7
7
  const {
8
8
  className: m,
9
9
  value: o,
@@ -11,12 +11,13 @@ function j(n) {
11
11
  maxValue: f = 1,
12
12
  color: u,
13
13
  ranges: p = {},
14
+ empty: g,
14
15
  children: r,
15
16
  ...l
16
- } = n, a = _(o, d, f), g = r !== void 0, s = u || P(o, p) || "default", e = y(l), t = ["ProgressBar", m, N(l)], c = {
17
- width: `${x(a) * 100}%`
17
+ } = n, t = v(o, d, f), B = r !== void 0, s = u || h(o, p) || "default", e = N(l), a = ["ProgressBar", m, S(l)], c = {
18
+ width: `${_(t) * 100}%`
18
19
  };
19
- return C.includes(s) || s === "default" ? t.push(`ProgressBar--color--${s}`) : (e.style = { ...e.style, borderColor: s }, c.backgroundColor = s), /* @__PURE__ */ B("div", { className: v(t), ...e, children: [
20
+ return P.includes(s) || s === "default" ? a.push(`ProgressBar--color--${s}`) : (e.style = { ...e.style, borderColor: s }, c.backgroundColor = s), /* @__PURE__ */ C("div", { className: y(a), ...e, children: [
20
21
  /* @__PURE__ */ i(
21
22
  "div",
22
23
  {
@@ -24,9 +25,9 @@ function j(n) {
24
25
  style: c
25
26
  }
26
27
  ),
27
- /* @__PURE__ */ i("div", { className: "ProgressBar__content", children: g ? r : `${h(a * 100)}%` })
28
+ /* @__PURE__ */ i("div", { className: "ProgressBar__content", children: B ? r : !g && `${x(t * 100)}%` })
28
29
  ] });
29
30
  }
30
31
  export {
31
- j as ProgressBar
32
+ k as ProgressBar
32
33
  };
@@ -42,12 +42,6 @@ type Props = {
42
42
  * while dragging. Use higher for larger sliders. Default is 1.
43
43
  */
44
44
  stepPixelSize: number;
45
- /**
46
- * A number in milliseconds, for which the input will hold off from updating
47
- * while events propagate through the backend. Default is about 250ms,
48
- * increase it if you still see flickering.
49
- */
50
- suppressFlicker: number;
51
45
  /** Unit to display to the right of value. */
52
46
  unit: string;
53
47
  }> & BoxProps & PropsWithChildren;
@@ -1,69 +1,67 @@
1
- import { jsx as e, jsxs as p } from "react/jsx-runtime";
2
- import { keyOfMatchingRange as E, clamp01 as r, scale as u } from "../common/math.js";
1
+ import { jsx as e, jsxs as u } from "react/jsx-runtime";
2
+ import { keyOfMatchingRange as F, clamp01 as s, scale as p } from "../common/math.js";
3
3
  import { classes as g } from "../common/react.js";
4
4
  import { computeBoxProps as O, computeBoxClassName as b } from "../common/ui.js";
5
- import { DraggableControl as z } from "./DraggableControl.js";
6
- function I(f) {
5
+ import { DraggableControl as k } from "./DraggableControl.js";
6
+ function H(f) {
7
7
  const {
8
8
  // Draggable props (passthrough)
9
9
  animated: _,
10
10
  format: h,
11
- maxValue: a,
12
- minValue: l,
11
+ maxValue: l,
12
+ minValue: r,
13
13
  onChange: v,
14
14
  onDrag: N,
15
15
  step: x,
16
16
  stepPixelSize: y,
17
- suppressFlicker: B,
18
- unit: P,
17
+ unit: B,
19
18
  value: i,
20
19
  // Own props
21
- className: S,
22
- fillValue: s,
23
- color: V,
24
- ranges: C = {},
20
+ className: P,
21
+ fillValue: a,
22
+ color: S,
23
+ ranges: V = {},
25
24
  children: o,
26
25
  ...t
27
- } = f, D = o !== void 0;
26
+ } = f, C = o !== void 0;
28
27
  return /* @__PURE__ */ e(
29
- z,
28
+ k,
30
29
  {
31
30
  dragMatrix: [1, 0],
32
31
  animated: _,
33
32
  format: h,
34
- maxValue: a,
35
- minValue: l,
33
+ maxValue: l,
34
+ minValue: r,
36
35
  onChange: v,
37
36
  onDrag: N,
38
37
  step: x,
39
38
  stepPixelSize: y,
40
- suppressFlicker: B,
41
- unit: P,
39
+ unit: B,
42
40
  value: i,
43
- children: (w) => {
41
+ children: (D) => {
44
42
  const {
45
43
  displayElement: n,
46
44
  displayValue: c,
47
- dragging: M,
48
- handleDragStart: $,
49
- inputElement: F
50
- } = w, j = s != null, d = u(
51
- s ?? c,
52
- l,
53
- a
54
- ), m = u(c, l, a), k = V || E(s ?? i, C) || "default";
55
- return /* @__PURE__ */ p(
45
+ dragging: w,
46
+ handleDragStart: M,
47
+ inputElement: $
48
+ } = D, j = a != null, d = p(
49
+ a ?? c,
50
+ r,
51
+ l
52
+ ), m = p(c, r, l), E = S || F(a ?? i, V) || "default";
53
+ return /* @__PURE__ */ u(
56
54
  "div",
57
55
  {
58
56
  className: g([
59
57
  "Slider",
60
58
  "ProgressBar",
61
- `ProgressBar--color--${k}`,
62
- S,
59
+ `ProgressBar--color--${E}`,
60
+ P,
63
61
  b(t)
64
62
  ]),
65
63
  ...O(t),
66
- onMouseDown: $,
64
+ onMouseDown: M,
67
65
  children: [
68
66
  /* @__PURE__ */ e(
69
67
  "div",
@@ -73,7 +71,7 @@ function I(f) {
73
71
  j && "ProgressBar__fill--animated"
74
72
  ]),
75
73
  style: {
76
- width: `${r(d) * 100}%`,
74
+ width: `${s(d) * 100}%`,
77
75
  opacity: 0.4
78
76
  }
79
77
  }
@@ -83,26 +81,26 @@ function I(f) {
83
81
  {
84
82
  className: "ProgressBar__fill",
85
83
  style: {
86
- width: `${r(Math.min(d, m)) * 100}%`
84
+ width: `${s(Math.min(d, m)) * 100}%`
87
85
  }
88
86
  }
89
87
  ),
90
- /* @__PURE__ */ p(
88
+ /* @__PURE__ */ u(
91
89
  "div",
92
90
  {
93
91
  className: "Slider__cursorOffset",
94
92
  style: {
95
- width: `${r(m) * 100}%`
93
+ width: `${s(m) * 100}%`
96
94
  },
97
95
  children: [
98
96
  /* @__PURE__ */ e("div", { className: "Slider__cursor" }),
99
97
  /* @__PURE__ */ e("div", { className: "Slider__pointer" }),
100
- M && /* @__PURE__ */ e("div", { className: "Slider__popupValue", children: n })
98
+ w && /* @__PURE__ */ e("div", { className: "Slider__popupValue", children: n })
101
99
  ]
102
100
  }
103
101
  ),
104
- /* @__PURE__ */ e("div", { className: "ProgressBar__content", children: D ? o : n }),
105
- F
102
+ /* @__PURE__ */ e("div", { className: "ProgressBar__content", children: C ? o : n }),
103
+ $
106
104
  ]
107
105
  }
108
106
  );
@@ -111,5 +109,5 @@ function I(f) {
111
109
  );
112
110
  }
113
111
  export {
114
- I as Slider
112
+ H as Slider
115
113
  };
@@ -67,7 +67,7 @@ export declare namespace Stack {
67
67
  var Divider: typeof StackDivider;
68
68
  }
69
69
  type StackItemProps = FlexItemProps & Partial<{
70
- innerRef: RefObject<HTMLDivElement>;
70
+ innerRef: RefObject<HTMLDivElement | null>;
71
71
  }>;
72
72
  declare function StackItem(props: StackItemProps): import("react/jsx-runtime").JSX.Element;
73
73
  type StackDividerProps = FlexItemProps & Partial<{
@@ -1,46 +1,47 @@
1
1
  import { jsx as i } from "react/jsx-runtime";
2
- import { classes as a } from "../common/react.js";
2
+ import { useRef as S } from "react";
3
+ import { classes as s } from "../common/react.js";
3
4
  import { computeBoxClassName as o } from "../common/ui.js";
4
5
  import { computeFlexProps as k, computeFlexClassName as v, computeFlexItemProps as m } from "./Flex.js";
5
- function n(r) {
6
- const { className: c, vertical: e, fill: t, reverse: s, zebra: l, ...d } = r, f = e ? "column" : "row", S = s ? "-reverse" : "";
6
+ function l(r) {
7
+ const { className: c, vertical: e, fill: t, reverse: a, zebra: n, ...d } = r, u = e ? "column" : "row", f = a ? "-reverse" : "";
7
8
  return /* @__PURE__ */ i(
8
9
  "div",
9
10
  {
10
- className: a([
11
+ className: s([
11
12
  "Stack",
12
13
  t && "Stack--fill",
13
14
  e ? "Stack--vertical" : "Stack--horizontal",
14
- l && "Stack--zebra",
15
- s && `Stack--reverse${e ? "--vertical" : ""}`,
15
+ n && "Stack--zebra",
16
+ a && `Stack--reverse${e ? "--vertical" : ""}`,
16
17
  c,
17
18
  v(r)
18
19
  ]),
19
20
  ...k({
20
- direction: `${f}${S}`,
21
+ direction: `${u}${f}`,
21
22
  ...d
22
23
  })
23
24
  }
24
25
  );
25
26
  }
26
- function u(r) {
27
- const { className: c, innerRef: e, ...t } = r;
27
+ function p(r) {
28
+ const { className: c, innerRef: e, ...t } = r, a = S((e == null ? void 0 : e.current) ?? null);
28
29
  return /* @__PURE__ */ i(
29
30
  "div",
30
31
  {
31
- className: a(["Stack__item", c, o(t)]),
32
- ref: e,
32
+ className: s(["Stack__item", c, o(t)]),
33
+ ref: a,
33
34
  ...m(t)
34
35
  }
35
36
  );
36
37
  }
37
- n.Item = u;
38
- function p(r) {
38
+ l.Item = p;
39
+ function x(r) {
39
40
  const { className: c, hidden: e, ...t } = r;
40
41
  return /* @__PURE__ */ i(
41
42
  "div",
42
43
  {
43
- className: a([
44
+ className: s([
44
45
  "Stack__item",
45
46
  "Stack__divider",
46
47
  e && "Stack__divider--hidden",
@@ -51,7 +52,7 @@ function p(r) {
51
52
  }
52
53
  );
53
54
  }
54
- n.Divider = p;
55
+ l.Divider = x;
55
56
  export {
56
- n as Stack
57
+ l as Stack
57
58
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tgui-core",
3
- "version": "2.0.4",
3
+ "version": "2.0.5",
4
4
  "description": "TGUI core component library",
5
5
  "keywords": ["TGUI", "library", "typescript"],
6
6
  "files": ["dist", "styles"],
@@ -11,6 +11,8 @@ $border-radius: 0 !default;
11
11
  display: inline-block;
12
12
  position: relative;
13
13
  width: 100%;
14
+ min-height: 1.667em;
15
+ align-content: center;
14
16
  padding: 0 var(--space-m);
15
17
  border-width: var(--border-thickness-tiny) !important;
16
18
  border-style: solid !important;