tgui-core 1.7.6 → 1.8.0

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.
@@ -7,4 +7,11 @@ type Zip<T extends unknown[][]> = {
7
7
  * the second elements of the given arrays, and so on.
8
8
  */
9
9
  export declare function zip<T extends unknown[][]>(...arr: T): Zip<T>;
10
+ /**
11
+ * Helper function for string compares with native sorts
12
+ * @param a first string to compare
13
+ * @param b second string to compare
14
+ * @returns -1 for a < b, 1 for a > b and 0 otherwise
15
+ */
16
+ export declare function stringCompare(a: string, b: string): 0 | 1 | -1;
10
17
  export {};
@@ -1,6 +1,10 @@
1
- function m(...a) {
2
- return Array(Math.max(...a.map((p) => p.length))).fill(void 0).map((p, t) => a.map((i) => i[t]));
1
+ function p(...n) {
2
+ return Array(Math.max(...n.map((t) => t.length))).fill(void 0).map((t, r) => n.map((i) => i[r]));
3
+ }
4
+ function a(n, t) {
5
+ return n < t ? -1 : n > t ? 1 : 0;
3
6
  }
4
7
  export {
5
- m as zip
8
+ a as stringCompare,
9
+ p as zip
6
10
  };
@@ -1,14 +1,14 @@
1
- import { jsxs as j, jsx as p } from "react/jsx-runtime";
2
- import { useRef as k, useEffect as m } from "react";
3
- import { KEY as w, isEscape as B } from "../common/keys.js";
4
- import { classes as F } from "../common/react.js";
5
- import { debounce as O } from "../common/timer.js";
6
- import { Box as R } from "./Box.js";
1
+ import { jsxs as S, jsx as p } from "react/jsx-runtime";
2
+ import { useRef as j, useEffect as m } from "react";
3
+ import { KEY as k, isEscape as v } from "../common/keys.js";
4
+ import { classes as w } from "../common/react.js";
5
+ import { debounce as B } from "../common/timer.js";
6
+ import { Box as F } from "./Box.js";
7
7
  function d(r) {
8
8
  return typeof r != "number" && typeof r != "string" ? "" : String(r);
9
9
  }
10
- const V = O((r) => r(), 250);
11
- function C(r) {
10
+ const O = B((r) => r(), 250);
11
+ function z(r) {
12
12
  const {
13
13
  autoFocus: g,
14
14
  autoSelect: l,
@@ -19,55 +19,58 @@ function C(r) {
19
19
  maxLength: x,
20
20
  monospace: y,
21
21
  onChange: n,
22
- onEnter: c,
22
+ onEnter: o,
23
23
  onEscape: s,
24
- onInput: i,
25
- placeholder: N,
26
- selfClear: _,
27
- updateOnPropsChange: D,
28
- value: o,
29
- ...E
30
- } = r, a = k(null);
31
- function K(t) {
24
+ onInput: a,
25
+ placeholder: E,
26
+ selfClear: N,
27
+ updateOnPropsChange: _,
28
+ value: c,
29
+ ...A
30
+ } = r, i = j(null);
31
+ function D(t) {
32
32
  var u;
33
- if (!i) return;
33
+ if (!a) return;
34
34
  const e = (u = t.currentTarget) == null ? void 0 : u.value;
35
- b ? V(() => i(t, e)) : i(t, e);
35
+ b ? O(() => a(t, e)) : a(t, e);
36
36
  }
37
- function S(t) {
38
- if (t.key === w.Enter) {
39
- c == null || c(t, t.currentTarget.value), _ ? t.currentTarget.value = "" : (t.currentTarget.blur(), n == null || n(t, t.currentTarget.value));
37
+ function K(t) {
38
+ if (t.key === k.Enter) {
39
+ o == null || o(t, t.currentTarget.value), N ? t.currentTarget.value = "" : (t.currentTarget.blur(), n == null || n(t, t.currentTarget.value));
40
40
  return;
41
41
  }
42
- B(t.key) && (s == null || s(t), t.currentTarget.value = d(o), t.currentTarget.blur());
42
+ v(t.key) && (s == null || s(t), t.currentTarget.value = d(c), t.currentTarget.blur());
43
43
  }
44
44
  function f(t) {
45
- const e = a.current;
45
+ const e = i.current;
46
46
  if (!e) return;
47
47
  const u = d(t);
48
48
  e.value !== u && (e.value = u);
49
49
  }
50
50
  return m(() => {
51
- const t = a.current;
51
+ const t = i.current;
52
52
  if (t) {
53
- f(o);
53
+ f(c);
54
54
  const e = g || l, u = document.activeElement === t;
55
55
  e && !u && setTimeout(() => {
56
56
  t.focus(), l && t.select();
57
57
  }, 1);
58
58
  }
59
59
  }, []), m(() => {
60
- D && f(o);
61
- }, [o]), /* @__PURE__ */ j(
62
- R,
60
+ if (_) {
61
+ const t = i.current;
62
+ t && (document.activeElement === t || f(c));
63
+ }
64
+ }, [c]), /* @__PURE__ */ S(
65
+ F,
63
66
  {
64
- className: F([
67
+ className: w([
65
68
  "Input",
66
69
  h && "Input--fluid",
67
70
  y && "Input--monospace",
68
71
  I
69
72
  ]),
70
- ...E,
73
+ ...A,
71
74
  children: [
72
75
  /* @__PURE__ */ p("div", { className: "Input__baseline", children: "." }),
73
76
  /* @__PURE__ */ p(
@@ -77,10 +80,10 @@ function C(r) {
77
80
  disabled: T,
78
81
  maxLength: x,
79
82
  onBlur: (t) => n == null ? void 0 : n(t, t.target.value),
80
- onChange: K,
81
- onKeyDown: S,
82
- placeholder: N,
83
- ref: a
83
+ onChange: D,
84
+ onKeyDown: K,
85
+ placeholder: E,
86
+ ref: i
84
87
  }
85
88
  )
86
89
  ]
@@ -88,6 +91,6 @@ function C(r) {
88
91
  );
89
92
  }
90
93
  export {
91
- C as Input,
94
+ z as Input,
92
95
  d as toInputValue
93
96
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tgui-core",
3
- "version": "1.7.6",
3
+ "version": "1.8.0",
4
4
  "description": "TGUI core component library",
5
5
  "keywords": ["TGUI", "library", "typescript"],
6
6
  "files": ["dist", "styles"],