tgui-core 2.0.2 → 2.0.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/components/Button.js +145 -153
- package/dist/components/DraggableControl.d.ts +0 -2
- package/dist/components/DraggableControl.js +83 -104
- package/dist/components/FitText.d.ts +2 -2
- package/dist/components/NumberInput.d.ts +2 -2
- package/package.json +1 -1
- package/styles/components/Button.scss +12 -8
- package/styles/components/NoticeBox.scss +5 -1
- package/styles/components/Tooltip.scss +1 -0
|
@@ -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
|
|
@@ -37,8 +37,6 @@ type Props = {
|
|
|
37
37
|
step: number;
|
|
38
38
|
/** The step size in pixels. */
|
|
39
39
|
stepPixelSize: number;
|
|
40
|
-
/** The number of milliseconds to suppress flickering. */
|
|
41
|
-
suppressFlicker: number;
|
|
42
40
|
/** Whether to unclamp the value. */
|
|
43
41
|
unclamped: boolean;
|
|
44
42
|
/** The unit of the value. */
|
|
@@ -1,132 +1,111 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useState as
|
|
3
|
-
import { KEY as
|
|
4
|
-
import { clamp as
|
|
5
|
-
import { AnimatedNumber as
|
|
6
|
-
const
|
|
7
|
-
function
|
|
8
|
-
return
|
|
1
|
+
import { jsxs as $, Fragment as q, jsx as D } from "react/jsx-runtime";
|
|
2
|
+
import { useState as F, useRef as i, useEffect as J } from "react";
|
|
3
|
+
import { KEY as Q, isEscape as W } from "../common/keys.js";
|
|
4
|
+
import { clamp as b } from "../common/math.js";
|
|
5
|
+
import { AnimatedNumber as Z } from "./AnimatedNumber.js";
|
|
6
|
+
const C = 400, x = -1;
|
|
7
|
+
function A(n, m) {
|
|
8
|
+
return n.screenX * m[0] + n.screenY * m[1];
|
|
9
9
|
}
|
|
10
|
-
function
|
|
10
|
+
function ie(n) {
|
|
11
11
|
const {
|
|
12
12
|
// Our props
|
|
13
|
-
animated:
|
|
14
|
-
children:
|
|
15
|
-
dragMatrix:
|
|
16
|
-
format:
|
|
17
|
-
maxValue:
|
|
18
|
-
minValue:
|
|
19
|
-
onChange:
|
|
20
|
-
onDrag:
|
|
21
|
-
step:
|
|
13
|
+
animated: m,
|
|
14
|
+
children: L,
|
|
15
|
+
dragMatrix: S = [1, 0],
|
|
16
|
+
format: g,
|
|
17
|
+
maxValue: N = Number.POSITIVE_INFINITY,
|
|
18
|
+
minValue: o = Number.NEGATIVE_INFINITY,
|
|
19
|
+
onChange: a,
|
|
20
|
+
onDrag: l,
|
|
21
|
+
step: s = 1,
|
|
22
22
|
stepPixelSize: O = 1,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
updateRate: w = te,
|
|
23
|
+
unclamped: Y,
|
|
24
|
+
unit: V,
|
|
25
|
+
updateRate: k = C,
|
|
27
26
|
// Box props
|
|
28
|
-
fontSize:
|
|
29
|
-
height:
|
|
27
|
+
fontSize: K,
|
|
28
|
+
height: P,
|
|
30
29
|
lineHeight: U
|
|
31
|
-
} =
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}, [
|
|
35
|
-
function
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
30
|
+
} = n, [ee, I] = F(n.value), [d, v] = F(!1), r = i(!1), u = i(n.value), c = i(0), E = i(x), y = i(null), T = i(null), p = i(null);
|
|
31
|
+
J(() => {
|
|
32
|
+
n.value !== u.current && (u.current = n.value, I(n.value));
|
|
33
|
+
}, [n.value]);
|
|
34
|
+
function j(e) {
|
|
35
|
+
d || (document.body.style["pointer-events"] = "none", E.current = A(e.nativeEvent, S), c.current = n.value, r.current = !0, document.addEventListener("mouseup", _), p.current = setTimeout(() => {
|
|
36
|
+
w(e.nativeEvent);
|
|
37
|
+
}, 100));
|
|
38
|
+
}
|
|
39
|
+
function w(e) {
|
|
40
|
+
if (r.current)
|
|
41
|
+
document.addEventListener("mousemove", h), T.current = setInterval(() => {
|
|
42
|
+
r.current && (l == null || l(e, n.value));
|
|
43
|
+
}, k);
|
|
44
|
+
else if (v(!0), y.current) {
|
|
45
|
+
const t = y.current;
|
|
46
|
+
t.value = c.current.toString(), setTimeout(() => {
|
|
39
47
|
t.focus(), t.select();
|
|
40
48
|
}, 10);
|
|
41
49
|
}
|
|
50
|
+
p.current && clearTimeout(p.current);
|
|
42
51
|
}
|
|
43
|
-
function
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
),
|
|
56
|
-
F(
|
|
57
|
-
n.current - n.current % o + Q,
|
|
58
|
-
l,
|
|
59
|
-
g
|
|
60
|
-
)
|
|
61
|
-
), m.current = t;
|
|
52
|
+
function h(e) {
|
|
53
|
+
const t = A(e, S), H = t - E.current, X = Number.isFinite(o) ? o % s : 0;
|
|
54
|
+
c.current = b(
|
|
55
|
+
c.current + H * s / O,
|
|
56
|
+
o - s,
|
|
57
|
+
N + s
|
|
58
|
+
);
|
|
59
|
+
const R = b(
|
|
60
|
+
c.current - c.current % s + X,
|
|
61
|
+
o,
|
|
62
|
+
N
|
|
63
|
+
);
|
|
64
|
+
u.current = R, I(R), E.current = t;
|
|
62
65
|
}
|
|
63
|
-
function
|
|
64
|
-
|
|
65
|
-
const t = e.nativeEvent;
|
|
66
|
-
document.body.style["pointer-events"] = "none", m.current = K(t, V), n.current = r.value, b.current = setTimeout(() => {
|
|
67
|
-
i.current = !0;
|
|
68
|
-
}, 250), I.current = setInterval(() => {
|
|
69
|
-
i && (a == null || a(t, r.value));
|
|
70
|
-
}, w), document.addEventListener("mousemove", x), document.addEventListener("mouseup", _);
|
|
66
|
+
function _(e) {
|
|
67
|
+
document.body.style["pointer-events"] = "auto", T.current && clearInterval(T.current), E.current = x, document.removeEventListener("mousemove", h), document.removeEventListener("mouseup", _), r.current && (a == null || a(e, u.current), l == null || l(e, u.current), r.current = !1);
|
|
71
68
|
}
|
|
72
|
-
function
|
|
73
|
-
|
|
74
|
-
e.preventDefault(), e.stopPropagation(), A(e.nativeEvent, e.currentTarget.value);
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
if (e.key === Y.Escape) {
|
|
78
|
-
f(!1);
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
69
|
+
function z(e) {
|
|
70
|
+
(e.key === Q.Enter || W(e.key)) && v(!1);
|
|
81
71
|
}
|
|
82
|
-
function
|
|
83
|
-
let
|
|
84
|
-
if (
|
|
85
|
-
|
|
72
|
+
function B(e) {
|
|
73
|
+
let t = Number.parseFloat(e.currentTarget.value);
|
|
74
|
+
if (Y || (t = b(t, o, N)), Number.isNaN(t)) {
|
|
75
|
+
v(!1);
|
|
86
76
|
return;
|
|
87
77
|
}
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
function L() {
|
|
91
|
-
if (S <= 0) return;
|
|
92
|
-
const e = R.current;
|
|
93
|
-
if (e)
|
|
94
|
-
return D(!0), clearTimeout(e), R.current = setTimeout(() => {
|
|
95
|
-
D(!1);
|
|
96
|
-
}, S), () => clearTimeout(e);
|
|
97
|
-
}
|
|
98
|
-
function $(e) {
|
|
99
|
-
v && f(!1), A(e.nativeEvent, e.currentTarget.value);
|
|
78
|
+
c.current = t, u.current = t, I(t), a == null || a(e.nativeEvent, t), d && v(!1);
|
|
100
79
|
}
|
|
101
|
-
let
|
|
102
|
-
|
|
103
|
-
const
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
] }),
|
|
80
|
+
let f = n.value;
|
|
81
|
+
r.current && (f = u.current);
|
|
82
|
+
const G = /* @__PURE__ */ $(q, { children: [
|
|
83
|
+
m && !r.current ? /* @__PURE__ */ D(Z, { value: f, format: g }) : g ? g(f) : f,
|
|
84
|
+
V ? ` ${V}` : ""
|
|
85
|
+
] }), M = /* @__PURE__ */ D(
|
|
107
86
|
"input",
|
|
108
87
|
{
|
|
109
|
-
ref:
|
|
88
|
+
ref: y,
|
|
110
89
|
className: "NumberInput__input",
|
|
111
90
|
style: {
|
|
112
|
-
display:
|
|
113
|
-
height:
|
|
91
|
+
display: d ? void 0 : "none",
|
|
92
|
+
height: P,
|
|
114
93
|
lineHeight: U,
|
|
115
|
-
fontSize:
|
|
94
|
+
fontSize: K
|
|
116
95
|
},
|
|
117
|
-
onBlur:
|
|
118
|
-
onKeyDown:
|
|
96
|
+
onBlur: B,
|
|
97
|
+
onKeyDown: z
|
|
119
98
|
}
|
|
120
99
|
);
|
|
121
|
-
return
|
|
122
|
-
displayElement:
|
|
123
|
-
displayValue:
|
|
124
|
-
dragging:
|
|
125
|
-
editing:
|
|
126
|
-
handleDragStart:
|
|
127
|
-
inputElement:
|
|
100
|
+
return L({
|
|
101
|
+
displayElement: G,
|
|
102
|
+
displayValue: f,
|
|
103
|
+
dragging: r.current,
|
|
104
|
+
editing: d,
|
|
105
|
+
handleDragStart: j,
|
|
106
|
+
inputElement: M
|
|
128
107
|
});
|
|
129
108
|
}
|
|
130
109
|
export {
|
|
131
|
-
|
|
110
|
+
ie as DraggableControl
|
|
132
111
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Component, HTMLAttributes, PropsWithChildren
|
|
1
|
+
import { Component, HTMLAttributes, PropsWithChildren } from 'react';
|
|
2
2
|
type Props = {
|
|
3
3
|
acceptableDifference?: number;
|
|
4
4
|
maxFontSize: number;
|
|
@@ -9,7 +9,7 @@ type State = {
|
|
|
9
9
|
fontSize: number;
|
|
10
10
|
};
|
|
11
11
|
export declare class FitText extends Component<Props, State> {
|
|
12
|
-
ref: RefObject<HTMLDivElement | null>;
|
|
12
|
+
ref: import('react').RefObject<HTMLDivElement | null>;
|
|
13
13
|
state: State;
|
|
14
14
|
constructor(props: Props);
|
|
15
15
|
componentDidUpdate(prevProps: any): void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CSSProperties, Component, FocusEventHandler, KeyboardEventHandler, MouseEventHandler
|
|
1
|
+
import { CSSProperties, Component, FocusEventHandler, KeyboardEventHandler, MouseEventHandler } from 'react';
|
|
2
2
|
import { BooleanLike } from '../common/react';
|
|
3
3
|
import { BoxProps } from './Box';
|
|
4
4
|
type Props = Required<{
|
|
@@ -51,7 +51,7 @@ type State = {
|
|
|
51
51
|
* to fine tune the value, or single click it to manually type a number.
|
|
52
52
|
*/
|
|
53
53
|
export declare class NumberInput extends Component<Props, State> {
|
|
54
|
-
inputRef: RefObject<HTMLInputElement | null>;
|
|
54
|
+
inputRef: import('react').RefObject<HTMLInputElement | null>;
|
|
55
55
|
dragTimeout: NodeJS.Timeout;
|
|
56
56
|
dragInterval: NodeJS.Timeout;
|
|
57
57
|
state: State;
|
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
|
}
|