tgui-core 3.1.4 → 3.2.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 +6 -0
- package/dist/common/color.js +1 -1
- package/dist/common/constants.d.ts +42 -42
- package/dist/common/constants.js +1 -1
- package/dist/common/fp.d.ts +2 -1
- package/dist/common/fuzzysearch.d.ts +22 -0
- package/dist/common/fuzzysearch.js +1 -0
- package/dist/common/hotkeys.d.ts +2 -0
- package/dist/common/hotkeys.js +1 -1
- package/dist/common/string.d.ts +14 -7
- package/dist/common/string.js +1 -1
- package/dist/common/type-utils.d.ts +2 -1
- package/dist/common/ui.d.ts +1 -1
- package/dist/common/ui.js +1 -1
- package/dist/common/uuid.d.ts +2 -1
- package/dist/components/AnimatedNumber.d.ts +3 -0
- package/dist/components/Autofocus.d.ts +5 -1
- package/dist/components/Blink.d.ts +7 -0
- package/dist/components/BlockQuote.d.ts +3 -0
- package/dist/components/Box.d.ts +21 -16
- package/dist/components/Button.d.ts +3 -0
- package/dist/components/Button.js +1 -1
- package/dist/components/ByondUi.d.ts +5 -2
- package/dist/components/Chart.js +1 -1
- package/dist/components/Collapsible.d.ts +3 -0
- package/dist/components/Collapsible.js +1 -1
- package/dist/components/ColorBox.d.ts +3 -0
- package/dist/components/Dialog.d.ts +5 -1
- package/dist/components/Dialog.js +1 -1
- package/dist/components/Dimmer.d.ts +3 -0
- package/dist/components/Divider.d.ts +3 -0
- package/dist/components/DmIcon.d.ts +1 -0
- package/dist/components/DraggableControl.js +1 -1
- package/dist/components/Dropdown.d.ts +3 -0
- package/dist/components/Dropdown.js +1 -1
- package/dist/components/Flex.d.ts +5 -1
- package/dist/components/Flex.js +1 -1
- package/dist/components/Floating.d.ts +1 -0
- package/dist/components/Floating.js +1 -1
- package/dist/components/Icon.d.ts +10 -3
- package/dist/components/Image.d.ts +1 -0
- package/dist/components/ImageButton.d.ts +4 -0
- package/dist/components/ImageButton.js +1 -1
- package/dist/components/InfinitePlane.d.ts +5 -1
- package/dist/components/InfinitePlane.js +1 -1
- package/dist/components/Input.d.ts +5 -5
- package/dist/components/Input.js +1 -1
- package/dist/components/KeyListener.d.ts +3 -0
- package/dist/components/Knob.d.ts +3 -0
- package/dist/components/Knob.js +1 -1
- package/dist/components/LabeledControls.d.ts +6 -2
- package/dist/components/LabeledControls.js +1 -1
- package/dist/components/LabeledList.d.ts +7 -2
- package/dist/components/LabeledList.js +1 -1
- package/dist/components/MenuBar.js +1 -1
- package/dist/components/Modal.d.ts +7 -2
- package/dist/components/NoticeBox.d.ts +3 -0
- package/dist/components/NumberInput.d.ts +3 -0
- package/dist/components/NumberInput.js +1 -1
- package/dist/components/Popper.d.ts +3 -0
- package/dist/components/Popper.js +1 -1
- package/dist/components/ProgressBar.d.ts +3 -0
- package/dist/components/RestrictedInput.d.ts +2 -2
- package/dist/components/RestrictedInput.js +1 -1
- package/dist/components/RoundGauge.d.ts +4 -1
- package/dist/components/RoundGauge.js +1 -1
- package/dist/components/Section.d.ts +7 -0
- package/dist/components/Section.js +1 -1
- package/dist/components/Slider.d.ts +5 -1
- package/dist/components/Slider.js +1 -1
- package/dist/components/Stack.d.ts +8 -3
- package/dist/components/Table.d.ts +5 -1
- package/dist/components/Tabs.d.ts +12 -6
- package/dist/components/TextArea.d.ts +2 -2
- package/dist/components/TextArea.js +1 -1
- package/dist/components/TimeDisplay.d.ts +7 -0
- package/dist/components/Tooltip.d.ts +16 -0
- package/dist/components/Tooltip.js +1 -1
- package/dist/components/VirtualList.d.ts +4 -0
- package/package.json +48 -39
package/README.md
CHANGED
|
@@ -74,3 +74,9 @@ This project uses [pnpm](https://pnpm.io/installation) for its package manager.
|
|
|
74
74
|
|
|
75
75
|
To set up the repository:
|
|
76
76
|
`pnpm install`
|
|
77
|
+
|
|
78
|
+
To test your changes using [Storybook](https://storybook.js.org/docs) run:
|
|
79
|
+
`pnpm run storybook`
|
|
80
|
+
|
|
81
|
+
To run unit tests run
|
|
82
|
+
`pnpm test`
|
package/dist/common/color.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
class
|
|
1
|
+
class r{r;g;b;a;constructor(r=0,t=0,e=0,s=1){this.r=r,this.g=t,this.b=e,this.a=s}toString(){let r=this.a;return"string"==typeof r&&(r=Number.parseFloat(this.a)),Number.isNaN(r)&&(r=1),`rgba(${0|this.r}, ${0|this.g}, ${0|this.b}, ${r})`}darken(t){let e=t/100;return new r(this.r-this.r*e,this.g-this.g*e,this.b-this.b*e,this.a)}lighten(r){return this.darken(-r)}static fromHex(t){if(7===t.length)return new r(Number.parseInt(t.slice(1,3),16),Number.parseInt(t.slice(3,5),16),Number.parseInt(t.slice(5,7),16));if(9===t.length)return new r(Number.parseInt(t.slice(1,3),16),Number.parseInt(t.slice(3,5),16),Number.parseInt(t.slice(5,7),16),Number.parseInt(t.slice(7,9),16)/256);throw Error("Invalid hex color format. Expected #RRGGBB or #RRGGBBAA.")}static lerp(t,e,s){return new r((e.r-t.r)*s+t.r,(e.g-t.g)*s+t.g,(e.b-t.b)*s+t.b,(e.a-t.a)*s+t.a)}static lookup(t,e){let s=e.length;if(s<2)throw Error("Needs at least two colors!");let i=t*(s-1);if(t<1e-4)return e[0];if(t>=.9999)return e[s-1];let n=0|i;return r.lerp(e[n],e[n+1],i%1)}}export{r as Color};
|
|
@@ -10,22 +10,22 @@ export declare const UI_UPDATE = 1;
|
|
|
10
10
|
export declare const UI_DISABLED = 0;
|
|
11
11
|
export declare const UI_CLOSE = -1;
|
|
12
12
|
export declare const COLORS: {
|
|
13
|
+
readonly damageType: {
|
|
14
|
+
readonly brute: "#e74c3c";
|
|
15
|
+
readonly burn: "#e67e22";
|
|
16
|
+
readonly oxy: "#3498db";
|
|
17
|
+
readonly toxin: "#2ecc71";
|
|
18
|
+
};
|
|
13
19
|
readonly department: {
|
|
14
20
|
readonly captain: "#c06616";
|
|
15
|
-
readonly security: "#e74c3c";
|
|
16
|
-
readonly medbay: "#3498db";
|
|
17
|
-
readonly science: "#9b59b6";
|
|
18
|
-
readonly engineering: "#f1c40f";
|
|
19
21
|
readonly cargo: "#f39c12";
|
|
20
|
-
readonly service: "#7cc46a";
|
|
21
22
|
readonly centcom: "#00c100";
|
|
23
|
+
readonly engineering: "#f1c40f";
|
|
24
|
+
readonly medbay: "#3498db";
|
|
22
25
|
readonly other: "#c38312";
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
readonly
|
|
26
|
-
readonly toxin: "#2ecc71";
|
|
27
|
-
readonly burn: "#e67e22";
|
|
28
|
-
readonly brute: "#e74c3c";
|
|
26
|
+
readonly science: "#9b59b6";
|
|
27
|
+
readonly security: "#e74c3c";
|
|
28
|
+
readonly service: "#7cc46a";
|
|
29
29
|
};
|
|
30
30
|
readonly reagent: {
|
|
31
31
|
readonly acidicbuffer: "#fbc314";
|
|
@@ -35,72 +35,72 @@ export declare const COLORS: {
|
|
|
35
35
|
export declare const CSS_COLORS: readonly ["average", "bad", "black", "blue", "brown", "good", "green", "grey", "label", "olive", "orange", "pink", "purple", "red", "teal", "transparent", "violet", "white", "yellow"];
|
|
36
36
|
export type CssColor = (typeof CSS_COLORS)[number];
|
|
37
37
|
export declare const RADIO_CHANNELS: readonly [{
|
|
38
|
-
readonly name: "Syndicate";
|
|
39
|
-
readonly freq: 1213;
|
|
40
38
|
readonly color: "#8f4a4b";
|
|
39
|
+
readonly freq: 1213;
|
|
40
|
+
readonly name: "Syndicate";
|
|
41
41
|
}, {
|
|
42
|
-
readonly name: "Red Team";
|
|
43
|
-
readonly freq: 1215;
|
|
44
42
|
readonly color: "#ff4444";
|
|
43
|
+
readonly freq: 1215;
|
|
44
|
+
readonly name: "Red Team";
|
|
45
45
|
}, {
|
|
46
|
-
readonly name: "Blue Team";
|
|
47
|
-
readonly freq: 1217;
|
|
48
46
|
readonly color: "#3434fd";
|
|
47
|
+
readonly freq: 1217;
|
|
48
|
+
readonly name: "Blue Team";
|
|
49
49
|
}, {
|
|
50
|
-
readonly name: "Green Team";
|
|
51
|
-
readonly freq: 1219;
|
|
52
50
|
readonly color: "#34fd34";
|
|
51
|
+
readonly freq: 1219;
|
|
52
|
+
readonly name: "Green Team";
|
|
53
53
|
}, {
|
|
54
|
-
readonly name: "Yellow Team";
|
|
55
|
-
readonly freq: 1221;
|
|
56
54
|
readonly color: "#fdfd34";
|
|
55
|
+
readonly freq: 1221;
|
|
56
|
+
readonly name: "Yellow Team";
|
|
57
57
|
}, {
|
|
58
|
-
readonly name: "CentCom";
|
|
59
|
-
readonly freq: 1337;
|
|
60
58
|
readonly color: "#2681a5";
|
|
59
|
+
readonly freq: 1337;
|
|
60
|
+
readonly name: "CentCom";
|
|
61
61
|
}, {
|
|
62
|
-
readonly name: "Supply";
|
|
63
|
-
readonly freq: 1347;
|
|
64
62
|
readonly color: "#b88646";
|
|
63
|
+
readonly freq: 1347;
|
|
64
|
+
readonly name: "Supply";
|
|
65
65
|
}, {
|
|
66
|
-
readonly name: "Service";
|
|
67
|
-
readonly freq: 1349;
|
|
68
66
|
readonly color: "#6ca729";
|
|
67
|
+
readonly freq: 1349;
|
|
68
|
+
readonly name: "Service";
|
|
69
69
|
}, {
|
|
70
|
-
readonly name: "Science";
|
|
71
|
-
readonly freq: 1351;
|
|
72
70
|
readonly color: "#c68cfa";
|
|
71
|
+
readonly freq: 1351;
|
|
72
|
+
readonly name: "Science";
|
|
73
73
|
}, {
|
|
74
|
-
readonly name: "Command";
|
|
75
|
-
readonly freq: 1353;
|
|
76
74
|
readonly color: "#fcdf03";
|
|
75
|
+
readonly freq: 1353;
|
|
76
|
+
readonly name: "Command";
|
|
77
77
|
}, {
|
|
78
|
-
readonly name: "Medical";
|
|
79
|
-
readonly freq: 1355;
|
|
80
78
|
readonly color: "#57b8f0";
|
|
79
|
+
readonly freq: 1355;
|
|
80
|
+
readonly name: "Medical";
|
|
81
81
|
}, {
|
|
82
|
-
readonly name: "Engineering";
|
|
83
|
-
readonly freq: 1357;
|
|
84
82
|
readonly color: "#f37746";
|
|
83
|
+
readonly freq: 1357;
|
|
84
|
+
readonly name: "Engineering";
|
|
85
85
|
}, {
|
|
86
|
-
readonly name: "Security";
|
|
87
|
-
readonly freq: 1359;
|
|
88
86
|
readonly color: "#dd3535";
|
|
87
|
+
readonly freq: 1359;
|
|
88
|
+
readonly name: "Security";
|
|
89
89
|
}, {
|
|
90
|
-
readonly name: "AI Private";
|
|
91
|
-
readonly freq: 1447;
|
|
92
90
|
readonly color: "#d65d95";
|
|
91
|
+
readonly freq: 1447;
|
|
92
|
+
readonly name: "AI Private";
|
|
93
93
|
}, {
|
|
94
|
-
readonly name: "Common";
|
|
95
|
-
readonly freq: 1459;
|
|
96
94
|
readonly color: "#1ecc43";
|
|
95
|
+
readonly freq: 1459;
|
|
96
|
+
readonly name: "Common";
|
|
97
97
|
}];
|
|
98
98
|
export declare function getGasLabel(gasId: string, fallbackValue?: string): string;
|
|
99
99
|
export declare function getGasColor(gasId: string): string;
|
|
100
100
|
export declare const getGasFromId: (gasId: string) => Gas | undefined;
|
|
101
101
|
export declare const getGasFromPath: (gasPath: string) => Gas | undefined;
|
|
102
102
|
export declare const COMPONENT_COLORS: {
|
|
103
|
-
readonly states: readonly ["", "good", "average", "bad", "black", "white"];
|
|
104
103
|
readonly spectrum: readonly ["red", "orange", "yellow", "olive", "green", "teal", "blue", "violet", "purple", "pink", "brown", "grey", "gold"];
|
|
104
|
+
readonly states: readonly ["", "good", "average", "bad", "black", "white"];
|
|
105
105
|
};
|
|
106
106
|
export {};
|
package/dist/common/constants.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
let e=2,a=1,o=0,r=-1,l={
|
|
1
|
+
let e=2,a=1,o=0,r=-1,l={damageType:{brute:"#e74c3c",burn:"#e67e22",oxy:"#3498db",toxin:"#2ecc71"},department:{captain:"#c06616",cargo:"#f39c12",centcom:"#00c100",engineering:"#f1c40f",medbay:"#3498db",other:"#c38312",science:"#9b59b6",security:"#e74c3c",service:"#7cc46a"},reagent:{acidicbuffer:"#fbc314",basicbuffer:"#3853a4"}},t=["average","bad","black","blue","brown","good","green","grey","label","olive","orange","pink","purple","red","teal","transparent","violet","white","yellow"],i=[{color:"#8f4a4b",freq:1213,name:"Syndicate"},{color:"#ff4444",freq:1215,name:"Red Team"},{color:"#3434fd",freq:1217,name:"Blue Team"},{color:"#34fd34",freq:1219,name:"Green Team"},{color:"#fdfd34",freq:1221,name:"Yellow Team"},{color:"#2681a5",freq:1337,name:"CentCom"},{color:"#b88646",freq:1347,name:"Supply"},{color:"#6ca729",freq:1349,name:"Service"},{color:"#c68cfa",freq:1351,name:"Science"},{color:"#fcdf03",freq:1353,name:"Command"},{color:"#57b8f0",freq:1355,name:"Medical"},{color:"#f37746",freq:1357,name:"Engineering"},{color:"#dd3535",freq:1359,name:"Security"},{color:"#d65d95",freq:1447,name:"AI Private"},{color:"#1ecc43",freq:1459,name:"Common"}],n=[{color:"blue",id:"o2",label:"O₂",name:"Oxygen",path:"/datum/gas/oxygen"},{color:"yellow",id:"n2",label:"N₂",name:"Nitrogen",path:"/datum/gas/nitrogen"},{color:"grey",id:"co2",label:"CO₂",name:"Carbon Dioxide",path:"/datum/gas/carbon_dioxide"},{color:"pink",id:"plasma",label:"Plasma",name:"Plasma",path:"/datum/gas/plasma"},{color:"lightsteelblue",id:"water_vapor",label:"H₂O",name:"Water Vapor",path:"/datum/gas/water_vapor"},{color:"teal",id:"hypernoblium",label:"Hyper-nob",name:"Hyper-noblium",path:"/datum/gas/hypernoblium"},{color:"bisque",id:"n2o",label:"N₂O",name:"Nitrous Oxide",path:"/datum/gas/nitrous_oxide"},{color:"brown",id:"no2",label:"Nitrium",name:"Nitrium",path:"/datum/gas/nitrium"},{color:"limegreen",id:"tritium",label:"Tritium",name:"Tritium",path:"/datum/gas/tritium"},{color:"mediumpurple",id:"bz",label:"BZ",name:"BZ",path:"/datum/gas/bz"},{color:"mediumslateblue",id:"pluoxium",label:"Pluoxium",name:"Pluoxium",path:"/datum/gas/pluoxium"},{color:"olive",id:"miasma",label:"Miasma",name:"Miasma",path:"/datum/gas/miasma"},{color:"paleturquoise",id:"freon",label:"Freon",name:"Freon",path:"/datum/gas/freon"},{color:"white",id:"hydrogen",label:"H₂",name:"Hydrogen",path:"/datum/gas/hydrogen"},{color:"salmon",id:"healium",label:"Healium",name:"Healium",path:"/datum/gas/healium"},{color:"greenyellow",id:"proto_nitrate",label:"Proto-Nitrate",name:"Proto Nitrate",path:"/datum/gas/proto_nitrate"},{color:"darkgreen",id:"zauker",label:"Zauker",name:"Zauker",path:"/datum/gas/zauker"},{color:"purple",id:"halon",label:"Halon",name:"Halon",path:"/datum/gas/halon"},{color:"aliceblue",id:"helium",label:"He",name:"Helium",path:"/datum/gas/helium"},{color:"maroon",id:"antinoblium",label:"Anti-Noblium",name:"Antinoblium",path:"/datum/gas/antinoblium"},{color:"brown",id:"nitrium",label:"Nitrium",name:"Nitrium",path:"/datum/gas/nitrium"}];function m(e,a){if(!e)return a||"None";let o=e.toLowerCase();for(let e=0;e<n.length;e++)if(n[e].id===o)return n[e].label;return a||"None"}function u(e){if(!e)return"black";let a=e.toLowerCase();for(let e=0;e<n.length;e++)if(n[e].id===a)return n[e].color;return"black"}let c=e=>{if(!e)return;let a=e.toLowerCase();for(let e=0;e<n.length;e++)if(n[e].id===a)return n[e]},d=e=>{if(e){for(let a=0;a<n.length;a++)if(n[a].path===e)return n[a]}},b={spectrum:["red","orange","yellow","olive","green","teal","blue","violet","purple","pink","brown","grey","gold"],states:["","good","average","bad","black","white"]};export{l as COLORS,b as COMPONENT_COLORS,t as CSS_COLORS,i as RADIO_CHANNELS,r as UI_CLOSE,o as UI_DISABLED,e as UI_INTERACTIVE,a as UI_UPDATE,u as getGasColor,c as getGasFromId,d as getGasFromPath,m as getGasLabel};
|
package/dist/common/fp.d.ts
CHANGED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
interface UseFuzzySearchProps<T> {
|
|
2
|
+
/** An input array to match */
|
|
3
|
+
searchArray: T[];
|
|
4
|
+
/**
|
|
5
|
+
* The matching strategy to use. `off` - don't use fuzzy search.
|
|
6
|
+
* `smart` - ignore low density matches. `agressive` - accept
|
|
7
|
+
* any match avaliable. Defaults to 'smart' if not set.
|
|
8
|
+
*/
|
|
9
|
+
matchStrategy?: 'off' | 'smart' | 'aggressive';
|
|
10
|
+
/** The input string to match */
|
|
11
|
+
getSearchString: (item: T) => string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* A simple hook prooviding fuzzy searching - approximate rather
|
|
15
|
+
* than exact pattern matching.
|
|
16
|
+
*/
|
|
17
|
+
export declare function useFuzzySearch<T>({ searchArray, matchStrategy, getSearchString, }: UseFuzzySearchProps<T>): {
|
|
18
|
+
query: string;
|
|
19
|
+
setQuery: (value: string) => void;
|
|
20
|
+
results: T[];
|
|
21
|
+
};
|
|
22
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import*as t from"@nozbe/microfuzz";import*as e from"react";function r({searchArray:r,matchStrategy:a="smart",getSearchString:u}){let[o,i]=(0,e.useState)(""),[m,s]=(0,e.useState)([]),f=(0,e.useCallback)((0,t.default)(r,{getText:t=>[u(t)],strategy:a}),[r,u]);return{query:o,setQuery:function(t){if(i(t),""===t.trim())return void s([]);s(f(t).map(t=>t.item))},results:m}}export{r as useFuzzySearch};
|
package/dist/common/hotkeys.d.ts
CHANGED
|
@@ -10,6 +10,8 @@ export declare function acquireHotKey(keyCode: number): void;
|
|
|
10
10
|
export declare function releaseHotKey(keyCode: number): void;
|
|
11
11
|
export declare function releaseHeldKeys(): void;
|
|
12
12
|
export declare function setupHotKeys(): void;
|
|
13
|
+
export declare function startKeyPassthrough(): void;
|
|
14
|
+
export declare function stopKeyPassthrough(): void;
|
|
13
15
|
/**
|
|
14
16
|
* Registers for any key events, such as key down or key up.
|
|
15
17
|
* This should be preferred over directly connecting to keydown/keyup
|
package/dist/common/hotkeys.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as e from"./events.js";import*as t from"./keycodes.js";let o={},n=[t.KEY_ESCAPE,t.KEY_ENTER,t.KEY_SPACE,t.KEY_TAB,t.KEY_CTRL,t.KEY_SHIFT,t.KEY_UP,t.KEY_DOWN,t.KEY_LEFT,t.KEY_RIGHT,t.KEY_F5],l={},r=[];function i(e){n.push(e)}function s(e){let t=n.indexOf(e);t>=0&&n.splice(t,1)}function
|
|
1
|
+
import*as e from"./events.js";import*as t from"./keycodes.js";let o={},n=[t.KEY_ESCAPE,t.KEY_ENTER,t.KEY_SPACE,t.KEY_TAB,t.KEY_CTRL,t.KEY_SHIFT,t.KEY_UP,t.KEY_DOWN,t.KEY_LEFT,t.KEY_RIGHT,t.KEY_F5],l={},r=[];function i(e){n.push(e)}function s(e){let t=n.indexOf(e);t>=0&&n.splice(t,1)}function a(){for(let e in l)l[e]&&(l[e]=!1,Byond.command(`${globalThis.ByondKeyUp} "${e}"`))}function d(){globalThis.ByondKeyUp||(globalThis.ByondKeyUp="KeyUp",globalThis.ByondKeyDown="KeyDown"),Byond.winget("default.*").then(e=>{let t={};for(let o in e){let n=o.split("."),l=n[1],r=n[2];l&&r&&(t[l]||(t[l]={}),t[l][r]=e[o])}let n=/\\"/g;function l(e){return e.substring(1,e.length-1).replace(n,'"')}for(let e in t){let n=t[e];o[l(n.name)]=l(n.command)}}),e.globalEvents.on("window-blur",()=>{a()}),f()}function f(){e.globalEvents.on("key",y)}function u(){e.globalEvents.off("key",y)}function y(e){for(let t of r)t(e);!function(e){var t;let r=String(e);if("Ctrl+F5"===r||"Ctrl+R"===r)return location.reload();if("Ctrl+F"===r||e.event.defaultPrevented||e.isModifierKey()||n.includes(e.code))return;let i=16===(t=e.code)?"Shift":17===t?"Ctrl":18===t?"Alt":33===t?"Northeast":34===t?"Southeast":35===t?"Southwest":36===t?"Northwest":37===t?"West":38===t?"North":39===t?"East":40===t?"South":45===t?"Insert":46===t?"Delete":t>=48&&t<=57||t>=65&&t<=90?String.fromCharCode(t):t>=96&&t<=105?`Numpad${t-96}`:t>=112&&t<=123?`F${t-111}`:188===t?",":189===t?"-":190===t?".":void 0;if(!i)return;let s=o[i];if(s)return Byond.command(s);if(e.isDown()&&!l[i]){l[i]=!0;let e=`${globalThis.ByondKeyDown} "${i}"`;return Byond.command(e)}if(e.isUp()&&l[i]){l[i]=!1;let e=`${globalThis.ByondKeyUp} "${i}"`;Byond.command(e)}}(e)}function K(e){r.push(e);let t=!1;return()=>{t||(t=!0,r.splice(r.indexOf(e),1))}}export{i as acquireHotKey,K as listenForKeyEvents,a as releaseHeldKeys,s as releaseHotKey,d as setupHotKeys,f as startKeyPassthrough,u as stopKeyPassthrough};
|
package/dist/common/string.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Creates a search terms matcher. Returns true if given string matches the search text.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Example:
|
|
5
|
+
*
|
|
5
6
|
* ```tsx
|
|
6
7
|
* type Thing = { id: string; name: string };
|
|
7
8
|
*
|
|
@@ -23,7 +24,8 @@ export declare const VOWELS: string[];
|
|
|
23
24
|
*
|
|
24
25
|
* @param override - A custom string to be appended instead for plurals. Useful for words that don't follow the standard rules.
|
|
25
26
|
*
|
|
26
|
-
*
|
|
27
|
+
* Example:
|
|
28
|
+
*
|
|
27
29
|
* ```tsx
|
|
28
30
|
* pluralize('Dog', 1) // Dog
|
|
29
31
|
* pluralize('Dog', 2) // Dogs
|
|
@@ -34,7 +36,8 @@ export declare function pluralize(str: string, n: number, override?: string): st
|
|
|
34
36
|
/**
|
|
35
37
|
* Capitalizes a word and lowercases the rest.
|
|
36
38
|
*
|
|
37
|
-
*
|
|
39
|
+
* Example:
|
|
40
|
+
*
|
|
38
41
|
* ```tsx
|
|
39
42
|
* capitalize('heLLo') // Hello
|
|
40
43
|
* ```
|
|
@@ -44,7 +47,8 @@ export declare function capitalize(str: string): string;
|
|
|
44
47
|
* Similar to capitalize, this takes a string and replaces all first letters
|
|
45
48
|
* of any words.
|
|
46
49
|
*
|
|
47
|
-
*
|
|
50
|
+
* Example:
|
|
51
|
+
*
|
|
48
52
|
* ```tsx
|
|
49
53
|
* capitalizeAll('heLLo woRLd') // 'HeLLo WoRLd'
|
|
50
54
|
* ```
|
|
@@ -53,7 +57,8 @@ export declare function capitalizeAll(str: string): string;
|
|
|
53
57
|
/**
|
|
54
58
|
* Capitalizes only the first letter of the str, leaving others untouched.
|
|
55
59
|
*
|
|
56
|
-
*
|
|
60
|
+
* Example:
|
|
61
|
+
*
|
|
57
62
|
* ```tsx
|
|
58
63
|
* capitalizeFirst('heLLo woRLd') // 'HeLLo woRLd'
|
|
59
64
|
* ```
|
|
@@ -62,7 +67,8 @@ export declare function capitalizeFirst(str: string): string;
|
|
|
62
67
|
/**
|
|
63
68
|
* Converts a string to title case.
|
|
64
69
|
*
|
|
65
|
-
*
|
|
70
|
+
* Example:
|
|
71
|
+
*
|
|
66
72
|
* ```tsx
|
|
67
73
|
* toTitleCase('a tale of two cities') // 'A Tale of Two Cities'
|
|
68
74
|
* ```
|
|
@@ -71,7 +77,8 @@ export declare function toTitleCase(str: string): string;
|
|
|
71
77
|
/**
|
|
72
78
|
* Decodes HTML entities and removes unnecessary HTML tags.
|
|
73
79
|
*
|
|
74
|
-
*
|
|
80
|
+
* Example:
|
|
81
|
+
*
|
|
75
82
|
* ```tsx
|
|
76
83
|
* decodeHtmlEntities('&') // returns '&'
|
|
77
84
|
* decodeHtmlEntities('<') // returns '<'
|
package/dist/common/string.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function e(t,r=e=>JSON.stringify(e)){let n=t.toLowerCase().trim();return e=>{if(!n)return!0;let t=r(e);return!!t&&t.toLowerCase().includes(n)}}let t=["a","e","i","o","u"];function r(e,r,n){return 1===r?e:n?e+n:e.endsWith("s")||e.endsWith("x")||e.endsWith("z")||e.endsWith("ch")||e.endsWith("sh")?`${e}es`:e.endsWith("y")&&!t.includes(e.charAt(e.length-2))?`${e.slice(0,-1)}ies`:`${e}s`}function n(e){return e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}function o(e){return e.replace(/(^\w{1})|(\s+\w{1})/g,e=>e.toUpperCase())}function a(e){return e.replace(/^\w/,e=>e.toUpperCase())}let i=["Id","Tv"],s=["A","An","And","As","At","But","By","For","For","From","In","Into","Near","Nor","Of","On","Onto","Or","The","To","With"];function l(e){if(!e)return e;let t=e.replace(/([^\W_]+[^\s-]*) */g,e=>n(e));for(let e of s){let r=RegExp(`\\s${e}\\s`,"g");t=t.replace(r,e=>e.toLowerCase())}for(let e of i){let r=RegExp(`\\b${e}\\b`,"g");t=t.replace(r,e=>e.toLowerCase())}return t}let p=/&(nbsp|amp|quot|lt|gt|apos|trade|copy);/g,c={amp:"&",apos:"'",gt:">",lt:"<",nbsp:" ",quot:'"',trade:"™"
|
|
1
|
+
function e(t,r=e=>JSON.stringify(e)){let n=t.toLowerCase().trim();return e=>{if(!n)return!0;let t=r(e);return!!t&&t.toLowerCase().includes(n)}}let t=["a","e","i","o","u"];function r(e,r,n){return 1===r?e:n?e+n:e.endsWith("s")||e.endsWith("x")||e.endsWith("z")||e.endsWith("ch")||e.endsWith("sh")?`${e}es`:e.endsWith("y")&&!t.includes(e.charAt(e.length-2))?`${e.slice(0,-1)}ies`:`${e}s`}function n(e){return e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}function o(e){return e.replace(/(^\w{1})|(\s+\w{1})/g,e=>e.toUpperCase())}function a(e){return e.replace(/^\w/,e=>e.toUpperCase())}let i=["Id","Tv"],s=["A","An","And","As","At","But","By","For","For","From","In","Into","Near","Nor","Of","On","Onto","Or","The","To","With"];function l(e){if(!e)return e;let t=e.replace(/([^\W_]+[^\s-]*) */g,e=>n(e));for(let e of s){let r=RegExp(`\\s${e}\\s`,"g");t=t.replace(r,e=>e.toLowerCase())}for(let e of i){let r=RegExp(`\\b${e}\\b`,"g");t=t.replace(r,e=>e.toLowerCase())}return t}let p=/&(nbsp|amp|quot|lt|gt|apos|trade|copy);/g,c={amp:"&",apos:"'",cops:"\xa9",gt:">",lt:"<",nbsp:" ",quot:'"',trade:"™"};function u(e){return e?e.replace(/<br>/gi,"\n").replace(/<\/?[a-z0-9-_]+[^>]*>/gi,"").replace(p,(e,t)=>c[t]).replace(/&#?([0-9]+);/gi,(e,t)=>String.fromCharCode(Number.parseInt(t,10))).replace(/&#x?([0-9a-f]+);/gi,(e,t)=>String.fromCharCode(Number.parseInt(t,16))):e}export{t as VOWELS,n as capitalize,o as capitalizeAll,a as capitalizeFirst,e as createSearch,u as decodeHtmlEntities,r as pluralize,l as toTitleCase};
|
package/dist/common/ui.d.ts
CHANGED
|
@@ -112,7 +112,7 @@ export type BooleanStyleMap = {
|
|
|
112
112
|
};
|
|
113
113
|
export declare const booleanStyleMap: Record<keyof BooleanStyleMap, any>;
|
|
114
114
|
export declare function computeBoxProps(props: any): Record<string, any>;
|
|
115
|
-
export declare function computeBoxClassName(props: BoxProps): string;
|
|
115
|
+
export declare function computeBoxClassName<TElement = HTMLDivElement>(props: BoxProps<TElement>): string;
|
|
116
116
|
type StyleMap = StringStyleMap & BooleanStyleMap;
|
|
117
117
|
/** Super light implementation of tailwind-like class names. */
|
|
118
118
|
export declare function computeTwClass(input: string | undefined): StyleMap;
|
package/dist/common/ui.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as t from"./constants.js";import*as o from"./react.js";let i=t=>"string"==typeof t?t.endsWith("px")?`${Number.parseFloat(t)/12}rem`:t:"number"==typeof t?`${t}rem`:void 0,e=t=>"string"==typeof t?i(t):"number"==typeof t?i(.5*t):void 0;function n(o){return"string"==typeof o&&t.CSS_COLORS.includes(o)}let r=t=>(o,i)=>{("number"==typeof i||"string"==typeof i)&&(o[t]=i)},l=(t,o)=>(i,e)=>{("number"==typeof e||"string"==typeof e)&&(i[t]=o(e))},p=(t,o)=>(i,e)=>{e&&(i[t]=o)},a=(t,o,i)=>(e,n)=>{if("number"==typeof n||"string"==typeof n)for(let r=0;r<i.length;r++)e[t+i[r]]=o(n)},g=t=>(o,i)=>{n(i)||(o[t]=i)},f={align:r("textAlign"),
|
|
1
|
+
import*as t from"./constants.js";import*as o from"./react.js";let i=t=>"string"==typeof t?t.endsWith("px")?`${Number.parseFloat(t)/12}rem`:t:"number"==typeof t?`${t}rem`:void 0,e=t=>"string"==typeof t?i(t):"number"==typeof t?i(.5*t):void 0;function n(o){return"string"==typeof o&&t.CSS_COLORS.includes(o)}let r=t=>(o,i)=>{("number"==typeof i||"string"==typeof i)&&(o[t]=i)},l=(t,o)=>(i,e)=>{("number"==typeof e||"string"==typeof e)&&(i[t]=o(e))},p=(t,o)=>(i,e)=>{e&&(i[t]=o)},a=(t,o,i)=>(e,n)=>{if("number"==typeof n||"string"==typeof n)for(let r=0;r<i.length;r++)e[t+i[r]]=o(n)},g=t=>(o,i)=>{n(i)||(o[t]=i)},f={align:r("textAlign"),backgroundColor:g("backgroundColor"),bottom:l("bottom",i),color:g("color"),fontFamily:r("fontFamily"),fontSize:l("fontSize",i),fontWeight:r("fontWeight"),g:l("gap",e),gc:l("columnGap",e),gr:l("rowGap",e),height:l("height",i),left:l("left",i),lineHeight:(t,o)=>{"number"==typeof o?t.lineHeight=o:"string"==typeof o&&(t.lineHeight=i(o))},m:a("margin",e,["Top","Bottom","Left","Right"]),maxHeight:l("maxHeight",i),maxWidth:l("maxWidth",i),mb:l("marginBottom",e),minHeight:l("minHeight",i),minWidth:l("minWidth",i),ml:l("marginLeft",e),mr:l("marginRight",e),mt:l("marginTop",e),mx:a("margin",e,["Left","Right"]),my:a("margin",e,["Top","Bottom"]),opacity:r("opacity"),overflow:r("overflow"),overflowX:r("overflowX"),overflowY:r("overflowY"),p:a("padding",e,["Top","Bottom","Left","Right"]),pb:l("paddingBottom",e),pl:l("paddingLeft",e),position:r("position"),pr:l("paddingRight",e),pt:l("paddingTop",e),px:a("padding",e,["Left","Right"]),py:a("padding",e,["Top","Bottom"]),right:l("right",i),textAlign:r("textAlign"),textColor:g("color"),top:l("top",i),verticalAlign:r("verticalAlign"),width:l("width",i)},m={bold:p("fontWeight","bold"),fillPositionedParent:(t,o)=>{o&&(t.position="absolute",t.top=0,t.bottom=0,t.left=0,t.right=0)},inline:p("display","inline-block"),italic:p("fontStyle","italic"),nowrap:p("whiteSpace","nowrap"),preserveWhitespace:p("whiteSpace","pre-wrap")};function s(t){let o={},i={};for(let e in t){if("style"===e)continue;let n=t[e],r=f[e]||m[e];r?r(i,n):o[e]=n}return o.style={...i,...t.style},o}function h(t){let i=t.textColor||t.color,{backgroundColor:e}=t;return(0,o.classes)([n(i)&&`color-${i}`,n(e)&&`color-bg-${e}`])}function c(t){let o={};if(!t)return o;for(let i of t.split(" ")){let[t,e]=i.split("-");if(t)if(t in f){if(""===e)continue;let i=Number(e);!Number.isNaN(i)&&Number.isFinite(i)?o[t]=i:o[t]=e}else t in m?o[t]=!0:console.warn(`Unknown prop ${t}`)}return o}export{m as booleanStyleMap,h as computeBoxClassName,s as computeBoxProps,c as computeTwClass,e as halfUnit,f as stringStyleMap,i as unit};
|
package/dist/common/uuid.d.ts
CHANGED
|
@@ -19,8 +19,11 @@ type Props = {
|
|
|
19
19
|
}>;
|
|
20
20
|
/**
|
|
21
21
|
* ## AnimatedNumber
|
|
22
|
+
*
|
|
22
23
|
* An animated number label. Shows a number, formatted with an optionally
|
|
23
24
|
* provided function, and animates it towards its target value.
|
|
25
|
+
*
|
|
26
|
+
* - [View documentation on tgui core](https://tgstation.github.io/tgui-core/?path=/docs/components-animatednumber--docs)
|
|
24
27
|
*/
|
|
25
28
|
export declare class AnimatedNumber extends Component<Props> {
|
|
26
29
|
/**
|
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
import { type PropsWithChildren } from 'react';
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* ## Autofocus
|
|
4
|
+
*
|
|
5
|
+
* Used to force the window to steal focus on load. Children optional.
|
|
6
|
+
*/
|
|
3
7
|
export declare function Autofocus(props: PropsWithChildren): import("react/jsx-runtime").JSX.Element;
|
|
@@ -12,6 +12,13 @@ type Props = Partial<{
|
|
|
12
12
|
type State = {
|
|
13
13
|
hidden: boolean;
|
|
14
14
|
};
|
|
15
|
+
/**
|
|
16
|
+
* ## Blink
|
|
17
|
+
*
|
|
18
|
+
* A component that blinks its children at a specified interval.
|
|
19
|
+
*
|
|
20
|
+
* - [View documentation on tgui core](https://tgstation.github.io/tgui-core/?path=/docs/components-blink--docs)
|
|
21
|
+
*/
|
|
15
22
|
export declare class Blink extends Component<Props, State> {
|
|
16
23
|
interval: NodeJS.Timeout;
|
|
17
24
|
timer: NodeJS.Timeout;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { type BoxProps } from './Box';
|
|
2
2
|
/**
|
|
3
3
|
* ## BlockQuote
|
|
4
|
+
*
|
|
4
5
|
* Just a block quote, just like this example in markdown:
|
|
5
6
|
* > Here's an example of a block quote.
|
|
7
|
+
*
|
|
8
|
+
* - [View documentation on tgui core](https://tgstation.github.io/tgui-core/?path=/docs/components-blockquote--docs)
|
|
6
9
|
*/
|
|
7
10
|
export declare function BlockQuote(props: BoxProps): import("react/jsx-runtime").JSX.Element;
|
package/dist/components/Box.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { type CSSProperties, type KeyboardEventHandler, type MouseEventHandler, type ReactNode, type UIEventHandler } from 'react';
|
|
2
2
|
import type { BooleanLike } from '../common/react';
|
|
3
3
|
import { type BooleanStyleMap, type StringStyleMap } from '../common/ui';
|
|
4
|
-
type EventHandlers = {
|
|
5
|
-
onClick: MouseEventHandler<
|
|
6
|
-
onContextMenu: MouseEventHandler<
|
|
7
|
-
onDoubleClick: MouseEventHandler<
|
|
8
|
-
onKeyDown: KeyboardEventHandler<
|
|
9
|
-
onKeyUp: KeyboardEventHandler<
|
|
10
|
-
onMouseDown: MouseEventHandler<
|
|
11
|
-
onMouseLeave: MouseEventHandler<
|
|
12
|
-
onMouseMove: MouseEventHandler<
|
|
13
|
-
onMouseOver: MouseEventHandler<
|
|
14
|
-
onMouseUp: MouseEventHandler<
|
|
15
|
-
onScroll: UIEventHandler<
|
|
4
|
+
type EventHandlers<TElement = HTMLDivElement> = {
|
|
5
|
+
onClick: MouseEventHandler<TElement>;
|
|
6
|
+
onContextMenu: MouseEventHandler<TElement>;
|
|
7
|
+
onDoubleClick: MouseEventHandler<TElement>;
|
|
8
|
+
onKeyDown: KeyboardEventHandler<TElement>;
|
|
9
|
+
onKeyUp: KeyboardEventHandler<TElement>;
|
|
10
|
+
onMouseDown: MouseEventHandler<TElement>;
|
|
11
|
+
onMouseLeave: MouseEventHandler<TElement>;
|
|
12
|
+
onMouseMove: MouseEventHandler<TElement>;
|
|
13
|
+
onMouseOver: MouseEventHandler<TElement>;
|
|
14
|
+
onMouseUp: MouseEventHandler<TElement>;
|
|
15
|
+
onScroll: UIEventHandler<TElement>;
|
|
16
16
|
};
|
|
17
17
|
type InternalProps = {
|
|
18
18
|
/** The component used for the root node. */
|
|
@@ -49,7 +49,7 @@ type InternalProps = {
|
|
|
49
49
|
*/
|
|
50
50
|
tw: string;
|
|
51
51
|
};
|
|
52
|
-
export type BoxProps = Partial<InternalProps & BooleanStyleMap & StringStyleMap & EventHandlers
|
|
52
|
+
export type BoxProps<TElement = HTMLDivElement> = Partial<InternalProps & BooleanStyleMap & StringStyleMap & EventHandlers<TElement>>;
|
|
53
53
|
type DangerDoNotUse = {
|
|
54
54
|
dangerouslySetInnerHTML?: {
|
|
55
55
|
__html: any;
|
|
@@ -57,11 +57,13 @@ type DangerDoNotUse = {
|
|
|
57
57
|
};
|
|
58
58
|
/**
|
|
59
59
|
* ## Box
|
|
60
|
+
*
|
|
60
61
|
* The Box component serves as a wrapper component for most of the CSS utility
|
|
61
62
|
* needs. It creates a new DOM element, a `<div>` by default that can be changed
|
|
62
63
|
* with the `as` property. Let's say you want to use a `<span>` instead:
|
|
63
64
|
*
|
|
64
|
-
*
|
|
65
|
+
* Example:
|
|
66
|
+
*
|
|
65
67
|
* ```tsx
|
|
66
68
|
* <Box as="span" m={1}>
|
|
67
69
|
* <Button />
|
|
@@ -78,7 +80,8 @@ type DangerDoNotUse = {
|
|
|
78
80
|
* To workaround this problem, the Box children accept a render props function.
|
|
79
81
|
* This way, `Button` can pull out the `className` generated by the `Box`.
|
|
80
82
|
*
|
|
81
|
-
*
|
|
83
|
+
* Example:
|
|
84
|
+
*
|
|
82
85
|
* ```tsx
|
|
83
86
|
* <Box color="primary">{(props) => <Button {...props} />}</Box>
|
|
84
87
|
* ```
|
|
@@ -96,8 +99,10 @@ type DangerDoNotUse = {
|
|
|
96
99
|
* If you need more precision, you can always use fractional numbers.
|
|
97
100
|
*
|
|
98
101
|
* Default font size (`1rem`) is equal to `12px`.
|
|
102
|
+
*
|
|
103
|
+
* - [View documentation on tgui core](https://tgstation.github.io/tgui-core/?path=/docs/components-box--docs)
|
|
99
104
|
*/
|
|
100
|
-
export declare function Box(props: BoxProps & DangerDoNotUse): import("react").ReactElement<{
|
|
105
|
+
export declare function Box<TElement = HTMLDivElement>(props: BoxProps<TElement> & DangerDoNotUse): import("react").ReactElement<{
|
|
101
106
|
className: string;
|
|
102
107
|
}, string | import("react").JSXElementConstructor<any>>;
|
|
103
108
|
export {};
|
|
@@ -90,7 +90,10 @@ type FileProps = {
|
|
|
90
90
|
declare function ButtonFile(props: FileProps): import("react/jsx-runtime").JSX.Element;
|
|
91
91
|
/**
|
|
92
92
|
* ## Button
|
|
93
|
+
*
|
|
93
94
|
* Buttons allow users to take actions, and make choices, with a single click.
|
|
95
|
+
*
|
|
96
|
+
* - [View documentation on tgui core](https://tgstation.github.io/tgui-core/?path=/docs/components-button--docs)
|
|
94
97
|
*/
|
|
95
98
|
export declare namespace Button {
|
|
96
99
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var t;import*as e from"react/jsx-runtime";import*as n from"react";import*as o from"../common/keys.js";import*as r from"../common/react.js";import*as s from"../common/ui.js";import*as u from"./Box.js";import*as i from"./Icon.js";import*as c from"./Tooltip.js";function l(t){let{captureKeys:n=!0,children:u,circular:l,className:a,color:f,compact:m,content:p,disabled:d,ellipsis:B,fluid:x,icon:j,iconColor:h,iconPosition:y,iconRotation:g,iconSize:k,iconSpin:v,onClick:C,selected:b,tooltip:E,tooltipPosition:N,verticalAlignContent:_,...w}=t,D=p||u,I=(0,e.jsx)(i.Icon,{className:"Button--icon",name:j||"",
|
|
1
|
+
var t;import*as e from"react/jsx-runtime";import*as n from"react";import*as o from"../common/keys.js";import*as r from"../common/react.js";import*as s from"../common/ui.js";import*as u from"./Box.js";import*as i from"./Icon.js";import*as c from"./Tooltip.js";function l(t){let{captureKeys:n=!0,children:u,circular:l,className:a,color:f,compact:m,content:p,disabled:d,ellipsis:B,fluid:x,icon:j,iconColor:h,iconPosition:y,iconRotation:g,iconSize:k,iconSpin:v,onClick:C,selected:b,tooltip:E,tooltipPosition:N,verticalAlignContent:_,...w}=t,D=p||u,I=(0,e.jsx)(i.Icon,{className:"Button--icon",color:h,name:j||"",rotation:g,size:k,spin:v}),T=(0,e.jsx)("div",{className:(0,r.classes)(["Button",x&&"Button--fluid",d&&"Button--disabled",b&&"Button--selected",l&&"Button--circular",m&&"Button--compact",!D&&"Button--empty",y&&`Button--icon-${y}`,_&&"Button--flex",_&&x&&"Button--flex--fluid",_&&`Button--verticalAlignContent--${_}`,f&&"string"==typeof f?`Button--color--${f}`:"Button--color--default",a,(0,s.computeBoxClassName)(w)]),onClick:t=>{!d&&C&&C(t)},onKeyDown:t=>{if(n){if(t.key===o.KEY.Space||t.key===o.KEY.Enter){t.preventDefault(),!d&&C&&C(t);return}(0,o.isEscape)(t.key)&&t.preventDefault()}},tabIndex:d?void 0:0,...(0,s.computeBoxProps)(w),children:(0,e.jsxs)("div",{className:(0,r.classes)(["Button__content",B&&"Button__content--ellipsis"]),children:[j&&"right"!==y&&I,B?(0,e.jsx)("span",{className:"Button--ellipsis",children:D}):D,j&&"right"===y&&I]})});return E&&(T=(0,e.jsx)(c.Tooltip,{content:E,position:N,children:T})),T}(t=l||(l={})).Checkbox=function(t){let{checked:n,...o}=t;return(0,e.jsx)(l,{color:"transparent",icon:n?"check-square-o":"square-o",selected:n,...o})},t.Confirm=function(t){let{children:o,color:r,confirmColor:s="bad",confirmContent:u="Confirm?",confirmIcon:i,ellipsis:c=!0,icon:a,onBlur:f,onClick:m,...p}=t,[d,B]=(0,n.useState)(!1);return(0,e.jsx)(l,{color:d?s:r,icon:d?i:a,onBlur:function(t){B(!1),f?.(t)},onClick:function(t){if(!d)return void B(!0);m?.(t),B(!1)},...p,children:d?u:o})},t.Input=function(t){let{buttonText:s,children:c,color:l="default",disabled:a,fluid:f,icon:m,iconRotation:p,iconSpin:d,maxLength:B,onCommit:x,ref:j,value:h="",...y}=t,[g,k]=(0,n.useState)(h),[v,C]=(0,n.useState)(!1),b=(0,n.useRef)(!1),E=(0,n.createRef)(),N=j??E;return(0,n.useEffect)(()=>{v&&(N.current?.focus(),N.current?.select())},[v]),(0,n.useEffect)(()=>{v||h===g||k(h)},[v,h]),(0,e.jsxs)(u.Box,{className:(0,r.classes)(["Button",f&&"Button--fluid",a&&"Button--disabled",`Button--color--${l}`]),onClick:()=>C(!0),...y,children:[m&&(0,e.jsx)(i.Icon,{name:m,rotation:p,spin:d}),s??g,(0,e.jsx)("input",{className:"NumberInput__input",disabled:!!a,maxLength:B,onBlur:function(){b.current||h===g||(x?.(g),b.current=!1),C(!1)},onChange:function(t){k(t.currentTarget.value)},onKeyDown:function(t){if(t.key===o.KEY.Enter){t.preventDefault(),t.currentTarget.blur();return}if((0,o.isEscape)(t.key)){t.preventDefault(),b.current=!0,t.currentTarget.blur();return}},ref:N,spellCheck:"false",style:{display:v?"":"none",textAlign:"left"},type:"text",value:g})]})},t.File=function(t){let{accept:o,multiple:r,onSelectFiles:s,...u}=t,i=(0,n.useRef)(null);async function c(t){let e=Array.from(t).map(t=>{let e=new FileReader;return new Promise(n=>{e.onload=()=>n(e.result),e.readAsText(t)})});return await Promise.all(e)}async function a(t){let e=t.target.files;if(e?.length){let t=await c(e);s(r?t:t[0])}}return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(l,{onClick:()=>i.current?.click(),...u}),(0,e.jsx)("input",{accept:o,hidden:!0,multiple:r,onChange:a,ref:i,type:"file"})]})};export{l as Button};
|
|
@@ -19,12 +19,14 @@ type Props = Partial<{
|
|
|
19
19
|
}> & BoxProps;
|
|
20
20
|
/**
|
|
21
21
|
* ## ByondUi
|
|
22
|
+
*
|
|
22
23
|
* Displays a BYOND UI element on top of the browser, and leverages browser's
|
|
23
24
|
* layout engine to position it just like any other HTML element. It is
|
|
24
25
|
* especially useful if you want to display a secondary game map in your
|
|
25
26
|
* interface.
|
|
26
27
|
*
|
|
27
|
-
*
|
|
28
|
+
* Example:
|
|
29
|
+
*
|
|
28
30
|
* ```tsx
|
|
29
31
|
* <ByondUi
|
|
30
32
|
* params={{
|
|
@@ -35,7 +37,8 @@ type Props = Partial<{
|
|
|
35
37
|
* }} />
|
|
36
38
|
* ```
|
|
37
39
|
*
|
|
38
|
-
*
|
|
40
|
+
* Example:
|
|
41
|
+
*
|
|
39
42
|
* ```tsx
|
|
40
43
|
* <ByondUi
|
|
41
44
|
* params={{
|
package/dist/components/Chart.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as e from"react/jsx-runtime";import*as t from"react";import*as i from"../common/collections.js";import*as n from"./Box.js";let r={
|
|
1
|
+
import*as e from"react/jsx-runtime";import*as t from"react";import*as i from"../common/collections.js";import*as n from"./Box.js";let r={bottom:0,left:0,overflow:"hidden",position:"absolute",right:0,top:0};function o(o){let{data:s=[],rangeX:l,rangeY:f,fillColor:a="none",strokeColor:h="#ffffff",strokeWidth:p=2,...u}=o,m=(0,t.useRef)(null),[c,d]=(0,t.useState)([600,200]),v=function(e,t,n,r){if(0===e.length)return[];let o=(0,i.zip)(...e),s=o.map(e=>Math.min(...e)),l=o.map(e=>Math.max(...e));return void 0!==n&&(s[0]=n[0],l[0]=n[1]),void 0!==r&&(s[1]=r[0],l[1]=r[1]),e.map(e=>(0,i.zip)(e,s,l,t).map(([e,t,i,n])=>(e-t)/(i-t)*n))}(s,c,l,f);if(v.length>0){let e=v[0],t=v[v.length-1];v.push([c[0]+p,t[1]]),v.push([c[0]+p,-p]),v.push([-p,-p]),v.push([-p,e[1]])}let x=function(e){let t="";for(let i=0;i<e.length;i++){let n=e[i];t+=`${n[0]},${n[1]} `}return t}(v);function g(){let e=m.current;if(!e)return;let t=e.getBoundingClientRect();d([t.width,t.height])}return(0,t.useEffect)(()=>(window.addEventListener("resize",g),g(),()=>{window.removeEventListener("resize",g)}),[]),(0,e.jsx)(n.Box,{position:"relative",...u,children:(0,e.jsx)("div",{ref:m,style:r,children:(0,e.jsxs)("svg",{preserveAspectRatio:"none",style:r,viewBox:`0 0 ${c[0]} ${c[1]}`,children:[(0,e.jsx)("title",{children:"chart"}),(0,e.jsx)("polyline",{fill:a,points:x,stroke:h,strokeWidth:p,transform:`scale(1, -1) translate(0, -${c[1]})`})]})})})}o.Line=o;export{o as Chart};
|
|
@@ -16,9 +16,12 @@ type Props = Partial<{
|
|
|
16
16
|
}> & BoxProps;
|
|
17
17
|
/**
|
|
18
18
|
* ## Collapsible
|
|
19
|
+
*
|
|
19
20
|
* Displays contents when open, acts as a fluid button when closed.
|
|
20
21
|
*
|
|
21
22
|
* Click to toggle, closed by default.
|
|
23
|
+
*
|
|
24
|
+
* - [View documentation on tgui core](https://tgstation.github.io/tgui-core/?path=/docs/components-collapsible--docs)
|
|
22
25
|
*/
|
|
23
26
|
export declare function Collapsible(props: Props): import("react/jsx-runtime").JSX.Element;
|
|
24
27
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as e from"react/jsx-runtime";import*as l from"react";import*as o from"./Box.js";import*as s from"./Button.js";function r(r){let{children:c,child_mt:i=1,childStyles:t,color:a,title:n,buttons:m,icon:d,...x}=r,[h,j]=(0,l.useState)(r.open);return(0,e.jsxs)(o.Box,{mb:1,children:[(0,e.jsxs)("div",{className:"Table",children:[(0,e.jsx)("div",{className:"Table__cell",children:(0,e.jsx)(s.Button,{fluid:!0,
|
|
1
|
+
import*as e from"react/jsx-runtime";import*as l from"react";import*as o from"./Box.js";import*as s from"./Button.js";function r(r){let{children:c,child_mt:i=1,childStyles:t,color:a,title:n,buttons:m,icon:d,...x}=r,[h,j]=(0,l.useState)(r.open);return(0,e.jsxs)(o.Box,{mb:1,children:[(0,e.jsxs)("div",{className:"Table",children:[(0,e.jsx)("div",{className:"Table__cell",children:(0,e.jsx)(s.Button,{color:a,fluid:!0,icon:d||(h?"chevron-down":"chevron-right"),onClick:()=>j(!h),...x,children:n})}),m&&(0,e.jsx)("div",{className:"Table__cell Table__cell--collapsing",children:m})]}),h&&(0,e.jsx)(o.Box,{mt:i,style:t,children:c})]})}export{r as Collapsible};
|
|
@@ -5,11 +5,14 @@ type Props = {
|
|
|
5
5
|
} & BoxProps;
|
|
6
6
|
/**
|
|
7
7
|
* ## ColorBox
|
|
8
|
+
*
|
|
8
9
|
* Displays a 1-character wide colored square. Can be used as a status indicator,
|
|
9
10
|
* or for visually representing a color.
|
|
10
11
|
*
|
|
11
12
|
* If you want to set a background color on an element, use a plain
|
|
12
13
|
* [Box](https://github.com/tgstation/tgui-core/tree/main/lib/components/Box.tsx) instead.
|
|
14
|
+
*
|
|
15
|
+
* - [View documentation on tgui core](https://tgstation.github.io/tgui-core/?path=/docs/components-colorbox--docs)
|
|
13
16
|
*/
|
|
14
17
|
export declare function ColorBox(props: Props): import("react/jsx-runtime").JSX.Element;
|
|
15
18
|
export {};
|