tgui-core 1.1.20 → 1.1.22
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 +13 -0
- package/dist/{ProgressBar.module-BkAFfFy0.js → ProgressBar.module-Jzqlebbx.js} +4 -4
- package/dist/common/string.d.ts +15 -0
- package/dist/common/string.js +21 -15
- package/dist/components/ProgressBar.js +13 -13
- package/dist/components/Slider.js +24 -24
- package/dist/components/TimeDisplay.js +7 -7
- package/package.json +10 -9
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",
|
|
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:
|
|
14
|
-
color__teal:
|
|
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
|
|
28
|
+
B as p
|
|
29
29
|
};
|
package/dist/common/string.d.ts
CHANGED
|
@@ -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
|
*
|
package/dist/common/string.js
CHANGED
|
@@ -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
|
-
|
|
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
|
|
17
|
+
function f(e) {
|
|
14
18
|
return e.replace(/(^\w{1})|(\s+\w{1})/g, (t) => t.toUpperCase());
|
|
15
19
|
}
|
|
16
|
-
function
|
|
20
|
+
function h(e) {
|
|
17
21
|
return e.replace(/^\w/, (t) => t.toUpperCase());
|
|
18
22
|
}
|
|
19
|
-
const
|
|
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
|
|
46
|
+
function g(e) {
|
|
43
47
|
if (!e) return e;
|
|
44
|
-
let t = e.replace(/([^\W_]+[^\s-]*) */g, (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
|
|
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
|
|
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
|
|
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) =>
|
|
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
|
|
78
|
-
|
|
79
|
-
|
|
81
|
+
a as VOWELS,
|
|
82
|
+
c as capitalize,
|
|
83
|
+
f as capitalizeAll,
|
|
84
|
+
h as capitalizeFirst,
|
|
80
85
|
p as createSearch,
|
|
81
|
-
|
|
82
|
-
|
|
86
|
+
d as decodeHtmlEntities,
|
|
87
|
+
l as pluralize,
|
|
88
|
+
g as toTitleCase
|
|
83
89
|
};
|
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
import { jsxs as
|
|
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
|
|
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 {
|
|
6
|
-
import { computeBoxProps as
|
|
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:
|
|
12
|
-
maxValue:
|
|
11
|
+
minValue: p = 0,
|
|
12
|
+
maxValue: u = 1,
|
|
13
13
|
color: C,
|
|
14
|
-
ranges:
|
|
14
|
+
ranges: g = {},
|
|
15
15
|
children: l,
|
|
16
16
|
...t
|
|
17
|
-
} = d, a =
|
|
18
|
-
|
|
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:
|
|
22
|
+
width: _(a) * 100 + "%"
|
|
23
23
|
};
|
|
24
|
-
return v.includes(
|
|
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([
|
|
28
|
+
className: m([e.fill, e.fill__animated]),
|
|
29
29
|
style: i
|
|
30
30
|
}
|
|
31
31
|
),
|
|
32
|
-
/* @__PURE__ */ n("div", { className:
|
|
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 {
|
|
5
|
-
import { computeBoxClassName as
|
|
6
|
-
import { DraggableControl as
|
|
7
|
-
import '../assets/Slider.css';const
|
|
8
|
-
slider:
|
|
9
|
-
cursorOffset:
|
|
10
|
-
cursor:
|
|
11
|
-
pointer:
|
|
12
|
-
popupValue:
|
|
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
|
|
14
|
+
function Z(h) {
|
|
15
15
|
const {
|
|
16
16
|
// Draggable props (passthrough)
|
|
17
|
-
animated:
|
|
18
|
-
format:
|
|
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:
|
|
32
|
+
ranges: S = {},
|
|
33
33
|
children: i,
|
|
34
34
|
...c
|
|
35
|
-
} = h,
|
|
35
|
+
} = h, B = i !== void 0;
|
|
36
36
|
return /* @__PURE__ */ s(
|
|
37
|
-
|
|
37
|
+
G,
|
|
38
38
|
{
|
|
39
39
|
dragMatrix: [1, 0],
|
|
40
|
-
animated:
|
|
41
|
-
format:
|
|
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: (
|
|
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
|
-
} =
|
|
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,
|
|
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
|
-
|
|
72
|
+
q(c)
|
|
73
73
|
]),
|
|
74
|
-
...
|
|
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:
|
|
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
|
-
|
|
123
|
+
Z as Slider
|
|
124
124
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Component as
|
|
2
|
-
import { formatTime as
|
|
1
|
+
import { Component as a } from "react";
|
|
2
|
+
import { formatTime as o } from "../common/format.js";
|
|
3
3
|
function s(e) {
|
|
4
4
|
return typeof e == "number" && Number.isFinite(e) && !Number.isNaN(e);
|
|
5
5
|
}
|
|
6
|
-
class
|
|
6
|
+
class l extends a {
|
|
7
7
|
constructor(t) {
|
|
8
8
|
super(t), this.timer = null, this.last_seen_value = void 0, this.state = {
|
|
9
9
|
value: 0
|
|
@@ -15,8 +15,8 @@ class o extends r {
|
|
|
15
15
|
tick() {
|
|
16
16
|
let t = Number(this.state.value);
|
|
17
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,
|
|
19
|
-
this.setState({ value:
|
|
18
|
+
const i = this.props.auto === "up" ? 10 : -10, r = Math.max(0, t + i);
|
|
19
|
+
this.setState({ value: r });
|
|
20
20
|
}
|
|
21
21
|
componentDidMount() {
|
|
22
22
|
this.props.auto !== void 0 && (this.timer = setInterval(() => this.tick(), 1e3));
|
|
@@ -26,9 +26,9 @@ class o extends r {
|
|
|
26
26
|
}
|
|
27
27
|
render() {
|
|
28
28
|
const t = this.state.value;
|
|
29
|
-
return s(t) ?
|
|
29
|
+
return s(t) ? this.props.format ? this.props.format(t) : o(t) : this.state.value || null;
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
export {
|
|
33
|
-
|
|
33
|
+
l as TimeDisplay
|
|
34
34
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tgui-core",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.22",
|
|
4
4
|
"description": "TGUI core component library",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"TGUI",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"import": "./dist/components/index.js",
|
|
16
16
|
"require": "./dist/components/index.cjs"
|
|
17
17
|
},
|
|
18
|
-
"./styles": {
|
|
18
|
+
"./styles/*": {
|
|
19
19
|
"import": "./dist/assets/*.css",
|
|
20
20
|
"require": "./dist/assets/*.css"
|
|
21
21
|
},
|
|
@@ -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
|
-
"
|
|
64
|
-
|
|
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
|
+
}
|