tgui-core 1.8.2 → 1.8.4

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 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 = (t) => {
4
- if (typeof t == "string")
5
- return t.endsWith("px") ? `${Number.parseFloat(t) / 12}rem` : t;
6
- if (typeof t == "number")
7
- return `${t}rem`;
8
- }, p = (t) => {
9
- if (typeof t == "string")
10
- return f(t);
11
- if (typeof t == "number")
12
- return f(t * 0.5);
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(t) {
15
- return !h(t);
14
+ function w(o) {
15
+ return !h(o);
16
16
  }
17
- function h(t) {
18
- return typeof t == "string" && u.includes(t);
17
+ function h(o) {
18
+ return typeof o == "string" && u.includes(o);
19
19
  }
20
- const l = (t) => (o, i) => {
21
- (typeof i == "number" || typeof i == "string") && (o[t] = i);
22
- }, n = (t, o) => (i, e) => {
23
- (typeof e == "number" || typeof e == "string") && (i[t] = o(e));
24
- }, s = (t, o) => (i, e) => {
25
- e && (i[t] = o);
26
- }, c = (t, o, i) => (e, r) => {
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[t + i[m]] = o(r);
30
- }, a = (t) => (o, i) => {
31
- w(i) && (o[t] = i);
29
+ e[o + i[m]] = t(r);
30
+ }, a = (o) => (t, i) => {
31
+ w(i) && (t[o] = i);
32
32
  }, d = {
33
- align: l("textAlign"),
33
+ align: c("textAlign"),
34
34
  bottom: n("bottom", f),
35
- fontFamily: l("fontFamily"),
35
+ fontFamily: c("fontFamily"),
36
36
  fontSize: n("fontSize", f),
37
- fontWeight: l("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: l("opacity"),
45
- overflow: l("overflow"),
46
- overflowX: l("overflowX"),
47
- overflowY: l("overflowY"),
48
- position: l("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: l("textAlign"),
50
+ textAlign: c("textAlign"),
51
51
  top: n("top", f),
52
- verticalAlign: l("verticalAlign"),
52
+ verticalAlign: c("verticalAlign"),
53
53
  width: n("width", f),
54
- lineHeight: (t, o) => {
55
- typeof o == "number" ? t.lineHeight = o : typeof o == "string" && (t.lineHeight = f(o));
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: c("margin", p, [
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: c("margin", p, ["left", "right"]),
69
- my: c("margin", p, ["top", "bottom"]),
68
+ mx: s("margin", p, ["Left", "Right"]),
69
+ my: s("margin", p, ["Top", "Bottom"]),
70
70
  // Padding
71
- p: c("padding", 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: c("padding", p, ["left", "right"]),
82
- py: c("padding", p, ["top", "bottom"]),
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: s("fontWeight", "bold"),
89
- fillPositionedParent: (t, o) => {
90
- o && (t.position = "absolute", t.top = 0, t.bottom = 0, t.left = 0, t.right = 0);
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: s("display", "inline-block"),
93
- italic: s("fontStyle", "italic"),
94
- nowrap: s("whiteSpace", "nowrap"),
95
- preserveWhitespace: s("whiteSpace", "pre-wrap")
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 S(t) {
98
- const o = {}, i = {};
99
- for (const e in t) {
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 = t[e], m = d[e] || b[e];
103
- m ? m(i, r) : o[e] = r;
102
+ const r = o[e], m = d[e] || b[e];
103
+ m ? m(i, r) : t[e] = r;
104
104
  }
105
- return o.style = { ...i, ...t.style }, o;
105
+ return t.style = { ...i, ...o.style }, t;
106
106
  }
107
- function T(t) {
108
- const o = t.textColor || t.color, { backgroundColor: i } = t;
107
+ function S(o) {
108
+ const t = o.textColor || o.color, { backgroundColor: i } = o;
109
109
  return y([
110
- h(o) && `color-${o}`,
110
+ h(t) && `color-${t}`,
111
111
  h(i) && `color-bg-${i}`
112
112
  ]);
113
113
  }
114
- function P(t) {
115
- const o = {};
116
- if (!t) return o;
117
- const i = t.split(" ");
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) ? o[r] = g : o[r] = m;
125
- } else r in b ? o[r] = !0 : console.warn(`Unknown prop ${r}`);
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 o;
127
+ return t;
128
128
  }
129
129
  export {
130
130
  b as booleanStyleMap,
131
- T as computeBoxClassName,
132
- S as computeBoxProps,
131
+ S as computeBoxClassName,
132
+ T as computeBoxProps,
133
133
  P as computeTwClass,
134
134
  p as halfUnit,
135
135
  d as stringStyleMap,
@@ -1,72 +1,70 @@
1
1
  import { jsx as l } from "react/jsx-runtime";
2
- import { classes as o } from "../common/react.js";
2
+ import { classes as r } from "../common/react.js";
3
3
  import { computeBoxClassName as m, computeBoxProps as a, unit as f } from "../common/ui.js";
4
- function d(e) {
5
- return o([
4
+ function p(e) {
5
+ return r([
6
6
  "Flex",
7
7
  e.inlineFlex && "Flex--inline",
8
8
  m(e)
9
9
  ]);
10
10
  }
11
- function p(e) {
12
- const { direction: i, wrap: t, align: r, justify: s, ...n } = e;
11
+ function d(e) {
12
+ const { direction: s, wrap: t, align: i, justify: n, ...o } = e;
13
13
  return a({
14
14
  style: {
15
- ...n.style,
16
- flexDirection: i,
15
+ ...o.style,
16
+ flexDirection: s,
17
17
  flexWrap: t === !0 ? "wrap" : t,
18
- alignItems: r,
19
- justifyContent: s
18
+ alignItems: i,
19
+ justifyContent: n
20
20
  },
21
- ...n
21
+ ...o
22
22
  });
23
23
  }
24
24
  function F(e) {
25
- const { className: i, ...t } = e;
25
+ const { className: s, ...t } = e;
26
26
  return /* @__PURE__ */ l(
27
27
  "div",
28
28
  {
29
- className: o([i, d(t)]),
30
- ...p(t)
29
+ className: r([s, p(t)]),
30
+ ...d(t)
31
31
  }
32
32
  );
33
33
  }
34
- const N = (e) => o(["Flex__item", m(e)]);
34
+ const N = (e) => r(["Flex__item", m(e)]);
35
35
  function v(e) {
36
- const { style: i, grow: t, order: r, shrink: s, basis: n, align: c, ...u } = e, x = n ?? // IE11: Set basis to specified width if it's known, which fixes certain
36
+ const { style: s, grow: t, order: i, shrink: n, basis: o, align: c, ...u } = e, x = o ?? // IE11: Set basis to specified width if it's known, which fixes certain
37
37
  // bugs when rendering tables inside the flex.
38
38
  e.width ?? // If grow is used, basis should be set to 0 to be consistent with
39
39
  // flex css shorthand `flex: 1`.
40
40
  (t !== void 0 ? 0 : void 0);
41
41
  return a({
42
42
  style: {
43
- ...i,
44
- minWidth: t !== void 0 && 0,
45
- minHeight: t !== void 0 && 0,
43
+ ...s,
46
44
  flexGrow: t !== void 0 && Number(t),
47
- flexShrink: s !== void 0 && Number(s),
45
+ flexShrink: n !== void 0 && Number(n),
48
46
  flexBasis: f(x),
49
- order: r,
47
+ order: i,
50
48
  alignSelf: c
51
49
  },
52
50
  ...u
53
51
  });
54
52
  }
55
- function g(e) {
56
- const { className: i, ...t } = e;
53
+ function y(e) {
54
+ const { className: s, ...t } = e;
57
55
  return /* @__PURE__ */ l(
58
56
  "div",
59
57
  {
60
- className: o([i, N(e)]),
58
+ className: r([s, N(e)]),
61
59
  ...v(t)
62
60
  }
63
61
  );
64
62
  }
65
- F.Item = g;
63
+ F.Item = y;
66
64
  export {
67
65
  F as Flex,
68
- d as computeFlexClassName,
66
+ p as computeFlexClassName,
69
67
  N as computeFlexItemClassName,
70
68
  v as computeFlexItemProps,
71
- p as computeFlexProps
69
+ d as computeFlexProps
72
70
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tgui-core",
3
- "version": "1.8.2",
3
+ "version": "1.8.4",
4
4
  "description": "TGUI core component library",
5
5
  "keywords": ["TGUI", "library", "typescript"],
6
6
  "files": ["dist", "styles"],