tgui-core 1.2.0 → 1.3.0
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 +3 -3
- package/dist/common/color.js +31 -30
- package/dist/common/events.js +5 -5
- package/dist/common/format.js +27 -27
- package/dist/common/hotkeys.d.ts +0 -1
- package/dist/common/hotkeys.js +2 -2
- package/dist/common/math.d.ts +4 -0
- package/dist/common/math.js +29 -25
- package/dist/common/random.js +14 -13
- package/dist/common/react.js +1 -1
- package/dist/common/string.js +9 -9
- package/dist/common/type-utils.d.ts +1 -1
- package/dist/components/AnimatedNumber.d.ts +6 -6
- package/dist/components/AnimatedNumber.js +14 -17
- package/dist/components/Autofocus.d.ts +0 -1
- package/dist/components/Blink.d.ts +0 -1
- package/dist/components/BlockQuote.d.ts +0 -1
- package/dist/components/BlockQuote.js +4 -7
- package/dist/components/Box.d.ts +0 -1
- package/dist/components/Box.js +4 -4
- package/dist/components/Button.d.ts +0 -1
- package/dist/components/Button.js +173 -211
- package/dist/components/ByondUi.js +3 -3
- package/dist/components/Chart.d.ts +0 -1
- package/dist/components/Chart.js +25 -22
- package/dist/components/Collapsible.d.ts +0 -1
- package/dist/components/ColorBox.d.ts +0 -1
- package/dist/components/ColorBox.js +7 -14
- package/dist/components/Dialog.js +31 -40
- package/dist/components/Dimmer.d.ts +0 -1
- package/dist/components/Dimmer.js +6 -9
- package/dist/components/Divider.js +10 -14
- package/dist/components/DmIcon.d.ts +0 -1
- package/dist/components/DraggableControl.js +57 -49
- package/dist/components/Dropdown.d.ts +0 -1
- package/dist/components/Dropdown.js +73 -67
- package/dist/components/FitText.d.ts +0 -1
- package/dist/components/Flex.d.ts +1 -1
- package/dist/components/Flex.js +39 -41
- package/dist/components/Icon.d.ts +0 -1
- package/dist/components/Icon.js +27 -34
- package/dist/components/Image.d.ts +0 -1
- package/dist/components/Image.js +7 -6
- package/dist/components/ImageButton.d.ts +0 -1
- package/dist/components/ImageButton.js +84 -171
- package/dist/components/InfinitePlane.js +1 -1
- package/dist/components/Input.d.ts +0 -1
- package/dist/components/Input.js +57 -64
- package/dist/components/KeyListener.d.ts +0 -1
- package/dist/components/Knob.d.ts +0 -1
- package/dist/components/Knob.js +91 -117
- package/dist/components/LabeledControls.d.ts +0 -1
- package/dist/components/LabeledList.d.ts +0 -1
- package/dist/components/LabeledList.js +48 -55
- package/dist/components/MenuBar.d.ts +0 -1
- package/dist/components/MenuBar.js +93 -102
- package/dist/components/Modal.d.ts +0 -1
- package/dist/components/Modal.js +11 -18
- package/dist/components/NoticeBox.d.ts +0 -1
- package/dist/components/NoticeBox.js +16 -43
- package/dist/components/NumberInput.d.ts +0 -2
- package/dist/components/NumberInput.js +99 -107
- package/dist/components/Popper.d.ts +0 -1
- package/dist/components/ProgressBar.d.ts +0 -1
- package/dist/components/ProgressBar.js +22 -27
- package/dist/components/RestrictedInput.js +64 -58
- package/dist/components/RoundGauge.d.ts +0 -1
- package/dist/components/RoundGauge.js +70 -104
- package/dist/components/Section.d.ts +1 -2
- package/dist/components/Section.js +50 -51
- package/dist/components/Slider.d.ts +0 -1
- package/dist/components/Slider.js +72 -80
- package/dist/components/Stack.d.ts +0 -1
- package/dist/components/Stack.js +37 -47
- package/dist/components/StyleableSection.d.ts +0 -1
- package/dist/components/StyleableSection.js +11 -11
- package/dist/components/Table.d.ts +0 -1
- package/dist/components/Table.js +38 -47
- package/dist/components/Tabs.d.ts +0 -1
- package/dist/components/Tabs.js +43 -75
- package/dist/components/TextArea.d.ts +0 -1
- package/dist/components/TextArea.js +74 -69
- package/dist/components/TimeDisplay.d.ts +7 -6
- package/dist/components/TimeDisplay.js +17 -17
- package/dist/components/Tooltip.d.ts +1 -2
- package/dist/components/Tooltip.js +8 -10
- package/dist/components/TrackOutsideClicks.d.ts +0 -1
- package/dist/components/VirtualList.d.ts +0 -1
- package/package.json +11 -25
- package/dist/ProgressBar.module-Jzqlebbx.js +0 -29
- package/dist/Section.module-qhQWhlUX.js +0 -18
- package/dist/assets/BlockQuote.css +0 -1
- package/dist/assets/Button.css +0 -1
- package/dist/assets/ColorBox.css +0 -1
- package/dist/assets/Dialog.css +0 -1
- package/dist/assets/Dimmer.css +0 -1
- package/dist/assets/Divider.css +0 -1
- package/dist/assets/Flex.css +0 -1
- package/dist/assets/Icon.css +0 -6
- package/dist/assets/ImageButton.css +0 -5
- package/dist/assets/Input.css +0 -1
- package/dist/assets/Knob.css +0 -1
- package/dist/assets/LabeledList.css +0 -1
- package/dist/assets/MenuBar.css +0 -1
- package/dist/assets/Modal.css +0 -1
- package/dist/assets/NoticeBox.css +0 -1
- package/dist/assets/NumberInput.css +0 -1
- package/dist/assets/ProgressBar.css +0 -1
- package/dist/assets/RoundGauge.css +0 -1
- package/dist/assets/Section.css +0 -1
- package/dist/assets/Slider.css +0 -1
- package/dist/assets/Stack.css +0 -1
- package/dist/assets/Table.css +0 -1
- package/dist/assets/Tabs.css +0 -1
- package/dist/assets/TextArea.css +0 -1
- package/dist/assets/Tooltip.css +0 -1
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ yarn add tgui-core
|
|
|
20
20
|
Now, you can use them like normal TGUI components.
|
|
21
21
|
|
|
22
22
|
```tsx
|
|
23
|
-
import { Button } from
|
|
23
|
+
import { Button } from "tgui-core/components";
|
|
24
24
|
|
|
25
25
|
<Button>Click</Button>;
|
|
26
26
|
```
|
|
@@ -28,8 +28,8 @@ import { Button } from 'tgui-core/components';
|
|
|
28
28
|
You can even use it in tandem with your own in house TGUI components,
|
|
29
29
|
|
|
30
30
|
```tsx
|
|
31
|
-
import { Button } from
|
|
32
|
-
import { Box } from
|
|
31
|
+
import { Button } from "tgui-core/components";
|
|
32
|
+
import { Box } from "../components";
|
|
33
33
|
```
|
|
34
34
|
|
|
35
35
|
## License
|
package/dist/common/color.js
CHANGED
|
@@ -1,24 +1,25 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
1
|
+
var g = Object.defineProperty;
|
|
2
|
+
var u = (e, t, r) => t in e ? g(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
|
|
3
|
+
var i = (e, t, r) => u(e, typeof t != "symbol" ? t + "" : t, r);
|
|
4
4
|
class n {
|
|
5
|
-
constructor(t = 0,
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
this.r = t, this.g =
|
|
5
|
+
constructor(t = 0, r = 0, s = 0, a = 1) {
|
|
6
|
+
i(this, "r");
|
|
7
|
+
i(this, "g");
|
|
8
|
+
i(this, "b");
|
|
9
|
+
i(this, "a");
|
|
10
|
+
this.r = t, this.g = r, this.b = s, this.a = a;
|
|
11
11
|
}
|
|
12
12
|
toString() {
|
|
13
13
|
let t = this.a;
|
|
14
|
-
return typeof t == "string" && (t = parseFloat(this.a)), isNaN(t) && (t = 1), `rgba(${this.r | 0}, ${this.g | 0}, ${this.b | 0}, ${t})`;
|
|
14
|
+
return typeof t == "string" && (t = Number.parseFloat(this.a)), Number.isNaN(t) && (t = 1), `rgba(${this.r | 0}, ${this.g | 0}, ${this.b | 0}, ${t})`;
|
|
15
15
|
}
|
|
16
16
|
/** Darkens a color by a given percent. Returns a color, which can have toString called to get it's rgba() css value. */
|
|
17
17
|
darken(t) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
this.
|
|
21
|
-
this.
|
|
18
|
+
const r = t / 100;
|
|
19
|
+
return new n(
|
|
20
|
+
this.r - this.r * r,
|
|
21
|
+
this.g - this.g * r,
|
|
22
|
+
this.b - this.b * r,
|
|
22
23
|
this.a
|
|
23
24
|
);
|
|
24
25
|
}
|
|
@@ -31,37 +32,37 @@ class n {
|
|
|
31
32
|
*/
|
|
32
33
|
static fromHex(t) {
|
|
33
34
|
return new n(
|
|
34
|
-
parseInt(t.slice(1, 3), 16),
|
|
35
|
-
parseInt(t.slice(3, 5), 16),
|
|
36
|
-
parseInt(t.slice(5, 7), 16)
|
|
35
|
+
Number.parseInt(t.slice(1, 3), 16),
|
|
36
|
+
Number.parseInt(t.slice(3, 5), 16),
|
|
37
|
+
Number.parseInt(t.slice(5, 7), 16)
|
|
37
38
|
);
|
|
38
39
|
}
|
|
39
40
|
/**
|
|
40
41
|
* Linear interpolation of two colors.
|
|
41
42
|
*/
|
|
42
|
-
static lerp(t,
|
|
43
|
+
static lerp(t, r, s) {
|
|
43
44
|
return new n(
|
|
44
|
-
(
|
|
45
|
-
(
|
|
46
|
-
(
|
|
47
|
-
(
|
|
45
|
+
(r.r - t.r) * s + t.r,
|
|
46
|
+
(r.g - t.g) * s + t.g,
|
|
47
|
+
(r.b - t.b) * s + t.b,
|
|
48
|
+
(r.a - t.a) * s + t.a
|
|
48
49
|
);
|
|
49
50
|
}
|
|
50
51
|
/**
|
|
51
52
|
* Loops up the color in the provided list of colors
|
|
52
53
|
* with linear interpolation.
|
|
53
54
|
*/
|
|
54
|
-
static lookup(t,
|
|
55
|
-
const
|
|
56
|
-
if (
|
|
55
|
+
static lookup(t, r) {
|
|
56
|
+
const s = r.length;
|
|
57
|
+
if (s < 2)
|
|
57
58
|
throw new Error("Needs at least two colors!");
|
|
58
|
-
const a = t * (
|
|
59
|
+
const a = t * (s - 1);
|
|
59
60
|
if (t < 1e-4)
|
|
60
|
-
return
|
|
61
|
+
return r[0];
|
|
61
62
|
if (t >= 1 - 1e-4)
|
|
62
|
-
return s
|
|
63
|
-
const
|
|
64
|
-
return
|
|
63
|
+
return r[s - 1];
|
|
64
|
+
const b = a % 1, h = a | 0;
|
|
65
|
+
return n.lerp(r[h], r[h + 1], b);
|
|
65
66
|
}
|
|
66
67
|
}
|
|
67
68
|
export {
|
package/dist/common/events.js
CHANGED
|
@@ -58,10 +58,10 @@ function a() {
|
|
|
58
58
|
}
|
|
59
59
|
let w = null, c = null;
|
|
60
60
|
const h = [];
|
|
61
|
-
function
|
|
61
|
+
function $(t) {
|
|
62
62
|
h.push(t);
|
|
63
63
|
}
|
|
64
|
-
function
|
|
64
|
+
function A(t) {
|
|
65
65
|
const e = h.indexOf(t);
|
|
66
66
|
e >= 0 && h.splice(e, 1);
|
|
67
67
|
}
|
|
@@ -121,7 +121,7 @@ class p {
|
|
|
121
121
|
return this.type === "keyup";
|
|
122
122
|
}
|
|
123
123
|
toString() {
|
|
124
|
-
return this._str ? this._str : (this._str = "", this.ctrl && (this._str += "Ctrl+"), this.alt && (this._str += "Alt+"), this.shift && (this._str += "Shift+"), this.code >= 48 && this.code <= 90 ? this._str += String.fromCharCode(this.code) : this.code >= K && this.code <= S ? this._str +=
|
|
124
|
+
return this._str ? this._str : (this._str = "", this.ctrl && (this._str += "Ctrl+"), this.alt && (this._str += "Alt+"), this.shift && (this._str += "Shift+"), this.code >= 48 && this.code <= 90 ? this._str += String.fromCharCode(this.code) : this.code >= K && this.code <= S ? this._str += `F${this.code - 111}` : this._str += `[${this.code}]`, this._str);
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
127
|
document.addEventListener("keydown", (t) => {
|
|
@@ -139,9 +139,9 @@ document.addEventListener("keyup", (t) => {
|
|
|
139
139
|
export {
|
|
140
140
|
C as EventEmitter,
|
|
141
141
|
p as KeyEvent,
|
|
142
|
-
|
|
142
|
+
$ as addScrollableNode,
|
|
143
143
|
E as canStealFocus,
|
|
144
144
|
o as globalEvents,
|
|
145
|
-
|
|
145
|
+
A as removeScrollableNode,
|
|
146
146
|
W as setupGlobalEvents
|
|
147
147
|
};
|
package/dist/common/format.js
CHANGED
|
@@ -38,21 +38,21 @@ const d = [
|
|
|
38
38
|
"F",
|
|
39
39
|
"N",
|
|
40
40
|
"H"
|
|
41
|
-
],
|
|
42
|
-
function
|
|
43
|
-
if (!isFinite(t))
|
|
41
|
+
], u = d.indexOf(" ");
|
|
42
|
+
function m(t, n = -u, s = "") {
|
|
43
|
+
if (!Number.isFinite(t))
|
|
44
44
|
return t.toString();
|
|
45
|
-
const o = Math.floor(Math.log10(Math.abs(t))),
|
|
46
|
-
let
|
|
47
|
-
return
|
|
48
|
-
}
|
|
49
|
-
function S(t, n = 0) {
|
|
50
|
-
return u(t, n, "W");
|
|
45
|
+
const o = Math.floor(Math.log10(Math.abs(t))), a = Math.max(n * 3, o), e = Math.floor(a / 3), i = d[Math.min(e + u, d.length - 1)];
|
|
46
|
+
let r = (t / 1e3 ** e).toFixed(2);
|
|
47
|
+
return r.endsWith(".00") ? r = r.slice(0, -3) : r.endsWith(".0") && (r = r.slice(0, -2)), `${r} ${i.trim()}${s}`.trim();
|
|
51
48
|
}
|
|
52
|
-
function
|
|
53
|
-
return
|
|
49
|
+
function M(t, n = 0) {
|
|
50
|
+
return m(t, n, "W");
|
|
54
51
|
}
|
|
55
52
|
function b(t, n = 0) {
|
|
53
|
+
return m(t, n, "J");
|
|
54
|
+
}
|
|
55
|
+
function $(t, n = 0) {
|
|
56
56
|
if (!Number.isFinite(t))
|
|
57
57
|
return String(t);
|
|
58
58
|
const s = Number(t.toFixed(n)), o = s < 0, e = Math.abs(s).toString().split(".");
|
|
@@ -63,9 +63,9 @@ function b(t, n = 0) {
|
|
|
63
63
|
function g(t) {
|
|
64
64
|
const n = 20 * Math.log10(t), s = n >= 0 ? "+" : "-";
|
|
65
65
|
let o = Math.abs(n);
|
|
66
|
-
return o ===
|
|
66
|
+
return o === Number.POSITIVE_INFINITY ? o = "Inf" : o = o.toFixed(2), `${s}${o} dB`;
|
|
67
67
|
}
|
|
68
|
-
const
|
|
68
|
+
const S = [
|
|
69
69
|
"",
|
|
70
70
|
"· 10³",
|
|
71
71
|
// kilo
|
|
@@ -91,27 +91,27 @@ const M = [
|
|
|
91
91
|
"· 10³⁶",
|
|
92
92
|
"· 10³⁹"
|
|
93
93
|
];
|
|
94
|
-
function
|
|
95
|
-
if (!isFinite(t))
|
|
94
|
+
function N(t, n = 0, s = "") {
|
|
95
|
+
if (!Number.isFinite(t))
|
|
96
96
|
return "NaN";
|
|
97
|
-
const o = Math.floor(Math.log10(t)),
|
|
98
|
-
return `${c.toFixed(
|
|
97
|
+
const o = Math.floor(Math.log10(t)), a = Math.max(n * 3, o), e = Math.floor(a / 3), i = S[e], c = t / 1e3 ** e, r = Math.max(0, 2 - a % 3);
|
|
98
|
+
return `${c.toFixed(r)} ${i} ${s}`.trim();
|
|
99
99
|
}
|
|
100
100
|
function F(t, n = "default") {
|
|
101
|
-
const s = Math.floor(t / 10), o = Math.floor(s / 3600),
|
|
101
|
+
const s = Math.floor(t / 10), o = Math.floor(s / 3600), a = Math.floor(s % 3600 / 60), e = s % 60;
|
|
102
102
|
if (n === "short") {
|
|
103
|
-
const f = o > 0 ? `${o}h` : "",
|
|
104
|
-
return `${f}${
|
|
103
|
+
const f = o > 0 ? `${o}h` : "", l = a > 0 ? `${a}m` : "", h = e > 0 ? `${e}s` : "";
|
|
104
|
+
return `${f}${l}${h}`;
|
|
105
105
|
}
|
|
106
|
-
const i = String(o).padStart(2, "0"), c = String(
|
|
107
|
-
return `${i}:${c}:${
|
|
106
|
+
const i = String(o).padStart(2, "0"), c = String(a).padStart(2, "0"), r = String(e).padStart(2, "0");
|
|
107
|
+
return `${i}:${c}:${r}`;
|
|
108
108
|
}
|
|
109
109
|
export {
|
|
110
110
|
g as formatDb,
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
111
|
+
b as formatEnergy,
|
|
112
|
+
$ as formatMoney,
|
|
113
|
+
M as formatPower,
|
|
114
|
+
N as formatSiBaseTenUnit,
|
|
115
|
+
m as formatSiUnit,
|
|
116
116
|
F as formatTime
|
|
117
117
|
};
|
package/dist/common/hotkeys.d.ts
CHANGED
package/dist/common/hotkeys.js
CHANGED
|
@@ -30,9 +30,9 @@ function w(t) {
|
|
|
30
30
|
if (t >= 48 && t <= 57 || t >= 65 && t <= 90)
|
|
31
31
|
return String.fromCharCode(t);
|
|
32
32
|
if (t >= 96 && t <= 105)
|
|
33
|
-
return
|
|
33
|
+
return `Numpad${t - 96}`;
|
|
34
34
|
if (t >= 112 && t <= 123)
|
|
35
|
-
return
|
|
35
|
+
return `F${t - 111}`;
|
|
36
36
|
if (t === 188) return ",";
|
|
37
37
|
if (t === 189) return "-";
|
|
38
38
|
if (t === 190) return ".";
|
package/dist/common/math.d.ts
CHANGED
|
@@ -37,3 +37,7 @@ export declare function keyOfMatchingRange(value: number, ranges: Record<string,
|
|
|
37
37
|
* Get number of digits following the decimal point in a number
|
|
38
38
|
*/
|
|
39
39
|
export declare function numberOfDecimalDigits(value: number): number;
|
|
40
|
+
/**
|
|
41
|
+
* Ensures the number is valid and not infinite/NaN.
|
|
42
|
+
*/
|
|
43
|
+
export declare function isSafeNumber(value: number): boolean;
|
package/dist/common/math.js
CHANGED
|
@@ -1,41 +1,45 @@
|
|
|
1
|
-
function e(
|
|
2
|
-
return
|
|
1
|
+
function e(n, t, r) {
|
|
2
|
+
return n < t ? t : n > r ? r : n;
|
|
3
3
|
}
|
|
4
|
-
function
|
|
5
|
-
return
|
|
4
|
+
function u(n) {
|
|
5
|
+
return n < 0 ? 0 : n > 1 ? 1 : n;
|
|
6
6
|
}
|
|
7
|
-
function f(
|
|
8
|
-
return (
|
|
7
|
+
function f(n, t = 0, r = 100) {
|
|
8
|
+
return (n - t) / (r - t);
|
|
9
9
|
}
|
|
10
|
-
function
|
|
11
|
-
const r =
|
|
12
|
-
return parseFloat(
|
|
13
|
-
(Math.round(
|
|
10
|
+
function c(n, t) {
|
|
11
|
+
const r = n >= 0 ? 1 : -1;
|
|
12
|
+
return Number.parseFloat(
|
|
13
|
+
(Math.round(n * 10 ** t + r * 1e-4) / 10 ** t).toFixed(t)
|
|
14
14
|
);
|
|
15
15
|
}
|
|
16
|
-
function s(
|
|
17
|
-
return Number(
|
|
16
|
+
function s(n, t = 0) {
|
|
17
|
+
return Number(n).toFixed(Math.max(t, 0));
|
|
18
18
|
}
|
|
19
|
-
function
|
|
20
|
-
return
|
|
19
|
+
function o(n, t) {
|
|
20
|
+
return t && n >= t[0] && n <= t[1];
|
|
21
21
|
}
|
|
22
|
-
function
|
|
23
|
-
for (const r of Object.keys(
|
|
24
|
-
const
|
|
25
|
-
if (
|
|
22
|
+
function m(n, t) {
|
|
23
|
+
for (const r of Object.keys(t)) {
|
|
24
|
+
const i = t[r];
|
|
25
|
+
if (o(n, i))
|
|
26
26
|
return r;
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
-
function
|
|
30
|
-
return Math.floor(
|
|
29
|
+
function b(n) {
|
|
30
|
+
return Math.floor(n) !== n && n.toString().split(".")[1].length || 0;
|
|
31
|
+
}
|
|
32
|
+
function N(n) {
|
|
33
|
+
return typeof n == "number" && Number.isFinite(n) && !Number.isNaN(n);
|
|
31
34
|
}
|
|
32
35
|
export {
|
|
33
36
|
e as clamp,
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
u as clamp01,
|
|
38
|
+
o as inRange,
|
|
39
|
+
N as isSafeNumber,
|
|
40
|
+
m as keyOfMatchingRange,
|
|
41
|
+
b as numberOfDecimalDigits,
|
|
42
|
+
c as round,
|
|
39
43
|
f as scale,
|
|
40
44
|
s as toFixed
|
|
41
45
|
};
|
package/dist/common/random.js
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
import { clamp as
|
|
2
|
-
function
|
|
3
|
-
return Math.random() * (
|
|
1
|
+
import { clamp as a } from "./math.js";
|
|
2
|
+
function e(n, o) {
|
|
3
|
+
return Math.random() * (o - n) + n;
|
|
4
4
|
}
|
|
5
|
-
function
|
|
6
|
-
|
|
5
|
+
function c(n, o) {
|
|
6
|
+
const r = Math.ceil(n), t = Math.floor(o);
|
|
7
|
+
return Math.floor(Math.random() * (t - r) + r);
|
|
7
8
|
}
|
|
8
|
-
function h(
|
|
9
|
-
return
|
|
9
|
+
function h(n) {
|
|
10
|
+
return n[Math.floor(Math.random() * n.length)];
|
|
10
11
|
}
|
|
11
|
-
function
|
|
12
|
-
const
|
|
13
|
-
return Math.random() <=
|
|
12
|
+
function u(n) {
|
|
13
|
+
const o = a(n, 0, 100) / 100;
|
|
14
|
+
return Math.random() <= o;
|
|
14
15
|
}
|
|
15
16
|
export {
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
c as randomInteger,
|
|
18
|
+
e as randomNumber,
|
|
18
19
|
h as randomPick,
|
|
19
|
-
|
|
20
|
+
u as randomProb
|
|
20
21
|
};
|
package/dist/common/react.js
CHANGED
package/dist/common/string.js
CHANGED
|
@@ -9,7 +9,7 @@ function p(e, t = (r) => JSON.stringify(r)) {
|
|
|
9
9
|
}
|
|
10
10
|
const a = ["a", "e", "i", "o", "u"];
|
|
11
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
|
|
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
13
|
}
|
|
14
14
|
function c(e) {
|
|
15
15
|
return e.charAt(0).toUpperCase() + e.slice(1).toLowerCase();
|
|
@@ -20,7 +20,7 @@ function f(e) {
|
|
|
20
20
|
function h(e) {
|
|
21
21
|
return e.replace(/^\w/, (t) => t.toUpperCase());
|
|
22
22
|
}
|
|
23
|
-
const i = ["Id", "Tv"],
|
|
23
|
+
const i = ["Id", "Tv"], u = [
|
|
24
24
|
"A",
|
|
25
25
|
"An",
|
|
26
26
|
"And",
|
|
@@ -46,17 +46,17 @@ const i = ["Id", "Tv"], s = [
|
|
|
46
46
|
function g(e) {
|
|
47
47
|
if (!e) return e;
|
|
48
48
|
let t = e.replace(/([^\W_]+[^\s-]*) */g, (r) => c(r));
|
|
49
|
-
for (const r of
|
|
50
|
-
const n = new RegExp(
|
|
49
|
+
for (const r of u) {
|
|
50
|
+
const n = new RegExp(`\\s${r}\\s`, "g");
|
|
51
51
|
t = t.replace(n, (o) => o.toLowerCase());
|
|
52
52
|
}
|
|
53
53
|
for (const r of i) {
|
|
54
|
-
const n = new RegExp(
|
|
54
|
+
const n = new RegExp(`\\b${r}\\b`, "g");
|
|
55
55
|
t = t.replace(n, (o) => o.toLowerCase());
|
|
56
56
|
}
|
|
57
57
|
return t;
|
|
58
58
|
}
|
|
59
|
-
const
|
|
59
|
+
const s = {
|
|
60
60
|
amp: "&",
|
|
61
61
|
apos: "'",
|
|
62
62
|
gt: ">",
|
|
@@ -68,12 +68,12 @@ function d(e) {
|
|
|
68
68
|
return e && e.replace(/<br>/gi, `
|
|
69
69
|
`).replace(/<\/?[a-z0-9-_]+[^>]*>/gi, "").replace(
|
|
70
70
|
/&(nbsp|amp|quot|lt|gt|apos);/g,
|
|
71
|
-
(t, r) =>
|
|
71
|
+
(t, r) => s[r]
|
|
72
72
|
).replace(/&#?([0-9]+);/gi, (t, r) => {
|
|
73
|
-
const n = parseInt(r, 10);
|
|
73
|
+
const n = Number.parseInt(r, 10);
|
|
74
74
|
return String.fromCharCode(n);
|
|
75
75
|
}).replace(/&#x?([0-9a-f]+);/gi, (t, r) => {
|
|
76
|
-
const n = parseInt(r, 16);
|
|
76
|
+
const n = Number.parseInt(r, 16);
|
|
77
77
|
return String.fromCharCode(n);
|
|
78
78
|
});
|
|
79
79
|
}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { Component } from 'react';
|
|
2
|
-
|
|
3
2
|
type Props = {
|
|
3
|
+
/**
|
|
4
|
+
* The target value to approach.
|
|
5
|
+
*/
|
|
6
|
+
value: number;
|
|
7
|
+
} & Partial<{
|
|
4
8
|
/**
|
|
5
9
|
* If provided, a function that formats the inner string. By default,
|
|
6
10
|
* attempts to match the numeric precision of `value`.
|
|
@@ -12,11 +16,7 @@ type Props = {
|
|
|
12
16
|
* animating.
|
|
13
17
|
*/
|
|
14
18
|
initial?: number;
|
|
15
|
-
|
|
16
|
-
* The target value to approach.
|
|
17
|
-
*/
|
|
18
|
-
value: number;
|
|
19
|
-
};
|
|
19
|
+
}>;
|
|
20
20
|
/**
|
|
21
21
|
* An animated number label. Shows a number, formatted with an optionally
|
|
22
22
|
* provided function, and animates it towards its target value.
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
var f = Object.defineProperty;
|
|
2
|
-
var p = (
|
|
3
|
-
var s = (
|
|
4
|
-
import { jsx as
|
|
5
|
-
import { Component as
|
|
6
|
-
import { toFixed as d, clamp as T } from "../common/math.js";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
const V = 1e3 / 60, a = 0.8333, l = 1e-3;
|
|
11
|
-
class S extends v {
|
|
2
|
+
var p = (r, i, t) => i in r ? f(r, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[i] = t;
|
|
3
|
+
var s = (r, i, t) => p(r, typeof i != "symbol" ? i + "" : i, t);
|
|
4
|
+
import { jsx as v } from "react/jsx-runtime";
|
|
5
|
+
import { Component as m, createRef as g } from "react";
|
|
6
|
+
import { isSafeNumber as o, toFixed as d, clamp as T } from "../common/math.js";
|
|
7
|
+
const V = 1e3 / 60, u = 0.8333, l = 1e-3;
|
|
8
|
+
class b extends m {
|
|
12
9
|
constructor(t) {
|
|
13
10
|
super(t);
|
|
14
11
|
/**
|
|
@@ -53,24 +50,24 @@ class S extends v {
|
|
|
53
50
|
*/
|
|
54
51
|
tick() {
|
|
55
52
|
const { currentValue: t } = this, { value: e } = this.props;
|
|
56
|
-
o(e) ? this.currentValue = t *
|
|
53
|
+
o(e) ? this.currentValue = t * u + e * (1 - u) : this.stopTicking(), Math.abs(e - this.currentValue) < Math.max(l, l * e) && (this.currentValue = e, this.stopTicking()), this.ref.current && (this.ref.current.textContent = this.getText());
|
|
57
54
|
}
|
|
58
55
|
/**
|
|
59
56
|
* Gets the inner text of the span.
|
|
60
57
|
*/
|
|
61
58
|
getText() {
|
|
62
|
-
const { props: t, currentValue: e } = this, { format: n, value:
|
|
63
|
-
if (!o(
|
|
64
|
-
return String(
|
|
59
|
+
const { props: t, currentValue: e } = this, { format: n, value: a } = t;
|
|
60
|
+
if (!o(a))
|
|
61
|
+
return String(a);
|
|
65
62
|
if (n)
|
|
66
63
|
return n(this.currentValue);
|
|
67
|
-
const c = String(
|
|
64
|
+
const c = String(a).split(".")[1], h = c ? c.length : 0;
|
|
68
65
|
return d(e, T(h, 0, 8));
|
|
69
66
|
}
|
|
70
67
|
render() {
|
|
71
|
-
return /* @__PURE__ */
|
|
68
|
+
return /* @__PURE__ */ v("span", { ref: this.ref, children: this.getText() });
|
|
72
69
|
}
|
|
73
70
|
}
|
|
74
71
|
export {
|
|
75
|
-
|
|
72
|
+
b as AnimatedNumber
|
|
76
73
|
};
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as t } from "react/jsx-runtime";
|
|
2
2
|
import { classes as e } from "../common/react.js";
|
|
3
|
-
import { Box as
|
|
4
|
-
import '../assets/BlockQuote.css';const l = "_blockQuote_14fvy_13", m = {
|
|
5
|
-
blockQuote: l
|
|
6
|
-
};
|
|
3
|
+
import { Box as m } from "./Box.js";
|
|
7
4
|
function f(o) {
|
|
8
|
-
const { className:
|
|
9
|
-
return /* @__PURE__ */
|
|
5
|
+
const { className: r, ...s } = o;
|
|
6
|
+
return /* @__PURE__ */ t(m, { className: e(["BlockQuote", r]), ...s });
|
|
10
7
|
}
|
|
11
8
|
export {
|
|
12
9
|
f as BlockQuote
|
package/dist/components/Box.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { CSSProperties, KeyboardEventHandler, MouseEventHandler, ReactNode, UIEventHandler } from 'react';
|
|
2
2
|
import { BooleanLike } from '../common/react';
|
|
3
|
-
|
|
4
3
|
type BooleanProps = Partial<Record<keyof typeof booleanStyleMap, boolean>>;
|
|
5
4
|
type StringProps = Partial<Record<keyof typeof stringStyleMap, string | BooleanLike>>;
|
|
6
5
|
export type EventHandlers = Partial<{
|
package/dist/components/Box.js
CHANGED
|
@@ -3,9 +3,9 @@ import { CSS_COLORS as b } from "../common/constants.js";
|
|
|
3
3
|
import { classes as u } from "../common/react.js";
|
|
4
4
|
function p(o) {
|
|
5
5
|
if (typeof o == "string")
|
|
6
|
-
return o.endsWith("px") ? parseFloat(o) / 12
|
|
6
|
+
return o.endsWith("px") ? `${Number.parseFloat(o) / 12}rem` : o;
|
|
7
7
|
if (typeof o == "number")
|
|
8
|
-
return o
|
|
8
|
+
return `${o}rem`;
|
|
9
9
|
}
|
|
10
10
|
function r(o) {
|
|
11
11
|
if (typeof o == "string")
|
|
@@ -109,8 +109,8 @@ function S(o) {
|
|
|
109
109
|
function d(o) {
|
|
110
110
|
const t = o.textColor || o.color, i = o.backgroundColor;
|
|
111
111
|
return u([
|
|
112
|
-
a(t) &&
|
|
113
|
-
a(i) &&
|
|
112
|
+
a(t) && `color-${t}`,
|
|
113
|
+
a(i) && `color-bg-${i}`
|
|
114
114
|
]);
|
|
115
115
|
}
|
|
116
116
|
function W(o) {
|