tgui-core 1.8.4 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/dist/common/constants.d.ts +4 -0
  2. package/dist/common/constants.js +17 -0
  3. package/dist/common/hotkeys.js +48 -48
  4. package/dist/common/ui.d.ts +6 -0
  5. package/dist/common/ui.js +63 -59
  6. package/dist/components/AnimatedNumber.d.ts +1 -1
  7. package/dist/components/Button.d.ts +3 -3
  8. package/dist/components/Button.js +21 -22
  9. package/dist/components/Chart.d.ts +3 -15
  10. package/dist/components/Chart.js +68 -86
  11. package/dist/components/ColorBox.js +3 -3
  12. package/dist/components/Dialog.d.ts +16 -0
  13. package/dist/components/Dialog.js +5 -5
  14. package/dist/components/DmIcon.d.ts +1 -1
  15. package/dist/components/DraggableControl.d.ts +56 -0
  16. package/dist/components/DraggableControl.js +126 -176
  17. package/dist/components/Dropdown.d.ts +8 -6
  18. package/dist/components/Dropdown.js +137 -129
  19. package/dist/components/FitText.d.ts +1 -1
  20. package/dist/components/Floating.d.ts +75 -0
  21. package/dist/components/Floating.js +2235 -0
  22. package/dist/components/ImageButton.d.ts +2 -3
  23. package/dist/components/ImageButton.js +88 -98
  24. package/dist/components/InfinitePlane.d.ts +35 -32
  25. package/dist/components/InfinitePlane.js +123 -133
  26. package/dist/components/Knob.d.ts +22 -6
  27. package/dist/components/Knob.js +45 -46
  28. package/dist/components/MenuBar.js +81 -97
  29. package/dist/components/Modal.js +12 -12
  30. package/dist/components/NumberInput.d.ts +1 -1
  31. package/dist/components/Popper.d.ts +5 -1
  32. package/dist/components/Popper.js +1026 -121
  33. package/dist/components/ProgressBar.js +3 -3
  34. package/dist/components/RoundGauge.js +30 -30
  35. package/dist/components/Section.js +7 -7
  36. package/dist/components/Slider.d.ts +22 -6
  37. package/dist/components/Slider.js +55 -56
  38. package/dist/components/Stack.js +3 -3
  39. package/dist/components/Table.js +7 -7
  40. package/dist/components/Tabs.js +7 -7
  41. package/dist/components/TextArea.d.ts +17 -0
  42. package/dist/components/TextArea.js +35 -33
  43. package/dist/components/Tooltip.d.ts +3 -34
  44. package/dist/components/Tooltip.js +14 -77
  45. package/dist/components/TrackOutsideClicks.d.ts +1 -1
  46. package/dist/components/index.d.ts +1 -0
  47. package/dist/components/index.js +64 -62
  48. package/package.json +26 -27
  49. package/styles/base.scss +13 -11
  50. package/styles/colors.scss +63 -67
  51. package/styles/components/BlockQuote.scss +5 -8
  52. package/styles/components/Button.scss +123 -99
  53. package/styles/components/Dialog.scss +23 -30
  54. package/styles/components/Dimmer.scss +3 -8
  55. package/styles/components/Divider.scss +6 -7
  56. package/styles/components/Dropdown.scss +103 -51
  57. package/styles/components/Flex.scss +0 -1
  58. package/styles/components/Floating.scss +60 -0
  59. package/styles/components/ImageButton.scss +136 -192
  60. package/styles/components/Input.scss +24 -26
  61. package/styles/components/Knob.scss +37 -41
  62. package/styles/components/LabeledList.scss +8 -6
  63. package/styles/components/MenuBar.scss +17 -21
  64. package/styles/components/Modal.scss +8 -7
  65. package/styles/components/NoticeBox.scss +22 -26
  66. package/styles/components/NumberInput.scss +30 -28
  67. package/styles/components/ProgressBar.scss +27 -19
  68. package/styles/components/RoundGauge.scss +46 -26
  69. package/styles/components/Section.scss +17 -32
  70. package/styles/components/Slider.scss +18 -15
  71. package/styles/components/Stack.scss +8 -48
  72. package/styles/components/Table.scss +2 -2
  73. package/styles/components/Tabs.scss +92 -66
  74. package/styles/components/TextArea.scss +32 -36
  75. package/styles/components/Tooltip.scss +10 -13
  76. package/styles/functions.scss +1 -62
  77. package/styles/main.scss +6 -1
  78. package/styles/reset.scss +7 -11
  79. package/styles/vars-colors.scss +108 -0
  80. package/styles/vars-components.scss +162 -0
  81. package/styles/vars-values.scss +110 -0
  82. package/dist/popper-CiqSDJTE.js +0 -906
@@ -1,157 +1,165 @@
1
- import { jsx as l, jsxs as p, Fragment as F } from "react/jsx-runtime";
2
- import { useState as L, useRef as S, useEffect as V } from "react";
3
- import { classes as N } from "../common/react.js";
4
- import { unit as $ } from "../common/ui.js";
5
- import { Button as D } from "./Button.js";
6
- import { Icon as b } from "./Icon.js";
7
- import { Popper as q } from "./Popper.js";
8
- const z = -1;
9
- function h(u) {
10
- return typeof u == "string" ? u : u.value;
1
+ import { jsxs as u, jsx as r, Fragment as I } from "react/jsx-runtime";
2
+ import { useState as S, useRef as V } from "react";
3
+ import { KEY as O } from "../common/keys.js";
4
+ import { classes as D } from "../common/react.js";
5
+ import { unit as C } from "../common/ui.js";
6
+ import { Button as E } from "./Button.js";
7
+ import { Floating as Y } from "./Floating.js";
8
+ import { Icon as T } from "./Icon.js";
9
+ const q = -1;
10
+ function f(d) {
11
+ return typeof d == "string" ? d : d.value;
11
12
  }
12
- function Y(u) {
13
+ function X(d) {
13
14
  const {
14
15
  autoScroll: v = !0,
15
- buttons: I,
16
- className: O,
17
- clipSelectedText: T = !0,
18
- color: B = "default",
19
- disabled: d,
20
- displayText: E,
16
+ buttons: k,
17
+ className: B,
18
+ color: K = "default",
19
+ disabled: i,
20
+ displayText: R,
21
21
  icon: x,
22
- iconRotation: k,
23
- iconSpin: j,
24
- menuWidth: C = "15rem",
25
- noChevron: R,
22
+ iconRotation: j,
23
+ iconSpin: A,
24
+ iconOnly: h,
25
+ menuWidth: _,
26
+ noChevron: F,
26
27
  onClick: a,
27
- onSelected: o,
28
- options: c = [],
28
+ onSelected: t,
29
+ options: l = [],
29
30
  over: y,
30
- placeholder: K = "Select...",
31
+ placeholder: W = "Select...",
31
32
  selected: m,
32
- width: P = "15rem"
33
- } = u, [r, f] = L(!1), W = y ? !r : r, w = S(null), i = c.findIndex((e) => h(e) === m) || 0;
33
+ width: $ = 15
34
+ } = d, [p, P] = S(!1), N = V(null), s = l.findIndex((e) => f(e) === m) || 0;
34
35
  function g(e) {
35
- let s = e;
36
- e < i ? s = e < 2 ? 0 : e - 2 : s = e > c.length - 3 ? c.length - 1 : e - 2;
37
- const n = w.current, t = n == null ? void 0 : n.children[s];
38
- n && t && (n.scrollTop = t.offsetTop);
36
+ let n = e;
37
+ e < s ? n = e < 2 ? 0 : e - 2 : n = e > l.length - 3 ? l.length - 1 : e - 2;
38
+ const o = N.current, c = o == null ? void 0 : o.children[n];
39
+ o && c && (o.scrollTop = c.offsetTop);
39
40
  }
40
- function _(e) {
41
- if (c.length < 1 || d)
41
+ function b(e) {
42
+ if (l.length < 1 || i)
42
43
  return;
43
- const s = 0, n = c.length - 1;
44
- let t;
45
- i < 0 ? t = e === "next" ? n : s : e === "next" ? t = i === n ? s : i + 1 : t = i === s ? n : i - 1, r && v && g(t), o == null || o(h(c[t]));
44
+ const n = 0, o = l.length - 1;
45
+ let c;
46
+ s < 0 ? c = e === "next" ? o : n : e === "next" ? c = s === o ? n : s + 1 : c = s === n ? o : s - 1, p && v && g(c), t == null || t(f(l[c]));
46
47
  }
47
- return V(() => {
48
- var e;
49
- r && (v && i !== z && g(i), (e = w.current) == null || e.focus());
50
- }, [r]), /* @__PURE__ */ l(
51
- q,
52
- {
53
- isOpen: r,
54
- onClickOutside: () => f(!1),
55
- placement: y ? "top-start" : "bottom-start",
56
- content: /* @__PURE__ */ p(
57
- "div",
58
- {
59
- className: "Layout Dropdown__menu",
60
- style: { minWidth: C },
61
- ref: w,
62
- children: [
63
- c.length === 0 && /* @__PURE__ */ l("div", { className: "Dropdown__menuentry", children: "No options" }),
64
- c.map((e, s) => {
65
- const n = h(e);
66
- return /* @__PURE__ */ l(
67
- "div",
68
- {
69
- className: N([
70
- "Dropdown__menuentry",
71
- m === n && "selected"
72
- ]),
73
- onClick: () => {
74
- f(!1), o == null || o(n);
75
- },
76
- onKeyDown: (t) => {
77
- t.key === "Enter" && (f(!1), o == null || o(n));
78
- },
79
- children: typeof e == "string" ? e : e.displayText
80
- },
81
- s
82
- );
83
- })
84
- ]
85
- }
86
- ),
87
- children: /* @__PURE__ */ p("div", { className: "Dropdown", style: { width: $(P) }, children: [
88
- /* @__PURE__ */ p(
48
+ let w = y ? "top" : "bottom";
49
+ return h && (w = `${w}-start`), /* @__PURE__ */ u("div", { className: "Dropdown", children: [
50
+ /* @__PURE__ */ r(
51
+ Y,
52
+ {
53
+ allowedOutsideClasses: ".Dropdown__button",
54
+ closeAfterInteract: !0,
55
+ contentAutoWidth: !_,
56
+ contentClasses: "Dropdown__menu--wrapper",
57
+ contentStyles: { width: _ ? C(_) : void 0 },
58
+ disabled: i,
59
+ onOpenChange: P,
60
+ placement: w,
61
+ content: /* @__PURE__ */ r("div", { ref: N, className: "Dropdown__menu", children: l.length === 0 ? /* @__PURE__ */ r("div", { className: "Dropdown__menu--entry", children: "No options" }) : l.map((e) => {
62
+ const n = f(e);
63
+ return /* @__PURE__ */ r(
64
+ "div",
65
+ {
66
+ className: D([
67
+ "Dropdown__menu--entry",
68
+ m === n && "selected"
69
+ ]),
70
+ onClick: () => {
71
+ t == null || t(n);
72
+ },
73
+ onKeyDown: (o) => {
74
+ o.key === O.Enter && (t == null || t(n));
75
+ },
76
+ children: typeof e == "string" ? e : e.displayText
77
+ },
78
+ n
79
+ );
80
+ }) }),
81
+ onMounted: () => {
82
+ p && v && s !== q && g(s);
83
+ },
84
+ children: /* @__PURE__ */ u(
89
85
  "div",
90
86
  {
91
- className: N([
87
+ className: D([
92
88
  "Dropdown__control",
93
- "Button",
94
- "Button--dropdown",
95
- `Button--color--${B}`,
96
- d && "Button--disabled",
97
- O
89
+ `Button--color--${K}`,
90
+ i && "Button--disabled",
91
+ h && "Dropdown__control--icon-only",
92
+ B
98
93
  ]),
94
+ style: { width: C($) },
99
95
  onClick: (e) => {
100
- d && !r || (f(!r), a == null || a(e));
96
+ i && !p || a == null || a(e);
101
97
  },
102
98
  onKeyDown: (e) => {
103
- e.key === "Enter" && !d && (f(!r), a == null || a(e));
99
+ e.key === O.Enter && !i && (a == null || a(e));
104
100
  },
105
101
  children: [
106
- x && /* @__PURE__ */ l(b, { mr: 1, name: x, rotation: k, spin: j }),
107
- /* @__PURE__ */ l(
108
- "span",
102
+ x && /* @__PURE__ */ r(
103
+ T,
109
104
  {
110
- className: "Dropdown__selected-text",
111
- style: {
112
- overflow: T ? "hidden" : "visible"
113
- },
114
- children: E || m && h(m) || K
105
+ className: "Dropdown__icon",
106
+ name: x,
107
+ rotation: j,
108
+ spin: A
115
109
  }
116
110
  ),
117
- !R && /* @__PURE__ */ l("span", { className: "Dropdown__arrow-button", children: /* @__PURE__ */ l(b, { name: W ? "chevron-up" : "chevron-down" }) })
111
+ !h && /* @__PURE__ */ u(I, { children: [
112
+ /* @__PURE__ */ r("span", { className: "Dropdown__selected-text", children: R || m && f(m) || W }),
113
+ !F && /* @__PURE__ */ r(
114
+ T,
115
+ {
116
+ className: D([
117
+ "Dropdown__icon",
118
+ "Dropdown__icon--arrow",
119
+ y && "over",
120
+ p && "open"
121
+ ]),
122
+ name: "chevron-down"
123
+ }
124
+ )
125
+ ] })
118
126
  ]
119
127
  }
120
- ),
121
- I && /* @__PURE__ */ p(F, { children: [
122
- /* @__PURE__ */ l(
123
- D,
124
- {
125
- disabled: d,
126
- height: 1.8,
127
- icon: "chevron-left",
128
- onClick: () => {
129
- _(
130
- "previous"
131
- /* Previous */
132
- );
133
- }
134
- }
135
- ),
136
- /* @__PURE__ */ l(
137
- D,
138
- {
139
- disabled: d,
140
- height: 1.8,
141
- icon: "chevron-right",
142
- onClick: () => {
143
- _(
144
- "next"
145
- /* Next */
146
- );
147
- }
148
- }
149
- )
150
- ] })
151
- ] })
152
- }
153
- );
128
+ )
129
+ }
130
+ ),
131
+ k && /* @__PURE__ */ u(I, { children: [
132
+ /* @__PURE__ */ r(
133
+ E,
134
+ {
135
+ className: "Dropdown__button",
136
+ disabled: i,
137
+ icon: "chevron-left",
138
+ onClick: () => {
139
+ b(
140
+ "previous"
141
+ /* Previous */
142
+ );
143
+ }
144
+ }
145
+ ),
146
+ /* @__PURE__ */ r(
147
+ E,
148
+ {
149
+ className: "Dropdown__button",
150
+ disabled: i,
151
+ icon: "chevron-right",
152
+ onClick: () => {
153
+ b(
154
+ "next"
155
+ /* Next */
156
+ );
157
+ }
158
+ }
159
+ )
160
+ ] })
161
+ ] });
154
162
  }
155
163
  export {
156
- Y as Dropdown
164
+ X as Dropdown
157
165
  };
@@ -9,7 +9,7 @@ type State = {
9
9
  fontSize: number;
10
10
  };
11
11
  export declare class FitText extends Component<Props, State> {
12
- ref: RefObject<HTMLDivElement>;
12
+ ref: RefObject<HTMLDivElement | null>;
13
13
  state: State;
14
14
  constructor(props: Props);
15
15
  componentDidUpdate(prevProps: any): void;
@@ -0,0 +1,75 @@
1
+ import { Placement } from '@floating-ui/react';
2
+ import { CSSProperties, ReactNode } from 'react';
3
+ import { BooleanLike } from '../common/react';
4
+ type Props = {
5
+ /** Interacting with this element will open the floating element. */
6
+ children: ReactNode;
7
+ /** The content to display like floating. */
8
+ content: ReactNode;
9
+ } & Partial<{
10
+ /**
11
+ * Where the content will be displayed, relative to children.
12
+ * - See [Placement](https://floating-ui.com/docs/useFloating#placement)
13
+ * @default 'bottom'
14
+ */
15
+ placement: Placement;
16
+ /** Classes with will be applied to the content. */
17
+ contentClasses: string;
18
+ /** Inline styles with will be applied to the content. */
19
+ contentStyles: CSSProperties;
20
+ /** Use calculated by Floating UI children width as content width. */
21
+ contentAutoWidth: boolean;
22
+ /**
23
+ * Indentation of content element from children.
24
+ * @default 6
25
+ */
26
+ contentOffset: number;
27
+ /** Disables all interactions. */
28
+ disabled: BooleanLike;
29
+ /**
30
+ * How long the animation takes in ms.
31
+ * - If specified, default animation will be disabled.
32
+ * - Fully disables animations if 0
33
+ * @default 200
34
+ */
35
+ animationDuration: number;
36
+ /** Content will open when you hover over children. */
37
+ hoverOpen: boolean;
38
+ /**
39
+ * Delay in ms before opening and closing the content.
40
+ * - Works only if used `hoverOpen` prop.
41
+ * @default 200
42
+ */
43
+ hoverDelay: number;
44
+ /**
45
+ * Whitelisted classes.
46
+ * Used to allow to add some secured classes,
47
+ * click on which will not close the content.
48
+ * - Classes must be sent like this: `".class1, .class2"`
49
+ */
50
+ allowedOutsideClasses: string;
51
+ /** Stops event propagation on children. */
52
+ stopChildPropagation: boolean;
53
+ /** Close the content after interaction with it. */
54
+ closeAfterInteract: boolean;
55
+ /**
56
+ * Called when the open state changes.
57
+ * Returns the new open state.
58
+ * Can be used this way:
59
+ * ```tsx
60
+ * onOpenChange={open ? makeThingsOnOpen : makeThingsOnClose}
61
+ * ```
62
+ */
63
+ onOpenChange: (open: boolean) => void;
64
+ /**
65
+ * Called when mounted
66
+ */
67
+ onMounted: () => void;
68
+ }>;
69
+ /**
70
+ * ## Floating
71
+ * Floating lets you position elements so that they don't go out of the bounds of the window.
72
+ * - [Documentation](https://floating-ui.com/docs/react) for more information.
73
+ */
74
+ export declare function Floating(props: Props): import("react/jsx-runtime").JSX.Element;
75
+ export {};