tgui-core 1.8.2 → 1.8.3
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/dist/common/ui.js +67 -67
- package/package.json +1 -1
package/dist/common/ui.js
CHANGED
|
@@ -1,61 +1,61 @@
|
|
|
1
1
|
import { CSS_COLORS as u } from "./constants.js";
|
|
2
2
|
import { classes as y } from "./react.js";
|
|
3
|
-
const f = (
|
|
4
|
-
if (typeof
|
|
5
|
-
return
|
|
6
|
-
if (typeof
|
|
7
|
-
return `${
|
|
8
|
-
}, p = (
|
|
9
|
-
if (typeof
|
|
10
|
-
return f(
|
|
11
|
-
if (typeof
|
|
12
|
-
return f(
|
|
3
|
+
const f = (o) => {
|
|
4
|
+
if (typeof o == "string")
|
|
5
|
+
return o.endsWith("px") ? `${Number.parseFloat(o) / 12}rem` : o;
|
|
6
|
+
if (typeof o == "number")
|
|
7
|
+
return `${o}rem`;
|
|
8
|
+
}, p = (o) => {
|
|
9
|
+
if (typeof o == "string")
|
|
10
|
+
return f(o);
|
|
11
|
+
if (typeof o == "number")
|
|
12
|
+
return f(o * 0.5);
|
|
13
13
|
};
|
|
14
|
-
function w(
|
|
15
|
-
return !h(
|
|
14
|
+
function w(o) {
|
|
15
|
+
return !h(o);
|
|
16
16
|
}
|
|
17
|
-
function h(
|
|
18
|
-
return typeof
|
|
17
|
+
function h(o) {
|
|
18
|
+
return typeof o == "string" && u.includes(o);
|
|
19
19
|
}
|
|
20
|
-
const
|
|
21
|
-
(typeof i == "number" || typeof i == "string") && (o
|
|
22
|
-
}, n = (
|
|
23
|
-
(typeof e == "number" || typeof e == "string") && (i[
|
|
24
|
-
},
|
|
25
|
-
e && (i[
|
|
26
|
-
},
|
|
20
|
+
const c = (o) => (t, i) => {
|
|
21
|
+
(typeof i == "number" || typeof i == "string") && (t[o] = i);
|
|
22
|
+
}, n = (o, t) => (i, e) => {
|
|
23
|
+
(typeof e == "number" || typeof e == "string") && (i[o] = t(e));
|
|
24
|
+
}, l = (o, t) => (i, e) => {
|
|
25
|
+
e && (i[o] = t);
|
|
26
|
+
}, s = (o, t, i) => (e, r) => {
|
|
27
27
|
if (typeof r == "number" || typeof r == "string")
|
|
28
28
|
for (let m = 0; m < i.length; m++)
|
|
29
|
-
e[
|
|
30
|
-
}, a = (
|
|
31
|
-
w(i) && (o
|
|
29
|
+
e[o + i[m]] = t(r);
|
|
30
|
+
}, a = (o) => (t, i) => {
|
|
31
|
+
w(i) && (t[o] = i);
|
|
32
32
|
}, d = {
|
|
33
|
-
align:
|
|
33
|
+
align: c("textAlign"),
|
|
34
34
|
bottom: n("bottom", f),
|
|
35
|
-
fontFamily:
|
|
35
|
+
fontFamily: c("fontFamily"),
|
|
36
36
|
fontSize: n("fontSize", f),
|
|
37
|
-
fontWeight:
|
|
37
|
+
fontWeight: c("fontWeight"),
|
|
38
38
|
height: n("height", f),
|
|
39
39
|
left: n("left", f),
|
|
40
40
|
maxHeight: n("maxHeight", f),
|
|
41
41
|
maxWidth: n("maxWidth", f),
|
|
42
42
|
minHeight: n("minHeight", f),
|
|
43
43
|
minWidth: n("minWidth", f),
|
|
44
|
-
opacity:
|
|
45
|
-
overflow:
|
|
46
|
-
overflowX:
|
|
47
|
-
overflowY:
|
|
48
|
-
position:
|
|
44
|
+
opacity: c("opacity"),
|
|
45
|
+
overflow: c("overflow"),
|
|
46
|
+
overflowX: c("overflowX"),
|
|
47
|
+
overflowY: c("overflowY"),
|
|
48
|
+
position: c("position"),
|
|
49
49
|
right: n("right", f),
|
|
50
|
-
textAlign:
|
|
50
|
+
textAlign: c("textAlign"),
|
|
51
51
|
top: n("top", f),
|
|
52
|
-
verticalAlign:
|
|
52
|
+
verticalAlign: c("verticalAlign"),
|
|
53
53
|
width: n("width", f),
|
|
54
|
-
lineHeight: (
|
|
55
|
-
typeof
|
|
54
|
+
lineHeight: (o, t) => {
|
|
55
|
+
typeof t == "number" ? o.lineHeight = t : typeof t == "string" && (o.lineHeight = f(t));
|
|
56
56
|
},
|
|
57
57
|
// Margin
|
|
58
|
-
m:
|
|
58
|
+
m: s("margin", p, [
|
|
59
59
|
"Top",
|
|
60
60
|
"Bottom",
|
|
61
61
|
"Left",
|
|
@@ -65,10 +65,10 @@ const l = (t) => (o, i) => {
|
|
|
65
65
|
ml: n("marginLeft", p),
|
|
66
66
|
mr: n("marginRight", p),
|
|
67
67
|
mt: n("marginTop", p),
|
|
68
|
-
mx:
|
|
69
|
-
my:
|
|
68
|
+
mx: s("margin", p, ["Left", "Right"]),
|
|
69
|
+
my: s("margin", p, ["Top", "Bottom"]),
|
|
70
70
|
// Padding
|
|
71
|
-
p:
|
|
71
|
+
p: s("padding", p, [
|
|
72
72
|
"Top",
|
|
73
73
|
"Bottom",
|
|
74
74
|
"Left",
|
|
@@ -78,58 +78,58 @@ const l = (t) => (o, i) => {
|
|
|
78
78
|
pl: n("paddingLeft", p),
|
|
79
79
|
pr: n("paddingRight", p),
|
|
80
80
|
pt: n("paddingTop", p),
|
|
81
|
-
px:
|
|
82
|
-
py:
|
|
81
|
+
px: s("padding", p, ["Left", "Right"]),
|
|
82
|
+
py: s("padding", p, ["Top", "Bottom"]),
|
|
83
83
|
// Color props
|
|
84
84
|
color: a("color"),
|
|
85
85
|
textColor: a("color"),
|
|
86
86
|
backgroundColor: a("backgroundColor")
|
|
87
87
|
}, b = {
|
|
88
|
-
bold:
|
|
89
|
-
fillPositionedParent: (
|
|
90
|
-
|
|
88
|
+
bold: l("fontWeight", "bold"),
|
|
89
|
+
fillPositionedParent: (o, t) => {
|
|
90
|
+
t && (o.position = "absolute", o.top = 0, o.bottom = 0, o.left = 0, o.right = 0);
|
|
91
91
|
},
|
|
92
|
-
inline:
|
|
93
|
-
italic:
|
|
94
|
-
nowrap:
|
|
95
|
-
preserveWhitespace:
|
|
92
|
+
inline: l("display", "inline-block"),
|
|
93
|
+
italic: l("fontStyle", "italic"),
|
|
94
|
+
nowrap: l("whiteSpace", "nowrap"),
|
|
95
|
+
preserveWhitespace: l("whiteSpace", "pre-wrap")
|
|
96
96
|
};
|
|
97
|
-
function
|
|
98
|
-
const
|
|
99
|
-
for (const e in
|
|
97
|
+
function T(o) {
|
|
98
|
+
const t = {}, i = {};
|
|
99
|
+
for (const e in o) {
|
|
100
100
|
if (e === "style")
|
|
101
101
|
continue;
|
|
102
|
-
const r =
|
|
103
|
-
m ? m(i, r) :
|
|
102
|
+
const r = o[e], m = d[e] || b[e];
|
|
103
|
+
m ? m(i, r) : t[e] = r;
|
|
104
104
|
}
|
|
105
|
-
return
|
|
105
|
+
return t.style = { ...i, ...o.style }, t;
|
|
106
106
|
}
|
|
107
|
-
function
|
|
108
|
-
const
|
|
107
|
+
function S(o) {
|
|
108
|
+
const t = o.textColor || o.color, { backgroundColor: i } = o;
|
|
109
109
|
return y([
|
|
110
|
-
h(
|
|
110
|
+
h(t) && `color-${t}`,
|
|
111
111
|
h(i) && `color-bg-${i}`
|
|
112
112
|
]);
|
|
113
113
|
}
|
|
114
|
-
function P(
|
|
115
|
-
const
|
|
116
|
-
if (!
|
|
117
|
-
const i =
|
|
114
|
+
function P(o) {
|
|
115
|
+
const t = {};
|
|
116
|
+
if (!o) return t;
|
|
117
|
+
const i = o.split(" ");
|
|
118
118
|
for (const e of i) {
|
|
119
119
|
const [r, m] = e.split("-");
|
|
120
120
|
if (r)
|
|
121
121
|
if (r in d) {
|
|
122
122
|
if (m === "") continue;
|
|
123
123
|
const g = Number(m);
|
|
124
|
-
!Number.isNaN(g) && Number.isFinite(g) ?
|
|
125
|
-
} else r in b ?
|
|
124
|
+
!Number.isNaN(g) && Number.isFinite(g) ? t[r] = g : t[r] = m;
|
|
125
|
+
} else r in b ? t[r] = !0 : console.warn(`Unknown prop ${r}`);
|
|
126
126
|
}
|
|
127
|
-
return
|
|
127
|
+
return t;
|
|
128
128
|
}
|
|
129
129
|
export {
|
|
130
130
|
b as booleanStyleMap,
|
|
131
|
-
|
|
132
|
-
|
|
131
|
+
S as computeBoxClassName,
|
|
132
|
+
T as computeBoxProps,
|
|
133
133
|
P as computeTwClass,
|
|
134
134
|
p as halfUnit,
|
|
135
135
|
d as stringStyleMap,
|