tgui-core 1.3.2 → 1.5.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 (37) hide show
  1. package/README.md +24 -2
  2. package/dist/common/ui.d.ts +113 -0
  3. package/dist/common/ui.js +137 -0
  4. package/dist/components/AnimatedNumber.d.ts +1 -0
  5. package/dist/components/BlockQuote.d.ts +5 -0
  6. package/dist/components/Box.d.ts +74 -63
  7. package/dist/components/Box.js +13 -127
  8. package/dist/components/Button.d.ts +22 -5
  9. package/dist/components/Button.js +2 -1
  10. package/dist/components/ByondUi.d.ts +50 -0
  11. package/dist/components/ByondUi.js +32 -44
  12. package/dist/components/ColorBox.js +1 -1
  13. package/dist/components/Dropdown.js +1 -1
  14. package/dist/components/Flex.js +1 -1
  15. package/dist/components/Icon.d.ts +1 -1
  16. package/dist/components/Icon.js +2 -2
  17. package/dist/components/Image.js +22 -21
  18. package/dist/components/ImageButton.js +1 -1
  19. package/dist/components/InfinitePlane.js +1 -1
  20. package/dist/components/Input.d.ts +6 -3
  21. package/dist/components/Input.js +60 -55
  22. package/dist/components/KeyListener.d.ts +2 -8
  23. package/dist/components/KeyListener.js +11 -19
  24. package/dist/components/Knob.js +1 -1
  25. package/dist/components/LabeledList.js +16 -15
  26. package/dist/components/Modal.js +1 -1
  27. package/dist/components/ProgressBar.js +1 -1
  28. package/dist/components/RoundGauge.d.ts +2 -1
  29. package/dist/components/RoundGauge.js +19 -18
  30. package/dist/components/Section.d.ts +43 -27
  31. package/dist/components/Section.js +64 -66
  32. package/dist/components/Slider.js +1 -1
  33. package/dist/components/Stack.js +1 -1
  34. package/dist/components/Table.js +1 -1
  35. package/dist/components/Tabs.js +1 -1
  36. package/dist/components/TextArea.d.ts +2 -1
  37. package/package.json +20 -12
@@ -1,43 +1,44 @@
1
1
  import { jsxs as m, jsx as e } from "react/jsx-runtime";
2
2
  import { scale as d, keyOfMatchingRange as M, clamp01 as k } from "../common/math.js";
3
- import { classes as h } from "../common/react.js";
4
- import { AnimatedNumber as v } from "./AnimatedNumber.js";
5
- import { Box as B, computeBoxClassName as $, computeBoxProps as j } from "./Box.js";
6
- function w(p) {
3
+ import { classes as p } from "../common/react.js";
4
+ import { computeBoxClassName as v, computeBoxProps as B } from "../common/ui.js";
5
+ import { AnimatedNumber as $ } from "./AnimatedNumber.js";
6
+ import { Box as j } from "./Box.js";
7
+ function z(h) {
7
8
  const {
8
9
  alertAfter: a,
9
10
  alertBefore: t,
10
11
  className: _,
11
12
  format: R,
12
13
  maxValue: c = 1,
13
- minValue: u = 1,
14
+ minValue: i = 1,
14
15
  ranges: n,
15
16
  size: y = 1,
16
17
  style: x,
17
18
  value: r,
18
19
  ...g
19
- } = p, G = d(r, u, c), f = k(G), l = n ? {} : { primary: [0, 1] };
20
+ } = h, G = d(r, i, c), f = k(G), l = n ? {} : { primary: [0, 1] };
20
21
  n && Object.keys(n).forEach((o) => {
21
22
  const s = n[o];
22
23
  l[o] = [
23
- d(s[0], u, c),
24
- d(s[1], u, c)
24
+ d(s[0], i, c),
25
+ d(s[1], i, c)
25
26
  ];
26
27
  });
27
28
  function N() {
28
29
  return !!(a && t && r > a && r < t || a && r > a || t && r < t);
29
30
  }
30
31
  const C = N() && M(f, l);
31
- return /* @__PURE__ */ m(B, { inline: !0, children: [
32
+ return /* @__PURE__ */ m(j, { inline: !0, children: [
32
33
  /* @__PURE__ */ e(
33
34
  "div",
34
35
  {
35
- className: h([
36
+ className: p([
36
37
  "RoundGauge",
37
38
  _,
38
- $(g)
39
+ v(g)
39
40
  ]),
40
- ...j({
41
+ ...B({
41
42
  style: {
42
43
  fontSize: `${y}em`,
43
44
  ...x
@@ -48,7 +49,7 @@ function w(p) {
48
49
  (a || t) && /* @__PURE__ */ e(
49
50
  "g",
50
51
  {
51
- className: h([
52
+ className: p([
52
53
  "RoundGauge__alert",
53
54
  C ? `active RoundGauge__alert--${C}` : ""
54
55
  ]),
@@ -57,18 +58,18 @@ function w(p) {
57
58
  ),
58
59
  /* @__PURE__ */ e("g", { children: /* @__PURE__ */ e("circle", { className: "RoundGauge__ringTrack", cx: "50", cy: "50", r: "45" }) }),
59
60
  /* @__PURE__ */ e("g", { children: Object.keys(l).map((o, s) => {
60
- const i = l[o];
61
+ const u = l[o];
61
62
  return /* @__PURE__ */ e(
62
63
  "circle",
63
64
  {
64
65
  className: `RoundGauge__ringFill RoundGauge--color--${o}`,
65
66
  style: {
66
67
  strokeDashoffset: Math.max(
67
- (2 - (i[1] - i[0])) * Math.PI * 50,
68
+ (2 - (u[1] - u[0])) * Math.PI * 50,
68
69
  0
69
70
  )
70
71
  },
71
- transform: `rotate(${180 + 180 * i[0]} 50 50)`,
72
+ transform: `rotate(${180 + 180 * u[0]} 50 50)`,
72
73
  cx: "50",
73
74
  cy: "50",
74
75
  r: "45"
@@ -105,9 +106,9 @@ function w(p) {
105
106
  ] })
106
107
  }
107
108
  ),
108
- /* @__PURE__ */ e(v, { value: r, format: R })
109
+ /* @__PURE__ */ e($, { value: r, format: R })
109
110
  ] });
110
111
  }
111
112
  export {
112
- w as RoundGauge
113
+ z as RoundGauge
113
114
  };
@@ -1,29 +1,4 @@
1
1
  import { ReactNode } from 'react';
2
- import { BoxProps } from './Box';
3
- type Props = Partial<{
4
- /** Buttons to render aside the section title. */
5
- buttons: ReactNode;
6
- /** id to assosiate with the parent div element used by this section, for uses with procs like getElementByID */
7
- container_id: string;
8
- /** If true, fills all available vertical space. */
9
- fill: boolean;
10
- /** If true, removes all section padding. */
11
- fitted: boolean;
12
- /** If true, fills the area without forcing height to 100% */
13
- flexGrow: boolean;
14
- /** If true, removes the section top padding */
15
- noTopPadding: boolean;
16
- /** @member Callback function for the `scroll` event */
17
- onScroll: ((this: GlobalEventHandlers, ev: Event) => any) | null;
18
- /** Shows or hides the scrollbar. */
19
- scrollable: boolean;
20
- /** Shows or hides the horizontal scrollbar. */
21
- scrollableHorizontal: boolean;
22
- /** If true, filly the area except for -3rem */
23
- stretchContents: boolean;
24
- /** Title of the section. */
25
- title: ReactNode;
26
- }> & BoxProps;
27
2
  /**
28
3
  * ## Section
29
4
  * Section is a surface that displays content and actions on a single topic.
@@ -51,5 +26,46 @@ type Props = Partial<{
51
26
  * </Section>
52
27
  * ```
53
28
  */
54
- export declare function Section(props: Props): import("react/jsx-runtime").JSX.Element;
55
- export {};
29
+ export declare const Section: import('react').ForwardRefExoticComponent<Partial<{
30
+ /** Buttons to render aside the section title. */
31
+ buttons: ReactNode;
32
+ /** id to assosiate with the parent div element used by this section, for uses with procs like getElementByID */
33
+ container_id: string;
34
+ /** If true, fills all available vertical space. */
35
+ fill: boolean;
36
+ /** If true, removes all section padding. */
37
+ fitted: boolean;
38
+ /** If true, fills the area without forcing height to 100% */
39
+ flexGrow: boolean;
40
+ /** If true, removes the section top padding */
41
+ noTopPadding: boolean;
42
+ /** @member Callback function for the `scroll` event */
43
+ onScroll: ((this: GlobalEventHandlers, ev: Event) => any) | null;
44
+ /** Shows or hides the scrollbar. */
45
+ scrollable: boolean;
46
+ /** Shows or hides the horizontal scrollbar. */
47
+ scrollableHorizontal: boolean;
48
+ /** If true, filly the area except for -3rem */
49
+ stretchContents: boolean;
50
+ /** Title of the section. */
51
+ title: ReactNode;
52
+ }> & Partial<{
53
+ as: string;
54
+ children: ReactNode;
55
+ className: string | import('../common/react').BooleanLike;
56
+ id: string;
57
+ style: import('react').CSSProperties;
58
+ tw: string;
59
+ } & import('../common/ui').BooleanStyleMap & import('../common/ui').StringStyleMap & {
60
+ onClick: import('react').MouseEventHandler<HTMLDivElement>;
61
+ onContextMenu: import('react').MouseEventHandler<HTMLDivElement>;
62
+ onDoubleClick: import('react').MouseEventHandler<HTMLDivElement>;
63
+ onKeyDown: import('react').KeyboardEventHandler<HTMLDivElement>;
64
+ onKeyUp: import('react').KeyboardEventHandler<HTMLDivElement>;
65
+ onMouseDown: import('react').MouseEventHandler<HTMLDivElement>;
66
+ onMouseLeave: import('react').MouseEventHandler<HTMLDivElement>;
67
+ onMouseMove: import('react').MouseEventHandler<HTMLDivElement>;
68
+ onMouseOver: import('react').MouseEventHandler<HTMLDivElement>;
69
+ onMouseUp: import('react').MouseEventHandler<HTMLDivElement>;
70
+ onScroll: import('react').UIEventHandler<HTMLDivElement>;
71
+ }> & import('react').RefAttributes<HTMLDivElement>>;
@@ -1,68 +1,66 @@
1
- import { jsxs as s, jsx as t } from "react/jsx-runtime";
2
- import { useRef as T, useEffect as C } from "react";
3
- import { addScrollableNode as P, removeScrollableNode as g } from "../common/events.js";
4
- import { classes as a, canRender as d } from "../common/react.js";
5
- import { computeBoxClassName as j, computeBoxProps as z } from "./Box.js";
6
- function G(m) {
7
- const {
8
- buttons: n,
9
- children: f,
10
- className: S,
11
- fill: u,
12
- fitted: _,
13
- flexGrow: p,
14
- noTopPadding: N,
15
- onScroll: h,
16
- scrollable: c,
17
- scrollableHorizontal: l,
18
- stretchContents: b,
19
- title: r,
20
- container_id: x,
21
- ...i
22
- } = m, e = T(null), v = d(r) || d(n);
23
- return C(() => {
24
- if (!(e != null && e.current) || !c && !l) return;
25
- const o = e.current;
26
- return P(o), () => {
27
- o && g(o);
28
- };
29
- }, []), /* @__PURE__ */ s(
30
- "div",
31
- {
32
- id: x || "",
33
- className: a([
34
- "Section",
35
- u && "Section--fill",
36
- _ && "Section--fitted",
37
- c && "Section--scrollable",
38
- l && "Section--scrollableHorizontal",
39
- p && "Section--flex",
40
- S,
41
- j(i)
42
- ]),
43
- ...z(i),
44
- children: [
45
- v && /* @__PURE__ */ s("div", { className: "Section__title", children: [
46
- /* @__PURE__ */ t("span", { className: "Section__titleText", children: r }),
47
- /* @__PURE__ */ t("div", { className: "Section__buttons", children: n })
48
- ] }),
49
- /* @__PURE__ */ t("div", { className: "Section__rest", children: /* @__PURE__ */ t(
50
- "div",
51
- {
52
- className: a([
53
- "Section__content",
54
- b && "Section__content--stretchContents",
55
- N && "Section__content--noTopPadding"
56
- ]),
57
- onScroll: h,
58
- ref: e,
59
- children: f
60
- }
61
- ) })
62
- ]
63
- }
64
- );
65
- }
1
+ import { jsxs as i, jsx as t } from "react/jsx-runtime";
2
+ import { forwardRef as C, useRef as P, useEffect as g } from "react";
3
+ import { addScrollableNode as j, removeScrollableNode as w } from "../common/events.js";
4
+ import { classes as s, canRender as a } from "../common/react.js";
5
+ import { computeBoxClassName as z, computeBoxProps as B } from "../common/ui.js";
6
+ const q = C(
7
+ (d, m) => {
8
+ const {
9
+ buttons: o,
10
+ children: f,
11
+ className: S,
12
+ container_id: _ = "",
13
+ fill: u,
14
+ fitted: p,
15
+ flexGrow: N,
16
+ noTopPadding: h,
17
+ onScroll: b,
18
+ scrollable: n,
19
+ scrollableHorizontal: c,
20
+ stretchContents: x,
21
+ title: r,
22
+ ...l
23
+ } = d, v = P(null), e = m || v, T = a(r) || a(o);
24
+ return g(() => (e != null && e.current && (n || c) && j(e.current), () => {
25
+ e != null && e.current && w(e.current);
26
+ }), []), /* @__PURE__ */ i(
27
+ "div",
28
+ {
29
+ id: _,
30
+ className: s([
31
+ "Section",
32
+ u && "Section--fill",
33
+ p && "Section--fitted",
34
+ n && "Section--scrollable",
35
+ c && "Section--scrollableHorizontal",
36
+ N && "Section--flex",
37
+ S,
38
+ z(l)
39
+ ]),
40
+ ...B(l),
41
+ children: [
42
+ T && /* @__PURE__ */ i("div", { className: "Section__title", children: [
43
+ /* @__PURE__ */ t("span", { className: "Section__titleText", children: r }),
44
+ /* @__PURE__ */ t("div", { className: "Section__buttons", children: o })
45
+ ] }),
46
+ /* @__PURE__ */ t("div", { className: "Section__rest", children: /* @__PURE__ */ t(
47
+ "div",
48
+ {
49
+ className: s([
50
+ "Section__content",
51
+ x && "Section__content--stretchContents",
52
+ h && "Section__content--noTopPadding"
53
+ ]),
54
+ onScroll: b,
55
+ ref: e,
56
+ children: f
57
+ }
58
+ ) })
59
+ ]
60
+ }
61
+ );
62
+ }
63
+ );
66
64
  export {
67
- G as Section
65
+ q as Section
68
66
  };
@@ -1,7 +1,7 @@
1
1
  import { jsx as e, jsxs as m } from "react/jsx-runtime";
2
2
  import { keyOfMatchingRange as O, clamp01 as r, scale as u } from "../common/math.js";
3
3
  import { classes as p } from "../common/react.js";
4
- import { computeBoxClassName as b, computeBoxProps as z } from "./Box.js";
4
+ import { computeBoxClassName as b, computeBoxProps as z } from "../common/ui.js";
5
5
  import { DraggableControl as R } from "./DraggableControl.js";
6
6
  function J(g) {
7
7
  const {
@@ -1,6 +1,6 @@
1
1
  import { jsx as i } from "react/jsx-runtime";
2
2
  import { classes as a } from "../common/react.js";
3
- import { computeBoxClassName as o } from "./Box.js";
3
+ import { computeBoxClassName as o } from "../common/ui.js";
4
4
  import { computeFlexClassName as k, computeFlexProps as v, computeFlexItemProps as m } from "./Flex.js";
5
5
  function n(r) {
6
6
  const { className: c, vertical: e, fill: t, reverse: s, zebra: l, ...d } = r, f = e ? "column" : "row", S = s ? "-reverse" : "";
@@ -1,6 +1,6 @@
1
1
  import { jsx as c } from "react/jsx-runtime";
2
2
  import { classes as r } from "../common/react.js";
3
- import { computeBoxClassName as t, computeBoxProps as n } from "./Box.js";
3
+ import { computeBoxClassName as t, computeBoxProps as n } from "../common/ui.js";
4
4
  function m(e) {
5
5
  const { className: l, collapsing: a, children: s, ...o } = e;
6
6
  return /* @__PURE__ */ c(
@@ -1,6 +1,6 @@
1
1
  import { jsx as a, jsxs as u } from "react/jsx-runtime";
2
2
  import { classes as T, canRender as d } from "../common/react.js";
3
- import { computeBoxClassName as f, computeBoxProps as h } from "./Box.js";
3
+ import { computeBoxClassName as f, computeBoxProps as h } from "../common/ui.js";
4
4
  import { Icon as N } from "./Icon.js";
5
5
  function v(l) {
6
6
  const { className: c, vertical: i, fill: o, fluid: e, children: r, ...s } = l;
@@ -25,7 +25,8 @@ export declare const TextArea: import('react').ForwardRefExoticComponent<Partial
25
25
  className: string | import('../common/react').BooleanLike;
26
26
  id: string;
27
27
  style: import('react').CSSProperties;
28
- }> & 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<{
28
+ tw: string;
29
+ } & import('../common/ui').BooleanStyleMap & import('../common/ui').StringStyleMap & {
29
30
  onClick: import('react').MouseEventHandler<HTMLDivElement>;
30
31
  onContextMenu: import('react').MouseEventHandler<HTMLDivElement>;
31
32
  onDoubleClick: import('react').MouseEventHandler<HTMLDivElement>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tgui-core",
3
- "version": "1.3.2",
3
+ "version": "1.5.1",
4
4
  "description": "TGUI core component library",
5
5
  "keywords": ["TGUI", "library", "typescript"],
6
6
  "files": ["dist"],
@@ -12,6 +12,13 @@
12
12
  "./*": {
13
13
  "import": "./dist/common/*.js",
14
14
  "require": "./dist/common/*.cjs"
15
+ },
16
+ "./styles": {
17
+ "default": "./lib/styles/main.scss",
18
+ "sass": "./lib/styles/main.scss"
19
+ },
20
+ "./styles/components/*": {
21
+ "sass": "./lib/styles/components/*"
15
22
  }
16
23
  },
17
24
  "repository": {
@@ -31,27 +38,28 @@
31
38
  "type": "module",
32
39
  "devDependencies": {
33
40
  "@biomejs/biome": "1.9.4",
34
- "@chromatic-com/storybook": "3.2.2",
41
+ "@chromatic-com/storybook": "^3.2.3",
35
42
  "@popperjs/core": "^2.11.8",
36
- "@storybook/addon-essentials": "8.4.4",
37
- "@storybook/addon-interactions": "8.4.4",
38
- "@storybook/addon-onboarding": "8.4.4",
39
- "@storybook/blocks": "8.4.4",
40
- "@storybook/react": "8.4.4",
41
- "@storybook/react-vite": "8.4.4",
42
- "@storybook/test": "8.4.4",
43
+ "@storybook/addon-console": "^3.0.0",
44
+ "@storybook/addon-essentials": "^8.4.7",
45
+ "@storybook/addon-interactions": "^8.4.7",
46
+ "@storybook/addon-onboarding": "^8.4.7",
47
+ "@storybook/blocks": "^8.4.7",
48
+ "@storybook/react": "^8.4.7",
49
+ "@storybook/react-vite": "^8.4.7",
50
+ "@storybook/test": "^8.4.7",
43
51
  "@types/node": "^22.9.0",
44
52
  "@types/react": "^18.3.3",
45
53
  "@types/react-dom": "^18.3.0",
46
54
  "@types/webpack-env": "^1.18.5",
47
55
  "@vitejs/plugin-react-swc": "^3.7.1",
56
+ "chromatic": "^11.18.1",
48
57
  "glob": "^11.0.0",
49
58
  "prettier": "^3.3.3",
50
59
  "react-popper": "^2.3.0",
51
60
  "sass": "^1.81.0",
52
- "storybook": "8.4.4",
61
+ "storybook": "^8.4.7",
53
62
  "storybook-addon-sass-postcss": "^0.3.2",
54
- "tgui-styles": "^0.0.8",
55
63
  "typescript": "^5.6.3",
56
64
  "vite": "^5.4.11",
57
65
  "vite-plugin-dts": "^4.3.0"
@@ -60,5 +68,5 @@
60
68
  "react": "^18.2.0",
61
69
  "react-dom": "^18.2.0"
62
70
  },
63
- "packageManager": "pnpm@9.13.0+sha512.beb9e2a803db336c10c9af682b58ad7181ca0fbd0d4119f2b33d5f2582e96d6c0d93c85b23869295b765170fbdaa92890c0da6ada457415039769edf3c959efe"
71
+ "packageManager": "pnpm@9.15.1+sha512.1acb565e6193efbebda772702950469150cf12bcc764262e7587e71d19dc98a423dff9536e57ea44c49bdf790ff694e83c27be5faa23d67e0c033b583be4bfcf"
64
72
  }