tgui-core 1.1.22 → 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.
@@ -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
  }
@@ -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 a } from "react";
2
- import { formatTime as o } from "../common/format.js";
3
- function s(e) {
4
- return typeof e == "number" && Number.isFinite(e) && !Number.isNaN(e);
5
- }
6
- class l extends a {
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, r = Math.max(0, t + i);
19
- this.setState({ value: r });
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) ? this.props.format ? this.props.format(t) : o(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
- l 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.22",
3
+ "version": "1.1.23",
4
4
  "description": "TGUI core component library",
5
5
  "keywords": [
6
6
  "TGUI",