tgui-core 1.8.3 → 2.0.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 (83) 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 +5 -5
  18. package/dist/components/Dropdown.js +135 -132
  19. package/dist/components/FitText.d.ts +1 -1
  20. package/dist/components/Flex.js +24 -26
  21. package/dist/components/Floating.d.ts +75 -0
  22. package/dist/components/Floating.js +2235 -0
  23. package/dist/components/ImageButton.d.ts +2 -3
  24. package/dist/components/ImageButton.js +88 -98
  25. package/dist/components/InfinitePlane.d.ts +35 -32
  26. package/dist/components/InfinitePlane.js +123 -133
  27. package/dist/components/Knob.d.ts +22 -6
  28. package/dist/components/Knob.js +45 -46
  29. package/dist/components/MenuBar.js +81 -97
  30. package/dist/components/Modal.js +12 -12
  31. package/dist/components/NumberInput.d.ts +1 -1
  32. package/dist/components/Popper.d.ts +5 -1
  33. package/dist/components/Popper.js +1026 -121
  34. package/dist/components/ProgressBar.js +3 -3
  35. package/dist/components/RoundGauge.js +30 -30
  36. package/dist/components/Section.js +7 -7
  37. package/dist/components/Slider.d.ts +22 -6
  38. package/dist/components/Slider.js +55 -56
  39. package/dist/components/Stack.js +3 -3
  40. package/dist/components/Table.js +7 -7
  41. package/dist/components/Tabs.js +7 -7
  42. package/dist/components/TextArea.d.ts +17 -0
  43. package/dist/components/TextArea.js +35 -33
  44. package/dist/components/Tooltip.d.ts +3 -34
  45. package/dist/components/Tooltip.js +14 -77
  46. package/dist/components/TrackOutsideClicks.d.ts +1 -1
  47. package/dist/components/index.d.ts +1 -0
  48. package/dist/components/index.js +64 -62
  49. package/package.json +26 -27
  50. package/styles/base.scss +13 -11
  51. package/styles/colors.scss +63 -67
  52. package/styles/components/BlockQuote.scss +5 -8
  53. package/styles/components/Button.scss +123 -99
  54. package/styles/components/Dialog.scss +23 -30
  55. package/styles/components/Dimmer.scss +3 -8
  56. package/styles/components/Divider.scss +6 -7
  57. package/styles/components/Dropdown.scss +97 -52
  58. package/styles/components/Flex.scss +0 -1
  59. package/styles/components/Floating.scss +60 -0
  60. package/styles/components/ImageButton.scss +136 -192
  61. package/styles/components/Input.scss +24 -26
  62. package/styles/components/Knob.scss +37 -41
  63. package/styles/components/LabeledList.scss +8 -6
  64. package/styles/components/MenuBar.scss +17 -21
  65. package/styles/components/Modal.scss +8 -7
  66. package/styles/components/NoticeBox.scss +22 -26
  67. package/styles/components/NumberInput.scss +30 -28
  68. package/styles/components/ProgressBar.scss +27 -19
  69. package/styles/components/RoundGauge.scss +46 -26
  70. package/styles/components/Section.scss +17 -32
  71. package/styles/components/Slider.scss +18 -15
  72. package/styles/components/Stack.scss +8 -48
  73. package/styles/components/Table.scss +2 -2
  74. package/styles/components/Tabs.scss +92 -66
  75. package/styles/components/TextArea.scss +32 -36
  76. package/styles/components/Tooltip.scss +10 -13
  77. package/styles/functions.scss +1 -62
  78. package/styles/main.scss +6 -1
  79. package/styles/reset.scss +7 -11
  80. package/styles/vars-colors.scss +108 -0
  81. package/styles/vars-components.scss +162 -0
  82. package/styles/vars-values.scss +110 -0
  83. package/dist/popper-CiqSDJTE.js +0 -906
@@ -1,157 +1,160 @@
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 f, jsx as r, Fragment as F } from "react/jsx-runtime";
2
+ import { useState as P, useRef as S } from "react";
3
+ import { KEY as g } from "../common/keys.js";
4
+ import { classes as h } from "../common/react.js";
5
+ import { unit as y } from "../common/ui.js";
6
+ import { Button as b } from "./Button.js";
7
+ import { Floating as V } from "./Floating.js";
8
+ import { Icon as I } from "./Icon.js";
9
+ const Y = -1;
10
+ function p(d) {
11
+ return typeof d == "string" ? d : d.value;
11
12
  }
12
- function Y(u) {
13
+ function Q(d) {
13
14
  const {
14
- autoScroll: v = !0,
15
- buttons: I,
16
- className: O,
17
- clipSelectedText: T = !0,
18
- color: B = "default",
19
- disabled: d,
20
- displayText: E,
21
- icon: x,
15
+ autoScroll: _ = !0,
16
+ buttons: C,
17
+ className: E,
18
+ color: O = "default",
19
+ disabled: a,
20
+ displayText: T,
21
+ icon: w,
22
22
  iconRotation: k,
23
- iconSpin: j,
24
- menuWidth: C = "15rem",
23
+ iconSpin: B,
24
+ menuWidth: K,
25
25
  noChevron: R,
26
- onClick: a,
27
- onSelected: o,
28
- options: c = [],
29
- over: y,
30
- placeholder: K = "Select...",
26
+ onClick: i,
27
+ onSelected: t,
28
+ options: s = [],
29
+ over: D,
30
+ placeholder: W = "Select...",
31
31
  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;
34
- 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);
32
+ width: j = 15
33
+ } = d, [u, A] = P(!1), x = S(null), l = s.findIndex((e) => p(e) === m) || 0;
34
+ function N(e) {
35
+ let n = e;
36
+ e < l ? n = e < 2 ? 0 : e - 2 : n = e > s.length - 3 ? s.length - 1 : e - 2;
37
+ const o = x.current, c = o == null ? void 0 : o.children[n];
38
+ o && c && (o.scrollTop = c.offsetTop);
39
39
  }
40
- function _(e) {
41
- if (c.length < 1 || d)
40
+ function v(e) {
41
+ if (s.length < 1 || a)
42
42
  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]));
43
+ const n = 0, o = s.length - 1;
44
+ let c;
45
+ l < 0 ? c = e === "next" ? o : n : e === "next" ? c = l === o ? n : l + 1 : c = l === n ? o : l - 1, u && _ && N(c), t == null || t(p(s[c]));
46
46
  }
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(
47
+ return /* @__PURE__ */ f("div", { className: "Dropdown", children: [
48
+ /* @__PURE__ */ r(
49
+ V,
50
+ {
51
+ contentAutoWidth: !0,
52
+ closeAfterInteract: !0,
53
+ placement: D ? "top" : "bottom",
54
+ allowedOutsideClasses: ".Dropdown__button",
55
+ contentClasses: "Dropdown__menu--wrapper",
56
+ contentStyles: { maxWidth: y(K) },
57
+ disabled: a,
58
+ onOpenChange: A,
59
+ content: /* @__PURE__ */ r("div", { ref: x, className: "Dropdown__menu", children: s.length === 0 ? /* @__PURE__ */ r("div", { className: "Dropdown__menu--entry", children: "No options" }) : s.map((e) => {
60
+ const n = p(e);
61
+ return /* @__PURE__ */ r(
62
+ "div",
63
+ {
64
+ className: h([
65
+ "Dropdown__menu--entry",
66
+ m === n && "selected"
67
+ ]),
68
+ onClick: () => {
69
+ t == null || t(n);
70
+ },
71
+ onKeyDown: (o) => {
72
+ o.key === g.Enter && (t == null || t(n));
73
+ },
74
+ children: typeof e == "string" ? e : e.displayText
75
+ },
76
+ n
77
+ );
78
+ }) }),
79
+ onMounted: () => {
80
+ u && _ && l !== Y && N(l);
81
+ },
82
+ children: /* @__PURE__ */ f(
89
83
  "div",
90
84
  {
91
- className: N([
85
+ className: h([
92
86
  "Dropdown__control",
93
- "Button",
94
- "Button--dropdown",
95
- `Button--color--${B}`,
96
- d && "Button--disabled",
97
- O
87
+ `Button--color--${O}`,
88
+ a && "Button--disabled",
89
+ E
98
90
  ]),
91
+ style: { width: y(j) },
99
92
  onClick: (e) => {
100
- d && !r || (f(!r), a == null || a(e));
93
+ a && !u || i == null || i(e);
101
94
  },
102
95
  onKeyDown: (e) => {
103
- e.key === "Enter" && !d && (f(!r), a == null || a(e));
96
+ e.key === g.Enter && !a && (i == null || i(e));
104
97
  },
105
98
  children: [
106
- x && /* @__PURE__ */ l(b, { mr: 1, name: x, rotation: k, spin: j }),
107
- /* @__PURE__ */ l(
108
- "span",
99
+ w && /* @__PURE__ */ r(
100
+ I,
109
101
  {
110
- className: "Dropdown__selected-text",
111
- style: {
112
- overflow: T ? "hidden" : "visible"
113
- },
114
- children: E || m && h(m) || K
102
+ className: "Dropdown__icon",
103
+ name: w,
104
+ rotation: k,
105
+ spin: B
115
106
  }
116
107
  ),
117
- !R && /* @__PURE__ */ l("span", { className: "Dropdown__arrow-button", children: /* @__PURE__ */ l(b, { name: W ? "chevron-up" : "chevron-down" }) })
108
+ /* @__PURE__ */ r("span", { className: "Dropdown__selected-text", children: T || m && p(m) || W }),
109
+ !R && /* @__PURE__ */ r(
110
+ I,
111
+ {
112
+ className: h([
113
+ "Dropdown__icon",
114
+ "Dropdown__icon--arrow",
115
+ D && "over",
116
+ u && "open"
117
+ ]),
118
+ name: "chevron-down"
119
+ }
120
+ )
118
121
  ]
119
122
  }
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
- );
123
+ )
124
+ }
125
+ ),
126
+ C && /* @__PURE__ */ f(F, { children: [
127
+ /* @__PURE__ */ r(
128
+ b,
129
+ {
130
+ className: "Dropdown__button",
131
+ disabled: a,
132
+ icon: "chevron-left",
133
+ onClick: () => {
134
+ v(
135
+ "previous"
136
+ /* Previous */
137
+ );
138
+ }
139
+ }
140
+ ),
141
+ /* @__PURE__ */ r(
142
+ b,
143
+ {
144
+ className: "Dropdown__button",
145
+ disabled: a,
146
+ icon: "chevron-right",
147
+ onClick: () => {
148
+ v(
149
+ "next"
150
+ /* Next */
151
+ );
152
+ }
153
+ }
154
+ )
155
+ ] })
156
+ ] });
154
157
  }
155
158
  export {
156
- Y as Dropdown
159
+ Q as Dropdown
157
160
  };
@@ -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;
@@ -1,72 +1,70 @@
1
1
  import { jsx as l } from "react/jsx-runtime";
2
- import { classes as o } from "../common/react.js";
2
+ import { classes as r } from "../common/react.js";
3
3
  import { computeBoxClassName as m, computeBoxProps as a, unit as f } from "../common/ui.js";
4
- function d(e) {
5
- return o([
4
+ function p(e) {
5
+ return r([
6
6
  "Flex",
7
7
  e.inlineFlex && "Flex--inline",
8
8
  m(e)
9
9
  ]);
10
10
  }
11
- function p(e) {
12
- const { direction: i, wrap: t, align: r, justify: s, ...n } = e;
11
+ function d(e) {
12
+ const { direction: s, wrap: t, align: i, justify: n, ...o } = e;
13
13
  return a({
14
14
  style: {
15
- ...n.style,
16
- flexDirection: i,
15
+ ...o.style,
16
+ flexDirection: s,
17
17
  flexWrap: t === !0 ? "wrap" : t,
18
- alignItems: r,
19
- justifyContent: s
18
+ alignItems: i,
19
+ justifyContent: n
20
20
  },
21
- ...n
21
+ ...o
22
22
  });
23
23
  }
24
24
  function F(e) {
25
- const { className: i, ...t } = e;
25
+ const { className: s, ...t } = e;
26
26
  return /* @__PURE__ */ l(
27
27
  "div",
28
28
  {
29
- className: o([i, d(t)]),
30
- ...p(t)
29
+ className: r([s, p(t)]),
30
+ ...d(t)
31
31
  }
32
32
  );
33
33
  }
34
- const N = (e) => o(["Flex__item", m(e)]);
34
+ const N = (e) => r(["Flex__item", m(e)]);
35
35
  function v(e) {
36
- const { style: i, grow: t, order: r, shrink: s, basis: n, align: c, ...u } = e, x = n ?? // IE11: Set basis to specified width if it's known, which fixes certain
36
+ const { style: s, grow: t, order: i, shrink: n, basis: o, align: c, ...u } = e, x = o ?? // IE11: Set basis to specified width if it's known, which fixes certain
37
37
  // bugs when rendering tables inside the flex.
38
38
  e.width ?? // If grow is used, basis should be set to 0 to be consistent with
39
39
  // flex css shorthand `flex: 1`.
40
40
  (t !== void 0 ? 0 : void 0);
41
41
  return a({
42
42
  style: {
43
- ...i,
44
- minWidth: t !== void 0 && 0,
45
- minHeight: t !== void 0 && 0,
43
+ ...s,
46
44
  flexGrow: t !== void 0 && Number(t),
47
- flexShrink: s !== void 0 && Number(s),
45
+ flexShrink: n !== void 0 && Number(n),
48
46
  flexBasis: f(x),
49
- order: r,
47
+ order: i,
50
48
  alignSelf: c
51
49
  },
52
50
  ...u
53
51
  });
54
52
  }
55
- function g(e) {
56
- const { className: i, ...t } = e;
53
+ function y(e) {
54
+ const { className: s, ...t } = e;
57
55
  return /* @__PURE__ */ l(
58
56
  "div",
59
57
  {
60
- className: o([i, N(e)]),
58
+ className: r([s, N(e)]),
61
59
  ...v(t)
62
60
  }
63
61
  );
64
62
  }
65
- F.Item = g;
63
+ F.Item = y;
66
64
  export {
67
65
  F as Flex,
68
- d as computeFlexClassName,
66
+ p as computeFlexClassName,
69
67
  N as computeFlexItemClassName,
70
68
  v as computeFlexItemProps,
71
- p as computeFlexProps
69
+ d as computeFlexProps
72
70
  };
@@ -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 {};