tgui-core 1.1.21 → 1.1.23

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
@@ -39,3 +39,16 @@ MIT
39
39
  ## Contributing
40
40
 
41
41
  Contributions are welcome. Please open an issue or a pull request. I am available on the tgstation [discord](https://discord.com/invite/EUvpBtU78X).
42
+
43
+ ### Releasing a new version
44
+
45
+ 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).
46
+
47
+ The release workflow will take care of setting the `package.json` version, building, generating a release changelog, and publishing to npm.
48
+
49
+ ### Development
50
+
51
+ This project uses [pnpm](https://pnpm.io/installation) for its package manager.
52
+
53
+ To set up the repository:
54
+ `pnpm install`
@@ -1,4 +1,4 @@
1
- import './assets/ProgressBar.css';const _ = "_progressBar_140lk_17", o = "_fill_140lk_29", l = "_fill__animated_140lk_36", r = "_content_140lk_40", c = "_color__default_140lk_47", e = "_color__black_140lk_54", t = "_color__white_140lk_61", n = "_color__red_140lk_68", a = "_color__orange_140lk_75", s = "_color__yellow_140lk_82", k = "_color__olive_140lk_89", i = "_color__green_140lk_96", g = "_color__teal_140lk_103", b = "_color__blue_140lk_110", d = "_color__violet_140lk_117", p = "_color__purple_140lk_124", f = "_color__pink_140lk_131", u = "_color__brown_140lk_138", v = "_color__grey_140lk_145", w = "_color__good_140lk_159", y = "_color__average_140lk_166", h = "_color__bad_140lk_173", m = "_color__label_140lk_180", B = {
1
+ import './assets/ProgressBar.css';const _ = "_progressBar_140lk_17", o = "_fill_140lk_29", l = "_fill__animated_140lk_36", r = "_content_140lk_40", c = "_color__default_140lk_47", e = "_color__black_140lk_54", t = "_color__white_140lk_61", n = "_color__red_140lk_68", a = "_color__orange_140lk_75", s = "_color__yellow_140lk_82", k = "_color__olive_140lk_89", g = "_color__green_140lk_96", i = "_color__teal_140lk_103", b = "_color__blue_140lk_110", d = "_color__violet_140lk_117", p = "_color__purple_140lk_124", f = "_color__pink_140lk_131", u = "_color__brown_140lk_138", v = "_color__grey_140lk_145", w = "_color__good_140lk_159", y = "_color__average_140lk_166", h = "_color__bad_140lk_173", m = "_color__label_140lk_180", B = {
2
2
  progressBar: _,
3
3
  fill: o,
4
4
  fill__animated: l,
@@ -10,8 +10,8 @@ import './assets/ProgressBar.css';const _ = "_progressBar_140lk_17", o = "_fill_
10
10
  color__orange: a,
11
11
  color__yellow: s,
12
12
  color__olive: k,
13
- color__green: i,
14
- color__teal: g,
13
+ color__green: g,
14
+ color__teal: i,
15
15
  color__blue: b,
16
16
  color__violet: d,
17
17
  color__purple: p,
@@ -25,5 +25,5 @@ import './assets/ProgressBar.css';const _ = "_progressBar_140lk_17", o = "_fill_
25
25
  color__label: m
26
26
  };
27
27
  export {
28
- B as s
28
+ B as p
29
29
  };
@@ -16,6 +16,21 @@
16
16
  * ```
17
17
  */
18
18
  export declare function createSearch<TObj>(searchText: string, stringifier?: (obj: TObj) => string): (obj: TObj) => boolean;
19
+ export declare const VOWELS: string[];
20
+ /**
21
+ * Pluralizes a word based on the number given.
22
+ * Handles -es and -ies.
23
+ *
24
+ * @param override - A custom string to be appended instead for plurals. Useful for words that don't follow the standard rules.
25
+ *
26
+ * @example
27
+ * ```tsx
28
+ * pluralize('Dog', 1) // Dog
29
+ * pluralize('Dog', 2) // Dogs
30
+ * pluralize('Monarch', 2, "s") // Monarchs
31
+ * ```
32
+ */
33
+ export declare function pluralize(str: string, n: number, override?: string): string;
19
34
  /**
20
35
  * Capitalizes a word and lowercases the rest.
21
36
  *
@@ -7,16 +7,20 @@ function p(e, t = (r) => JSON.stringify(r)) {
7
7
  return o ? o.toLowerCase().includes(r) : !1;
8
8
  };
9
9
  }
10
- function a(e) {
10
+ const a = ["a", "e", "i", "o", "u"];
11
+ function l(e, t, r) {
12
+ return t === 1 ? e : r ? e + r : e.endsWith("s") || e.endsWith("x") || e.endsWith("z") || e.endsWith("ch") || e.endsWith("sh") ? e + "es" : e.endsWith("y") && !a.includes(e.charAt(e.length - 2)) ? e.slice(0, -1) + "ies" : e + "s";
13
+ }
14
+ function c(e) {
11
15
  return e.charAt(0).toUpperCase() + e.slice(1).toLowerCase();
12
16
  }
13
- function u(e) {
17
+ function f(e) {
14
18
  return e.replace(/(^\w{1})|(\s+\w{1})/g, (t) => t.toUpperCase());
15
19
  }
16
- function l(e) {
20
+ function h(e) {
17
21
  return e.replace(/^\w/, (t) => t.toUpperCase());
18
22
  }
19
- const c = ["Id", "Tv"], s = [
23
+ const i = ["Id", "Tv"], s = [
20
24
  "A",
21
25
  "An",
22
26
  "And",
@@ -39,20 +43,20 @@ const c = ["Id", "Tv"], s = [
39
43
  "To",
40
44
  "With"
41
45
  ];
42
- function f(e) {
46
+ function g(e) {
43
47
  if (!e) return e;
44
- let t = e.replace(/([^\W_]+[^\s-]*) */g, (r) => a(r));
48
+ let t = e.replace(/([^\W_]+[^\s-]*) */g, (r) => c(r));
45
49
  for (const r of s) {
46
50
  const n = new RegExp("\\s" + r + "\\s", "g");
47
51
  t = t.replace(n, (o) => o.toLowerCase());
48
52
  }
49
- for (const r of c) {
53
+ for (const r of i) {
50
54
  const n = new RegExp("\\b" + r + "\\b", "g");
51
55
  t = t.replace(n, (o) => o.toLowerCase());
52
56
  }
53
57
  return t;
54
58
  }
55
- const i = {
59
+ const u = {
56
60
  amp: "&",
57
61
  apos: "'",
58
62
  gt: ">",
@@ -60,11 +64,11 @@ const i = {
60
64
  nbsp: " ",
61
65
  quot: '"'
62
66
  };
63
- function g(e) {
67
+ function d(e) {
64
68
  return e && e.replace(/<br>/gi, `
65
69
  `).replace(/<\/?[a-z0-9-_]+[^>]*>/gi, "").replace(
66
70
  /&(nbsp|amp|quot|lt|gt|apos);/g,
67
- (t, r) => i[r]
71
+ (t, r) => u[r]
68
72
  ).replace(/&#?([0-9]+);/gi, (t, r) => {
69
73
  const n = parseInt(r, 10);
70
74
  return String.fromCharCode(n);
@@ -74,10 +78,12 @@ function g(e) {
74
78
  });
75
79
  }
76
80
  export {
77
- a as capitalize,
78
- u as capitalizeAll,
79
- l as capitalizeFirst,
81
+ a as VOWELS,
82
+ c as capitalize,
83
+ f as capitalizeAll,
84
+ h as capitalizeFirst,
80
85
  p as createSearch,
81
- g as decodeHtmlEntities,
82
- f as toTitleCase
86
+ d as decodeHtmlEntities,
87
+ l as pluralize,
88
+ g as toTitleCase
83
89
  };
@@ -28,7 +28,7 @@ const m = (o) => (t, i) => {
28
28
  }, g = (o, t, i) => (e, f) => {
29
29
  if (typeof f == "number" || typeof f == "string")
30
30
  for (let c = 0; c < i.length; c++)
31
- e[o + "-" + i[c]] = t(f);
31
+ e[o + i[c]] = t(f);
32
32
  }, s = (o) => (t, i) => {
33
33
  x(i) && (t[o] = i);
34
34
  }, C = {
@@ -15,7 +15,7 @@ function d(r) {
15
15
  e(o)
16
16
  ]),
17
17
  ...n(o),
18
- children: c || "."
18
+ children: c || ""
19
19
  }
20
20
  );
21
21
  }
@@ -1,4 +1,4 @@
1
- import { jsx as l, jsxs as d } from "react/jsx-runtime";
1
+ import { jsx as l, jsxs as b } from "react/jsx-runtime";
2
2
  import { classes as i } from "../common/react.js";
3
3
  import { Box as r, unit as g } from "./Box.js";
4
4
  import { Divider as x } from "./Divider.js";
@@ -12,7 +12,7 @@ import '../assets/LabeledList.css';const v = "_labeledList_pb6nb_9", y = "_row_p
12
12
  };
13
13
  function p(e) {
14
14
  const { children: t } = e;
15
- return /* @__PURE__ */ l("table", { className: "LabeledList", children: t });
15
+ return /* @__PURE__ */ l("table", { className: "LabeledList", children: /* @__PURE__ */ l("tbody", { children: t }) });
16
16
  }
17
17
  function z(e) {
18
18
  const {
@@ -21,15 +21,15 @@ function z(e) {
21
21
  labelColor: _ = "label",
22
22
  labelWrap: m,
23
23
  color: L,
24
- textAlign: f,
24
+ textAlign: h,
25
25
  buttons: a,
26
- content: h,
26
+ content: f,
27
27
  children: u,
28
28
  verticalAlign: c = "baseline",
29
- tooltip: b
29
+ tooltip: d
30
30
  } = e;
31
31
  let n;
32
- s && (n = s, typeof s == "string" && (n += ":")), b !== void 0 && (n = /* @__PURE__ */ l(N, { content: b, children: /* @__PURE__ */ l(
32
+ s && (n = s, typeof s == "string" && (n += ":")), d !== void 0 && (n = /* @__PURE__ */ l(N, { content: d, children: /* @__PURE__ */ l(
33
33
  r,
34
34
  {
35
35
  as: "span",
@@ -53,19 +53,19 @@ function z(e) {
53
53
  children: n
54
54
  }
55
55
  );
56
- return /* @__PURE__ */ d("tr", { className: i([o.row, t]), children: [
56
+ return /* @__PURE__ */ b("tr", { className: i([o.row, t]), children: [
57
57
  w,
58
- /* @__PURE__ */ d(
58
+ /* @__PURE__ */ b(
59
59
  r,
60
60
  {
61
61
  as: "td",
62
62
  color: L,
63
- textAlign: f,
63
+ textAlign: h,
64
64
  className: o.cell,
65
65
  colSpan: a ? void 0 : 2,
66
66
  verticalAlign: c,
67
67
  children: [
68
- h,
68
+ f,
69
69
  u
70
70
  ]
71
71
  }
@@ -1,35 +1,35 @@
1
- import { jsxs as g, jsx as n } from "react/jsx-runtime";
1
+ import { jsxs as x, jsx as n } from "react/jsx-runtime";
2
2
  import { CSS_COLORS as v } from "../common/constants.js";
3
- import { keyOfMatchingRange as y, toFixed as N, scale as _, clamp01 as B } from "../common/math.js";
3
+ import { keyOfMatchingRange as y, toFixed as N, scale as S, clamp01 as _ } from "../common/math.js";
4
4
  import { classes as m } from "../common/react.js";
5
- import { s as o } from "../ProgressBar.module-BkAFfFy0.js";
6
- import { computeBoxProps as S, computeBoxClassName as O } from "./Box.js";
5
+ import { p as e } from "../ProgressBar.module-Jzqlebbx.js";
6
+ import { computeBoxProps as B, computeBoxClassName as O } from "./Box.js";
7
7
  function w(d) {
8
8
  const {
9
9
  className: f,
10
10
  value: r,
11
- minValue: u = 0,
12
- maxValue: p = 1,
11
+ minValue: p = 0,
12
+ maxValue: u = 1,
13
13
  color: C,
14
- ranges: h = {},
14
+ ranges: g = {},
15
15
  children: l,
16
16
  ...t
17
- } = d, a = _(r, u, p), x = l !== void 0, s = C || y(r, h) || "default", e = S(t), c = [
18
- o.progressBar,
17
+ } = d, a = S(r, p, u), h = l !== void 0, o = C || y(r, g) || "default", s = B(t), c = [
18
+ e.progressBar,
19
19
  f,
20
20
  O(t)
21
21
  ], i = {
22
- width: B(a) * 100 + "%"
22
+ width: _(a) * 100 + "%"
23
23
  };
24
- return v.includes(s) || s === "default" ? c.push(o["color__" + s]) : (e.style = { ...e.style, borderColor: s }, i.backgroundColor = s), /* @__PURE__ */ g("div", { className: m(c), ...e, children: [
24
+ return v.includes(o) || o === "default" ? c.push(e["color__" + o]) : (s.style = { ...s.style, borderColor: o }, i.backgroundColor = o), /* @__PURE__ */ x("div", { className: m(c), ...s, children: [
25
25
  /* @__PURE__ */ n(
26
26
  "div",
27
27
  {
28
- className: m([o.fill, o.fill__animated]),
28
+ className: m([e.fill, e.fill__animated]),
29
29
  style: i
30
30
  }
31
31
  ),
32
- /* @__PURE__ */ n("div", { className: o.content, children: x ? l : N(a * 100) + "%" })
32
+ /* @__PURE__ */ n("div", { className: e.content, children: h ? l : N(a * 100) + "%" })
33
33
  ] });
34
34
  }
35
35
  export {
@@ -1,21 +1,21 @@
1
1
  import { jsx as s, jsxs as m } from "react/jsx-runtime";
2
2
  import { keyOfMatchingRange as R, clamp01 as t, scale as f } from "../common/math.js";
3
3
  import { classes as _ } from "../common/react.js";
4
- import { s as e } from "../ProgressBar.module-BkAFfFy0.js";
5
- import { computeBoxClassName as $, computeBoxProps as q } from "./Box.js";
6
- import { DraggableControl as A } from "./DraggableControl.js";
7
- import '../assets/Slider.css';const G = "_slider_1assx_9", H = "_cursorOffset_1assx_13", I = "_cursor_1assx_13", J = "_pointer_1assx_30", K = "_popupValue_1assx_41", a = {
8
- slider: G,
9
- cursorOffset: H,
10
- cursor: I,
11
- pointer: J,
12
- popupValue: K
4
+ import { p as e } from "../ProgressBar.module-Jzqlebbx.js";
5
+ import { computeBoxClassName as q, computeBoxProps as A } from "./Box.js";
6
+ import { DraggableControl as G } from "./DraggableControl.js";
7
+ import '../assets/Slider.css';const H = "_slider_1assx_9", I = "_cursorOffset_1assx_13", J = "_cursor_1assx_13", K = "_pointer_1assx_30", L = "_popupValue_1assx_41", a = {
8
+ slider: H,
9
+ cursorOffset: I,
10
+ cursor: J,
11
+ pointer: K,
12
+ popupValue: L
13
13
  };
14
- function Y(h) {
14
+ function Z(h) {
15
15
  const {
16
16
  // Draggable props (passthrough)
17
- animated: v,
18
- format: g,
17
+ animated: g,
18
+ format: v,
19
19
  maxValue: o,
20
20
  minValue: r,
21
21
  onChange: x,
@@ -29,16 +29,16 @@ function Y(h) {
29
29
  className: w,
30
30
  fillValue: l,
31
31
  color: M,
32
- ranges: B = {},
32
+ ranges: S = {},
33
33
  children: i,
34
34
  ...c
35
- } = h, F = i !== void 0;
35
+ } = h, B = i !== void 0;
36
36
  return /* @__PURE__ */ s(
37
- A,
37
+ G,
38
38
  {
39
39
  dragMatrix: [1, 0],
40
- animated: v,
41
- format: g,
40
+ animated: g,
41
+ format: v,
42
42
  maxValue: o,
43
43
  minValue: r,
44
44
  onChange: x,
@@ -48,7 +48,7 @@ function Y(h) {
48
48
  suppressFlicker: C,
49
49
  unit: D,
50
50
  value: O,
51
- children: (S) => {
51
+ children: (F) => {
52
52
  const {
53
53
  displayElement: n,
54
54
  displayValue: p,
@@ -56,11 +56,11 @@ function Y(h) {
56
56
  handleDragStart: k,
57
57
  inputElement: E,
58
58
  value: P
59
- } = S, b = l != null, u = f(
59
+ } = F, b = l != null, u = f(
60
60
  l ?? p,
61
61
  r,
62
62
  o
63
- ), d = f(p, r, o), z = M || R(l ?? P, B) || "default";
63
+ ), d = f(p, r, o), z = M || R(l ?? P, S) || "default";
64
64
  return /* @__PURE__ */ m(
65
65
  "div",
66
66
  {
@@ -69,9 +69,9 @@ function Y(h) {
69
69
  e.progressBar,
70
70
  e["color__" + z],
71
71
  w,
72
- $(c)
72
+ q(c)
73
73
  ]),
74
- ...q(c),
74
+ ...A(c),
75
75
  onMouseDown: k,
76
76
  children: [
77
77
  /* @__PURE__ */ s(
@@ -110,7 +110,7 @@ function Y(h) {
110
110
  ]
111
111
  }
112
112
  ),
113
- /* @__PURE__ */ s("div", { className: e.content, children: F ? i : n }),
113
+ /* @__PURE__ */ s("div", { className: e.content, children: B ? i : n }),
114
114
  E
115
115
  ]
116
116
  }
@@ -120,5 +120,5 @@ function Y(h) {
120
120
  );
121
121
  }
122
122
  export {
123
- Y as Slider
123
+ Z as Slider
124
124
  };
@@ -0,0 +1,10 @@
1
+ interface TimeDisplayProps {
2
+ /** Whether the TimeDisplay should automatically increment or decrement (plain prop to dec.) */
3
+ auto?: 'up' | 'down' | true;
4
+ /** An optional function to format the value */
5
+ format?: (value: number) => string;
6
+ /** The value that the TimeDisplay needs to render - if you pass a wrong type it will be rendered directly */
7
+ value: number;
8
+ }
9
+ export declare function TimeDisplay(props: TimeDisplayProps): string | number | null;
10
+ export {};
@@ -1,34 +1,25 @@
1
- import { Component as r } from "react";
2
- import { formatTime as u } from "../common/format.js";
3
- function s(e) {
4
- return typeof e == "number" && Number.isFinite(e) && !Number.isNaN(e);
5
- }
6
- class o extends r {
7
- constructor(t) {
8
- super(t), this.timer = null, this.last_seen_value = void 0, this.state = {
9
- value: 0
10
- }, s(t.value) && (this.state.value = Number(t.value), this.last_seen_value = Number(t.value));
11
- }
12
- componentDidUpdate() {
13
- this.props.auto !== void 0 && (clearInterval(this.timer), this.timer = setInterval(() => this.tick(), 1e3));
14
- }
15
- tick() {
16
- let t = Number(this.state.value);
17
- this.props.value !== this.last_seen_value && (this.last_seen_value = this.props.value, t = this.props.value);
18
- const i = this.props.auto === "up" ? 10 : -10, a = Math.max(0, t + i);
19
- this.setState({ value: a });
20
- }
21
- componentDidMount() {
22
- this.props.auto !== void 0 && (this.timer = setInterval(() => this.tick(), 1e3));
23
- }
24
- componentWillUnmount() {
25
- clearInterval(this.timer);
26
- }
27
- render() {
28
- const t = this.state.value;
29
- return s(t) ? u(t) : this.state.value || null;
30
- }
1
+ import { useState as l, useRef as d, useEffect as f } from "react";
2
+ import { formatTime as v } from "../common/format.js";
3
+ const u = (t) => typeof t == "number" && Number.isFinite(t) && !Number.isNaN(t);
4
+ function b(t) {
5
+ const {
6
+ value: e = 0,
7
+ auto: r = void 0,
8
+ format: o = void 0
9
+ } = t, [i, a] = l(
10
+ () => u(e) ? e : 0
11
+ ), [s, m] = l(
12
+ u(e) ? e : void 0
13
+ ), n = d(null);
14
+ return f(() => (console.log("auto", r), r !== void 0 && (n.current = setInterval(() => {
15
+ const c = r === "up" ? 10 : -10;
16
+ a((p) => Math.max(0, p + c));
17
+ }, 1e3)), () => {
18
+ n.current && clearInterval(n.current);
19
+ }), [r]), f(() => {
20
+ e !== s && (m(e), a(e));
21
+ }, [e, s]), u(e) ? o ? o(i) : v(i) : e || null;
31
22
  }
32
23
  export {
33
- o as TimeDisplay
24
+ b as TimeDisplay
34
25
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tgui-core",
3
- "version": "1.1.21",
3
+ "version": "1.1.23",
4
4
  "description": "TGUI core component library",
5
5
  "keywords": [
6
6
  "TGUI",
@@ -28,6 +28,12 @@
28
28
  "type": "git",
29
29
  "url": "https://github.com/tgstation/tgui-core.git"
30
30
  },
31
+ "scripts": {
32
+ "dev": "vite",
33
+ "build": "tsc --noEmit && vite build",
34
+ "lint": "eslint lib/**",
35
+ "lint-fix": "eslint lib/** --fix"
36
+ },
31
37
  "author": "jlsnow301",
32
38
  "license": "MIT",
33
39
  "type": "module",
@@ -60,10 +66,5 @@
60
66
  "react": "^18.2.0",
61
67
  "react-dom": "^18.2.0"
62
68
  },
63
- "scripts": {
64
- "dev": "vite",
65
- "build": "tsc --noEmit && vite build",
66
- "lint": "eslint lib/**",
67
- "lint-fix": "eslint lib/** --fix"
68
- }
69
- }
69
+ "packageManager": "pnpm@9.5.0+sha512.140036830124618d624a2187b50d04289d5a087f326c9edfc0ccd733d76c4f52c3a313d4fc148794a2a9d81553016004e6742e8cf850670268a7387fc220c903"
70
+ }