tgui-core 1.3.2 → 1.5.1
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 +24 -2
- package/dist/common/ui.d.ts +113 -0
- package/dist/common/ui.js +137 -0
- package/dist/components/AnimatedNumber.d.ts +1 -0
- package/dist/components/BlockQuote.d.ts +5 -0
- package/dist/components/Box.d.ts +74 -63
- package/dist/components/Box.js +13 -127
- package/dist/components/Button.d.ts +22 -5
- package/dist/components/Button.js +2 -1
- package/dist/components/ByondUi.d.ts +50 -0
- package/dist/components/ByondUi.js +32 -44
- package/dist/components/ColorBox.js +1 -1
- package/dist/components/Dropdown.js +1 -1
- package/dist/components/Flex.js +1 -1
- package/dist/components/Icon.d.ts +1 -1
- package/dist/components/Icon.js +2 -2
- package/dist/components/Image.js +22 -21
- package/dist/components/ImageButton.js +1 -1
- package/dist/components/InfinitePlane.js +1 -1
- package/dist/components/Input.d.ts +6 -3
- package/dist/components/Input.js +60 -55
- package/dist/components/KeyListener.d.ts +2 -8
- package/dist/components/KeyListener.js +11 -19
- package/dist/components/Knob.js +1 -1
- package/dist/components/LabeledList.js +16 -15
- package/dist/components/Modal.js +1 -1
- package/dist/components/ProgressBar.js +1 -1
- package/dist/components/RoundGauge.d.ts +2 -1
- package/dist/components/RoundGauge.js +19 -18
- package/dist/components/Section.d.ts +43 -27
- package/dist/components/Section.js +64 -66
- package/dist/components/Slider.js +1 -1
- package/dist/components/Stack.js +1 -1
- package/dist/components/Table.js +1 -1
- package/dist/components/Tabs.js +1 -1
- package/dist/components/TextArea.d.ts +2 -1
- package/package.json +20 -12
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { BoxProps } from './Box';
|
|
2
|
+
type SampleByondParams = Partial<{
|
|
3
|
+
/** Can be auto-generated. */
|
|
4
|
+
id: string;
|
|
5
|
+
/** Defaults to the current window */
|
|
6
|
+
parent: string;
|
|
7
|
+
/** The type of control. Read-only. */
|
|
8
|
+
type: string;
|
|
9
|
+
/** Text shown in label/button/input. For input controls this setting is only available at runtime. */
|
|
10
|
+
text: string;
|
|
11
|
+
}>;
|
|
12
|
+
type Props = Partial<{
|
|
13
|
+
/** An object with parameters, which are directly passed to
|
|
14
|
+
* the `winset` proc call.
|
|
15
|
+
*
|
|
16
|
+
* You can find a full reference of these parameters
|
|
17
|
+
* in [BYOND controls and parameters guide](https://secure.byond.com/docs/ref/skinparams.html). */
|
|
18
|
+
params: SampleByondParams & Record<string, any>;
|
|
19
|
+
}> & BoxProps;
|
|
20
|
+
/**
|
|
21
|
+
* ## ByondUi
|
|
22
|
+
* Displays a BYOND UI element on top of the browser, and leverages browser's
|
|
23
|
+
* layout engine to position it just like any other HTML element. It is
|
|
24
|
+
* especially useful if you want to display a secondary game map in your
|
|
25
|
+
* interface.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```tsx
|
|
29
|
+
* <ByondUi
|
|
30
|
+
* params={{
|
|
31
|
+
* id: 'test_button', // optional, can be auto-generated
|
|
32
|
+
* parent: 'some_container', // optional, defaults to the current window
|
|
33
|
+
* type: 'button',
|
|
34
|
+
* text: 'Hello, world!',
|
|
35
|
+
* }} />
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```tsx
|
|
40
|
+
* <ByondUi
|
|
41
|
+
* params={{
|
|
42
|
+
* id: 'test_map',
|
|
43
|
+
* type: 'map',
|
|
44
|
+
* }} />
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* It supports a full set of `Box` properties for layout purposes.
|
|
48
|
+
*/
|
|
49
|
+
export declare function ByondUi(props: Props): import("react/jsx-runtime").JSX.Element;
|
|
50
|
+
export {};
|
|
@@ -1,19 +1,18 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import {
|
|
3
|
-
import { shallowDiffers as r } from "../common/react.js";
|
|
1
|
+
import { jsx as l } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as f, useEffect as p } from "react";
|
|
4
3
|
import { debounce as m } from "../common/timer.js";
|
|
5
|
-
import { computeBoxProps as
|
|
4
|
+
import { computeBoxProps as w } from "../common/ui.js";
|
|
6
5
|
const o = [];
|
|
7
|
-
function
|
|
8
|
-
const
|
|
6
|
+
function a(t) {
|
|
7
|
+
const e = o.length;
|
|
9
8
|
o.push(null);
|
|
10
|
-
const
|
|
9
|
+
const n = t || `byondui_${e}`;
|
|
11
10
|
return {
|
|
12
11
|
render: (i) => {
|
|
13
|
-
o[
|
|
12
|
+
o[e] = n, Byond.winset(n, i);
|
|
14
13
|
},
|
|
15
14
|
unmount: () => {
|
|
16
|
-
o[
|
|
15
|
+
o[e] = null, Byond.winset(n, {
|
|
17
16
|
parent: ""
|
|
18
17
|
});
|
|
19
18
|
}
|
|
@@ -21,53 +20,42 @@ function h(t) {
|
|
|
21
20
|
}
|
|
22
21
|
window.addEventListener("beforeunload", () => {
|
|
23
22
|
for (let t = 0; t < o.length; t++) {
|
|
24
|
-
const
|
|
25
|
-
typeof
|
|
23
|
+
const e = o[t];
|
|
24
|
+
typeof e == "string" && (o[t] = null, Byond.winset(e, {
|
|
26
25
|
parent: ""
|
|
27
26
|
}));
|
|
28
27
|
}
|
|
29
28
|
});
|
|
30
|
-
function
|
|
31
|
-
const
|
|
29
|
+
function x(t) {
|
|
30
|
+
const e = window.devicePixelRatio ?? 1, n = t.getBoundingClientRect();
|
|
32
31
|
return {
|
|
33
|
-
pos: [
|
|
32
|
+
pos: [n.left * e, n.top * e],
|
|
34
33
|
size: [
|
|
35
|
-
(
|
|
36
|
-
(
|
|
34
|
+
(n.right - n.left) * e,
|
|
35
|
+
(n.bottom - n.top) * e
|
|
37
36
|
]
|
|
38
37
|
};
|
|
39
38
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
shouldComponentUpdate(n) {
|
|
48
|
-
const { params: e = {}, ...i } = this.props, { params: d = {}, ...p } = n;
|
|
49
|
-
return r(e, d) || r(i, p);
|
|
50
|
-
}
|
|
51
|
-
componentDidMount() {
|
|
52
|
-
window.addEventListener("resize", this.handleResize), this.componentDidUpdate(), this.handleResize();
|
|
53
|
-
}
|
|
54
|
-
componentDidUpdate() {
|
|
55
|
-
const { params: n = {} } = this.props, e = u(this.containerRef.current);
|
|
56
|
-
this.byondUiElement.render({
|
|
39
|
+
function h(t) {
|
|
40
|
+
const { params: e, ...n } = t, i = f(null), d = f(a(e == null ? void 0 : e.id));
|
|
41
|
+
function s() {
|
|
42
|
+
const c = i.current;
|
|
43
|
+
if (!c) return;
|
|
44
|
+
const r = x(c);
|
|
45
|
+
d.current.render({
|
|
57
46
|
parent: Byond.windowId,
|
|
58
|
-
...
|
|
59
|
-
pos: `${
|
|
60
|
-
size: `${
|
|
47
|
+
...e,
|
|
48
|
+
pos: `${r.pos[0]},${r.pos[1]}`,
|
|
49
|
+
size: `${r.size[0]}x${r.size[1]}`
|
|
61
50
|
});
|
|
62
51
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
52
|
+
const u = m(() => {
|
|
53
|
+
s();
|
|
54
|
+
}, 100);
|
|
55
|
+
return p(() => (window.addEventListener("resize", u), s(), () => {
|
|
56
|
+
window.removeEventListener("resize", u), d.current.unmount();
|
|
57
|
+
}), []), /* @__PURE__ */ l("div", { ref: i, ...w(n), children: /* @__PURE__ */ l("div", { style: { minHeight: "22px" } }) });
|
|
70
58
|
}
|
|
71
59
|
export {
|
|
72
|
-
|
|
60
|
+
h as ByondUi
|
|
73
61
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as t } from "react/jsx-runtime";
|
|
2
2
|
import { classes as c } from "../common/react.js";
|
|
3
|
-
import { computeBoxClassName as s, computeBoxProps as m } from "
|
|
3
|
+
import { computeBoxClassName as s, computeBoxProps as m } from "../common/ui.js";
|
|
4
4
|
function d(r) {
|
|
5
5
|
const { content: l, children: a, className: e, ...o } = r;
|
|
6
6
|
return o.color = l ? null : "default", o.backgroundColor = r.color || "default", /* @__PURE__ */ t(
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as l, jsxs as p, Fragment as W } from "react/jsx-runtime";
|
|
2
2
|
import { useState as F, useRef as L, useEffect as S } from "react";
|
|
3
3
|
import { classes as N } from "../common/react.js";
|
|
4
|
-
import { unit as $ } from "
|
|
4
|
+
import { unit as $ } from "../common/ui.js";
|
|
5
5
|
import { Button as D } from "./Button.js";
|
|
6
6
|
import { Icon as b } from "./Icon.js";
|
|
7
7
|
import { Popper as q } from "./Popper.js";
|
package/dist/components/Flex.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as l } from "react/jsx-runtime";
|
|
2
2
|
import { classes as r } from "../common/react.js";
|
|
3
|
-
import { computeBoxClassName as m, computeBoxProps as a, unit as f } from "
|
|
3
|
+
import { computeBoxClassName as m, computeBoxProps as a, unit as f } from "../common/ui.js";
|
|
4
4
|
function p(e) {
|
|
5
5
|
return r([
|
|
6
6
|
"Flex",
|
|
@@ -15,7 +15,7 @@ type Props = {
|
|
|
15
15
|
spin: BooleanLike;
|
|
16
16
|
/** Custom CSS. */
|
|
17
17
|
style: CSSProperties;
|
|
18
|
-
}> & BoxProps
|
|
18
|
+
}> & Omit<BoxProps, 'children'>;
|
|
19
19
|
export declare function Icon(props: Props): import("react/jsx-runtime").JSX.Element;
|
|
20
20
|
export declare namespace Icon {
|
|
21
21
|
var Stack: typeof IconStack;
|
package/dist/components/Icon.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx as m } from "react/jsx-runtime";
|
|
2
2
|
import { classes as l } from "../common/react.js";
|
|
3
|
-
import { computeBoxProps as p, computeBoxClassName as u } from "
|
|
3
|
+
import { computeBoxProps as p, computeBoxClassName as u } from "../common/ui.js";
|
|
4
4
|
const f = /-o$/;
|
|
5
5
|
function d(c) {
|
|
6
|
-
const { name: s, size: o, spin: a, className: N, rotation: r, ...e } = c, n = e.style || {};
|
|
6
|
+
const { name: s = "", size: o, spin: a, className: N, rotation: r, ...e } = c, n = e.style || {};
|
|
7
7
|
o && (n.fontSize = `${o * 100}%`), r && (n.transform = `rotate(${r}deg)`), e.style = n;
|
|
8
8
|
const x = p(e);
|
|
9
9
|
let t = "";
|
package/dist/components/Image.js
CHANGED
|
@@ -1,32 +1,33 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useRef as
|
|
3
|
-
import { computeBoxProps as f } from "
|
|
1
|
+
import { jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as p } from "react";
|
|
3
|
+
import { computeBoxProps as f } from "../common/ui.js";
|
|
4
4
|
const l = 5;
|
|
5
|
-
function E(
|
|
5
|
+
function E(m) {
|
|
6
6
|
const {
|
|
7
|
-
fixBlur:
|
|
8
|
-
fixErrors:
|
|
9
|
-
objectFit:
|
|
10
|
-
src:
|
|
11
|
-
...
|
|
12
|
-
} =
|
|
13
|
-
return
|
|
14
|
-
...
|
|
15
|
-
"-ms-interpolation-mode":
|
|
16
|
-
|
|
17
|
-
|
|
7
|
+
fixBlur: r = !0,
|
|
8
|
+
fixErrors: n = !1,
|
|
9
|
+
objectFit: s = "fill",
|
|
10
|
+
src: o,
|
|
11
|
+
...i
|
|
12
|
+
} = m, t = p(0), e = f(i);
|
|
13
|
+
return e.style = {
|
|
14
|
+
...e.style,
|
|
15
|
+
"-ms-interpolation-mode": r ? "nearest-neighbor" : "auto",
|
|
16
|
+
imageRendering: r ? "pixelated" : "auto",
|
|
17
|
+
objectFit: s
|
|
18
|
+
}, /* @__PURE__ */ a(
|
|
18
19
|
"img",
|
|
19
20
|
{
|
|
20
|
-
onError: (
|
|
21
|
-
if (
|
|
22
|
-
const u =
|
|
21
|
+
onError: (c) => {
|
|
22
|
+
if (n && t.current < l) {
|
|
23
|
+
const u = c.currentTarget;
|
|
23
24
|
setTimeout(() => {
|
|
24
|
-
u.src = `${
|
|
25
|
+
u.src = `${o}?attempt=${t.current}`, t.current++;
|
|
25
26
|
}, 1e3);
|
|
26
27
|
}
|
|
27
28
|
},
|
|
28
|
-
src:
|
|
29
|
-
...
|
|
29
|
+
src: o,
|
|
30
|
+
...e,
|
|
30
31
|
alt: "dm icon"
|
|
31
32
|
}
|
|
32
33
|
);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsxs as g, jsx as t } from "react/jsx-runtime";
|
|
2
2
|
import { classes as l } from "../common/react.js";
|
|
3
|
-
import { computeBoxProps as A } from "
|
|
3
|
+
import { computeBoxProps as A } from "../common/ui.js";
|
|
4
4
|
import { DmIcon as D } from "./DmIcon.js";
|
|
5
5
|
import { Icon as F } from "./Icon.js";
|
|
6
6
|
import { Image as j } from "./Image.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsxs as l, jsx as n } from "react/jsx-runtime";
|
|
2
2
|
import { Component as v } from "react";
|
|
3
|
-
import { computeBoxProps as Z } from "
|
|
3
|
+
import { computeBoxProps as Z } from "../common/ui.js";
|
|
4
4
|
import { Button as c } from "./Button.js";
|
|
5
5
|
import { ProgressBar as g } from "./ProgressBar.js";
|
|
6
6
|
import { Stack as d } from "./Stack.js";
|
|
@@ -38,18 +38,21 @@ type OptionalProps = Partial<{
|
|
|
38
38
|
/** Fires when user is 'done typing': Clicked out, blur, enter key */
|
|
39
39
|
onChange: (event: SyntheticEvent<HTMLInputElement>, value: string) => void;
|
|
40
40
|
/** Fires once the enter key is pressed */
|
|
41
|
-
onEnter
|
|
41
|
+
onEnter: (event: SyntheticEvent<HTMLInputElement>, value: string) => void;
|
|
42
42
|
/** Fires once the escape key is pressed */
|
|
43
43
|
onEscape: (event: SyntheticEvent<HTMLInputElement>) => void;
|
|
44
44
|
/** The placeholder text when everything is cleared */
|
|
45
45
|
placeholder: string;
|
|
46
46
|
/** Clears the input value on enter */
|
|
47
47
|
selfClear: boolean;
|
|
48
|
+
/** Auto-updates the input value on props change, ie, data from Byond */
|
|
49
|
+
updateOnPropsChange: boolean;
|
|
48
50
|
/** The state variable of the input. */
|
|
49
51
|
value: string | number;
|
|
50
52
|
}>;
|
|
51
|
-
type Props = OptionalProps & ConditionalProps & BoxProps
|
|
52
|
-
|
|
53
|
+
type Props = OptionalProps & ConditionalProps & Omit<BoxProps, 'children'>;
|
|
54
|
+
type InputValue = string | number | undefined;
|
|
55
|
+
export declare function toInputValue(value: InputValue): string;
|
|
53
56
|
/**
|
|
54
57
|
* ### Input
|
|
55
58
|
* A basic text input which allow users to enter text into a UI.
|
package/dist/components/Input.js
CHANGED
|
@@ -1,81 +1,86 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useRef as
|
|
3
|
-
import { KEY as
|
|
4
|
-
import { classes as
|
|
5
|
-
import { debounce as
|
|
1
|
+
import { jsxs as j, jsx as p } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as k, useEffect as m } from "react";
|
|
3
|
+
import { KEY as w, isEscape as B } from "../common/keys.js";
|
|
4
|
+
import { classes as F } from "../common/react.js";
|
|
5
|
+
import { debounce as O } from "../common/timer.js";
|
|
6
6
|
import { Box as R } from "./Box.js";
|
|
7
|
-
function
|
|
8
|
-
return typeof
|
|
7
|
+
function d(r) {
|
|
8
|
+
return typeof r != "number" && typeof r != "string" ? "" : String(r);
|
|
9
9
|
}
|
|
10
|
-
const
|
|
11
|
-
function
|
|
10
|
+
const V = O((r) => r(), 250);
|
|
11
|
+
function C(r) {
|
|
12
12
|
const {
|
|
13
|
-
autoFocus:
|
|
14
|
-
autoSelect:
|
|
15
|
-
className:
|
|
16
|
-
disabled:
|
|
17
|
-
expensive:
|
|
18
|
-
fluid:
|
|
13
|
+
autoFocus: g,
|
|
14
|
+
autoSelect: l,
|
|
15
|
+
className: I,
|
|
16
|
+
disabled: T,
|
|
17
|
+
expensive: b,
|
|
18
|
+
fluid: h,
|
|
19
19
|
maxLength: x,
|
|
20
20
|
monospace: y,
|
|
21
|
-
onChange:
|
|
22
|
-
onEnter:
|
|
23
|
-
onEscape:
|
|
21
|
+
onChange: n,
|
|
22
|
+
onEnter: c,
|
|
23
|
+
onEscape: s,
|
|
24
24
|
onInput: i,
|
|
25
|
-
placeholder:
|
|
26
|
-
selfClear:
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
25
|
+
placeholder: N,
|
|
26
|
+
selfClear: _,
|
|
27
|
+
updateOnPropsChange: D,
|
|
28
|
+
value: o,
|
|
29
|
+
...E
|
|
30
|
+
} = r, a = k(null);
|
|
31
|
+
function K(t) {
|
|
32
|
+
var u;
|
|
32
33
|
if (!i) return;
|
|
33
|
-
const
|
|
34
|
-
|
|
34
|
+
const e = (u = t.currentTarget) == null ? void 0 : u.value;
|
|
35
|
+
b ? V(() => i(t, e)) : i(t, e);
|
|
35
36
|
}
|
|
36
|
-
function
|
|
37
|
-
if (
|
|
38
|
-
|
|
37
|
+
function S(t) {
|
|
38
|
+
if (t.key === w.Enter) {
|
|
39
|
+
c == null || c(t, t.currentTarget.value), _ ? t.currentTarget.value = "" : (t.currentTarget.blur(), n == null || n(t, t.currentTarget.value));
|
|
39
40
|
return;
|
|
40
41
|
}
|
|
41
|
-
|
|
42
|
+
B(t.key) && (s == null || s(t), t.currentTarget.value = d(o), t.currentTarget.blur());
|
|
42
43
|
}
|
|
43
|
-
|
|
44
|
-
const e =
|
|
44
|
+
function f(t) {
|
|
45
|
+
const e = a.current;
|
|
45
46
|
if (!e) return;
|
|
46
|
-
const
|
|
47
|
-
e.value !==
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
const u = d(t);
|
|
48
|
+
e.value !== u && (e.value = u);
|
|
49
|
+
}
|
|
50
|
+
return m(() => {
|
|
51
|
+
const t = a.current;
|
|
52
|
+
if (t) {
|
|
53
|
+
f(o);
|
|
54
|
+
const e = g || l, u = document.activeElement === t;
|
|
55
|
+
e && !u && setTimeout(() => {
|
|
56
|
+
t.focus(), l && t.select();
|
|
57
|
+
}, 1);
|
|
58
|
+
}
|
|
50
59
|
}, []), m(() => {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return;
|
|
54
|
-
const r = l(a);
|
|
55
|
-
e.value !== r && (e.value = r);
|
|
56
|
-
}), /* @__PURE__ */ E(
|
|
60
|
+
D && f(o);
|
|
61
|
+
}, [o]), /* @__PURE__ */ j(
|
|
57
62
|
R,
|
|
58
63
|
{
|
|
59
|
-
className:
|
|
64
|
+
className: F([
|
|
60
65
|
"Input",
|
|
61
|
-
|
|
66
|
+
h && "Input--fluid",
|
|
62
67
|
y && "Input--monospace",
|
|
63
|
-
|
|
68
|
+
I
|
|
64
69
|
]),
|
|
65
|
-
...
|
|
70
|
+
...E,
|
|
66
71
|
children: [
|
|
67
72
|
/* @__PURE__ */ p("div", { className: "Input__baseline", children: "." }),
|
|
68
73
|
/* @__PURE__ */ p(
|
|
69
74
|
"input",
|
|
70
75
|
{
|
|
71
76
|
className: "Input__input",
|
|
72
|
-
disabled:
|
|
77
|
+
disabled: T,
|
|
73
78
|
maxLength: x,
|
|
74
|
-
onBlur: (
|
|
75
|
-
onChange:
|
|
76
|
-
onKeyDown:
|
|
77
|
-
placeholder:
|
|
78
|
-
ref:
|
|
79
|
+
onBlur: (t) => n == null ? void 0 : n(t, t.target.value),
|
|
80
|
+
onChange: K,
|
|
81
|
+
onKeyDown: S,
|
|
82
|
+
placeholder: N,
|
|
83
|
+
ref: a
|
|
79
84
|
}
|
|
80
85
|
)
|
|
81
86
|
]
|
|
@@ -83,6 +88,6 @@ function A(u) {
|
|
|
83
88
|
);
|
|
84
89
|
}
|
|
85
90
|
export {
|
|
86
|
-
|
|
87
|
-
|
|
91
|
+
C as Input,
|
|
92
|
+
d as toInputValue
|
|
88
93
|
};
|
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
import { Component } from 'react';
|
|
2
1
|
import { KeyEvent } from '../common/events';
|
|
3
|
-
type
|
|
2
|
+
type Props = Partial<{
|
|
4
3
|
onKey: (key: KeyEvent) => void;
|
|
5
4
|
onKeyDown: (key: KeyEvent) => void;
|
|
6
5
|
onKeyUp: (key: KeyEvent) => void;
|
|
7
6
|
}>;
|
|
8
|
-
export declare
|
|
9
|
-
dispose: () => void;
|
|
10
|
-
constructor(props: any);
|
|
11
|
-
componentWillUnmount(): void;
|
|
12
|
-
render(): null;
|
|
13
|
-
}
|
|
7
|
+
export declare function KeyListener(props: Props): null;
|
|
14
8
|
export {};
|
|
@@ -1,23 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
constructor(p) {
|
|
8
|
-
super(p);
|
|
9
|
-
i(this, "dispose");
|
|
10
|
-
this.dispose = h((n) => {
|
|
11
|
-
this.props.onKey && this.props.onKey(n), n.isDown() && this.props.onKeyDown && this.props.onKeyDown(n), n.isUp() && this.props.onKeyUp && this.props.onKeyUp(n);
|
|
1
|
+
import { useEffect as i } from "react";
|
|
2
|
+
import { listenForKeyEvents as t } from "../common/hotkeys.js";
|
|
3
|
+
function r(n) {
|
|
4
|
+
return i(() => {
|
|
5
|
+
const o = t((e) => {
|
|
6
|
+
n.onKey && n.onKey(e), e.isDown() && n.onKeyDown && n.onKeyDown(e), e.isUp() && n.onKeyUp && n.onKeyUp(e);
|
|
12
7
|
});
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
render() {
|
|
18
|
-
return null;
|
|
19
|
-
}
|
|
8
|
+
return () => {
|
|
9
|
+
o();
|
|
10
|
+
};
|
|
11
|
+
}, []), null;
|
|
20
12
|
}
|
|
21
13
|
export {
|
|
22
|
-
|
|
14
|
+
r as KeyListener
|
|
23
15
|
};
|
package/dist/components/Knob.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as e, jsxs as o } from "react/jsx-runtime";
|
|
2
2
|
import { keyOfMatchingRange as $, scale as t } from "../common/math.js";
|
|
3
3
|
import { classes as j } from "../common/react.js";
|
|
4
|
-
import { computeBoxClassName as E, computeBoxProps as T } from "
|
|
4
|
+
import { computeBoxClassName as E, computeBoxProps as T } from "../common/ui.js";
|
|
5
5
|
import { DraggableControl as I } from "./DraggableControl.js";
|
|
6
6
|
function H(c) {
|
|
7
7
|
const {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx as e, jsxs as d } from "react/jsx-runtime";
|
|
2
2
|
import { classes as c } from "../common/react.js";
|
|
3
|
-
import {
|
|
3
|
+
import { unit as g } from "../common/ui.js";
|
|
4
|
+
import { Box as r } from "./Box.js";
|
|
4
5
|
import { Divider as x } from "./Divider.js";
|
|
5
6
|
import { Tooltip as N } from "./Tooltip.js";
|
|
6
7
|
function b(l) {
|
|
@@ -11,19 +12,19 @@ function v(l) {
|
|
|
11
12
|
const {
|
|
12
13
|
className: t,
|
|
13
14
|
label: a,
|
|
14
|
-
labelColor:
|
|
15
|
-
labelWrap:
|
|
15
|
+
labelColor: m = "label",
|
|
16
|
+
labelWrap: L,
|
|
16
17
|
color: p,
|
|
17
18
|
textAlign: _,
|
|
18
19
|
buttons: o,
|
|
19
|
-
content:
|
|
20
|
-
children:
|
|
21
|
-
verticalAlign:
|
|
20
|
+
content: f,
|
|
21
|
+
children: h,
|
|
22
|
+
verticalAlign: s = "baseline",
|
|
22
23
|
tooltip: n
|
|
23
24
|
} = l;
|
|
24
25
|
let i;
|
|
25
26
|
a && (i = a, typeof a == "string" && (i += ":")), n !== void 0 && (i = /* @__PURE__ */ e(N, { content: n, children: /* @__PURE__ */ e(
|
|
26
|
-
|
|
27
|
+
r,
|
|
27
28
|
{
|
|
28
29
|
as: "span",
|
|
29
30
|
style: {
|
|
@@ -33,33 +34,33 @@ function v(l) {
|
|
|
33
34
|
}
|
|
34
35
|
) }));
|
|
35
36
|
const u = /* @__PURE__ */ e(
|
|
36
|
-
|
|
37
|
+
r,
|
|
37
38
|
{
|
|
38
39
|
as: "td",
|
|
39
|
-
color:
|
|
40
|
+
color: m,
|
|
40
41
|
className: c([
|
|
41
42
|
"LabeledList__cell",
|
|
42
43
|
// Kinda flipped because we want nowrap as default. Cleaner CSS this way though.
|
|
43
|
-
!
|
|
44
|
+
!L && "LabeledList__label--nowrap"
|
|
44
45
|
]),
|
|
45
|
-
verticalAlign:
|
|
46
|
+
verticalAlign: s,
|
|
46
47
|
children: i
|
|
47
48
|
}
|
|
48
49
|
);
|
|
49
50
|
return /* @__PURE__ */ d("tr", { className: c(["LabeledList__row", t]), children: [
|
|
50
51
|
u,
|
|
51
52
|
/* @__PURE__ */ d(
|
|
52
|
-
|
|
53
|
+
r,
|
|
53
54
|
{
|
|
54
55
|
as: "td",
|
|
55
56
|
color: p,
|
|
56
57
|
textAlign: _,
|
|
57
58
|
className: "LabeledList__cell",
|
|
58
59
|
colSpan: o ? void 0 : 2,
|
|
59
|
-
verticalAlign:
|
|
60
|
+
verticalAlign: s,
|
|
60
61
|
children: [
|
|
61
|
-
|
|
62
|
-
|
|
62
|
+
f,
|
|
63
|
+
h
|
|
63
64
|
]
|
|
64
65
|
}
|
|
65
66
|
),
|
package/dist/components/Modal.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as r } from "react/jsx-runtime";
|
|
2
2
|
import { classes as t } from "../common/react.js";
|
|
3
|
-
import { computeBoxClassName as a, computeBoxProps as c } from "
|
|
3
|
+
import { computeBoxClassName as a, computeBoxProps as c } from "../common/ui.js";
|
|
4
4
|
import { Dimmer as i } from "./Dimmer.js";
|
|
5
5
|
function f(m) {
|
|
6
6
|
const { className: s, children: e, ...o } = m;
|
|
@@ -2,7 +2,7 @@ import { jsxs as B, jsx as i } from "react/jsx-runtime";
|
|
|
2
2
|
import { CSS_COLORS as C } from "../common/constants.js";
|
|
3
3
|
import { keyOfMatchingRange as P, toFixed as h, scale as x, clamp01 as _ } from "../common/math.js";
|
|
4
4
|
import { classes as v } from "../common/react.js";
|
|
5
|
-
import { computeBoxProps as y, computeBoxClassName as N } from "
|
|
5
|
+
import { computeBoxProps as y, computeBoxClassName as N } from "../common/ui.js";
|
|
6
6
|
function j(n) {
|
|
7
7
|
const {
|
|
8
8
|
className: m,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
1
2
|
import { BoxProps } from './Box';
|
|
2
3
|
type Props = {
|
|
3
4
|
/** The current value of the metric. */
|
|
@@ -20,7 +21,7 @@ type Props = {
|
|
|
20
21
|
/** When provided scales the gauge. */
|
|
21
22
|
size: number;
|
|
22
23
|
/** Custom css */
|
|
23
|
-
style:
|
|
24
|
+
style: CSSProperties;
|
|
24
25
|
}> & BoxProps;
|
|
25
26
|
/**
|
|
26
27
|
* ## RoundGauge
|