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,22 @@
1
+ import { jsx as r } from "react/jsx-runtime";
2
+ import { classes as e } from "../common/react.js";
3
+ import '../assets/Divider.css';const d = "_horizontal_1dhv5_9", c = "_hidden_1dhv5_12", s = "_vertical_1dhv5_16", i = {
4
+ horizontal: d,
5
+ hidden: c,
6
+ vertical: s
7
+ };
8
+ function l(t) {
9
+ const { hidden: o, vertical: n } = t;
10
+ return /* @__PURE__ */ r(
11
+ "div",
12
+ {
13
+ className: e([
14
+ o && i.hidden,
15
+ n ? i.vertical : i.horizontal
16
+ ])
17
+ }
18
+ );
19
+ }
20
+ export {
21
+ l as Divider
22
+ };
@@ -0,0 +1,33 @@
1
+ import { ReactNode } from 'react';
2
+ import { BooleanLike } from '../common/react';
3
+ import { BoxProps } from './Box';
4
+
5
+ declare enum Direction {
6
+ NORTH = 1,
7
+ SOUTH = 2,
8
+ EAST = 4,
9
+ WEST = 8,
10
+ NORTHEAST = 5,
11
+ NORTHWEST = 9,
12
+ SOUTHEAST = 6,
13
+ SOUTHWEST = 10
14
+ }
15
+ type Props = {
16
+ /** Required: The path of the icon */
17
+ icon: string;
18
+ /** Required: The state of the icon */
19
+ icon_state: string;
20
+ } & Partial<{
21
+ /** Facing direction. See direction enum. Default is South */
22
+ direction: Direction;
23
+ /** Fallback icon. */
24
+ fallback: ReactNode;
25
+ /** Frame number. Default is 1 */
26
+ frame: number;
27
+ /** Movement state. Default is false */
28
+ movement: BooleanLike;
29
+ }> & BoxProps;
30
+ export declare function DmIcon(props: Props): {
31
+ displayText: string;
32
+ };
33
+ export {};
@@ -0,0 +1,29 @@
1
+ import { useState as r, useEffect as i } from "react";
2
+ import { resolveAsset as u } from "../common/assets.js";
3
+ let e;
4
+ function p(c) {
5
+ const {
6
+ // className,
7
+ // direction = Direction.SOUTH,
8
+ // fallback,
9
+ // frame = 1,
10
+ // icon_state,
11
+ icon: o
12
+ // movement = false,
13
+ // ...rest
14
+ } = c, [a, s] = r(""), [f, n] = r("unloaded");
15
+ return i(() => {
16
+ if (e) {
17
+ n(Object.keys(e).length.toString()), s(e[o]);
18
+ return;
19
+ }
20
+ fetch(u("icon_ref_map.json")).then((t) => (n(t.statusText), t.json())).then((t) => {
21
+ e = t, s(t[o]);
22
+ }).catch((t) => {
23
+ n(t.message);
24
+ });
25
+ }, []), { displayText: f };
26
+ }
27
+ export {
28
+ p as DmIcon
29
+ };
@@ -0,0 +1,176 @@
1
+ import { jsxs as N, Fragment as T, jsx as F } from "react/jsx-runtime";
2
+ import { clamp as m } from "../common/math.js";
3
+ import { Component as b, createRef as I } from "react";
4
+ import { AnimatedNumber as M } from "./AnimatedNumber.js";
5
+ const R = 400;
6
+ function S(v, u) {
7
+ return v.screenX * u[0] + v.screenY * u[1];
8
+ }
9
+ class C extends b {
10
+ constructor(u) {
11
+ super(u), this.inputRef = I(), this.state = {
12
+ value: u.value,
13
+ dragging: !1,
14
+ editing: !1,
15
+ internalValue: null,
16
+ origin: null,
17
+ suppressingFlicker: !1
18
+ }, this.flickerTimer = null, this.suppressFlicker = () => {
19
+ const { suppressFlicker: e } = this.props;
20
+ e > 0 && (this.setState({
21
+ suppressingFlicker: !0
22
+ }), clearTimeout(this.flickerTimer), this.flickerTimer = setTimeout(() => {
23
+ this.setState({
24
+ suppressingFlicker: !1
25
+ });
26
+ }, e));
27
+ }, this.handleDragStart = (e) => {
28
+ const { value: i, dragMatrix: l } = this.props, { editing: s } = this.state;
29
+ s || (document.body.style["pointer-events"] = "none", this.ref = e.target, this.setState({
30
+ dragging: !1,
31
+ origin: S(e, l),
32
+ value: i,
33
+ internalValue: i
34
+ }), this.timer = setTimeout(() => {
35
+ this.setState({
36
+ dragging: !0
37
+ });
38
+ }, 250), this.dragInterval = setInterval(() => {
39
+ const { dragging: o, value: g } = this.state, { onDrag: a } = this.props;
40
+ o && a && a(e, g);
41
+ }, this.props.updateRate || R), document.addEventListener("mousemove", this.handleDragMove), document.addEventListener("mouseup", this.handleDragEnd));
42
+ }, this.handleDragMove = (e) => {
43
+ const { minValue: i, maxValue: l, step: s, stepPixelSize: o, dragMatrix: g } = this.props;
44
+ this.setState((a) => {
45
+ const n = { ...a }, p = S(e, g) - n.origin;
46
+ if (a.dragging) {
47
+ const h = Number.isFinite(i) ? i % s : 0;
48
+ n.internalValue = m(
49
+ n.internalValue + p * s / o,
50
+ i - s,
51
+ l + s
52
+ ), n.value = m(
53
+ n.internalValue - n.internalValue % s + h,
54
+ i,
55
+ l
56
+ ), n.origin = S(e, g);
57
+ } else Math.abs(p) > 4 && (n.dragging = !0);
58
+ return n;
59
+ });
60
+ }, this.handleDragEnd = (e) => {
61
+ const { onChange: i, onDrag: l } = this.props, { dragging: s, value: o, internalValue: g } = this.state;
62
+ if (document.body.style["pointer-events"] = "auto", clearTimeout(this.timer), clearInterval(this.dragInterval), this.setState({
63
+ dragging: !1,
64
+ editing: !s,
65
+ origin: null
66
+ }), document.removeEventListener("mousemove", this.handleDragMove), document.removeEventListener("mouseup", this.handleDragEnd), s)
67
+ this.suppressFlicker(), i && i(e, o), l && l(e, o);
68
+ else if (this.inputRef) {
69
+ const a = this.inputRef.current;
70
+ a.value = g;
71
+ try {
72
+ a.focus(), a.select();
73
+ } catch {
74
+ }
75
+ }
76
+ };
77
+ }
78
+ render() {
79
+ const {
80
+ dragging: u,
81
+ editing: e,
82
+ value: i,
83
+ suppressingFlicker: l
84
+ } = this.state, {
85
+ animated: s,
86
+ value: o,
87
+ unit: g,
88
+ minValue: a,
89
+ maxValue: n,
90
+ unclamped: p,
91
+ format: h,
92
+ onChange: f,
93
+ onDrag: c,
94
+ children: D,
95
+ // Input props
96
+ height: k,
97
+ lineHeight: V,
98
+ fontSize: y
99
+ } = this.props;
100
+ let d = o;
101
+ (u || l) && (d = i);
102
+ const E = /* @__PURE__ */ N(T, { children: [
103
+ s && !u && !l ? /* @__PURE__ */ F(M, { value: d, format: h }) : h ? h(d) : d,
104
+ g ? " " + g : ""
105
+ ] }), x = /* @__PURE__ */ F(
106
+ "input",
107
+ {
108
+ ref: this.inputRef,
109
+ className: "NumberInput__input",
110
+ style: {
111
+ display: e ? void 0 : "none",
112
+ height: k,
113
+ lineHeight: V,
114
+ fontsize: y
115
+ },
116
+ onBlur: (r) => {
117
+ if (!e)
118
+ return;
119
+ let t;
120
+ if (p ? t = parseFloat(r.target.value) : t = m(parseFloat(r.target.value), a, n), Number.isNaN(t)) {
121
+ this.setState({
122
+ editing: !1
123
+ });
124
+ return;
125
+ }
126
+ this.setState({
127
+ editing: !1,
128
+ value: t
129
+ }), this.suppressFlicker(), f && f(r, t), c && c(r, t);
130
+ },
131
+ onKeyDown: (r) => {
132
+ if (r.keyCode === 13) {
133
+ let t;
134
+ if (p ? t = parseFloat(r.target.value) : t = m(parseFloat(r.target.value), a, n), Number.isNaN(t)) {
135
+ this.setState({
136
+ editing: !1
137
+ });
138
+ return;
139
+ }
140
+ this.setState({
141
+ editing: !1,
142
+ value: t
143
+ }), this.suppressFlicker(), f && f(r, t), c && c(r, t);
144
+ return;
145
+ }
146
+ if (r.keyCode === 27) {
147
+ this.setState({
148
+ editing: !1
149
+ });
150
+ return;
151
+ }
152
+ }
153
+ }
154
+ );
155
+ return D({
156
+ dragging: u,
157
+ editing: e,
158
+ value: o,
159
+ displayValue: d,
160
+ displayElement: E,
161
+ inputElement: x,
162
+ handleDragStart: this.handleDragStart
163
+ });
164
+ }
165
+ }
166
+ C.defaultProps = {
167
+ minValue: -1 / 0,
168
+ maxValue: 1 / 0,
169
+ step: 1,
170
+ stepPixelSize: 1,
171
+ suppressFlicker: 50,
172
+ dragMatrix: [1, 0]
173
+ };
174
+ export {
175
+ C as DraggableControl
176
+ };
@@ -0,0 +1,48 @@
1
+ import { ReactNode } from 'react';
2
+ import { BoxProps } from './Box';
3
+
4
+ export type DropdownEntry = {
5
+ displayText: ReactNode;
6
+ value: string | number;
7
+ };
8
+ type DropdownOption = string | DropdownEntry;
9
+ type Props = {
10
+ /** Called when a value is picked from the list, `value` is the value that was picked */
11
+ onSelected: (value: any) => void;
12
+ /** An array of strings which will be displayed in the
13
+ dropdown when open. See Dropdown.tsx for more advanced usage with DropdownEntry */
14
+ options: DropdownOption[];
15
+ /** Currently selected entry to display. Can be left stateless to permanently display this value. */
16
+ selected: DropdownOption | null | undefined;
17
+ } & Partial<{
18
+ /** Whether to scroll automatically on open. Defaults to true */
19
+ autoScroll: boolean;
20
+ /** Whether to display previous / next buttons */
21
+ buttons: boolean;
22
+ /** Whether to clip the selected text */
23
+ clipSelectedText: boolean;
24
+ /** Color of dropdown button */
25
+ color: string;
26
+ /** Disables the dropdown */
27
+ disabled: boolean;
28
+ /** Overwrites selection text with this. Good for objects etc. */
29
+ displayText: ReactNode;
30
+ /** Icon to display in dropdown button */
31
+ icon: string;
32
+ /** Angle of the icon */
33
+ iconRotation: number;
34
+ /** Whether or not the icon should spin */
35
+ iconSpin: boolean;
36
+ /** Width of the dropdown menu. Default: 15rem */
37
+ menuWidth: string;
38
+ /** Whether or not the arrow on the right hand side of the dropdown button is visible */
39
+ noChevron: boolean;
40
+ /** Called when dropdown button is clicked */
41
+ onClick: (event: any) => void;
42
+ /** Dropdown renders over instead of below */
43
+ over: boolean;
44
+ /** Text to show when nothing has been selected. */
45
+ placeholder: string;
46
+ }> & BoxProps;
47
+ export declare function Dropdown(props: Props): import("react/jsx-runtime").JSX.Element;
48
+ export {};
@@ -0,0 +1,152 @@
1
+ import { jsx as o, jsxs as m, Fragment as W } from "react/jsx-runtime";
2
+ import { useState as F, useRef as L, useEffect as q } from "react";
3
+ import { classes as y } from "../common/react.js";
4
+ import { unit as z } from "./Box.js";
5
+ import { Button as D } from "./Button.js";
6
+ import { Icon as b } from "./Icon.js";
7
+ import { Popper as A } from "./Popper.js";
8
+ const G = -1;
9
+ function f(d) {
10
+ return typeof d == "string" ? d : d.value;
11
+ }
12
+ function Y(d) {
13
+ const {
14
+ autoScroll: w = !0,
15
+ buttons: I,
16
+ className: O,
17
+ clipSelectedText: k = !0,
18
+ color: B = "default",
19
+ disabled: a,
20
+ displayText: C,
21
+ icon: x,
22
+ iconRotation: T,
23
+ iconSpin: j,
24
+ menuWidth: R = "15rem",
25
+ noChevron: S,
26
+ onClick: p,
27
+ onSelected: i,
28
+ options: r = [],
29
+ over: g,
30
+ placeholder: E = "Select...",
31
+ selected: u,
32
+ width: P = "15rem"
33
+ } = d, [l, h] = F(!1), V = g ? !l : l, v = L(null), s = r.findIndex((e) => f(e) === u) || 0;
34
+ function _(e) {
35
+ var c;
36
+ let t = e;
37
+ e < s ? t = e < 2 ? 0 : e - 2 : t = e > r.length - 3 ? r.length - 1 : e - 2;
38
+ const n = (c = v.current) == null ? void 0 : c.children[t];
39
+ n == null || n.scrollIntoView({ block: "nearest" });
40
+ }
41
+ function N(e) {
42
+ if (r.length < 1 || a)
43
+ return;
44
+ const t = 0, n = r.length - 1;
45
+ let c;
46
+ s < 0 ? c = e === "next" ? n : t : e === "next" ? c = s === n ? t : s + 1 : c = s === t ? n : s - 1, l && w && _(c), i == null || i(f(r[c]));
47
+ }
48
+ return q(() => {
49
+ var e;
50
+ l && (w && s !== G && _(s), (e = v.current) == null || e.focus());
51
+ }, [l]), /* @__PURE__ */ o(
52
+ A,
53
+ {
54
+ isOpen: l,
55
+ onClickOutside: () => h(!1),
56
+ placement: g ? "top-start" : "bottom-start",
57
+ content: /* @__PURE__ */ m(
58
+ "div",
59
+ {
60
+ className: "Layout Dropdown__menu",
61
+ style: { minWidth: R },
62
+ ref: v,
63
+ children: [
64
+ r.length === 0 && /* @__PURE__ */ o("div", { className: "Dropdown__menuentry", children: "No options" }),
65
+ r.map((e, t) => {
66
+ const n = f(e);
67
+ return /* @__PURE__ */ o(
68
+ "div",
69
+ {
70
+ className: y([
71
+ "Dropdown__menuentry",
72
+ u === n && "selected"
73
+ ]),
74
+ onClick: () => {
75
+ h(!1), i == null || i(n);
76
+ },
77
+ children: typeof e == "string" ? e : e.displayText
78
+ },
79
+ t
80
+ );
81
+ })
82
+ ]
83
+ }
84
+ ),
85
+ children: /* @__PURE__ */ m("div", { className: "Dropdown", style: { width: z(P) }, children: [
86
+ /* @__PURE__ */ m(
87
+ "div",
88
+ {
89
+ className: y([
90
+ "Dropdown__control",
91
+ "Button",
92
+ "Button--dropdown",
93
+ "Button--color--" + B,
94
+ a && "Button--disabled",
95
+ O
96
+ ]),
97
+ onClick: (e) => {
98
+ a && !l || (h(!l), p == null || p(e));
99
+ },
100
+ children: [
101
+ x && /* @__PURE__ */ o(b, { mr: 1, name: x, rotation: T, spin: j }),
102
+ /* @__PURE__ */ o(
103
+ "span",
104
+ {
105
+ className: "Dropdown__selected-text",
106
+ style: {
107
+ overflow: k ? "hidden" : "visible"
108
+ },
109
+ children: C || u && f(u) || E
110
+ }
111
+ ),
112
+ !S && /* @__PURE__ */ o("span", { className: "Dropdown__arrow-button", children: /* @__PURE__ */ o(b, { name: V ? "chevron-up" : "chevron-down" }) })
113
+ ]
114
+ }
115
+ ),
116
+ I && /* @__PURE__ */ m(W, { children: [
117
+ /* @__PURE__ */ o(
118
+ D,
119
+ {
120
+ disabled: a,
121
+ height: 1.8,
122
+ icon: "chevron-left",
123
+ onClick: () => {
124
+ N(
125
+ "previous"
126
+ /* Previous */
127
+ );
128
+ }
129
+ }
130
+ ),
131
+ /* @__PURE__ */ o(
132
+ D,
133
+ {
134
+ disabled: a,
135
+ height: 1.8,
136
+ icon: "chevron-right",
137
+ onClick: () => {
138
+ N(
139
+ "next"
140
+ /* Next */
141
+ );
142
+ }
143
+ }
144
+ )
145
+ ] })
146
+ ] })
147
+ }
148
+ );
149
+ }
150
+ export {
151
+ Y as Dropdown
152
+ };
@@ -0,0 +1,38 @@
1
+ import { jsx as r, jsxs as i } from "react/jsx-runtime";
2
+ import { Component as o, Fragment as c } from "react";
3
+ import { Box as m } from "./Box.js";
4
+ class h extends o {
5
+ constructor(e) {
6
+ super(e), this.timer = null, this.state = {
7
+ currentIndex: 0,
8
+ currentDisplay: []
9
+ };
10
+ }
11
+ tick() {
12
+ const { props: e, state: t } = this;
13
+ if (t.currentIndex <= e.allMessages.length) {
14
+ this.setState((n) => ({
15
+ currentIndex: n.currentIndex + 1
16
+ }));
17
+ const { currentDisplay: s } = t;
18
+ s.push(e.allMessages[t.currentIndex]);
19
+ } else
20
+ clearTimeout(this.timer), setTimeout(e.onFinished, e.finishedTimeout);
21
+ }
22
+ componentDidMount() {
23
+ const { linesPerSecond: e = 2.5 } = this.props;
24
+ this.timer = setInterval(() => this.tick(), 1e3 / e);
25
+ }
26
+ componentWillUnmount() {
27
+ clearTimeout(this.timer);
28
+ }
29
+ render() {
30
+ return /* @__PURE__ */ r(m, { m: 1, children: this.state.currentDisplay.map((e) => /* @__PURE__ */ i(c, { children: [
31
+ e,
32
+ /* @__PURE__ */ r("br", {})
33
+ ] }, e)) });
34
+ }
35
+ }
36
+ export {
37
+ h as FakeTerminal
38
+ };
@@ -0,0 +1,22 @@
1
+ import { Component, HTMLAttributes, PropsWithChildren, RefObject } from 'react';
2
+
3
+ type Props = {
4
+ acceptableDifference?: number;
5
+ maxFontSize: number;
6
+ maxWidth: number;
7
+ native?: HTMLAttributes<HTMLDivElement>;
8
+ } & PropsWithChildren;
9
+ type State = {
10
+ fontSize: number;
11
+ };
12
+ export declare class FitText extends Component<Props, State> {
13
+ ref: RefObject<HTMLDivElement>;
14
+ state: State;
15
+ constructor(props: Props);
16
+ componentDidUpdate(prevProps: any): void;
17
+ componentWillUnmount(): void;
18
+ resize(): void;
19
+ componentDidMount(): void;
20
+ render(): import("react/jsx-runtime").JSX.Element;
21
+ }
22
+ export {};
@@ -0,0 +1,63 @@
1
+ var d = Object.defineProperty;
2
+ var c = (i, t, e) => t in i ? d(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e;
3
+ var o = (i, t, e) => c(i, typeof t != "symbol" ? t + "" : t, e);
4
+ import { jsx as a } from "react/jsx-runtime";
5
+ import { Component as l, createRef as m } from "react";
6
+ const z = 5;
7
+ class S extends l {
8
+ constructor(e) {
9
+ super(e);
10
+ o(this, "ref", m());
11
+ o(this, "state", {
12
+ fontSize: 0
13
+ });
14
+ this.resize = this.resize.bind(this), window.addEventListener("resize", this.resize);
15
+ }
16
+ componentDidUpdate(e) {
17
+ e.children !== this.props.children && this.resize();
18
+ }
19
+ componentWillUnmount() {
20
+ window.removeEventListener("resize", this.resize);
21
+ }
22
+ resize() {
23
+ const e = this.ref.current;
24
+ if (!e)
25
+ return;
26
+ const f = this.props.maxWidth;
27
+ let s = 0, r = this.props.maxFontSize;
28
+ for (let p = 0; p < 10; p++) {
29
+ const n = Math.round((s + r) / 2);
30
+ e.style.fontSize = `${n}px`;
31
+ const h = e.offsetWidth - f;
32
+ if (h > 0)
33
+ r = n;
34
+ else if (h < (this.props.acceptableDifference ?? z))
35
+ s = n;
36
+ else
37
+ break;
38
+ }
39
+ this.setState({
40
+ fontSize: Math.round((s + r) / 2)
41
+ });
42
+ }
43
+ componentDidMount() {
44
+ this.resize();
45
+ }
46
+ render() {
47
+ var e;
48
+ return /* @__PURE__ */ a(
49
+ "span",
50
+ {
51
+ ref: this.ref,
52
+ style: {
53
+ fontSize: `${this.state.fontSize}px`,
54
+ ...typeof ((e = this.props.native) == null ? void 0 : e.style) == "object" ? this.props.native.style : {}
55
+ },
56
+ children: this.props.children
57
+ }
58
+ );
59
+ }
60
+ }
61
+ export {
62
+ S as FitText
63
+ };
@@ -0,0 +1,93 @@
1
+ import { BoxProps } from './Box';
2
+
3
+ export type FlexProps = Partial<{
4
+ /**
5
+ * Default alignment of all children.
6
+ *
7
+ * - `stretch` (default) - stretch to fill the container.
8
+ * - `start` - items are placed at the start of the cross axis.
9
+ * - `end` - items are placed at the end of the cross axis.
10
+ * - `center` - items are centered on the cross axis.
11
+ * - `baseline` - items are aligned such as their baselines align.
12
+ */
13
+ align: string | boolean;
14
+ /**
15
+ * This establishes the main-axis, thus defining the direction flex items are placed in the flex container.
16
+ *
17
+ * - `row` (default) - left to right.
18
+ * - `row-reverse` - right to left.
19
+ * - `column` - top to bottom.
20
+ * - `column-reverse` - bottom to top.
21
+ */
22
+ direction: string;
23
+ /** Makes flexbox container inline, with similar behavior to an `inline` property on a `Box`. */
24
+ inline: boolean;
25
+ /**
26
+ * This defines the alignment along the main axis. It helps distribute extra free space leftover when either all the flex items on a line are
27
+ * inflexible, or are flexible but have reached their maximum size. It also exerts some control over the alignment of items when they overflow
28
+ * the line.
29
+ *
30
+ * - `flex-start` (default) - items are packed toward the start of the
31
+ * flex-direction.
32
+ * - `flex-end` - items are packed toward the end of the flex-direction.
33
+ * - `space-between` - items are evenly distributed in the line; first item is
34
+ * on the start line, last item on the end line
35
+ * - `space-around` - items are evenly distributed in the line with equal space
36
+ * around them. Note that visually the spaces aren't equal, since all the items
37
+ * have equal space on both sides. The first item will have one unit of space
38
+ * against the container edge, but two units of space between the next item
39
+ * because that next item has its own spacing that applies.
40
+ * - `space-evenly` - items are distributed so that the spacing between any two
41
+ * items (and the space to the edges) is equal.
42
+ */
43
+ justify: string;
44
+ /** By default, flex items will all try to fit onto one line. You can change that and allow the items to wrap as needed with this property. */
45
+ scrollable: boolean;
46
+ /**
47
+ * This defines the alignment along the cross axis. It helps distribute extra free space leftover when either all the flex items on a line are
48
+ * inflexible, or are flexible but have reached their maximum size. It also exerts some control over the alignment of items when they overflow
49
+ * the line.
50
+ *
51
+ * - `nowrap` (default) - all flex items will be on one line
52
+ * - `wrap` - flex items will wrap onto multiple lines, from top to bottom.
53
+ * - `wrap-reverse` - flex items will wrap onto multiple lines from bottom to top.
54
+ */
55
+ wrap: string | boolean;
56
+ }> & BoxProps;
57
+ export declare function computeFlexClassName(props: FlexProps): string;
58
+ export declare function computeFlexProps(props: FlexProps): Record<string, any>;
59
+ export declare function Flex(props: any): import("react/jsx-runtime").JSX.Element;
60
+ export declare namespace Flex {
61
+ var Item: typeof FlexItem;
62
+ }
63
+ export type FlexItemProps = Partial<{
64
+ /** This allows the default alignment (or the one specified by align-items) to be overridden for individual flex items. */
65
+ align: string | boolean;
66
+ /**
67
+ * This defines the default size of an element
68
+ * before any flex-related calculations are done. Has to be a length
69
+ * (e.g. `20%`, `5rem`), an `auto` or `content` keyword.
70
+ *
71
+ * - **Important:** IE11 flex is buggy, and auto width/height calculations
72
+ * can sometimes end up in a circular dependency. This usually happens, when
73
+ * working with tables inside flex (they have wacky internal widths and such).
74
+ * Setting basis to `0` breaks the loop and fixes all of the problems.
75
+ */
76
+ basis: string | number;
77
+ /**
78
+ * This defines the ability for a flex item to grow if necessary. It accepts a unitless value that serves as a proportion.
79
+ * It dictates what amount of the available space inside the flex container the item should take up.
80
+ * This number is unit-less and is relative to other siblings.
81
+ */
82
+ grow: number | boolean;
83
+ /**
84
+ * By default, flex items are laid out in the source order. However, the order property controls the order in which they appear in the
85
+ * flex container
86
+ */
87
+ order: number;
88
+ /** This defines the ability for a flex item to shrink if necessary. Inverse of `grow`. */
89
+ shrink: number | boolean;
90
+ }> & BoxProps;
91
+ export declare function computeFlexItemProps(props: FlexItemProps): Record<string, any>;
92
+ declare function FlexItem(props: any): import("react/jsx-runtime").JSX.Element;
93
+ export {};