tgui-core 2.0.2 → 2.0.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.
|
@@ -1,265 +1,257 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useState as A, createRef as
|
|
3
|
-
import { KEY as
|
|
4
|
-
import { classes as
|
|
5
|
-
import { computeBoxProps as
|
|
6
|
-
import { Box as
|
|
7
|
-
import { Icon as
|
|
8
|
-
import { Tooltip as
|
|
1
|
+
import { jsx as c, jsxs as _, Fragment as V } from "react/jsx-runtime";
|
|
2
|
+
import { useState as A, createRef as $, useEffect as j, useRef as q } from "react";
|
|
3
|
+
import { KEY as P, isEscape as E } from "../common/keys.js";
|
|
4
|
+
import { classes as S } from "../common/react.js";
|
|
5
|
+
import { computeBoxProps as z, computeBoxClassName as O } from "../common/ui.js";
|
|
6
|
+
import { Box as T } from "./Box.js";
|
|
7
|
+
import { Icon as v } from "./Icon.js";
|
|
8
|
+
import { Tooltip as K } from "./Tooltip.js";
|
|
9
9
|
function R(e) {
|
|
10
10
|
const {
|
|
11
|
-
captureKeys:
|
|
12
|
-
children:
|
|
13
|
-
circular:
|
|
14
|
-
className:
|
|
15
|
-
color:
|
|
16
|
-
compact:
|
|
17
|
-
content:
|
|
11
|
+
captureKeys: s = !0,
|
|
12
|
+
children: u,
|
|
13
|
+
circular: m,
|
|
14
|
+
className: p,
|
|
15
|
+
color: r,
|
|
16
|
+
compact: h,
|
|
17
|
+
content: B,
|
|
18
18
|
disabled: t,
|
|
19
19
|
ellipsis: o,
|
|
20
20
|
fluid: l,
|
|
21
21
|
icon: i,
|
|
22
|
-
iconColor:
|
|
23
|
-
iconPosition:
|
|
24
|
-
iconRotation:
|
|
25
|
-
iconSize:
|
|
26
|
-
iconSpin:
|
|
22
|
+
iconColor: a,
|
|
23
|
+
iconPosition: C,
|
|
24
|
+
iconRotation: x,
|
|
25
|
+
iconSize: y,
|
|
26
|
+
iconSpin: D,
|
|
27
27
|
onClick: f,
|
|
28
|
-
selected:
|
|
29
|
-
tooltip:
|
|
30
|
-
tooltipPosition:
|
|
31
|
-
verticalAlignContent:
|
|
32
|
-
...
|
|
33
|
-
} = e, n =
|
|
34
|
-
|
|
28
|
+
selected: b,
|
|
29
|
+
tooltip: g,
|
|
30
|
+
tooltipPosition: F,
|
|
31
|
+
verticalAlignContent: k,
|
|
32
|
+
...I
|
|
33
|
+
} = e, n = B || u, N = /* @__PURE__ */ c(
|
|
34
|
+
v,
|
|
35
|
+
{
|
|
36
|
+
className: "Button--icon",
|
|
37
|
+
name: i || "",
|
|
38
|
+
color: a,
|
|
39
|
+
rotation: x,
|
|
40
|
+
size: y,
|
|
41
|
+
spin: D
|
|
42
|
+
}
|
|
43
|
+
);
|
|
44
|
+
let w = /* @__PURE__ */ c(
|
|
35
45
|
"div",
|
|
36
46
|
{
|
|
37
|
-
className:
|
|
47
|
+
className: S([
|
|
38
48
|
"Button",
|
|
39
49
|
l && "Button--fluid",
|
|
40
50
|
t && "Button--disabled",
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
51
|
+
b && "Button--selected",
|
|
52
|
+
m && "Button--circular",
|
|
53
|
+
h && "Button--compact",
|
|
44
54
|
!n && "Button--empty",
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
55
|
+
C && `Button--icon-${C}`,
|
|
56
|
+
k && "Button--flex",
|
|
57
|
+
k && l && "Button--flex--fluid",
|
|
58
|
+
k && `Button--verticalAlignContent--${k}`,
|
|
59
|
+
r && typeof r == "string" ? `Button--color--${r}` : "Button--color--default",
|
|
60
|
+
p,
|
|
61
|
+
O(I)
|
|
52
62
|
]),
|
|
53
63
|
tabIndex: t ? void 0 : 0,
|
|
54
|
-
onClick: (
|
|
55
|
-
!t && f && f(
|
|
64
|
+
onClick: (d) => {
|
|
65
|
+
!t && f && f(d);
|
|
56
66
|
},
|
|
57
|
-
onKeyDown: (
|
|
58
|
-
if (
|
|
59
|
-
if (
|
|
60
|
-
|
|
67
|
+
onKeyDown: (d) => {
|
|
68
|
+
if (s) {
|
|
69
|
+
if (d.key === P.Space || d.key === P.Enter) {
|
|
70
|
+
d.preventDefault(), !t && f && f(d);
|
|
61
71
|
return;
|
|
62
72
|
}
|
|
63
|
-
E(
|
|
73
|
+
E(d.key) && d.preventDefault();
|
|
64
74
|
}
|
|
65
75
|
},
|
|
66
|
-
...
|
|
76
|
+
...z(I),
|
|
67
77
|
children: /* @__PURE__ */ _(
|
|
68
78
|
"div",
|
|
69
79
|
{
|
|
70
|
-
className:
|
|
80
|
+
className: S([
|
|
71
81
|
"Button__content",
|
|
72
82
|
o && "Button__content--ellipsis"
|
|
73
83
|
]),
|
|
74
84
|
children: [
|
|
75
|
-
i &&
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
name: i,
|
|
79
|
-
color: s,
|
|
80
|
-
rotation: k,
|
|
81
|
-
size: m,
|
|
82
|
-
spin: w
|
|
83
|
-
}
|
|
84
|
-
),
|
|
85
|
-
o ? /* @__PURE__ */ r("span", { className: "Button--ellipsis", children: n }) : n,
|
|
86
|
-
i && y === "right" && /* @__PURE__ */ r(
|
|
87
|
-
S,
|
|
88
|
-
{
|
|
89
|
-
name: i,
|
|
90
|
-
color: s,
|
|
91
|
-
rotation: k,
|
|
92
|
-
size: m,
|
|
93
|
-
spin: w
|
|
94
|
-
}
|
|
95
|
-
)
|
|
85
|
+
i && C !== "right" && N,
|
|
86
|
+
o ? /* @__PURE__ */ c("span", { className: "Button--ellipsis", children: n }) : n,
|
|
87
|
+
i && C === "right" && N
|
|
96
88
|
]
|
|
97
89
|
}
|
|
98
90
|
)
|
|
99
91
|
}
|
|
100
92
|
);
|
|
101
|
-
return
|
|
93
|
+
return g && (w = /* @__PURE__ */ c(K, { content: g, position: F, children: w })), w;
|
|
102
94
|
}
|
|
103
|
-
function
|
|
104
|
-
const { checked:
|
|
105
|
-
return /* @__PURE__ */
|
|
95
|
+
function L(e) {
|
|
96
|
+
const { checked: s, ...u } = e;
|
|
97
|
+
return /* @__PURE__ */ c(
|
|
106
98
|
R,
|
|
107
99
|
{
|
|
108
100
|
color: "transparent",
|
|
109
|
-
icon:
|
|
110
|
-
selected:
|
|
111
|
-
...
|
|
101
|
+
icon: s ? "check-square-o" : "square-o",
|
|
102
|
+
selected: s,
|
|
103
|
+
...u
|
|
112
104
|
}
|
|
113
105
|
);
|
|
114
106
|
}
|
|
115
|
-
function
|
|
107
|
+
function Y(e) {
|
|
116
108
|
const {
|
|
117
|
-
children:
|
|
118
|
-
color:
|
|
119
|
-
confirmColor:
|
|
120
|
-
confirmContent:
|
|
121
|
-
confirmIcon:
|
|
122
|
-
ellipsis:
|
|
123
|
-
icon:
|
|
109
|
+
children: s,
|
|
110
|
+
color: u,
|
|
111
|
+
confirmColor: m = "bad",
|
|
112
|
+
confirmContent: p = "Confirm?",
|
|
113
|
+
confirmIcon: r,
|
|
114
|
+
ellipsis: h = !0,
|
|
115
|
+
icon: B,
|
|
124
116
|
onBlur: t,
|
|
125
117
|
onClick: o,
|
|
126
118
|
...l
|
|
127
|
-
} = e, [i,
|
|
128
|
-
function y
|
|
129
|
-
|
|
119
|
+
} = e, [i, a] = A(!1);
|
|
120
|
+
function C(y) {
|
|
121
|
+
a(!1), t == null || t(y);
|
|
130
122
|
}
|
|
131
|
-
function
|
|
123
|
+
function x(y) {
|
|
132
124
|
if (!i) {
|
|
133
|
-
|
|
125
|
+
a(!0);
|
|
134
126
|
return;
|
|
135
127
|
}
|
|
136
|
-
o == null || o(
|
|
128
|
+
o == null || o(y), a(!1);
|
|
137
129
|
}
|
|
138
|
-
return /* @__PURE__ */
|
|
130
|
+
return /* @__PURE__ */ c(
|
|
139
131
|
R,
|
|
140
132
|
{
|
|
141
|
-
icon: i ?
|
|
142
|
-
color: i ?
|
|
143
|
-
onBlur:
|
|
144
|
-
onClick:
|
|
133
|
+
icon: i ? r : B,
|
|
134
|
+
color: i ? m : u,
|
|
135
|
+
onBlur: C,
|
|
136
|
+
onClick: x,
|
|
145
137
|
...l,
|
|
146
|
-
children: i ?
|
|
138
|
+
children: i ? p : s
|
|
147
139
|
}
|
|
148
140
|
);
|
|
149
141
|
}
|
|
150
|
-
function
|
|
142
|
+
function G(e) {
|
|
151
143
|
const {
|
|
152
|
-
children:
|
|
153
|
-
color:
|
|
154
|
-
content:
|
|
155
|
-
currentValue:
|
|
156
|
-
defaultValue:
|
|
157
|
-
disabled:
|
|
158
|
-
fluid:
|
|
144
|
+
children: s,
|
|
145
|
+
color: u = "default",
|
|
146
|
+
content: m,
|
|
147
|
+
currentValue: p,
|
|
148
|
+
defaultValue: r,
|
|
149
|
+
disabled: h,
|
|
150
|
+
fluid: B,
|
|
159
151
|
icon: t,
|
|
160
152
|
iconRotation: o,
|
|
161
153
|
iconSpin: l,
|
|
162
154
|
maxLength: i,
|
|
163
|
-
onCommit:
|
|
164
|
-
placeholder:
|
|
165
|
-
tooltip:
|
|
166
|
-
tooltipPosition:
|
|
167
|
-
...
|
|
168
|
-
} = e, [f,
|
|
169
|
-
function
|
|
170
|
-
const
|
|
171
|
-
if (!
|
|
172
|
-
|
|
155
|
+
onCommit: a = () => null,
|
|
156
|
+
placeholder: C,
|
|
157
|
+
tooltip: x,
|
|
158
|
+
tooltipPosition: y,
|
|
159
|
+
...D
|
|
160
|
+
} = e, [f, b] = A(!1), g = $(), F = m || s;
|
|
161
|
+
function k(n) {
|
|
162
|
+
const N = g.current;
|
|
163
|
+
if (!N) return;
|
|
164
|
+
N.value !== "" ? a(n, N.value) : r && a(n, r);
|
|
173
165
|
}
|
|
174
|
-
|
|
175
|
-
const n =
|
|
166
|
+
j(() => {
|
|
167
|
+
const n = g.current;
|
|
176
168
|
if (n && f) {
|
|
177
|
-
n.value =
|
|
169
|
+
n.value = p || "";
|
|
178
170
|
try {
|
|
179
171
|
n.focus(), n.select();
|
|
180
172
|
} catch {
|
|
181
173
|
}
|
|
182
174
|
}
|
|
183
|
-
}, [f,
|
|
184
|
-
let
|
|
185
|
-
|
|
175
|
+
}, [f, p]);
|
|
176
|
+
let I = /* @__PURE__ */ _(
|
|
177
|
+
T,
|
|
186
178
|
{
|
|
187
|
-
className:
|
|
179
|
+
className: S([
|
|
188
180
|
"Button",
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
`Button--color--${
|
|
181
|
+
B && "Button--fluid",
|
|
182
|
+
h && "Button--disabled",
|
|
183
|
+
`Button--color--${u}`
|
|
192
184
|
]),
|
|
193
|
-
...
|
|
194
|
-
onClick: () =>
|
|
185
|
+
...D,
|
|
186
|
+
onClick: () => b(!0),
|
|
195
187
|
children: [
|
|
196
|
-
t && /* @__PURE__ */
|
|
197
|
-
/* @__PURE__ */
|
|
198
|
-
/* @__PURE__ */
|
|
188
|
+
t && /* @__PURE__ */ c(v, { name: t, rotation: o, spin: l }),
|
|
189
|
+
/* @__PURE__ */ c("div", { children: F }),
|
|
190
|
+
/* @__PURE__ */ c(
|
|
199
191
|
"input",
|
|
200
192
|
{
|
|
201
|
-
disabled: !!
|
|
202
|
-
ref:
|
|
193
|
+
disabled: !!h,
|
|
194
|
+
ref: g,
|
|
203
195
|
className: "NumberInput__input",
|
|
204
196
|
style: {
|
|
205
197
|
display: f ? "" : "none",
|
|
206
198
|
textAlign: "left"
|
|
207
199
|
},
|
|
208
200
|
onBlur: (n) => {
|
|
209
|
-
f && (
|
|
201
|
+
f && (b(!1), k(n));
|
|
210
202
|
},
|
|
211
203
|
onKeyDown: (n) => {
|
|
212
|
-
if (n.key ===
|
|
213
|
-
|
|
204
|
+
if (n.key === P.Enter) {
|
|
205
|
+
b(!1), k(n);
|
|
214
206
|
return;
|
|
215
207
|
}
|
|
216
|
-
E(n.key) &&
|
|
208
|
+
E(n.key) && b(!1);
|
|
217
209
|
}
|
|
218
210
|
}
|
|
219
211
|
)
|
|
220
212
|
]
|
|
221
213
|
}
|
|
222
214
|
);
|
|
223
|
-
return
|
|
215
|
+
return x && (I = /* @__PURE__ */ c(K, { content: x, position: y, children: I })), I;
|
|
224
216
|
}
|
|
225
|
-
function
|
|
226
|
-
const { accept:
|
|
227
|
-
async function
|
|
217
|
+
function H(e) {
|
|
218
|
+
const { accept: s, multiple: u, onSelectFiles: m, ...p } = e, r = q(null);
|
|
219
|
+
async function h(t) {
|
|
228
220
|
const o = Array.from(t).map((l) => {
|
|
229
221
|
const i = new FileReader();
|
|
230
|
-
return new Promise((
|
|
231
|
-
i.onload = () =>
|
|
222
|
+
return new Promise((a) => {
|
|
223
|
+
i.onload = () => a(i.result), i.readAsText(l);
|
|
232
224
|
});
|
|
233
225
|
});
|
|
234
226
|
return await Promise.all(o);
|
|
235
227
|
}
|
|
236
|
-
async function
|
|
228
|
+
async function B(t) {
|
|
237
229
|
const o = t.target.files;
|
|
238
230
|
if (o != null && o.length) {
|
|
239
|
-
const l = await
|
|
240
|
-
|
|
231
|
+
const l = await h(o);
|
|
232
|
+
m(u ? l : l[0]);
|
|
241
233
|
}
|
|
242
234
|
}
|
|
243
|
-
return /* @__PURE__ */ _(
|
|
244
|
-
/* @__PURE__ */
|
|
235
|
+
return /* @__PURE__ */ _(V, { children: [
|
|
236
|
+
/* @__PURE__ */ c(R, { onClick: () => {
|
|
245
237
|
var t;
|
|
246
|
-
return (t =
|
|
247
|
-
}, ...
|
|
248
|
-
/* @__PURE__ */
|
|
238
|
+
return (t = r.current) == null ? void 0 : t.click();
|
|
239
|
+
}, ...p }),
|
|
240
|
+
/* @__PURE__ */ c(
|
|
249
241
|
"input",
|
|
250
242
|
{
|
|
251
243
|
hidden: !0,
|
|
252
244
|
type: "file",
|
|
253
|
-
ref:
|
|
254
|
-
accept:
|
|
255
|
-
multiple:
|
|
256
|
-
onChange:
|
|
245
|
+
ref: r,
|
|
246
|
+
accept: s,
|
|
247
|
+
multiple: u,
|
|
248
|
+
onChange: B
|
|
257
249
|
}
|
|
258
250
|
)
|
|
259
251
|
] });
|
|
260
252
|
}
|
|
261
253
|
((e) => {
|
|
262
|
-
e.Checkbox =
|
|
254
|
+
e.Checkbox = L, e.Confirm = Y, e.Input = G, e.File = H;
|
|
263
255
|
})(R || (R = {}));
|
|
264
256
|
export {
|
|
265
257
|
R as Button
|
package/package.json
CHANGED
|
@@ -71,30 +71,29 @@ $border-radius: 0 !default;
|
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
|
|
74
|
+
.Button--icon {
|
|
75
75
|
min-width: 1.333em;
|
|
76
76
|
text-align: center;
|
|
77
|
-
vertical-align: middle;
|
|
78
77
|
}
|
|
79
78
|
|
|
80
|
-
&:has(
|
|
79
|
+
&:has(.Button--icon) {
|
|
81
80
|
padding-left: 0;
|
|
82
81
|
|
|
83
|
-
|
|
82
|
+
.Button--icon {
|
|
84
83
|
margin: 0 var(--space-s);
|
|
85
84
|
}
|
|
86
85
|
}
|
|
87
86
|
|
|
88
|
-
&--icon-right:has(
|
|
87
|
+
&--icon-right:has(.Button--icon) {
|
|
89
88
|
padding-left: var(--space-m);
|
|
90
89
|
padding-right: var(--space-s);
|
|
91
90
|
|
|
92
|
-
|
|
91
|
+
.Button--icon {
|
|
93
92
|
margin: 0 0 0 var(--space-s);
|
|
94
93
|
}
|
|
95
94
|
}
|
|
96
95
|
|
|
97
|
-
&--empty:has(
|
|
96
|
+
&--empty:has(.Button--icon) {
|
|
98
97
|
padding: 0;
|
|
99
98
|
}
|
|
100
99
|
|
|
@@ -102,7 +101,7 @@ $border-radius: 0 !default;
|
|
|
102
101
|
padding: 0 var(--space-s);
|
|
103
102
|
line-height: 1.333em;
|
|
104
103
|
|
|
105
|
-
&:has(
|
|
104
|
+
&:has(.Button--icon) .Button--icon {
|
|
106
105
|
margin: 0 var(--space-xxs);
|
|
107
106
|
}
|
|
108
107
|
}
|
|
@@ -123,6 +122,11 @@ $border-radius: 0 !default;
|
|
|
123
122
|
overflow: hidden;
|
|
124
123
|
margin-right: calc(-1 * var(--space-s));
|
|
125
124
|
}
|
|
125
|
+
|
|
126
|
+
// We don't need additional margin if button inside stack
|
|
127
|
+
.Stack__item & {
|
|
128
|
+
margin: 0;
|
|
129
|
+
}
|
|
126
130
|
}
|
|
127
131
|
|
|
128
132
|
@each $color-name, $color-value in $bg-map {
|
|
@@ -23,7 +23,7 @@ $color-stripes: 0 !default;
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
@mixin box-color($color) {
|
|
26
|
-
background-color:
|
|
26
|
+
background-color: oklch(from $color calc(l - 0.14) calc(c - 0.06) h);
|
|
27
27
|
color: var(--color-text-fixed-white);
|
|
28
28
|
}
|
|
29
29
|
|
|
@@ -35,6 +35,10 @@ $color-stripes: 0 !default;
|
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
@if $color-name == "black" {
|
|
39
|
+
--notice-box-stripes: hsla(0, 0%, 100%, 0.1);
|
|
40
|
+
}
|
|
41
|
+
|
|
38
42
|
@include box-color($color-value);
|
|
39
43
|
}
|
|
40
44
|
}
|