tgui-core 3.1.5 → 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.
Files changed (72) hide show
  1. package/dist/common/constants.d.ts +42 -42
  2. package/dist/common/constants.js +1 -1
  3. package/dist/common/fp.d.ts +2 -1
  4. package/dist/common/fuzzysearch.d.ts +22 -0
  5. package/dist/common/fuzzysearch.js +1 -0
  6. package/dist/common/string.d.ts +14 -7
  7. package/dist/common/string.js +1 -1
  8. package/dist/common/type-utils.d.ts +2 -1
  9. package/dist/common/ui.js +1 -1
  10. package/dist/common/uuid.d.ts +2 -1
  11. package/dist/components/AnimatedNumber.d.ts +3 -0
  12. package/dist/components/Autofocus.d.ts +5 -1
  13. package/dist/components/Blink.d.ts +7 -0
  14. package/dist/components/BlockQuote.d.ts +3 -0
  15. package/dist/components/Box.d.ts +7 -2
  16. package/dist/components/Button.d.ts +3 -0
  17. package/dist/components/Button.js +1 -1
  18. package/dist/components/ByondUi.d.ts +5 -2
  19. package/dist/components/Chart.js +1 -1
  20. package/dist/components/Collapsible.d.ts +3 -0
  21. package/dist/components/Collapsible.js +1 -1
  22. package/dist/components/ColorBox.d.ts +3 -0
  23. package/dist/components/Dialog.d.ts +5 -1
  24. package/dist/components/Dialog.js +1 -1
  25. package/dist/components/Dimmer.d.ts +3 -0
  26. package/dist/components/Divider.d.ts +3 -0
  27. package/dist/components/DmIcon.d.ts +1 -0
  28. package/dist/components/DraggableControl.js +1 -1
  29. package/dist/components/Dropdown.d.ts +3 -0
  30. package/dist/components/Dropdown.js +1 -1
  31. package/dist/components/Flex.d.ts +5 -1
  32. package/dist/components/Flex.js +1 -1
  33. package/dist/components/Floating.d.ts +1 -0
  34. package/dist/components/Floating.js +1 -1
  35. package/dist/components/Icon.d.ts +10 -3
  36. package/dist/components/Image.d.ts +1 -0
  37. package/dist/components/ImageButton.d.ts +4 -0
  38. package/dist/components/ImageButton.js +1 -1
  39. package/dist/components/InfinitePlane.d.ts +5 -1
  40. package/dist/components/InfinitePlane.js +1 -1
  41. package/dist/components/Input.d.ts +1 -1
  42. package/dist/components/KeyListener.d.ts +3 -0
  43. package/dist/components/Knob.d.ts +3 -0
  44. package/dist/components/Knob.js +1 -1
  45. package/dist/components/LabeledControls.d.ts +6 -2
  46. package/dist/components/LabeledControls.js +1 -1
  47. package/dist/components/LabeledList.d.ts +7 -2
  48. package/dist/components/LabeledList.js +1 -1
  49. package/dist/components/MenuBar.js +1 -1
  50. package/dist/components/Modal.d.ts +7 -2
  51. package/dist/components/NoticeBox.d.ts +3 -0
  52. package/dist/components/NumberInput.d.ts +3 -0
  53. package/dist/components/NumberInput.js +1 -1
  54. package/dist/components/Popper.d.ts +3 -0
  55. package/dist/components/Popper.js +1 -1
  56. package/dist/components/ProgressBar.d.ts +3 -0
  57. package/dist/components/RestrictedInput.d.ts +2 -2
  58. package/dist/components/RoundGauge.d.ts +4 -1
  59. package/dist/components/RoundGauge.js +1 -1
  60. package/dist/components/Section.d.ts +7 -0
  61. package/dist/components/Section.js +1 -1
  62. package/dist/components/Slider.d.ts +5 -1
  63. package/dist/components/Slider.js +1 -1
  64. package/dist/components/Stack.d.ts +8 -3
  65. package/dist/components/Table.d.ts +5 -1
  66. package/dist/components/Tabs.d.ts +12 -6
  67. package/dist/components/TextArea.d.ts +1 -1
  68. package/dist/components/TimeDisplay.d.ts +7 -0
  69. package/dist/components/Tooltip.d.ts +16 -0
  70. package/dist/components/Tooltip.js +1 -1
  71. package/dist/components/VirtualList.d.ts +4 -0
  72. package/package.json +48 -39
@@ -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
- readonly damageType: {
25
- readonly oxy: "#3498db";
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 {};
@@ -1 +1 @@
1
- let e=2,a=1,o=0,r=-1,l={department:{captain:"#c06616",security:"#e74c3c",medbay:"#3498db",science:"#9b59b6",engineering:"#f1c40f",cargo:"#f39c12",service:"#7cc46a",centcom:"#00c100",other:"#c38312"},damageType:{oxy:"#3498db",toxin:"#2ecc71",burn:"#e67e22",brute:"#e74c3c"},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=[{name:"Syndicate",freq:1213,color:"#8f4a4b"},{name:"Red Team",freq:1215,color:"#ff4444"},{name:"Blue Team",freq:1217,color:"#3434fd"},{name:"Green Team",freq:1219,color:"#34fd34"},{name:"Yellow Team",freq:1221,color:"#fdfd34"},{name:"CentCom",freq:1337,color:"#2681a5"},{name:"Supply",freq:1347,color:"#b88646"},{name:"Service",freq:1349,color:"#6ca729"},{name:"Science",freq:1351,color:"#c68cfa"},{name:"Command",freq:1353,color:"#fcdf03"},{name:"Medical",freq:1355,color:"#57b8f0"},{name:"Engineering",freq:1357,color:"#f37746"},{name:"Security",freq:1359,color:"#dd3535"},{name:"AI Private",freq:1447,color:"#d65d95"},{name:"Common",freq:1459,color:"#1ecc43"}],n=[{id:"o2",path:"/datum/gas/oxygen",name:"Oxygen",label:"O₂",color:"blue"},{id:"n2",path:"/datum/gas/nitrogen",name:"Nitrogen",label:"N₂",color:"yellow"},{id:"co2",path:"/datum/gas/carbon_dioxide",name:"Carbon Dioxide",label:"CO₂",color:"grey"},{id:"plasma",path:"/datum/gas/plasma",name:"Plasma",label:"Plasma",color:"pink"},{id:"water_vapor",path:"/datum/gas/water_vapor",name:"Water Vapor",label:"H₂O",color:"lightsteelblue"},{id:"hypernoblium",path:"/datum/gas/hypernoblium",name:"Hyper-noblium",label:"Hyper-nob",color:"teal"},{id:"n2o",path:"/datum/gas/nitrous_oxide",name:"Nitrous Oxide",label:"N₂O",color:"bisque"},{id:"no2",path:"/datum/gas/nitrium",name:"Nitrium",label:"Nitrium",color:"brown"},{id:"tritium",path:"/datum/gas/tritium",name:"Tritium",label:"Tritium",color:"limegreen"},{id:"bz",path:"/datum/gas/bz",name:"BZ",label:"BZ",color:"mediumpurple"},{id:"pluoxium",path:"/datum/gas/pluoxium",name:"Pluoxium",label:"Pluoxium",color:"mediumslateblue"},{id:"miasma",path:"/datum/gas/miasma",name:"Miasma",label:"Miasma",color:"olive"},{id:"freon",path:"/datum/gas/freon",name:"Freon",label:"Freon",color:"paleturquoise"},{id:"hydrogen",path:"/datum/gas/hydrogen",name:"Hydrogen",label:"H₂",color:"white"},{id:"healium",path:"/datum/gas/healium",name:"Healium",label:"Healium",color:"salmon"},{id:"proto_nitrate",path:"/datum/gas/proto_nitrate",name:"Proto Nitrate",label:"Proto-Nitrate",color:"greenyellow"},{id:"zauker",path:"/datum/gas/zauker",name:"Zauker",label:"Zauker",color:"darkgreen"},{id:"halon",path:"/datum/gas/halon",name:"Halon",label:"Halon",color:"purple"},{id:"helium",path:"/datum/gas/helium",name:"Helium",label:"He",color:"aliceblue"},{id:"antinoblium",path:"/datum/gas/antinoblium",name:"Antinoblium",label:"Anti-Noblium",color:"maroon"},{id:"nitrium",path:"/datum/gas/nitrium",name:"Nitrium",label:"Nitrium",color:"brown"}];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={states:["","good","average","bad","black","white"],spectrum:["red","orange","yellow","olive","green","teal","blue","violet","purple","pink","brown","grey","gold"]};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};
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};
@@ -4,7 +4,8 @@ type Func = (...args: any[]) => any;
4
4
  * functions, where each successive invocation is supplied the return
5
5
  * value of the previous.
6
6
  *
7
- * @example
7
+ * Example:
8
+ *
8
9
  * ```tsx
9
10
  * const add2 = (x) => x + 2;
10
11
  * const multiplyBy3 = (x) => x * 3;
@@ -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};
@@ -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
- * @example
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
- * @example
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
- * @example
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
- * @example
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
- * @example
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
- * @example
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
- * @example
80
+ * Example:
81
+ *
75
82
  * ```tsx
76
83
  * decodeHtmlEntities('&amp;') // returns '&'
77
84
  * decodeHtmlEntities('&lt;') // returns '<'
@@ -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:"™",cops:"\xa9"};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};
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};
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * Helps visualize highly complex ui data on the fly.
3
- * @example
3
+ * Example:
4
+ *
4
5
  * ```tsx
5
6
  * const { data } = useBackend<CargoData>();
6
7
  * logger.log(getShallowTypes(data));
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"),bottom:l("bottom",i),fontFamily:r("fontFamily"),fontSize:l("fontSize",i),fontWeight:r("fontWeight"),height:l("height",i),left:l("left",i),maxHeight:l("maxHeight",i),maxWidth:l("maxWidth",i),minHeight:l("minHeight",i),minWidth:l("minWidth",i),opacity:r("opacity"),overflow:r("overflow"),overflowX:r("overflowX"),overflowY:r("overflowY"),position:r("position"),right:l("right",i),textAlign:r("textAlign"),top:l("top",i),verticalAlign:r("verticalAlign"),width:l("width",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"]),mb:l("marginBottom",e),ml:l("marginLeft",e),mr:l("marginRight",e),mt:l("marginTop",e),mx:a("margin",e,["Left","Right"]),my:a("margin",e,["Top","Bottom"]),g:l("gap",e),gr:l("rowGap",e),gc:l("columnGap",e),p:a("padding",e,["Top","Bottom","Left","Right"]),pb:l("paddingBottom",e),pl:l("paddingLeft",e),pr:l("paddingRight",e),pt:l("paddingTop",e),px:a("padding",e,["Left","Right"]),py:a("padding",e,["Top","Bottom"]),color:g("color"),textColor:g("color"),backgroundColor:g("backgroundColor")},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};
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};
@@ -1,7 +1,8 @@
1
1
  /**
2
2
  * Creates a UUID v4 string
3
3
  *
4
- * @example
4
+ * Example:
5
+ *
5
6
  * ```tsx
6
7
  * createUuid(); // 'f47ac10b-58cc-4372-a567-0e02b2c3d479'
7
8
  * ```
@@ -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
- /** Used to force the window to steal focus on load. Children optional */
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;
@@ -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
- * @example
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
- * @example
83
+ * Example:
84
+ *
82
85
  * ```tsx
83
86
  * <Box color="primary">{(props) => <Button {...props} />}</Box>
84
87
  * ```
@@ -96,6 +99,8 @@ 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
105
  export declare function Box<TElement = HTMLDivElement>(props: BoxProps<TElement> & DangerDoNotUse): import("react").ReactElement<{
101
106
  className: string;
@@ -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||"",color:h,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)]),tabIndex:d?void 0:0,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()}},...(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,{icon:d?i:a,color:d?s:r,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",{hidden:!0,type:"file",ref:i,accept:o,multiple:r,onChange:a})]})};export{l as Button};
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
- * @example
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
- * @example
40
+ * Example:
41
+ *
39
42
  * ```tsx
40
43
  * <ByondUi
41
44
  * params={{
@@ -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={position:"absolute",top:0,left:0,right:0,bottom:0,overflow:"hidden"};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",{viewBox:`0 0 ${c[0]} ${c[1]}`,preserveAspectRatio:"none",style:r,children:[(0,e.jsx)("title",{children:"chart"}),(0,e.jsx)("polyline",{transform:`scale(1, -1) translate(0, -${c[1]})`,fill:a,stroke:h,strokeWidth:p,points:x})]})})})}o.Line=o;export{o as Chart};
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,color:a,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};
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 {};
@@ -13,14 +13,18 @@ type DialogProps = {
13
13
  };
14
14
  /**
15
15
  * ## Dialog
16
+ *
16
17
  * A themed dialog for user interaction.
17
18
  *
18
- * @example
19
+ * Example:
20
+ *
19
21
  * ```tsx
20
22
  * <Dialog title="Dialog Title" onClose={() => {}}>
21
23
  * <div>Dialog Content</div>
22
24
  * </Dialog>
23
25
  * ```
26
+ *
27
+ * - [View documentation on tgui core](https://tgstation.github.io/tgui-core/?path=/docs/components-dialog--docs)
24
28
  */
25
29
  export declare function Dialog(props: DialogProps): import("react/jsx-runtime").JSX.Element;
26
30
  export declare namespace Dialog {
@@ -1 +1 @@
1
- import*as t from"react/jsx-runtime";import*as o from"./Box.js";import*as i from"./Button.js";function e(e){let{title:n,onClose:l,children:s,width:r,height:a}=e;return(0,t.jsx)("div",{className:"Dialog",children:(0,t.jsxs)(o.Box,{className:"Dialog__content",width:r||"370px",height:a,children:[(0,t.jsxs)("div",{className:"Dialog__header",children:[(0,t.jsx)("div",{className:"Dialog__title",children:n}),(0,t.jsx)(o.Box,{mr:2,children:(0,t.jsx)(i.Button,{color:"transparent",icon:"window-close-o",lineHeight:"22px",mr:"-3px",onClick:l,textAlign:"center",tooltip:"Close",tooltipPosition:"bottom-start",width:"26px"})})]}),s]})})}e.Button=function(o){let{onClick:e,children:n}=o;return(0,t.jsx)(i.Button,{onClick:e,className:"Dialog__button",verticalAlignContent:"middle",children:n})};export{e as Dialog};
1
+ import*as t from"react/jsx-runtime";import*as o from"./Box.js";import*as i from"./Button.js";function e(e){let{title:n,onClose:l,children:s,width:r,height:a}=e;return(0,t.jsx)("div",{className:"Dialog",children:(0,t.jsxs)(o.Box,{className:"Dialog__content",height:a,width:r||"370px",children:[(0,t.jsxs)("div",{className:"Dialog__header",children:[(0,t.jsx)("div",{className:"Dialog__title",children:n}),(0,t.jsx)(o.Box,{mr:2,children:(0,t.jsx)(i.Button,{color:"transparent",icon:"window-close-o",lineHeight:"22px",mr:"-3px",onClick:l,textAlign:"center",tooltip:"Close",tooltipPosition:"bottom-start",width:"26px"})})]}),s]})})}e.Button=function(o){let{onClick:e,children:n}=o;return(0,t.jsx)(i.Button,{className:"Dialog__button",onClick:e,verticalAlignContent:"middle",children:n})};export{e as Dialog};
@@ -1,8 +1,11 @@
1
1
  import { type BoxProps } from './Box';
2
2
  /**
3
3
  * ## Dimmer
4
+ *
4
5
  * Dims surrounding area to emphasize content placed inside.
5
6
  *
6
7
  * Content is automatically centered inside the dimmer.
8
+ *
9
+ * - [View documentation on tgui core](https://tgstation.github.io/tgui-core/?path=/docs/components-dimmer--docs)
7
10
  */
8
11
  export declare function Dimmer(props: BoxProps): import("react/jsx-runtime").JSX.Element;
@@ -7,8 +7,11 @@ type Props = Partial<{
7
7
  /**
8
8
  *
9
9
  * ## Divider
10
+ *
10
11
  * Draws a horizontal or vertical line, dividing a section into groups.
11
12
  * Works like the good old `<hr>` element, but it's fancier.
13
+ *
14
+ * - [View documentation on tgui core](https://tgstation.github.io/tgui-core/?path=/docs/components-divider--docs)
12
15
  */
13
16
  export declare function Divider(props: Props): import("react/jsx-runtime").JSX.Element;
14
17
  export {};
@@ -27,6 +27,7 @@ type Props = {
27
27
  }> & BoxProps;
28
28
  /**
29
29
  * ## DmIcon
30
+ *
30
31
  * Displays an icon from the BYOND icon reference map. Requires Byond 515+.
31
32
  * A much faster alternative to base64 icons.
32
33
  */
@@ -1 +1 @@
1
- import*as e from"react/jsx-runtime";import*as r from"react";import*as t from"../common/keys.js";import*as n from"../common/math.js";import*as u from"./AnimatedNumber.js";function c(e,r){return e.screenX*r[0]+e.screenY*r[1]}function o(o){let{animated:a,children:s,dragMatrix:m=[1,0],format:i,maxValue:l=Number.POSITIVE_INFINITY,minValue:v=Number.NEGATIVE_INFINITY,onChange:f,onDrag:d,step:p=1,stepPixelSize:N=1,unclamped:E,unit:I,updateRate:b=400,fontSize:g,height:y,lineHeight:T}=o,[j,R]=(0,r.useState)(o.value),[h,S]=(0,r.useState)(!1),x=(0,r.useRef)(!1),F=(0,r.useRef)(o.value),L=(0,r.useRef)(0),Y=(0,r.useRef)(-1),_=(0,r.useRef)(null),k=(0,r.useRef)(null),A=(0,r.useRef)(null);function D(e){let r=c(e,m),t=r-Y.current,u=Number.isFinite(v)?v%p:0;L.current=(0,n.clamp)(L.current+t*p/N,v-p,l+p);let o=(0,n.clamp)(L.current-L.current%p+u,v,l);F.current=o,R(o),Y.current=r}function K(e){document.body.style["pointer-events"]="auto",k.current&&clearInterval(k.current),Y.current=-1,document.removeEventListener("mousemove",D),document.removeEventListener("mouseup",K),x.current&&(f?.(e,F.current),d?.(e,F.current),x.current=!1)}(0,r.useEffect)(()=>{o.value!==F.current&&(F.current=o.value,R(o.value))},[o.value]);let V=o.value;x.current&&(V=F.current);let w=(0,e.jsxs)(e.Fragment,{children:[a&&!x.current?(0,e.jsx)(u.AnimatedNumber,{value:V,format:i}):i?i(V):V,I?` ${I}`:""]}),z=(0,e.jsx)("input",{ref:_,className:"NumberInput__input",style:{display:h?void 0:"none",height:y,lineHeight:T,fontSize:g},onBlur:function(e){let r=Number.parseFloat(e.currentTarget.value);if(E||(r=(0,n.clamp)(r,v,l)),Number.isNaN(r))return void S(!1);L.current=r,F.current=r,R(r),f?.(e.nativeEvent,r),h&&S(!1)},onKeyDown:function(e){(e.key===t.KEY.Enter||(0,t.isEscape)(e.key))&&S(!1)}});return s({displayElement:w,displayValue:V,dragging:x.current,editing:h,handleDragStart:function(e){h||(document.body.style["pointer-events"]="none",Y.current=c(e.nativeEvent,m),L.current=o.value,x.current=!0,document.addEventListener("mouseup",K),A.current=setTimeout(()=>{var r=e.nativeEvent;if(x.current)document.addEventListener("mousemove",D),k.current=setInterval(()=>{x.current&&d?.(r,o.value)},b);else if(S(!0),_.current){let e=_.current;e.value=L.current.toString(),setTimeout(()=>{e.focus(),e.select()},10)}A.current&&clearTimeout(A.current)},100))},inputElement:z})}export{o as DraggableControl};
1
+ import*as e from"react/jsx-runtime";import*as r from"react";import*as t from"../common/keys.js";import*as n from"../common/math.js";import*as u from"./AnimatedNumber.js";function c(e,r){return e.screenX*r[0]+e.screenY*r[1]}function o(o){let{animated:a,children:s,dragMatrix:m=[1,0],format:i,maxValue:l=Number.POSITIVE_INFINITY,minValue:v=Number.NEGATIVE_INFINITY,onChange:f,onDrag:d,step:p=1,stepPixelSize:N=1,unclamped:E,unit:I,updateRate:b=400,fontSize:g,height:y,lineHeight:T}=o,[j,R]=(0,r.useState)(o.value),[h,S]=(0,r.useState)(!1),x=(0,r.useRef)(!1),F=(0,r.useRef)(o.value),L=(0,r.useRef)(0),Y=(0,r.useRef)(-1),_=(0,r.useRef)(null),k=(0,r.useRef)(null),A=(0,r.useRef)(null);function D(e){let r=c(e,m),t=r-Y.current,u=Number.isFinite(v)?v%p:0;L.current=(0,n.clamp)(L.current+t*p/N,v-p,l+p);let o=(0,n.clamp)(L.current-L.current%p+u,v,l);F.current=o,R(o),Y.current=r}function K(e){document.body.style["pointer-events"]="auto",k.current&&clearInterval(k.current),Y.current=-1,document.removeEventListener("mousemove",D),document.removeEventListener("mouseup",K),x.current&&(f?.(e,F.current),d?.(e,F.current),x.current=!1)}(0,r.useEffect)(()=>{o.value!==F.current&&(F.current=o.value,R(o.value))},[o.value]);let V=o.value;x.current&&(V=F.current);let w=(0,e.jsxs)(e.Fragment,{children:[a&&!x.current?(0,e.jsx)(u.AnimatedNumber,{format:i,value:V}):i?i(V):V,I?` ${I}`:""]}),z=(0,e.jsx)("input",{className:"NumberInput__input",onBlur:function(e){let r=Number.parseFloat(e.currentTarget.value);if(E||(r=(0,n.clamp)(r,v,l)),Number.isNaN(r))return void S(!1);L.current=r,F.current=r,R(r),f?.(e.nativeEvent,r),h&&S(!1)},onKeyDown:function(e){(e.key===t.KEY.Enter||(0,t.isEscape)(e.key))&&S(!1)},ref:_,style:{display:h?void 0:"none",fontSize:g,height:y,lineHeight:T}});return s({displayElement:w,displayValue:V,dragging:x.current,editing:h,handleDragStart:function(e){h||(document.body.style["pointer-events"]="none",Y.current=c(e.nativeEvent,m),L.current=o.value,x.current=!0,document.addEventListener("mouseup",K),A.current=setTimeout(()=>{var r=e.nativeEvent;if(x.current)document.addEventListener("mousemove",D),k.current=setInterval(()=>{x.current&&d?.(r,o.value)},b);else if(S(!0),_.current){let e=_.current;e.value=L.current.toString(),setTimeout(()=>{e.focus(),e.select()},10)}A.current&&clearTimeout(A.current)},100))},inputElement:z})}export{o as DraggableControl};
@@ -47,8 +47,11 @@ type Props = {
47
47
  }> & BoxProps;
48
48
  /**
49
49
  * ## Dropdown
50
+ *
50
51
  * A simple dropdown box component. Lets the user select from a list of options
51
52
  * and displays selected entry.
53
+ *
54
+ * - [View documentation on tgui core](https://tgstation.github.io/tgui-core/?path=/docs/components-dropdown--docs)
52
55
  */
53
56
  export declare function Dropdown(props: Props): import("react/jsx-runtime").JSX.Element;
54
57
  export {};