tgui-core 1.1.11 → 1.1.13

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 (292) hide show
  1. package/dist/ProgressBar.module-BkAFfFy0.js +29 -0
  2. package/dist/Section.module-CLVHJ4yA.js +15 -0
  3. package/dist/assets/BlockQuote.css +1 -0
  4. package/dist/assets/Button.css +1 -0
  5. package/dist/assets/ColorBox.css +1 -0
  6. package/dist/assets/Dialog.css +1 -0
  7. package/dist/assets/Dimmer.css +1 -0
  8. package/dist/assets/Divider.css +1 -0
  9. package/dist/assets/Flex.css +1 -0
  10. package/dist/assets/Icon.css +6 -0
  11. package/dist/assets/Input.css +1 -0
  12. package/dist/assets/Knob.css +1 -0
  13. package/dist/assets/LabeledList.css +1 -0
  14. package/dist/assets/MenuBar.css +1 -0
  15. package/dist/assets/Modal.css +1 -0
  16. package/dist/assets/NoticeBox.css +1 -0
  17. package/dist/assets/NumberInput.css +1 -0
  18. package/dist/assets/ProgressBar.css +1 -0
  19. package/dist/assets/RoundGauge.css +1 -0
  20. package/dist/assets/Section.css +1 -0
  21. package/dist/assets/Slider.css +1 -0
  22. package/dist/assets/Stack.css +1 -0
  23. package/dist/assets/Table.css +1 -0
  24. package/dist/assets/Tabs.css +1 -0
  25. package/dist/assets/TextArea.css +1 -0
  26. package/dist/assets/Tooltip.css +1 -0
  27. package/dist/common/assets.d.ts +4 -0
  28. package/dist/common/assets.js +25 -0
  29. package/dist/common/collections.d.ts +10 -0
  30. package/dist/common/collections.js +15 -0
  31. package/dist/common/color.d.ts +25 -0
  32. package/dist/common/color.js +69 -0
  33. package/dist/common/constants.d.ts +102 -0
  34. package/dist/common/constants.js +312 -0
  35. package/dist/common/events.d.ts +33 -0
  36. package/dist/common/events.js +147 -0
  37. package/{lib/common/exhaustive.ts → dist/common/exhaustive.d.ts} +1 -3
  38. package/dist/common/exhaustive.js +6 -0
  39. package/dist/common/format.d.ts +11 -0
  40. package/dist/common/format.js +114 -0
  41. package/{lib/common/fp.ts → dist/common/fp.d.ts} +2 -16
  42. package/dist/common/fp.js +9 -0
  43. package/dist/common/hotkeys.d.ts +25 -0
  44. package/dist/common/hotkeys.js +112 -0
  45. package/dist/common/http.d.ts +4 -0
  46. package/dist/common/http.js +10 -0
  47. package/dist/common/keycodes.d.ts +85 -0
  48. package/dist/common/keycodes.js +88 -0
  49. package/{lib/common/keys.ts → dist/common/keys.d.ts} +21 -24
  50. package/dist/common/keys.js +8 -0
  51. package/dist/common/math.d.ts +39 -0
  52. package/dist/common/math.js +41 -0
  53. package/dist/common/perf.d.ts +24 -0
  54. package/dist/common/perf.js +33 -0
  55. package/dist/common/random.d.ts +16 -0
  56. package/dist/common/random.js +18 -0
  57. package/dist/common/react.d.ts +23 -0
  58. package/dist/common/react.js +30 -0
  59. package/dist/common/redux.d.ts +64 -0
  60. package/dist/common/redux.js +72 -0
  61. package/dist/common/storage.d.ts +24 -0
  62. package/dist/common/storage.js +133 -0
  63. package/dist/common/string.d.ts +65 -0
  64. package/dist/common/string.js +83 -0
  65. package/dist/common/timer.d.ts +18 -0
  66. package/dist/common/timer.js +28 -0
  67. package/dist/common/type-utils.d.ts +9 -0
  68. package/dist/common/type-utils.js +25 -0
  69. package/dist/common/uuid.d.ts +9 -0
  70. package/dist/common/uuid.js +10 -0
  71. package/dist/components/AnimatedNumber.d.ts +60 -0
  72. package/dist/components/AnimatedNumber.js +76 -0
  73. package/dist/components/Autofocus.d.ts +4 -0
  74. package/dist/components/Autofocus.js +17 -0
  75. package/dist/components/Blink.d.ts +26 -0
  76. package/dist/components/Blink.js +56 -0
  77. package/dist/components/BlockQuote.d.ts +3 -0
  78. package/dist/components/BlockQuote.js +13 -0
  79. package/dist/components/BodyZoneSelector.d.ts +28 -0
  80. package/dist/components/BodyZoneSelector.js +115 -0
  81. package/dist/components/Box.d.ts +91 -0
  82. package/dist/components/Box.js +133 -0
  83. package/dist/components/Button.d.ts +93 -0
  84. package/dist/components/Button.js +298 -0
  85. package/dist/components/ByondUi.js +73 -0
  86. package/dist/components/Chart.d.ts +28 -0
  87. package/dist/components/Chart.js +95 -0
  88. package/dist/components/Collapsible.d.ts +15 -0
  89. package/dist/components/Collapsible.js +27 -0
  90. package/dist/components/ColorBox.d.ts +8 -0
  91. package/dist/components/ColorBox.js +24 -0
  92. package/dist/components/Dialog.d.ts +24 -0
  93. package/dist/components/Dialog.js +67 -0
  94. package/dist/components/Dimmer.d.ts +3 -0
  95. package/dist/components/Dimmer.js +13 -0
  96. package/dist/components/Divider.d.ts +6 -0
  97. package/dist/components/Divider.js +22 -0
  98. package/dist/components/DmIcon.d.ts +33 -0
  99. package/dist/components/DmIcon.js +29 -0
  100. package/dist/components/DraggableControl.js +176 -0
  101. package/dist/components/Dropdown.d.ts +48 -0
  102. package/dist/components/Dropdown.js +152 -0
  103. package/dist/components/FakeTerminal.js +38 -0
  104. package/dist/components/FitText.d.ts +22 -0
  105. package/dist/components/FitText.js +63 -0
  106. package/dist/components/Flex.d.ts +93 -0
  107. package/dist/components/Flex.js +72 -0
  108. package/dist/components/Icon.d.ts +30 -0
  109. package/dist/components/Icon.js +51 -0
  110. package/dist/components/Image.d.ts +14 -0
  111. package/dist/components/Image.js +35 -0
  112. package/dist/components/InfinitePlane.js +139 -0
  113. package/dist/components/Input.d.ts +61 -0
  114. package/dist/components/Input.js +89 -0
  115. package/dist/components/KeyListener.d.ts +15 -0
  116. package/dist/components/KeyListener.js +23 -0
  117. package/dist/components/Knob.d.ts +49 -0
  118. package/dist/components/Knob.js +162 -0
  119. package/dist/components/LabeledControls.d.ts +11 -0
  120. package/dist/components/LabeledControls.js +39 -0
  121. package/dist/components/LabeledList.d.ts +57 -0
  122. package/dist/components/LabeledList.js +94 -0
  123. package/dist/components/MenuBar.d.ts +28 -0
  124. package/dist/components/MenuBar.js +174 -0
  125. package/dist/components/Modal.d.ts +3 -0
  126. package/dist/components/Modal.js +25 -0
  127. package/dist/components/NoticeBox.d.ts +20 -0
  128. package/dist/components/NoticeBox.js +49 -0
  129. package/dist/components/NumberInput.d.ts +45 -0
  130. package/dist/components/NumberInput.js +221 -0
  131. package/dist/components/Popper.d.ts +27 -0
  132. package/dist/components/Popper.js +177 -0
  133. package/dist/components/ProgressBar.d.ts +46 -0
  134. package/dist/components/ProgressBar.js +37 -0
  135. package/dist/components/RestrictedInput.js +155 -0
  136. package/dist/components/RoundGauge.d.ts +53 -0
  137. package/dist/components/RoundGauge.js +147 -0
  138. package/dist/components/Section.d.ts +63 -0
  139. package/dist/components/Section.js +62 -0
  140. package/dist/components/Slider.d.ts +46 -0
  141. package/dist/components/Slider.js +124 -0
  142. package/dist/components/Stack.d.ts +27 -0
  143. package/dist/components/Stack.js +67 -0
  144. package/dist/components/StyleableSection.d.ts +11 -0
  145. package/dist/components/StyleableSection.js +16 -0
  146. package/dist/components/Table.d.ts +29 -0
  147. package/dist/components/Table.js +67 -0
  148. package/dist/components/Tabs.d.ts +23 -0
  149. package/dist/components/Tabs.js +89 -0
  150. package/dist/components/TextArea.d.ts +39 -0
  151. package/dist/components/TextArea.js +118 -0
  152. package/dist/components/TimeDisplay.js +34 -0
  153. package/dist/components/Tooltip.d.ts +29 -0
  154. package/dist/components/Tooltip.js +83 -0
  155. package/dist/components/TrackOutsideClicks.d.ts +13 -0
  156. package/dist/components/TrackOutsideClicks.js +24 -0
  157. package/dist/components/VirtualList.d.ts +8 -0
  158. package/dist/components/VirtualList.js +34 -0
  159. package/dist/components/index.js +92 -0
  160. package/dist/popper-CiqSDJTE.js +906 -0
  161. package/package.json +8 -10
  162. package/lib/common/assets.ts +0 -38
  163. package/lib/common/collections.ts +0 -27
  164. package/lib/common/color.ts +0 -88
  165. package/lib/common/constants.ts +0 -349
  166. package/lib/common/events.ts +0 -262
  167. package/lib/common/format.ts +0 -167
  168. package/lib/common/hotkeys.ts +0 -207
  169. package/lib/common/http.ts +0 -16
  170. package/lib/common/keycodes.ts +0 -86
  171. package/lib/common/math.ts +0 -76
  172. package/lib/common/perf.ts +0 -72
  173. package/lib/common/random.ts +0 -32
  174. package/lib/common/react.ts +0 -59
  175. package/lib/common/redux.ts +0 -187
  176. package/lib/common/storage.ts +0 -207
  177. package/lib/common/string.ts +0 -169
  178. package/lib/common/timer.ts +0 -63
  179. package/lib/common/type-utils.ts +0 -41
  180. package/lib/common/types.d.ts +0 -12
  181. package/lib/common/uuid.ts +0 -18
  182. package/lib/components/AnimatedNumber.tsx +0 -180
  183. package/lib/components/Autofocus.tsx +0 -23
  184. package/lib/components/Blink.tsx +0 -91
  185. package/lib/components/BlockQuote.tsx +0 -9
  186. package/lib/components/BodyZoneSelector.tsx +0 -149
  187. package/lib/components/Box.tsx +0 -252
  188. package/lib/components/Button.tsx +0 -425
  189. package/lib/components/ByondUi.jsx +0 -110
  190. package/lib/components/Chart.tsx +0 -155
  191. package/lib/components/Collapsible.tsx +0 -43
  192. package/lib/components/ColorBox.tsx +0 -29
  193. package/lib/components/Dialog.tsx +0 -81
  194. package/lib/components/Dimmer.tsx +0 -13
  195. package/lib/components/Divider.tsx +0 -20
  196. package/lib/components/DmIcon.tsx +0 -86
  197. package/lib/components/DraggableControl.jsx +0 -276
  198. package/lib/components/Dropdown.tsx +0 -246
  199. package/lib/components/FakeTerminal.jsx +0 -52
  200. package/lib/components/FitText.tsx +0 -99
  201. package/lib/components/Flex.tsx +0 -159
  202. package/lib/components/Icon.tsx +0 -95
  203. package/lib/components/Image.tsx +0 -54
  204. package/lib/components/InfinitePlane.jsx +0 -192
  205. package/lib/components/Input.tsx +0 -176
  206. package/lib/components/KeyListener.tsx +0 -40
  207. package/lib/components/Knob.tsx +0 -178
  208. package/lib/components/LabeledControls.tsx +0 -44
  209. package/lib/components/LabeledList.tsx +0 -154
  210. package/lib/components/MenuBar.tsx +0 -228
  211. package/lib/components/Modal.tsx +0 -23
  212. package/lib/components/NoticeBox.tsx +0 -45
  213. package/lib/components/NumberInput.tsx +0 -328
  214. package/lib/components/Popper.tsx +0 -100
  215. package/lib/components/ProgressBar.tsx +0 -105
  216. package/lib/components/RestrictedInput.jsx +0 -301
  217. package/lib/components/RoundGauge.tsx +0 -180
  218. package/lib/components/Section.tsx +0 -120
  219. package/lib/components/Slider.tsx +0 -169
  220. package/lib/components/Stack.tsx +0 -96
  221. package/lib/components/StyleableSection.tsx +0 -33
  222. package/lib/components/Table.tsx +0 -84
  223. package/lib/components/Tabs.tsx +0 -89
  224. package/lib/components/TextArea.tsx +0 -182
  225. package/lib/components/TimeDisplay.jsx +0 -64
  226. package/lib/components/Tooltip.tsx +0 -152
  227. package/lib/components/TrackOutsideClicks.tsx +0 -35
  228. package/lib/components/VirtualList.tsx +0 -69
  229. package/lib/styles/atomic/candystripe.scss +0 -8
  230. package/lib/styles/atomic/centered-image.scss +0 -7
  231. package/lib/styles/atomic/color.scss +0 -21
  232. package/lib/styles/atomic/debug-layout.scss +0 -17
  233. package/lib/styles/atomic/fit-text.scss +0 -14
  234. package/lib/styles/atomic/links.scss +0 -12
  235. package/lib/styles/atomic/outline.scss +0 -47
  236. package/lib/styles/atomic/text.scss +0 -44
  237. package/lib/styles/base.scss +0 -32
  238. package/lib/styles/colors.scss +0 -92
  239. package/lib/styles/components/BlockQuote.module.scss +0 -20
  240. package/lib/styles/components/BlockQuote.module.scss.d.ts +0 -4
  241. package/lib/styles/components/Button.module.scss +0 -157
  242. package/lib/styles/components/Button.module.scss.d.ts +0 -46
  243. package/lib/styles/components/ColorBox.module.scss +0 -12
  244. package/lib/styles/components/ColorBox.module.scss.d.ts +0 -4
  245. package/lib/styles/components/Dialog.module.scss +0 -60
  246. package/lib/styles/components/Dialog.module.scss.d.ts +0 -10
  247. package/lib/styles/components/Dimmer.module.scss +0 -22
  248. package/lib/styles/components/Dimmer.module.scss.d.ts +0 -4
  249. package/lib/styles/components/Divider.module.scss +0 -27
  250. package/lib/styles/components/Divider.module.scss.d.ts +0 -6
  251. package/lib/styles/components/Dropdown.scss +0 -72
  252. package/lib/styles/components/Flex.module.scss +0 -13
  253. package/lib/styles/components/Flex.module.scss.d.ts +0 -5
  254. package/lib/styles/components/Icon.module.scss +0 -25
  255. package/lib/styles/components/Icon.module.scss.d.ts +0 -5
  256. package/lib/styles/components/Input.module.scss +0 -64
  257. package/lib/styles/components/Input.module.scss.d.ts +0 -8
  258. package/lib/styles/components/Knob.module.scss +0 -131
  259. package/lib/styles/components/Knob.module.scss.d.ts +0 -33
  260. package/lib/styles/components/LabeledList.module.scss +0 -49
  261. package/lib/styles/components/LabeledList.module.scss.d.ts +0 -8
  262. package/lib/styles/components/MenuBar.module.scss +0 -75
  263. package/lib/styles/components/MenuBar.module.scss.d.ts +0 -14
  264. package/lib/styles/components/Modal.module.scss +0 -14
  265. package/lib/styles/components/Modal.module.scss.d.ts +0 -4
  266. package/lib/styles/components/NoticeBox.module.scss +0 -65
  267. package/lib/styles/components/NoticeBox.module.scss.d.ts +0 -27
  268. package/lib/styles/components/NumberInput.module.scss +0 -71
  269. package/lib/styles/components/NumberInput.module.scss.d.ts +0 -9
  270. package/lib/styles/components/ProgressBar.module.scss +0 -63
  271. package/lib/styles/components/ProgressBar.module.scss.d.ts +0 -27
  272. package/lib/styles/components/RoundGauge.module.scss +0 -85
  273. package/lib/styles/components/RoundGauge.module.scss.d.ts +0 -49
  274. package/lib/styles/components/Section.module.scss +0 -130
  275. package/lib/styles/components/Section.module.scss.d.ts +0 -13
  276. package/lib/styles/components/Slider.module.scss +0 -54
  277. package/lib/styles/components/Slider.module.scss.d.ts +0 -8
  278. package/lib/styles/components/Stack.module.scss +0 -60
  279. package/lib/styles/components/Stack.module.scss.d.ts +0 -12
  280. package/lib/styles/components/Table.module.scss +0 -44
  281. package/lib/styles/components/Table.module.scss.d.ts +0 -10
  282. package/lib/styles/components/Tabs.module.scss +0 -144
  283. package/lib/styles/components/Tabs.module.scss.d.ts +0 -35
  284. package/lib/styles/components/TextArea.module.scss +0 -86
  285. package/lib/styles/components/TextArea.module.scss.d.ts +0 -11
  286. package/lib/styles/components/Tooltip.module.scss +0 -24
  287. package/lib/styles/components/Tooltip.module.scss.d.ts +0 -4
  288. package/lib/styles/functions.scss +0 -79
  289. package/lib/styles/input.scss +0 -9
  290. package/lib/styles/main.scss +0 -20
  291. package/lib/styles/reset.scss +0 -68
  292. /package/{lib/components/index.ts → dist/components/index.d.ts} +0 -0
@@ -0,0 +1,155 @@
1
+ import { jsxs as E, jsx as h } from "react/jsx-runtime";
2
+ import { KEY_ENTER as I, KEY_ESCAPE as S } from "../common/keycodes.js";
3
+ import { clamp as m } from "../common/math.js";
4
+ import { classes as v } from "../common/react.js";
5
+ import { Component as F, createRef as N } from "react";
6
+ import { Box as C } from "./Box.js";
7
+ const g = 0, x = 1e4;
8
+ function M(e, n, t, s) {
9
+ const i = n || g, o = t || t === 0 ? t : x;
10
+ let r = s ? e.replace(/[^\-\d.]/g, "") : e.replace(/[^\-\d]/g, "");
11
+ return s && (r = b(r, i), r = d(".", r)), n < 0 ? (r = _(r), r = d("-", r)) : r = r.replaceAll("-", ""), i <= 1 && o >= 0 ? V(r, i, o, s) : r;
12
+ }
13
+ const V = (e, n, t, s) => {
14
+ let i = s ? parseFloat(e) : parseInt(e, 10);
15
+ if (!isNaN(i) && (e.slice(-1) !== "." || i < Math.floor(n))) {
16
+ let o = m(i, n, t);
17
+ if (i !== o)
18
+ return String(o);
19
+ }
20
+ return e;
21
+ };
22
+ function _(e) {
23
+ let n = e, t = e.indexOf("-");
24
+ return t > 0 ? (e = e.replace("-", ""), n = "-".concat(e)) : t === 0 && e.indexOf("-", t + 1) > 0 && (n = e.replaceAll("-", "")), n;
25
+ }
26
+ function b(e, n) {
27
+ let t = e, s = Math.sign(n) * Math.floor(Math.abs(n));
28
+ return e.indexOf(".") === 0 ? t = String(s).concat(e) : e.indexOf("-") === 0 && e.indexOf(".") === 1 && (t = s + ".".concat(e.slice(2))), t;
29
+ }
30
+ function d(e, n) {
31
+ const t = n.indexOf(e), s = n.length;
32
+ let i = n;
33
+ if (t !== -1 && t < s - 1) {
34
+ let o = n.slice(t + 1, s);
35
+ o = o.replaceAll(e, ""), i = n.slice(0, t + 1).concat(o);
36
+ }
37
+ return i;
38
+ }
39
+ function f(e, n, t, s) {
40
+ const i = n || g, o = t || t === 0 ? t : x;
41
+ if (!e || !e.length)
42
+ return String(i);
43
+ let r = s ? parseFloat(e.replace(/[^\-\d.]/g, "")) : parseInt(e.replace(/[^\-\d]/g, ""), 10);
44
+ return isNaN(r) ? String(i) : String(m(r, i, o));
45
+ }
46
+ class B extends F {
47
+ constructor(n) {
48
+ super(n), this.inputRef = N(), this.state = {
49
+ editing: !1
50
+ }, this.handleBlur = (t) => {
51
+ const { maxValue: s, minValue: i, onBlur: o, allowFloats: r } = this.props, { editing: l } = this.state;
52
+ l && this.setEditing(!1);
53
+ const a = f(
54
+ t.target.value,
55
+ i,
56
+ s,
57
+ r
58
+ );
59
+ o && o(t, +a);
60
+ }, this.handleChange = (t) => {
61
+ const { maxValue: s, minValue: i, onChange: o, allowFloats: r } = this.props;
62
+ t.target.value = M(
63
+ t.target.value,
64
+ i,
65
+ s,
66
+ r
67
+ ), o && o(t, +t.target.value);
68
+ }, this.handleFocus = (t) => {
69
+ const { editing: s } = this.state;
70
+ s || this.setEditing(!0);
71
+ }, this.handleInput = (t) => {
72
+ const { editing: s } = this.state, { onInput: i } = this.props;
73
+ s || this.setEditing(!0), i && i(t, +t.target.value);
74
+ }, this.handleKeyDown = (t) => {
75
+ const { maxValue: s, minValue: i, onChange: o, onEnter: r, allowFloats: l } = this.props;
76
+ if (t.keyCode === I) {
77
+ const a = f(
78
+ t.target.value,
79
+ i,
80
+ s,
81
+ l
82
+ );
83
+ this.setEditing(!1), o && o(t, +a), r && r(t, +a), t.target.blur();
84
+ return;
85
+ }
86
+ if (t.keyCode === S) {
87
+ if (this.props.onEscape) {
88
+ this.props.onEscape(t);
89
+ return;
90
+ }
91
+ this.setEditing(!1), t.target.value = this.props.value, t.target.blur();
92
+ return;
93
+ }
94
+ };
95
+ }
96
+ componentDidMount() {
97
+ var r;
98
+ const { maxValue: n, minValue: t, allowFloats: s } = this.props, i = (r = this.props.value) == null ? void 0 : r.toString(), o = this.inputRef.current;
99
+ o && (o.value = f(
100
+ i,
101
+ t,
102
+ n,
103
+ s
104
+ )), (this.props.autoFocus || this.props.autoSelect) && setTimeout(() => {
105
+ o.focus(), this.props.autoSelect && o.select();
106
+ }, 1);
107
+ }
108
+ componentDidUpdate(n, t) {
109
+ var p, c;
110
+ const { maxValue: s, minValue: i, allowFloats: o } = this.props, { editing: r } = this.state, l = (p = n.value) == null ? void 0 : p.toString(), a = (c = this.props.value) == null ? void 0 : c.toString(), u = this.inputRef.current;
111
+ u && !r && a !== l && a !== u.value && (u.value = f(
112
+ a,
113
+ i,
114
+ s,
115
+ o
116
+ ));
117
+ }
118
+ setEditing(n) {
119
+ this.setState({ editing: n });
120
+ }
121
+ render() {
122
+ const { props: n } = this, { onChange: t, onEnter: s, onInput: i, onBlur: o, value: r, ...l } = n, { className: a, fluid: u, monospace: p, ...c } = l;
123
+ return /* @__PURE__ */ E(
124
+ C,
125
+ {
126
+ className: v([
127
+ "Input",
128
+ u && "Input--fluid",
129
+ p && "Input--monospace",
130
+ a
131
+ ]),
132
+ ...c,
133
+ children: [
134
+ /* @__PURE__ */ h("div", { className: "Input__baseline", children: "." }),
135
+ /* @__PURE__ */ h(
136
+ "input",
137
+ {
138
+ className: "Input__input",
139
+ onChange: this.handleChange,
140
+ onInput: this.handleInput,
141
+ onFocus: this.handleFocus,
142
+ onBlur: this.handleBlur,
143
+ onKeyDown: this.handleKeyDown,
144
+ ref: this.inputRef,
145
+ type: "number | string"
146
+ }
147
+ )
148
+ ]
149
+ }
150
+ );
151
+ }
152
+ }
153
+ export {
154
+ B as RestrictedInput
155
+ };
@@ -0,0 +1,53 @@
1
+ import { BoxProps } from './Box';
2
+
3
+ type Props = {
4
+ /** The current value of the metric. */
5
+ value: number;
6
+ } & Partial<{
7
+ /** When provided, will cause an alert symbol on the gauge to begin flashing in the color upon which the needle currently rests, as defined in `ranges`. */
8
+ alertAfter: number;
9
+ /** As with alertAfter, but alerts below a value. If both are set, and alertAfter comes earlier, the alert will only flash when the needle is between both values. Otherwise, the alert will flash when on the active side of either threshold. */
10
+ alertBefore: number;
11
+ /** CSS style. */
12
+ className: string;
13
+ /** When provided, will be used to format the value of the metric for display. */
14
+ format: (value: number) => string;
15
+ /** The upper bound of the gauge. */
16
+ maxValue: number;
17
+ /** The lower bound of the gauge. */
18
+ minValue: number;
19
+ /** Provide regions of the gauge to color between two specified values of the metric. */
20
+ ranges: Record<string, [number, number]>;
21
+ /** When provided scales the gauge. */
22
+ size: number;
23
+ /** Custom css */
24
+ style: React.CSSProperties;
25
+ }> & BoxProps;
26
+ /**
27
+ * ## RoundGauge
28
+ * The RoundGauge component provides a visual representation of a single metric, as well as being capable of showing
29
+ * informational or cautionary boundaries related to that metric.
30
+ *
31
+ * @example
32
+ * ```tsx
33
+ * <RoundGauge
34
+ * size={1.75}
35
+ * value={tankPressure}
36
+ * minValue={0}
37
+ * maxValue={pressureLimit}
38
+ * alertAfter={pressureLimit * 0.7}
39
+ * ranges={{
40
+ * good: [0, pressureLimit * 0.7],
41
+ * average: [pressureLimit * 0.7, pressureLimit * 0.85],
42
+ * bad: [pressureLimit * 0.85, pressureLimit],
43
+ * }}
44
+ * format={formatPressure}
45
+ * />
46
+ * ```
47
+ *
48
+ * The alert on the gauge is optional, and will only be shown if the `alertAfter` prop is defined. When defined, the alert
49
+ * will begin to flash the respective color upon which the needle currently rests, as defined in the `ranges` prop.
50
+ *
51
+ */
52
+ export declare function RoundGauge(props: Props): import("react/jsx-runtime").JSX.Element;
53
+ export {};
@@ -0,0 +1,147 @@
1
+ import { jsxs as k, jsx as _ } from "react/jsx-runtime";
2
+ import { scale as d, keyOfMatchingRange as M, clamp01 as N } from "../common/math.js";
3
+ import { classes as u } from "../common/react.js";
4
+ import { AnimatedNumber as A } from "./AnimatedNumber.js";
5
+ import { Box as B, computeBoxClassName as G, computeBoxProps as j } from "./Box.js";
6
+ import '../assets/RoundGauge.css';const F = "_roundGauge_gktag_17", L = "_ringTrack_gktag_25", T = "_ringFill_gktag_33", V = "_needle_gktag_41", O = "_needleLine_gktag_46", R = "_needleMiddle_gktag_47", Z = "_alert_gktag_51", z = "_max_gktag_59", P = "_color__black_gktag_63", S = "_color__white_gktag_67", $ = "_color__red_gktag_71", D = "_color__orange_gktag_75", E = "_color__yellow_gktag_79", I = "_color__olive_gktag_83", q = "_color__green_gktag_87", H = "_color__teal_gktag_91", J = "_color__blue_gktag_95", K = "_color__violet_gktag_99", Q = "_color__purple_gktag_103", U = "_color__pink_gktag_107", W = "_color__brown_gktag_111", X = "_color__grey_gktag_115", Y = "_color__good_gktag_123", __ = "_color__average_gktag_127", e_ = "_color__bad_gktag_131", l_ = "_color__label_gktag_135", o_ = "_alert__black_gktag_139", r_ = "_alertAnim_gktag_1", t_ = "_alert__white_gktag_145", a_ = "_alert__red_gktag_151", c_ = "_alert__orange_gktag_157", g_ = "_alert__yellow_gktag_163", n_ = "_alert__olive_gktag_169", s_ = "_alert__green_gktag_175", i_ = "_alert__teal_gktag_181", k_ = "_alert__blue_gktag_187", d_ = "_alert__violet_gktag_193", u_ = "_alert__purple_gktag_199", m_ = "_alert__pink_gktag_205", p_ = "_alert__brown_gktag_211", b_ = "_alert__grey_gktag_217", y_ = "_alert__good_gktag_229", h_ = "_alert__average_gktag_235", f_ = "_alert__bad_gktag_241", v_ = "_alert__label_gktag_247", e = {
7
+ roundGauge: F,
8
+ ringTrack: L,
9
+ ringFill: T,
10
+ needle: V,
11
+ needleLine: O,
12
+ needleMiddle: R,
13
+ alert: Z,
14
+ max: z,
15
+ color__black: P,
16
+ color__white: S,
17
+ color__red: $,
18
+ color__orange: D,
19
+ color__yellow: E,
20
+ color__olive: I,
21
+ color__green: q,
22
+ color__teal: H,
23
+ color__blue: J,
24
+ color__violet: K,
25
+ color__purple: Q,
26
+ color__pink: U,
27
+ color__brown: W,
28
+ color__grey: X,
29
+ "color__light-grey": "_color__light-grey_gktag_119",
30
+ color__good: Y,
31
+ color__average: __,
32
+ color__bad: e_,
33
+ color__label: l_,
34
+ alert__black: o_,
35
+ alertAnim: r_,
36
+ alert__white: t_,
37
+ alert__red: a_,
38
+ alert__orange: c_,
39
+ alert__yellow: g_,
40
+ alert__olive: n_,
41
+ alert__green: s_,
42
+ alert__teal: i_,
43
+ alert__blue: k_,
44
+ alert__violet: d_,
45
+ alert__purple: u_,
46
+ alert__pink: m_,
47
+ alert__brown: p_,
48
+ alert__grey: b_,
49
+ "alert__light-grey": "_alert__light-grey_gktag_223",
50
+ alert__good: y_,
51
+ alert__average: h_,
52
+ alert__bad: f_,
53
+ alert__label: v_
54
+ };
55
+ function A_(y) {
56
+ const {
57
+ alertAfter: o,
58
+ alertBefore: r,
59
+ className: h,
60
+ format: f,
61
+ maxValue: n = 1,
62
+ minValue: s = 1,
63
+ ranges: a,
64
+ size: v = 1,
65
+ style: w,
66
+ value: l,
67
+ ...m
68
+ } = y, C = d(l, s, n), p = N(C), c = a ? {} : { primary: [0, 1] };
69
+ a && Object.keys(a).forEach((t) => {
70
+ const g = a[t];
71
+ c[t] = [
72
+ d(g[0], s, n),
73
+ d(g[1], s, n)
74
+ ];
75
+ });
76
+ function x() {
77
+ return o && r && l > o && l < r || o && l > o ? !0 : !!(r && l < r);
78
+ }
79
+ const b = x() && M(p, c);
80
+ return /* @__PURE__ */ k(B, { inline: !0, children: [
81
+ /* @__PURE__ */ _(
82
+ "div",
83
+ {
84
+ className: u([
85
+ e.roundGauge,
86
+ h,
87
+ G(m)
88
+ ]),
89
+ ...j({
90
+ style: {
91
+ fontSize: v + "em",
92
+ ...w
93
+ },
94
+ ...m
95
+ }),
96
+ children: /* @__PURE__ */ k("svg", { viewBox: "0 0 100 50", children: [
97
+ (o || r) && /* @__PURE__ */ _(
98
+ "g",
99
+ {
100
+ className: u([
101
+ e.alert,
102
+ b ? e["alert__" + b] : ""
103
+ ]),
104
+ children: /* @__PURE__ */ _("path", { d: "M48.211,14.578C48.55,13.9 49.242,13.472 50,13.472C50.758,13.472 51.45,13.9 51.789,14.578C54.793,20.587 60.795,32.589 63.553,38.106C63.863,38.726 63.83,39.462 63.465,40.051C63.101,40.641 62.457,41 61.764,41C55.996,41 44.004,41 38.236,41C37.543,41 36.899,40.641 36.535,40.051C36.17,39.462 36.137,38.726 36.447,38.106C39.205,32.589 45.207,20.587 48.211,14.578ZM50,34.417C51.426,34.417 52.583,35.574 52.583,37C52.583,38.426 51.426,39.583 50,39.583C48.574,39.583 47.417,38.426 47.417,37C47.417,35.574 48.574,34.417 50,34.417ZM50,32.75C50,32.75 53,31.805 53,22.25C53,20.594 51.656,19.25 50,19.25C48.344,19.25 47,20.594 47,22.25C47,31.805 50,32.75 50,32.75Z" })
105
+ }
106
+ ),
107
+ /* @__PURE__ */ _("g", { children: /* @__PURE__ */ _("circle", { className: e.ringTrack, cx: "50", cy: "50", r: "45" }) }),
108
+ /* @__PURE__ */ _("g", { children: Object.keys(c).map((t, g) => {
109
+ const i = c[t];
110
+ return /* @__PURE__ */ _(
111
+ "circle",
112
+ {
113
+ className: u([e.ringFill, e["color__" + t]]),
114
+ style: {
115
+ strokeDashoffset: Math.max(
116
+ (2 - (i[1] - i[0])) * Math.PI * 50,
117
+ 0
118
+ )
119
+ },
120
+ transform: `rotate(${180 + 180 * i[0]} 50 50)`,
121
+ cx: "50",
122
+ cy: "50",
123
+ r: "45"
124
+ },
125
+ g
126
+ );
127
+ }) }),
128
+ /* @__PURE__ */ k(
129
+ "g",
130
+ {
131
+ className: e.needle,
132
+ transform: `rotate(${p * 180 - 90} 50 50)`,
133
+ children: [
134
+ /* @__PURE__ */ _("polygon", { className: e.needleLine, points: "46,50 50,0 54,50" }),
135
+ /* @__PURE__ */ _("circle", { className: e.needleMiddle, cx: "50", cy: "50", r: "8" })
136
+ ]
137
+ }
138
+ )
139
+ ] })
140
+ }
141
+ ),
142
+ /* @__PURE__ */ _(A, { value: l, format: f })
143
+ ] });
144
+ }
145
+ export {
146
+ A_ as RoundGauge
147
+ };
@@ -0,0 +1,63 @@
1
+ import { ReactNode } from 'react';
2
+
3
+ /**
4
+ * ## Section
5
+ * Section is a surface that displays content and actions on a single topic.
6
+ *
7
+ * They should be easy to scan for relevant and actionable information.
8
+ * Elements, like text and images, should be placed in them in a way that
9
+ * clearly indicates hierarchy.
10
+ *
11
+ * Sections can now be nested, and will automatically font size of the
12
+ * header according to their nesting level. Previously this was done via `level`
13
+ * prop, but now it is automatically calculated.
14
+ *
15
+ * Section can also be titled to clearly define its purpose.
16
+ *
17
+ * ```tsx
18
+ * <Section title="Cargo">Here you can order supply crates.</Section>
19
+ * ```
20
+ *
21
+ * If you want to have a button on the right side of an section title
22
+ * (for example, to perform some sort of action), there is a way to do that:
23
+ *
24
+ * ```tsx
25
+ * <Section title="Cargo" buttons={<Button>Send shuttle</Button>}>
26
+ * Here you can order supply crates.
27
+ * </Section>
28
+ * ```
29
+ */
30
+ export declare const Section: import('react').ForwardRefExoticComponent<Partial<{
31
+ /** Buttons to render aside the section title. */
32
+ buttons: ReactNode;
33
+ /** id to assosiate with the parent div element used by this section, for uses with procs like getElementByID */
34
+ container_id: string;
35
+ /** If true, fills all available vertical space. */
36
+ fill: boolean;
37
+ /** If true, removes all section padding. */
38
+ fitted: boolean;
39
+ /** @member Callback function for the `scroll` event */
40
+ onScroll: ((this: GlobalEventHandlers, ev: Event) => any) | null;
41
+ /** Shows or hides the scrollbar. */
42
+ scrollable: boolean;
43
+ /** Shows or hides the horizontal scrollbar. */
44
+ scrollableHorizontal: boolean;
45
+ /** Title of the section. */
46
+ title: ReactNode;
47
+ }> & Partial<{
48
+ as: string;
49
+ children: ReactNode;
50
+ className: string | import('../common/react').BooleanLike;
51
+ style: import('react').CSSProperties;
52
+ }> & Partial<Record<"bold" | "italic" | "nowrap" | "fillPositionedParent" | "inline" | "preserveWhitespace", boolean>> & Partial<Record<"fontWeight" | "textAlign" | "bottom" | "fontFamily" | "fontSize" | "height" | "left" | "maxHeight" | "maxWidth" | "minHeight" | "minWidth" | "opacity" | "overflow" | "overflowX" | "overflowY" | "position" | "right" | "top" | "verticalAlign" | "width" | "color" | "backgroundColor" | "align" | "lineHeight" | "m" | "mb" | "ml" | "mr" | "mt" | "mx" | "my" | "p" | "pb" | "pl" | "pr" | "pt" | "px" | "py" | "textColor", string | import('../common/react').BooleanLike>> & Partial<{
53
+ onClick: import('react').MouseEventHandler<HTMLDivElement>;
54
+ onContextMenu: import('react').MouseEventHandler<HTMLDivElement>;
55
+ onDoubleClick: import('react').MouseEventHandler<HTMLDivElement>;
56
+ onKeyDown: import('react').KeyboardEventHandler<HTMLDivElement>;
57
+ onKeyUp: import('react').KeyboardEventHandler<HTMLDivElement>;
58
+ onMouseDown: import('react').MouseEventHandler<HTMLDivElement>;
59
+ onMouseMove: import('react').MouseEventHandler<HTMLDivElement>;
60
+ onMouseOver: import('react').MouseEventHandler<HTMLDivElement>;
61
+ onMouseUp: import('react').MouseEventHandler<HTMLDivElement>;
62
+ onScroll: import('react').UIEventHandler<HTMLDivElement>;
63
+ }> & import('react').RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,62 @@
1
+ import { jsxs as r, jsx as s } from "react/jsx-runtime";
2
+ import { forwardRef as S, useEffect as j } from "react";
3
+ import { addScrollableNode as z, removeScrollableNode as B } from "../common/events.js";
4
+ import { classes as H, canRender as m } from "../common/react.js";
5
+ import { s as t } from "../Section.module-CLVHJ4yA.js";
6
+ import { computeBoxClassName as T, computeBoxProps as y } from "./Box.js";
7
+ const q = S(
8
+ (a, l) => {
9
+ const {
10
+ buttons: c,
11
+ children: u,
12
+ className: p,
13
+ fill: N,
14
+ fitted: b,
15
+ onScroll: h,
16
+ scrollable: i,
17
+ scrollableHorizontal: e,
18
+ title: n,
19
+ container_id: v,
20
+ ...o
21
+ } = a, x = m(n) || m(c);
22
+ return j(() => {
23
+ if (l != null && l.current && !(!i && !e))
24
+ return z(l.current), () => {
25
+ l != null && l.current && B(l.current);
26
+ };
27
+ }, []), /* @__PURE__ */ r(
28
+ "div",
29
+ {
30
+ id: v || "",
31
+ className: H([
32
+ t.section,
33
+ N && t.fill,
34
+ b && t.fitted,
35
+ i && t.scrollable,
36
+ e && t.scrollableHorizontal,
37
+ p,
38
+ T(o)
39
+ ]),
40
+ ...y(o),
41
+ children: [
42
+ x && /* @__PURE__ */ r("div", { className: t.title, children: [
43
+ /* @__PURE__ */ s("span", { className: t.titleText, children: n }),
44
+ /* @__PURE__ */ s("div", { className: t.buttons, children: c })
45
+ ] }),
46
+ /* @__PURE__ */ s("div", { className: t.rest, children: /* @__PURE__ */ s(
47
+ "div",
48
+ {
49
+ className: t.content,
50
+ onScroll: h,
51
+ ref: l,
52
+ children: u
53
+ }
54
+ ) })
55
+ ]
56
+ }
57
+ );
58
+ }
59
+ );
60
+ export {
61
+ q as Section
62
+ };
@@ -0,0 +1,46 @@
1
+ import { PropsWithChildren } from 'react';
2
+ import { BoxProps } from './Box';
3
+
4
+ type Props = {
5
+ /** Highest possible value. */
6
+ maxValue: number;
7
+ /** Lowest possible value. */
8
+ minValue: number;
9
+ /** Value itself, controls the position of the cursor. */
10
+ value: number;
11
+ } & Partial<{
12
+ /** Animates the value if it was changed externally. */
13
+ animated: boolean;
14
+ /** Custom css */
15
+ className: string;
16
+ /** Color of the slider. */
17
+ color: string;
18
+ /** If set, this value will be used to set the fill percentage of the progress bar filler independently of the main value. */
19
+ fillValue: number;
20
+ /** Format value using this function before displaying it. */
21
+ format: (value: number) => string;
22
+ /** Adjust value by this amount when dragging the input. */
23
+ onChange: (event: Event, value: number) => void;
24
+ /** An event, which fires when you release the input, or successfully enter a number. */
25
+ onDrag: (event: Event, value: number) => void;
26
+ /** Applies a `color` to the slider based on whether the value lands in the range between `from` and `to`. */
27
+ ranges: Record<string, [number, number]>;
28
+ /** Screen distance mouse needs to travel to adjust value by one `step`. */
29
+ step: number;
30
+ /** A number in milliseconds, for which the input will hold off from updating while events propagate through the backend. Default is about 250ms, increase it if you still see flickering. */
31
+ stepPixelSize: number;
32
+ /** Adjust value by this amount when dragging the input. */
33
+ suppressFlicker: boolean;
34
+ /** Unit to display to the right of value. */
35
+ unit: string;
36
+ }> & BoxProps & PropsWithChildren;
37
+ /**
38
+ * ## Slider
39
+ * A horizontal, progressbar-like control which allows dialing
40
+ * in precise values by dragging it left and right.
41
+ *
42
+ * Single click opens an input box to manually type in a number.
43
+ *
44
+ */
45
+ export declare function Slider(props: Props): import("react/jsx-runtime").JSX.Element;
46
+ export {};
@@ -0,0 +1,124 @@
1
+ import { jsx as s, jsxs as m } from "react/jsx-runtime";
2
+ import { keyOfMatchingRange as R, clamp01 as t, scale as f } from "../common/math.js";
3
+ import { classes as _ } from "../common/react.js";
4
+ import { s as e } from "../ProgressBar.module-BkAFfFy0.js";
5
+ import { computeBoxClassName as $, computeBoxProps as q } from "./Box.js";
6
+ import { DraggableControl as A } from "./DraggableControl.js";
7
+ import '../assets/Slider.css';const G = "_slider_1assx_9", H = "_cursorOffset_1assx_13", I = "_cursor_1assx_13", J = "_pointer_1assx_30", K = "_popupValue_1assx_41", a = {
8
+ slider: G,
9
+ cursorOffset: H,
10
+ cursor: I,
11
+ pointer: J,
12
+ popupValue: K
13
+ };
14
+ function Y(h) {
15
+ const {
16
+ // Draggable props (passthrough)
17
+ animated: v,
18
+ format: g,
19
+ maxValue: o,
20
+ minValue: r,
21
+ onChange: x,
22
+ onDrag: V,
23
+ step: y,
24
+ stepPixelSize: N,
25
+ suppressFlicker: C,
26
+ unit: D,
27
+ value: O,
28
+ // Own props
29
+ className: w,
30
+ fillValue: l,
31
+ color: M,
32
+ ranges: B = {},
33
+ children: i,
34
+ ...c
35
+ } = h, F = i !== void 0;
36
+ return /* @__PURE__ */ s(
37
+ A,
38
+ {
39
+ dragMatrix: [1, 0],
40
+ animated: v,
41
+ format: g,
42
+ maxValue: o,
43
+ minValue: r,
44
+ onChange: x,
45
+ onDrag: V,
46
+ step: y,
47
+ stepPixelSize: N,
48
+ suppressFlicker: C,
49
+ unit: D,
50
+ value: O,
51
+ children: (S) => {
52
+ const {
53
+ displayElement: n,
54
+ displayValue: p,
55
+ dragging: j,
56
+ handleDragStart: k,
57
+ inputElement: E,
58
+ value: P
59
+ } = S, b = l != null, u = f(
60
+ l ?? p,
61
+ r,
62
+ o
63
+ ), d = f(p, r, o), z = M || R(l ?? P, B) || "default";
64
+ return /* @__PURE__ */ m(
65
+ "div",
66
+ {
67
+ className: _([
68
+ a.slider,
69
+ e.progressBar,
70
+ e["color__" + z],
71
+ w,
72
+ $(c)
73
+ ]),
74
+ ...q(c),
75
+ onMouseDown: k,
76
+ children: [
77
+ /* @__PURE__ */ s(
78
+ "div",
79
+ {
80
+ className: _([
81
+ e.fill,
82
+ b && e.fill__animated
83
+ ]),
84
+ style: {
85
+ width: t(u) * 100 + "%",
86
+ opacity: 0.4
87
+ }
88
+ }
89
+ ),
90
+ /* @__PURE__ */ s(
91
+ "div",
92
+ {
93
+ className: e.fill,
94
+ style: {
95
+ width: t(Math.min(u, d)) * 100 + "%"
96
+ }
97
+ }
98
+ ),
99
+ /* @__PURE__ */ m(
100
+ "div",
101
+ {
102
+ className: a.cursorOffset,
103
+ style: {
104
+ width: t(d) * 100 + "%"
105
+ },
106
+ children: [
107
+ /* @__PURE__ */ s("div", { className: a.cursor }),
108
+ /* @__PURE__ */ s("div", { className: a.pointer }),
109
+ j && /* @__PURE__ */ s("div", { className: a.popupValue, children: n })
110
+ ]
111
+ }
112
+ ),
113
+ /* @__PURE__ */ s("div", { className: e.content, children: F ? i : n }),
114
+ E
115
+ ]
116
+ }
117
+ );
118
+ }
119
+ }
120
+ );
121
+ }
122
+ export {
123
+ Y as Slider
124
+ };
@@ -0,0 +1,27 @@
1
+ import { RefObject } from 'react';
2
+ import { FlexItemProps, FlexProps } from './Flex';
3
+
4
+ type Props = Partial<{
5
+ /** Fills available space. */
6
+ fill: boolean;
7
+ /** Reverses the stack. */
8
+ reverse: boolean;
9
+ /** Flex column */
10
+ vertical: boolean;
11
+ /** Adds zebra striping to the stack. */
12
+ zebra: boolean;
13
+ }> & FlexProps;
14
+ export declare function Stack(props: Props): import("react/jsx-runtime").JSX.Element;
15
+ export declare namespace Stack {
16
+ var Item: typeof StackItem;
17
+ var Divider: typeof StackDivider;
18
+ }
19
+ type StackItemProps = FlexItemProps & Partial<{
20
+ innerRef: RefObject<HTMLDivElement>;
21
+ }>;
22
+ declare function StackItem(props: StackItemProps): import("react/jsx-runtime").JSX.Element;
23
+ type StackDividerProps = FlexItemProps & Partial<{
24
+ hidden: boolean;
25
+ }>;
26
+ declare function StackDivider(props: StackDividerProps): import("react/jsx-runtime").JSX.Element;
27
+ export {};