tgui-core 1.7.3 → 1.7.5
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/keys.d.ts +62 -1
- package/dist/common/keys.js +29 -5
- package/dist/common/string.js +17 -18
- package/dist/components/Flex.d.ts +1 -1
- package/dist/components/Flex.js +1 -1
- package/dist/components/Image.js +16 -15
- package/dist/components/ImageButton.d.ts +6 -0
- package/dist/components/ImageButton.js +90 -77
- package/dist/components/InfinitePlane.d.ts +35 -0
- package/dist/components/InfinitePlane.js +81 -77
- package/dist/components/Modal.d.ts +8 -1
- package/dist/components/Modal.js +15 -11
- package/package.json +1 -1
- package/styles/components/Dimmer.scss +2 -1
- package/styles/components/ImageButton.scss +8 -1
- package/styles/components/Tooltip.scss +2 -1
package/dist/common/keys.d.ts
CHANGED
|
@@ -21,11 +21,14 @@
|
|
|
21
21
|
*
|
|
22
22
|
*/
|
|
23
23
|
export declare enum KEY {
|
|
24
|
+
A = "a",
|
|
24
25
|
Alt = "Alt",
|
|
25
26
|
Backspace = "Backspace",
|
|
26
27
|
Control = "Control",
|
|
28
|
+
D = "d",
|
|
27
29
|
Delete = "Delete",
|
|
28
30
|
Down = "ArrowDown",
|
|
31
|
+
E = "e",
|
|
29
32
|
End = "End",
|
|
30
33
|
Enter = "Enter",
|
|
31
34
|
Esc = "Esc",
|
|
@@ -33,13 +36,17 @@ export declare enum KEY {
|
|
|
33
36
|
Home = "Home",
|
|
34
37
|
Insert = "Insert",
|
|
35
38
|
Left = "ArrowLeft",
|
|
39
|
+
N = "n",
|
|
36
40
|
PageDown = "PageDown",
|
|
37
41
|
PageUp = "PageUp",
|
|
38
42
|
Right = "ArrowRight",
|
|
43
|
+
S = "s",
|
|
39
44
|
Shift = "Shift",
|
|
40
45
|
Space = " ",
|
|
41
46
|
Tab = "Tab",
|
|
42
|
-
Up = "ArrowUp"
|
|
47
|
+
Up = "ArrowUp",
|
|
48
|
+
W = "w",
|
|
49
|
+
Z = "z"
|
|
43
50
|
}
|
|
44
51
|
/**
|
|
45
52
|
* ### isEscape
|
|
@@ -53,3 +60,57 @@ export declare enum KEY {
|
|
|
53
60
|
* @returns true if key is Escape or Esc, false otherwise
|
|
54
61
|
*/
|
|
55
62
|
export declare function isEscape(key: string): boolean;
|
|
63
|
+
/**
|
|
64
|
+
* ### isAlphabetic
|
|
65
|
+
*
|
|
66
|
+
* Checks if the user has hit any alphabetic key (a - z)
|
|
67
|
+
*
|
|
68
|
+
* @param key - the key to check, typically from event.key
|
|
69
|
+
* @returns true if key is in the range of a-z
|
|
70
|
+
*/
|
|
71
|
+
export declare function isAlphabetic(key: string): boolean;
|
|
72
|
+
/**
|
|
73
|
+
* ### isNumeric
|
|
74
|
+
*
|
|
75
|
+
* Checks if the user has hit any numeric key (0 - 9)
|
|
76
|
+
*
|
|
77
|
+
* @param key - the key to check, typically from event.key
|
|
78
|
+
* @returns true if key is in the range of 0 - 9
|
|
79
|
+
*/
|
|
80
|
+
export declare function isNumeric(key: string): boolean;
|
|
81
|
+
/**
|
|
82
|
+
* ### isCardinal
|
|
83
|
+
*
|
|
84
|
+
* Checks if the user has hit any cardinal key (n s w e)
|
|
85
|
+
*
|
|
86
|
+
* @param key - the key to check, typically from event.key
|
|
87
|
+
* @returns true if key matches any cardinal n s w e
|
|
88
|
+
*/
|
|
89
|
+
export declare function isCardinal(key: string): boolean;
|
|
90
|
+
/**
|
|
91
|
+
* ### isArrow
|
|
92
|
+
*
|
|
93
|
+
* Checks if the user has hit any arrow key
|
|
94
|
+
*
|
|
95
|
+
* @param key - the key to check, typically from event.key
|
|
96
|
+
* @returns true if key matches any arrow keys
|
|
97
|
+
*/
|
|
98
|
+
export declare function isArrow(key: string): boolean;
|
|
99
|
+
/**
|
|
100
|
+
* ### isWasd
|
|
101
|
+
*
|
|
102
|
+
* Checks if the user has hit any w a s d key
|
|
103
|
+
*
|
|
104
|
+
* @param key - the key to check, typically from event.key
|
|
105
|
+
* @returns true if key matches any w a s d
|
|
106
|
+
*/
|
|
107
|
+
export declare function isWasd(key: string): boolean;
|
|
108
|
+
/**
|
|
109
|
+
* ### isMovement
|
|
110
|
+
*
|
|
111
|
+
* Checks if the user has hit any movement key (w a s d and arrow keys)
|
|
112
|
+
*
|
|
113
|
+
* @param key - the key to check, typically from event.key
|
|
114
|
+
* @returns true if key matches any movement key w a s d and arrow keys
|
|
115
|
+
*/
|
|
116
|
+
export declare function isMovement(key: string): boolean;
|
package/dist/common/keys.js
CHANGED
|
@@ -1,8 +1,32 @@
|
|
|
1
|
-
var
|
|
2
|
-
function
|
|
3
|
-
return
|
|
1
|
+
var n = /* @__PURE__ */ ((r) => (r.A = "a", r.Alt = "Alt", r.Backspace = "Backspace", r.Control = "Control", r.D = "d", r.Delete = "Delete", r.Down = "ArrowDown", r.E = "e", r.End = "End", r.Enter = "Enter", r.Esc = "Esc", r.Escape = "Escape", r.Home = "Home", r.Insert = "Insert", r.Left = "ArrowLeft", r.N = "n", r.PageDown = "PageDown", r.PageUp = "PageUp", r.Right = "ArrowRight", r.S = "s", r.Shift = "Shift", r.Space = " ", r.Tab = "Tab", r.Up = "ArrowUp", r.W = "w", r.Z = "z", r))(n || {});
|
|
2
|
+
function e(r) {
|
|
3
|
+
return r === "Esc" || r === "Escape";
|
|
4
|
+
}
|
|
5
|
+
function a(r) {
|
|
6
|
+
return r >= "a" && r <= "z";
|
|
7
|
+
}
|
|
8
|
+
function i(r) {
|
|
9
|
+
return r >= "0" && r <= "9";
|
|
10
|
+
}
|
|
11
|
+
function s(r) {
|
|
12
|
+
return r === "n" || r === "s" || r === "w" || r === "e";
|
|
13
|
+
}
|
|
14
|
+
function t(r) {
|
|
15
|
+
return r === "ArrowUp" || r === "ArrowDown" || r === "ArrowLeft" || r === "ArrowRight";
|
|
16
|
+
}
|
|
17
|
+
function o(r) {
|
|
18
|
+
return r === "w" || r === "a" || r === "s" || r === "d";
|
|
19
|
+
}
|
|
20
|
+
function c(r) {
|
|
21
|
+
return o(r) || t(r);
|
|
4
22
|
}
|
|
5
23
|
export {
|
|
6
|
-
|
|
7
|
-
|
|
24
|
+
n as KEY,
|
|
25
|
+
a as isAlphabetic,
|
|
26
|
+
t as isArrow,
|
|
27
|
+
s as isCardinal,
|
|
28
|
+
e as isEscape,
|
|
29
|
+
c as isMovement,
|
|
30
|
+
i as isNumeric,
|
|
31
|
+
o as isWasd
|
|
8
32
|
};
|
package/dist/common/string.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function
|
|
1
|
+
function l(e, t = (r) => JSON.stringify(r)) {
|
|
2
2
|
const r = e.toLowerCase().trim();
|
|
3
3
|
return (n) => {
|
|
4
4
|
if (!r)
|
|
@@ -8,16 +8,16 @@ function p(e, t = (r) => JSON.stringify(r)) {
|
|
|
8
8
|
};
|
|
9
9
|
}
|
|
10
10
|
const a = ["a", "e", "i", "o", "u"];
|
|
11
|
-
function
|
|
11
|
+
function f(e, t, r) {
|
|
12
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();
|
|
16
16
|
}
|
|
17
|
-
function
|
|
17
|
+
function h(e) {
|
|
18
18
|
return e.replace(/(^\w{1})|(\s+\w{1})/g, (t) => t.toUpperCase());
|
|
19
19
|
}
|
|
20
|
-
function
|
|
20
|
+
function g(e) {
|
|
21
21
|
return e.replace(/^\w/, (t) => t.toUpperCase());
|
|
22
22
|
}
|
|
23
23
|
const i = ["Id", "Tv"], u = [
|
|
@@ -43,7 +43,7 @@ const i = ["Id", "Tv"], u = [
|
|
|
43
43
|
"To",
|
|
44
44
|
"With"
|
|
45
45
|
];
|
|
46
|
-
function
|
|
46
|
+
function d(e) {
|
|
47
47
|
if (!e) return e;
|
|
48
48
|
let t = e.replace(/([^\W_]+[^\s-]*) */g, (r) => c(r));
|
|
49
49
|
for (const r of u) {
|
|
@@ -56,20 +56,19 @@ function g(e) {
|
|
|
56
56
|
}
|
|
57
57
|
return t;
|
|
58
58
|
}
|
|
59
|
-
const s = {
|
|
59
|
+
const s = /&(nbsp|amp|quot|lt|gt|apos|trade|copy);/g, p = {
|
|
60
60
|
amp: "&",
|
|
61
61
|
apos: "'",
|
|
62
62
|
gt: ">",
|
|
63
63
|
lt: "<",
|
|
64
64
|
nbsp: " ",
|
|
65
|
-
quot: '"'
|
|
65
|
+
quot: '"',
|
|
66
|
+
trade: "™",
|
|
67
|
+
cops: "©"
|
|
66
68
|
};
|
|
67
|
-
function
|
|
69
|
+
function m(e) {
|
|
68
70
|
return e && e.replace(/<br>/gi, `
|
|
69
|
-
`).replace(/<\/?[a-z0-9-_]+[^>]*>/gi, "").replace(
|
|
70
|
-
/&(nbsp|amp|quot|lt|gt|apos);/g,
|
|
71
|
-
(t, r) => s[r]
|
|
72
|
-
).replace(/&#?([0-9]+);/gi, (t, r) => {
|
|
71
|
+
`).replace(/<\/?[a-z0-9-_]+[^>]*>/gi, "").replace(s, (t, r) => p[r]).replace(/&#?([0-9]+);/gi, (t, r) => {
|
|
73
72
|
const n = Number.parseInt(r, 10);
|
|
74
73
|
return String.fromCharCode(n);
|
|
75
74
|
}).replace(/&#x?([0-9a-f]+);/gi, (t, r) => {
|
|
@@ -80,10 +79,10 @@ function d(e) {
|
|
|
80
79
|
export {
|
|
81
80
|
a as VOWELS,
|
|
82
81
|
c as capitalize,
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
82
|
+
h as capitalizeAll,
|
|
83
|
+
g as capitalizeFirst,
|
|
84
|
+
l as createSearch,
|
|
85
|
+
m as decodeHtmlEntities,
|
|
86
|
+
f as pluralize,
|
|
87
|
+
d as toTitleCase
|
|
89
88
|
};
|
|
@@ -20,7 +20,7 @@ export type FlexProps = Partial<{
|
|
|
20
20
|
*/
|
|
21
21
|
direction: string;
|
|
22
22
|
/** Makes flexbox container inline, with similar behavior to an `inline` property on a `Box`. */
|
|
23
|
-
|
|
23
|
+
inlineFlex: boolean;
|
|
24
24
|
/**
|
|
25
25
|
* This defines the alignment along the main axis. It helps distribute extra free space leftover when either all the flex items on a line are
|
|
26
26
|
* inflexible, or are flexible but have reached their maximum size. It also exerts some control over the alignment of items when they overflow
|
package/dist/components/Flex.js
CHANGED
package/dist/components/Image.js
CHANGED
|
@@ -1,37 +1,38 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as c } from "react/jsx-runtime";
|
|
2
2
|
import { useRef as p } from "react";
|
|
3
|
-
import { computeBoxProps as
|
|
4
|
-
const
|
|
5
|
-
function
|
|
3
|
+
import { computeBoxProps as u } from "../common/ui.js";
|
|
4
|
+
const g = 5;
|
|
5
|
+
function C(o) {
|
|
6
6
|
const {
|
|
7
7
|
fixBlur: r = !0,
|
|
8
|
-
fixErrors:
|
|
8
|
+
fixErrors: m = !1,
|
|
9
9
|
objectFit: s = "fill",
|
|
10
|
-
src:
|
|
11
|
-
...
|
|
12
|
-
} =
|
|
10
|
+
src: A,
|
|
11
|
+
...n
|
|
12
|
+
} = o, t = p(0), e = u(n);
|
|
13
13
|
return e.style = {
|
|
14
14
|
...e.style,
|
|
15
15
|
"-ms-interpolation-mode": r ? "nearest-neighbor" : "auto",
|
|
16
16
|
imageRendering: r ? "pixelated" : "auto",
|
|
17
17
|
objectFit: s
|
|
18
|
-
}, /* @__PURE__ */
|
|
18
|
+
}, /* @__PURE__ */ c(
|
|
19
19
|
"img",
|
|
20
20
|
{
|
|
21
|
-
onError: (
|
|
22
|
-
if (
|
|
23
|
-
const
|
|
21
|
+
onError: (i) => {
|
|
22
|
+
if (m && t.current < g) {
|
|
23
|
+
const a = i.currentTarget;
|
|
24
24
|
setTimeout(() => {
|
|
25
|
-
|
|
25
|
+
a.src = `${A}?attempt=${t.current}`, t.current++;
|
|
26
26
|
}, 1e3);
|
|
27
27
|
}
|
|
28
28
|
},
|
|
29
|
-
src:
|
|
29
|
+
src: A || /** Use transparent base64 pixel if there is no src. So we don't get broken image icon when using assets */
|
|
30
|
+
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=",
|
|
30
31
|
...e,
|
|
31
32
|
alt: "dm icon"
|
|
32
33
|
}
|
|
33
34
|
);
|
|
34
35
|
}
|
|
35
36
|
export {
|
|
36
|
-
|
|
37
|
+
C as Image
|
|
37
38
|
};
|
|
@@ -6,6 +6,12 @@ import { Direction } from './DmIcon';
|
|
|
6
6
|
type Props = Partial<{
|
|
7
7
|
/** Asset cache. Example: `asset={['assetname32x32', thing.key]}` */
|
|
8
8
|
asset: string[];
|
|
9
|
+
/**
|
|
10
|
+
* Asset size. Used for asset scaling. Example: `assetSize={32}`
|
|
11
|
+
* With that, you can use `imageSize` to set asset image size in px.
|
|
12
|
+
* By default, it's 32px. So if you have 32x32 you don't need to touch it.
|
|
13
|
+
*/
|
|
14
|
+
assetSize: number;
|
|
9
15
|
/** Classic way to put images. Example: `base64={thing.image}` */
|
|
10
16
|
base64: string;
|
|
11
17
|
/**
|
|
@@ -1,148 +1,161 @@
|
|
|
1
1
|
import { jsxs as I, jsx as t } from "react/jsx-runtime";
|
|
2
|
-
import { classes as
|
|
3
|
-
import { computeBoxProps as
|
|
4
|
-
import { DmIcon as
|
|
5
|
-
import { Icon as
|
|
6
|
-
import { Image as
|
|
7
|
-
import { Stack as
|
|
8
|
-
import { Tooltip as
|
|
2
|
+
import { classes as c } from "../common/react.js";
|
|
3
|
+
import { computeBoxProps as A } from "../common/ui.js";
|
|
4
|
+
import { DmIcon as D } from "./DmIcon.js";
|
|
5
|
+
import { Icon as E } from "./Icon.js";
|
|
6
|
+
import { Image as y } from "./Image.js";
|
|
7
|
+
import { Stack as N } from "./Stack.js";
|
|
8
|
+
import { Tooltip as F } from "./Tooltip.js";
|
|
9
9
|
function W(d) {
|
|
10
10
|
const {
|
|
11
|
-
asset:
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
11
|
+
asset: m,
|
|
12
|
+
assetSize: u = 32,
|
|
13
|
+
base64: a,
|
|
14
|
+
buttons: p,
|
|
15
|
+
buttonsAlt: g,
|
|
16
|
+
children: s,
|
|
17
|
+
className: k,
|
|
18
|
+
color: e,
|
|
19
|
+
disabled: i,
|
|
20
|
+
dmFallback: v,
|
|
20
21
|
dmIcon: b,
|
|
21
22
|
dmIconState: x,
|
|
22
|
-
fluid:
|
|
23
|
+
fluid: o,
|
|
23
24
|
imageSize: n = 64,
|
|
24
|
-
imageSrc:
|
|
25
|
-
onClick:
|
|
25
|
+
imageSrc: B,
|
|
26
|
+
onClick: r,
|
|
26
27
|
onRightClick: f,
|
|
27
|
-
selected:
|
|
28
|
-
title:
|
|
28
|
+
selected: $,
|
|
29
|
+
title: C,
|
|
29
30
|
tooltip: _,
|
|
30
|
-
tooltipPosition:
|
|
31
|
-
...
|
|
31
|
+
tooltipPosition: S,
|
|
32
|
+
...z
|
|
32
33
|
} = d;
|
|
33
34
|
let h = /* @__PURE__ */ I(
|
|
34
35
|
"div",
|
|
35
36
|
{
|
|
36
|
-
className:
|
|
37
|
+
className: c([
|
|
37
38
|
"container",
|
|
38
|
-
|
|
39
|
-
!
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
o && (!!p || !!g) && "hasButtons",
|
|
40
|
+
!r && !f && "noAction",
|
|
41
|
+
$ && "ImageButton--selected",
|
|
42
|
+
i && "ImageButton--disabled",
|
|
43
|
+
e && typeof e == "string" ? `ImageButton--color__${e}` : "ImageButton--color__default"
|
|
43
44
|
]),
|
|
44
|
-
tabIndex:
|
|
45
|
-
onClick: (
|
|
46
|
-
!
|
|
45
|
+
tabIndex: i ? void 0 : 0,
|
|
46
|
+
onClick: (l) => {
|
|
47
|
+
!i && r && r(l);
|
|
47
48
|
},
|
|
48
|
-
onKeyDown: (
|
|
49
|
-
|
|
49
|
+
onKeyDown: (l) => {
|
|
50
|
+
l.key === "Enter" && !i && r && r(l);
|
|
50
51
|
},
|
|
51
|
-
onContextMenu: (
|
|
52
|
-
|
|
52
|
+
onContextMenu: (l) => {
|
|
53
|
+
l.preventDefault(), !i && f && f(l);
|
|
53
54
|
},
|
|
54
|
-
style: { width:
|
|
55
|
+
style: { width: o ? "auto" : `calc(${n}px + 0.5em + 2px)` },
|
|
55
56
|
children: [
|
|
56
|
-
/* @__PURE__ */ t("div", { className: "image", children:
|
|
57
|
-
|
|
57
|
+
/* @__PURE__ */ t("div", { className: "image", children: a || B ? /* @__PURE__ */ t(
|
|
58
|
+
y,
|
|
58
59
|
{
|
|
59
|
-
|
|
60
|
-
src: c ? `data:image/png;base64,${c}` : g,
|
|
60
|
+
src: a ? `data:image/png;base64,${a}` : B,
|
|
61
61
|
height: `${n}px`,
|
|
62
62
|
width: `${n}px`
|
|
63
63
|
}
|
|
64
64
|
) : b && x ? /* @__PURE__ */ t(
|
|
65
|
-
|
|
65
|
+
D,
|
|
66
66
|
{
|
|
67
67
|
icon: b,
|
|
68
68
|
icon_state: x,
|
|
69
|
-
fallback:
|
|
69
|
+
fallback: v || /* @__PURE__ */ t(w, { icon: "spinner", spin: !0, size: n }),
|
|
70
70
|
height: `${n}px`,
|
|
71
71
|
width: `${n}px`
|
|
72
72
|
}
|
|
73
|
-
) : /* @__PURE__ */ t(
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
73
|
+
) : m ? /* @__PURE__ */ t(
|
|
74
|
+
y,
|
|
75
|
+
{
|
|
76
|
+
className: c(m || []),
|
|
77
|
+
height: `${n}px`,
|
|
78
|
+
width: `${n}px`,
|
|
79
|
+
style: {
|
|
80
|
+
transform: `scale(${n / u})`,
|
|
81
|
+
transformOrigin: "top left"
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
) : /* @__PURE__ */ t(w, { icon: "question", size: n }) }),
|
|
85
|
+
o ? /* @__PURE__ */ I("div", { className: "info", children: [
|
|
86
|
+
C && /* @__PURE__ */ t("span", { className: c(["title", s && "divider"]), children: C }),
|
|
87
|
+
s && /* @__PURE__ */ t("span", { className: "contentFluid", children: s })
|
|
88
|
+
] }) : s && /* @__PURE__ */ t(
|
|
78
89
|
"span",
|
|
79
90
|
{
|
|
80
|
-
className:
|
|
91
|
+
className: c([
|
|
81
92
|
"content",
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
93
|
+
$ && "ImageButton--contentSelected",
|
|
94
|
+
i && "ImageButton--contentDisabled",
|
|
95
|
+
e && typeof e == "string" ? `ImageButton--contentColor__${e}` : "ImageButton--contentColor__default"
|
|
85
96
|
]),
|
|
86
|
-
children:
|
|
97
|
+
children: s
|
|
87
98
|
}
|
|
88
99
|
)
|
|
89
100
|
]
|
|
90
101
|
}
|
|
91
102
|
);
|
|
92
|
-
return _ && (h = /* @__PURE__ */ t(
|
|
103
|
+
return _ && (h = /* @__PURE__ */ t(F, { content: _, position: S, children: h })), /* @__PURE__ */ I(
|
|
93
104
|
"div",
|
|
94
105
|
{
|
|
95
|
-
className:
|
|
106
|
+
className: c([
|
|
96
107
|
"ImageButton",
|
|
97
|
-
|
|
98
|
-
|
|
108
|
+
o && "ImageButton--fluid",
|
|
109
|
+
k
|
|
99
110
|
]),
|
|
100
|
-
...
|
|
111
|
+
...A(z),
|
|
101
112
|
children: [
|
|
102
113
|
h,
|
|
103
|
-
|
|
114
|
+
p && /* @__PURE__ */ t(
|
|
104
115
|
"div",
|
|
105
116
|
{
|
|
106
|
-
className:
|
|
117
|
+
className: c([
|
|
107
118
|
"buttonsContainer",
|
|
108
|
-
!
|
|
109
|
-
|
|
119
|
+
!s && "buttonsEmpty",
|
|
120
|
+
o && i && "ImageButton--disabled",
|
|
121
|
+
o && e && typeof e == "string" ? `ImageButton--buttonsContainerColor__${e}` : o && "ImageButton--buttonsContainerColor__default"
|
|
110
122
|
]),
|
|
111
123
|
style: {
|
|
112
124
|
width: "auto"
|
|
113
125
|
},
|
|
114
|
-
children:
|
|
126
|
+
children: p
|
|
115
127
|
}
|
|
116
128
|
),
|
|
117
|
-
|
|
129
|
+
g && /* @__PURE__ */ t(
|
|
118
130
|
"div",
|
|
119
131
|
{
|
|
120
|
-
className:
|
|
132
|
+
className: c([
|
|
121
133
|
"buttonsContainer",
|
|
122
134
|
"buttonsAltContainer",
|
|
123
|
-
!
|
|
124
|
-
|
|
135
|
+
!s && "buttonsEmpty",
|
|
136
|
+
o && i && "ImageButton--disabled",
|
|
137
|
+
o && e && typeof e == "string" ? `ImageButton--buttonsContainerColor__${e}` : o && "ImageButton--buttonsContainerColor__default"
|
|
125
138
|
]),
|
|
126
139
|
style: {
|
|
127
|
-
width: `calc(${n}px + ${
|
|
128
|
-
maxWidth:
|
|
140
|
+
width: `calc(${n}px + ${o ? 0 : 0.5}em)`,
|
|
141
|
+
maxWidth: o ? "auto" : `calc(${n}px + 0.5em)`
|
|
129
142
|
},
|
|
130
|
-
children:
|
|
143
|
+
children: g
|
|
131
144
|
}
|
|
132
145
|
)
|
|
133
146
|
]
|
|
134
147
|
}
|
|
135
148
|
);
|
|
136
149
|
}
|
|
137
|
-
function
|
|
138
|
-
const { icon:
|
|
139
|
-
return /* @__PURE__ */ t(
|
|
140
|
-
|
|
150
|
+
function w(d) {
|
|
151
|
+
const { icon: m, spin: u = !1, size: a = 64 } = d;
|
|
152
|
+
return /* @__PURE__ */ t(N, { height: `${a}px`, width: `${a}px`, children: /* @__PURE__ */ t(N.Item, { grow: !0, textAlign: "center", align: "center", children: /* @__PURE__ */ t(
|
|
153
|
+
E,
|
|
141
154
|
{
|
|
142
|
-
spin:
|
|
143
|
-
name:
|
|
155
|
+
spin: u,
|
|
156
|
+
name: m,
|
|
144
157
|
color: "gray",
|
|
145
|
-
style: { fontSize: `calc(${
|
|
158
|
+
style: { fontSize: `calc(${a}px * 0.75)` }
|
|
146
159
|
}
|
|
147
160
|
) }) });
|
|
148
161
|
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Component, PropsWithChildren } from 'react';
|
|
2
|
+
import { BoxProps } from './Box';
|
|
3
|
+
export type InfinitePlaneProps = PropsWithChildren<{
|
|
4
|
+
onZoomChange?: (newZoomValue: number) => void;
|
|
5
|
+
onBackgroundMoved?: (newX: number, newY: number) => void;
|
|
6
|
+
initialLeft?: number;
|
|
7
|
+
initialTop?: number;
|
|
8
|
+
backgroundImage?: string;
|
|
9
|
+
imageWidth: number;
|
|
10
|
+
} & BoxProps>;
|
|
11
|
+
type InfinitePlaneState = {
|
|
12
|
+
mouseDown: boolean;
|
|
13
|
+
left: number;
|
|
14
|
+
top: number;
|
|
15
|
+
lastLeft: number;
|
|
16
|
+
lastTop: number;
|
|
17
|
+
zoom: number;
|
|
18
|
+
};
|
|
19
|
+
export type MouseEventExtension = {
|
|
20
|
+
screenZoomX: number;
|
|
21
|
+
screenZoomY: number;
|
|
22
|
+
};
|
|
23
|
+
export declare class InfinitePlane extends Component<InfinitePlaneProps, InfinitePlaneState> {
|
|
24
|
+
constructor(props: InfinitePlaneProps);
|
|
25
|
+
componentDidMount(): void;
|
|
26
|
+
componentWillUnmount(): void;
|
|
27
|
+
doOffsetMouse: (event: MouseEvent & MouseEventExtension) => void;
|
|
28
|
+
handleMouseDown: (event: React.MouseEvent<HTMLDivElement>) => void;
|
|
29
|
+
onMouseUp: () => void;
|
|
30
|
+
handleZoomIncrease: (_event: any) => void;
|
|
31
|
+
handleZoomDecrease: (_event: any) => void;
|
|
32
|
+
handleMouseMove: (event: React.MouseEvent<HTMLDivElement>) => void;
|
|
33
|
+
render(): import("react/jsx-runtime").JSX.Element;
|
|
34
|
+
}
|
|
35
|
+
export {};
|
|
@@ -1,20 +1,63 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
var x = Object.defineProperty;
|
|
2
|
+
var O = (a, s, o) => s in a ? x(a, s, { enumerable: !0, configurable: !0, writable: !0, value: o }) : a[s] = o;
|
|
3
|
+
var i = (a, s, o) => O(a, typeof s != "symbol" ? s + "" : s, o);
|
|
4
|
+
import { jsxs as c, jsx as r } from "react/jsx-runtime";
|
|
5
|
+
import { Component as Z } from "react";
|
|
6
|
+
import { computeBoxProps as D } from "../common/ui.js";
|
|
7
|
+
import { Button as w } from "./Button.js";
|
|
8
|
+
import { ProgressBar as E } from "./ProgressBar.js";
|
|
9
|
+
import { Stack as h } from "./Stack.js";
|
|
10
|
+
const M = 0.5, v = 1.5, g = 0.1;
|
|
11
|
+
class b extends Z {
|
|
12
|
+
constructor(o) {
|
|
13
|
+
super(o);
|
|
14
|
+
// This is really, REALLY cursed and basically overrides a built-in browser event via propagation rules
|
|
15
|
+
i(this, "doOffsetMouse", (o) => {
|
|
16
|
+
const { zoom: e } = this.state;
|
|
17
|
+
o.screenZoomX = o.screenX * e ** -1, o.screenZoomY = o.screenY * e ** -1;
|
|
18
|
+
});
|
|
19
|
+
i(this, "handleMouseDown", (o) => {
|
|
20
|
+
this.setState((e) => ({
|
|
21
|
+
mouseDown: !0,
|
|
22
|
+
lastLeft: o.clientX - e.left,
|
|
23
|
+
lastTop: o.clientY - e.top
|
|
24
|
+
}));
|
|
25
|
+
});
|
|
26
|
+
i(this, "onMouseUp", () => {
|
|
27
|
+
this.setState({
|
|
28
|
+
mouseDown: !1
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
i(this, "handleZoomIncrease", (o) => {
|
|
32
|
+
const { onZoomChange: e } = this.props, { zoom: n } = this.state, t = Math.min(n + g, v);
|
|
33
|
+
this.setState({
|
|
34
|
+
zoom: t
|
|
35
|
+
}), e && e(t);
|
|
36
|
+
});
|
|
37
|
+
i(this, "handleZoomDecrease", (o) => {
|
|
38
|
+
const { onZoomChange: e } = this.props, { zoom: n } = this.state, t = Math.max(n - g, M);
|
|
39
|
+
this.setState({
|
|
40
|
+
zoom: t
|
|
41
|
+
}), e && e(t);
|
|
42
|
+
});
|
|
43
|
+
i(this, "handleMouseMove", (o) => {
|
|
44
|
+
const { onBackgroundMoved: e, initialLeft: n = 0, initialTop: t = 0 } = this.props;
|
|
45
|
+
if (this.state.mouseDown) {
|
|
46
|
+
let l, m;
|
|
47
|
+
this.setState((d) => (l = o.clientX - d.lastLeft, m = o.clientY - d.lastTop, e && e(l + n, m + t), {
|
|
48
|
+
left: l,
|
|
49
|
+
top: m
|
|
50
|
+
}));
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
this.state = {
|
|
11
54
|
mouseDown: !1,
|
|
12
55
|
left: 0,
|
|
13
56
|
top: 0,
|
|
14
57
|
lastLeft: 0,
|
|
15
58
|
lastTop: 0,
|
|
16
59
|
zoom: 1
|
|
17
|
-
}
|
|
60
|
+
};
|
|
18
61
|
}
|
|
19
62
|
componentDidMount() {
|
|
20
63
|
window.addEventListener("mouseup", this.onMouseUp), window.addEventListener("mousedown", this.doOffsetMouse), window.addEventListener("mousemove", this.doOffsetMouse), window.addEventListener("mouseup", this.doOffsetMouse);
|
|
@@ -22,67 +65,28 @@ class k extends v {
|
|
|
22
65
|
componentWillUnmount() {
|
|
23
66
|
window.removeEventListener("mouseup", this.onMouseUp), window.removeEventListener("mousedown", this.doOffsetMouse), window.removeEventListener("mousemove", this.doOffsetMouse), window.removeEventListener("mouseup", this.doOffsetMouse);
|
|
24
67
|
}
|
|
25
|
-
doOffsetMouse(e) {
|
|
26
|
-
const { zoom: o } = this.state;
|
|
27
|
-
e.screenZoomX = e.screenX * o ** -1, e.screenZoomY = e.screenY * o ** -1;
|
|
28
|
-
}
|
|
29
|
-
handleMouseDown(e) {
|
|
30
|
-
this.setState((o) => ({
|
|
31
|
-
mouseDown: !0,
|
|
32
|
-
lastLeft: e.clientX - o.left,
|
|
33
|
-
lastTop: e.clientY - o.top
|
|
34
|
-
}));
|
|
35
|
-
}
|
|
36
|
-
onMouseUp() {
|
|
37
|
-
this.setState({
|
|
38
|
-
mouseDown: !1
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
handleZoomIncrease(e) {
|
|
42
|
-
const { onZoomChange: o } = this.props, { zoom: s } = this.state, t = Math.min(s + M, f);
|
|
43
|
-
this.setState({
|
|
44
|
-
zoom: t
|
|
45
|
-
}), o && o(t);
|
|
46
|
-
}
|
|
47
|
-
handleZoomDecrease(e) {
|
|
48
|
-
const { onZoomChange: o } = this.props, { zoom: s } = this.state, t = Math.max(s - M, p);
|
|
49
|
-
this.setState({
|
|
50
|
-
zoom: t
|
|
51
|
-
}), o && o(t);
|
|
52
|
-
}
|
|
53
|
-
handleMouseMove(e) {
|
|
54
|
-
const { onBackgroundMoved: o, initialLeft: s = 0, initialTop: t = 0 } = this.props;
|
|
55
|
-
if (this.state.mouseDown) {
|
|
56
|
-
let a, i;
|
|
57
|
-
this.setState((h) => (a = e.clientX - h.lastLeft, i = e.clientY - h.lastTop, {
|
|
58
|
-
left: a,
|
|
59
|
-
top: i
|
|
60
|
-
})), o && o(a + s, i + t);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
68
|
render() {
|
|
64
69
|
const {
|
|
65
|
-
children:
|
|
66
|
-
backgroundImage:
|
|
67
|
-
imageWidth:
|
|
70
|
+
children: o,
|
|
71
|
+
backgroundImage: e,
|
|
72
|
+
imageWidth: n,
|
|
68
73
|
initialLeft: t = 0,
|
|
69
|
-
initialTop:
|
|
70
|
-
...
|
|
71
|
-
} = this.props, { left:
|
|
72
|
-
return /* @__PURE__ */
|
|
74
|
+
initialTop: l = 0,
|
|
75
|
+
...m
|
|
76
|
+
} = this.props, { left: d, top: L, zoom: u } = this.state, p = t + d, f = l + L;
|
|
77
|
+
return /* @__PURE__ */ c(
|
|
73
78
|
"div",
|
|
74
79
|
{
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
...i,
|
|
80
|
+
...D({
|
|
81
|
+
...m,
|
|
78
82
|
style: {
|
|
79
|
-
...
|
|
83
|
+
...m.style,
|
|
80
84
|
overflow: "hidden",
|
|
81
85
|
position: "relative"
|
|
82
86
|
}
|
|
83
87
|
}),
|
|
84
88
|
children: [
|
|
85
|
-
/* @__PURE__ */
|
|
89
|
+
/* @__PURE__ */ r(
|
|
86
90
|
"div",
|
|
87
91
|
{
|
|
88
92
|
onMouseDown: this.handleMouseDown,
|
|
@@ -91,43 +95,43 @@ class k extends v {
|
|
|
91
95
|
position: "fixed",
|
|
92
96
|
height: "100%",
|
|
93
97
|
width: "100%",
|
|
94
|
-
backgroundImage: `url("${
|
|
95
|
-
backgroundPosition: `${
|
|
98
|
+
backgroundImage: `url("${e}")`,
|
|
99
|
+
backgroundPosition: `${p}px ${f}px`,
|
|
96
100
|
backgroundRepeat: "repeat",
|
|
97
|
-
backgroundSize: `${
|
|
101
|
+
backgroundSize: `${u * n}px`
|
|
98
102
|
}
|
|
99
103
|
}
|
|
100
104
|
),
|
|
101
|
-
/* @__PURE__ */
|
|
105
|
+
/* @__PURE__ */ r(
|
|
102
106
|
"div",
|
|
103
107
|
{
|
|
104
108
|
onMouseDown: this.handleMouseDown,
|
|
105
109
|
onMouseMove: this.handleMouseMove,
|
|
106
110
|
style: {
|
|
107
111
|
position: "fixed",
|
|
108
|
-
transform: `translate(${
|
|
112
|
+
transform: `translate(${p}px, ${f}px) scale(${u})`,
|
|
109
113
|
transformOrigin: "top left",
|
|
110
114
|
height: "100%",
|
|
111
115
|
width: "100%"
|
|
112
116
|
},
|
|
113
|
-
children:
|
|
117
|
+
children: o
|
|
114
118
|
}
|
|
115
119
|
),
|
|
116
|
-
/* @__PURE__ */
|
|
117
|
-
/* @__PURE__ */
|
|
118
|
-
/* @__PURE__ */
|
|
119
|
-
|
|
120
|
+
/* @__PURE__ */ c(h, { position: "absolute", width: "100%", children: [
|
|
121
|
+
/* @__PURE__ */ r(h.Item, { children: /* @__PURE__ */ r(w, { icon: "minus", onClick: this.handleZoomDecrease }) }),
|
|
122
|
+
/* @__PURE__ */ r(h.Item, { grow: 1, children: /* @__PURE__ */ c(
|
|
123
|
+
E,
|
|
120
124
|
{
|
|
121
|
-
minValue:
|
|
122
|
-
value:
|
|
123
|
-
maxValue:
|
|
125
|
+
minValue: M,
|
|
126
|
+
value: u,
|
|
127
|
+
maxValue: v,
|
|
124
128
|
children: [
|
|
125
|
-
|
|
129
|
+
u,
|
|
126
130
|
"x"
|
|
127
131
|
]
|
|
128
132
|
}
|
|
129
133
|
) }),
|
|
130
|
-
/* @__PURE__ */
|
|
134
|
+
/* @__PURE__ */ r(h.Item, { children: /* @__PURE__ */ r(w, { icon: "plus", onClick: this.handleZoomIncrease }) })
|
|
131
135
|
] })
|
|
132
136
|
]
|
|
133
137
|
}
|
|
@@ -135,5 +139,5 @@ class k extends v {
|
|
|
135
139
|
}
|
|
136
140
|
}
|
|
137
141
|
export {
|
|
138
|
-
|
|
142
|
+
b as InfinitePlane
|
|
139
143
|
};
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
+
import { KeyboardEvent } from 'react';
|
|
1
2
|
import { BoxProps } from './Box';
|
|
3
|
+
export type ModalProps = BoxProps & Partial<{
|
|
4
|
+
/** Fires once the enter key is pressed */
|
|
5
|
+
onEnter: (e: KeyboardEvent<HTMLInputElement>) => void;
|
|
6
|
+
/** Fires once the escape key is pressed */
|
|
7
|
+
onEscape: (e: KeyboardEvent<HTMLInputElement>) => void;
|
|
8
|
+
}>;
|
|
2
9
|
/**
|
|
3
10
|
* ## Modal
|
|
4
11
|
* A modal window. Uses a [Dimmer](https://github.com/tgstation/tgui-core/tree/main/lib/components/Dimmer.tsx)
|
|
@@ -6,4 +13,4 @@ import { BoxProps } from './Box';
|
|
|
6
13
|
*
|
|
7
14
|
* Must be a direct child of a layout component (e.g. `Window`).
|
|
8
15
|
*/
|
|
9
|
-
export declare function Modal(props:
|
|
16
|
+
export declare function Modal(props: ModalProps): import("react/jsx-runtime").JSX.Element;
|
package/dist/components/Modal.js
CHANGED
|
@@ -1,18 +1,22 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { jsx as i } from "react/jsx-runtime";
|
|
2
|
+
import { KEY as n, isEscape as f } from "../common/keys.js";
|
|
3
|
+
import { classes as l } from "../common/react.js";
|
|
4
|
+
import { computeBoxClassName as p, computeBoxProps as d } from "../common/ui.js";
|
|
5
|
+
import { Dimmer as u } from "./Dimmer.js";
|
|
6
|
+
function N(s) {
|
|
7
|
+
const { className: t, children: a, onEnter: r, onEscape: m, ...e } = s;
|
|
8
|
+
function c(o) {
|
|
9
|
+
o.key === n.Enter && (r == null || r(o)), f(o.key) && (m == null || m(o));
|
|
10
|
+
}
|
|
11
|
+
return /* @__PURE__ */ i(u, { onKeyDown: c, children: /* @__PURE__ */ i(
|
|
8
12
|
"div",
|
|
9
13
|
{
|
|
10
|
-
className:
|
|
11
|
-
...
|
|
12
|
-
children:
|
|
14
|
+
className: l(["Modal", t, p(e)]),
|
|
15
|
+
...d(e),
|
|
16
|
+
children: a
|
|
13
17
|
}
|
|
14
18
|
) });
|
|
15
19
|
}
|
|
16
20
|
export {
|
|
17
|
-
|
|
21
|
+
N as Modal
|
|
18
22
|
};
|
package/package.json
CHANGED
|
@@ -36,7 +36,7 @@ $bg-map: colors.$bg-map !default;
|
|
|
36
36
|
|
|
37
37
|
@if $hoverable {
|
|
38
38
|
&:hover {
|
|
39
|
-
background-color: rgba(lighten($color,
|
|
39
|
+
background-color: rgba(lighten($color, 66%), $opacity);
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
}
|
|
@@ -159,6 +159,12 @@ $bg-map: colors.$bg-map !default;
|
|
|
159
159
|
pointer-events: none;
|
|
160
160
|
top: 1px;
|
|
161
161
|
bottom: inherit !important;
|
|
162
|
+
/** Text outline. Sort of. */
|
|
163
|
+
text-shadow:
|
|
164
|
+
0px 0px 4px base.$color-bg,
|
|
165
|
+
0px 0px 4px base.$color-bg,
|
|
166
|
+
0px 0px 4px base.$color-bg,
|
|
167
|
+
0px 0px 4px base.$color-bg;
|
|
162
168
|
}
|
|
163
169
|
|
|
164
170
|
&.buttonsEmpty {
|
|
@@ -249,6 +255,7 @@ $bg-map: colors.$bg-map !default;
|
|
|
249
255
|
overflow: hidden;
|
|
250
256
|
pointer-events: auto;
|
|
251
257
|
top: inherit;
|
|
258
|
+
text-shadow: none;
|
|
252
259
|
|
|
253
260
|
& > * {
|
|
254
261
|
border-top: 1px solid rgba(255, 255, 255, 0.075);
|
|
@@ -6,7 +6,6 @@ $background-color: hsl(0, 0%, 0%) !default;
|
|
|
6
6
|
$border-radius: base.$border-radius !default;
|
|
7
7
|
|
|
8
8
|
.Tooltip {
|
|
9
|
-
z-index: 2;
|
|
10
9
|
padding: 0.5em 0.75em;
|
|
11
10
|
pointer-events: none;
|
|
12
11
|
text-align: left;
|
|
@@ -16,4 +15,6 @@ $border-radius: base.$border-radius !default;
|
|
|
16
15
|
box-shadow: 0.1em 0.1em 1.25em -0.1em rgba(0, 0, 0, 0.5);
|
|
17
16
|
border-radius: $border-radius;
|
|
18
17
|
max-width: base.em(250px);
|
|
18
|
+
// Must be over everything
|
|
19
|
+
z-index: 999;
|
|
19
20
|
}
|