tgui-core 2.0.5 → 2.1.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 (121) hide show
  1. package/dist/common/collections.d.ts +1 -1
  2. package/dist/common/collections.js +1 -10
  3. package/dist/common/color.js +1 -70
  4. package/dist/common/constants.js +1 -329
  5. package/dist/common/events.js +1 -147
  6. package/dist/common/exhaustive.js +1 -6
  7. package/dist/common/format.js +1 -117
  8. package/dist/common/fp.js +1 -9
  9. package/dist/common/hotkeys.d.ts +1 -1
  10. package/dist/common/hotkeys.js +1 -112
  11. package/dist/common/http.js +1 -10
  12. package/dist/common/keycodes.js +1 -88
  13. package/dist/common/keys.js +1 -32
  14. package/dist/common/math.js +1 -45
  15. package/dist/common/random.js +1 -21
  16. package/dist/common/react.js +1 -30
  17. package/dist/common/string.js +1 -88
  18. package/dist/common/timer.js +1 -28
  19. package/dist/common/type-utils.js +1 -25
  20. package/dist/common/ui.d.ts +2 -2
  21. package/dist/common/ui.js +1 -141
  22. package/dist/common/uuid.js +1 -10
  23. package/dist/common/vector.js +1 -48
  24. package/dist/components/AnimatedNumber.d.ts +1 -1
  25. package/dist/components/AnimatedNumber.js +1 -73
  26. package/dist/components/Autofocus.d.ts +1 -1
  27. package/dist/components/Autofocus.js +1 -17
  28. package/dist/components/Blink.d.ts +1 -1
  29. package/dist/components/Blink.js +1 -56
  30. package/dist/components/BlockQuote.d.ts +1 -1
  31. package/dist/components/BlockQuote.js +1 -10
  32. package/dist/components/Box.d.ts +5 -5
  33. package/dist/components/Box.js +1 -19
  34. package/dist/components/Button.d.ts +4 -4
  35. package/dist/components/Button.js +1 -258
  36. package/dist/components/ByondUi.d.ts +1 -1
  37. package/dist/components/ByondUi.js +1 -61
  38. package/dist/components/Chart.d.ts +1 -1
  39. package/dist/components/Chart.js +1 -80
  40. package/dist/components/Collapsible.d.ts +2 -2
  41. package/dist/components/Collapsible.js +1 -36
  42. package/dist/components/ColorBox.d.ts +2 -2
  43. package/dist/components/ColorBox.js +1 -17
  44. package/dist/components/Dialog.d.ts +1 -1
  45. package/dist/components/Dialog.js +1 -42
  46. package/dist/components/Dimmer.d.ts +1 -1
  47. package/dist/components/Dimmer.js +1 -10
  48. package/dist/components/Divider.js +1 -18
  49. package/dist/components/DmIcon.d.ts +3 -3
  50. package/dist/components/DmIcon.js +1 -23
  51. package/dist/components/DraggableControl.d.ts +2 -2
  52. package/dist/components/DraggableControl.js +1 -111
  53. package/dist/components/Dropdown.d.ts +2 -2
  54. package/dist/components/Dropdown.js +1 -165
  55. package/dist/components/FitText.d.ts +2 -2
  56. package/dist/components/FitText.js +1 -63
  57. package/dist/components/Flex.d.ts +1 -1
  58. package/dist/components/Flex.js +1 -70
  59. package/dist/components/Floating.d.ts +3 -3
  60. package/dist/components/Floating.js +1 -2235
  61. package/dist/components/Icon.d.ts +2 -2
  62. package/dist/components/Icon.js +1 -45
  63. package/dist/components/Image.d.ts +1 -1
  64. package/dist/components/Image.js +1 -38
  65. package/dist/components/ImageButton.d.ts +10 -5
  66. package/dist/components/ImageButton.js +1 -154
  67. package/dist/components/InfinitePlane.d.ts +2 -2
  68. package/dist/components/InfinitePlane.js +1 -133
  69. package/dist/components/Input.d.ts +2 -2
  70. package/dist/components/Input.js +1 -96
  71. package/dist/components/KeyListener.d.ts +1 -1
  72. package/dist/components/KeyListener.js +1 -15
  73. package/dist/components/Knob.d.ts +2 -2
  74. package/dist/components/Knob.js +1 -133
  75. package/dist/components/LabeledControls.d.ts +1 -1
  76. package/dist/components/LabeledControls.js +1 -39
  77. package/dist/components/LabeledList.d.ts +2 -2
  78. package/dist/components/LabeledList.js +1 -89
  79. package/dist/components/MenuBar.d.ts +32 -0
  80. package/dist/components/MenuBar.js +1 -133
  81. package/dist/components/Modal.d.ts +2 -2
  82. package/dist/components/Modal.js +1 -22
  83. package/dist/components/NoticeBox.d.ts +1 -1
  84. package/dist/components/NoticeBox.js +1 -23
  85. package/dist/components/NumberInput.d.ts +9 -19
  86. package/dist/components/NumberInput.js +1 -213
  87. package/dist/components/Popper.d.ts +8 -9
  88. package/dist/components/Popper.js +1 -1082
  89. package/dist/components/ProgressBar.d.ts +2 -2
  90. package/dist/components/ProgressBar.js +1 -33
  91. package/dist/components/RestrictedInput.d.ts +29 -0
  92. package/dist/components/RestrictedInput.js +1 -161
  93. package/dist/components/RoundGauge.d.ts +2 -2
  94. package/dist/components/RoundGauge.js +1 -114
  95. package/dist/components/Section.d.ts +30 -44
  96. package/dist/components/Section.js +1 -66
  97. package/dist/components/Slider.d.ts +2 -2
  98. package/dist/components/Slider.js +1 -113
  99. package/dist/components/Stack.d.ts +2 -2
  100. package/dist/components/Stack.js +1 -58
  101. package/dist/components/StyleableSection.d.ts +1 -1
  102. package/dist/components/StyleableSection.js +1 -16
  103. package/dist/components/Table.d.ts +1 -1
  104. package/dist/components/Table.js +1 -57
  105. package/dist/components/Tabs.d.ts +2 -2
  106. package/dist/components/Tabs.js +1 -65
  107. package/dist/components/TextArea.d.ts +14 -28
  108. package/dist/components/TextArea.js +1 -139
  109. package/dist/components/TimeDisplay.js +1 -25
  110. package/dist/components/Tooltip.d.ts +2 -2
  111. package/dist/components/Tooltip.js +1 -18
  112. package/dist/components/TrackOutsideClicks.d.ts +2 -2
  113. package/dist/components/TrackOutsideClicks.js +1 -24
  114. package/dist/components/VirtualList.d.ts +1 -1
  115. package/dist/components/VirtualList.js +1 -34
  116. package/dist/components/index.js +1 -96
  117. package/license.txt +1 -1
  118. package/package.json +11 -17
  119. package/styles/components/Button.scss +1 -1
  120. package/styles/components/TextArea.scss +7 -0
  121. package/dist/components/FakeTerminal.js +0 -38
@@ -1,5 +1,5 @@
1
- import { PropsWithChildren } from 'react';
2
- import { BoxProps } from './Box';
1
+ import type { PropsWithChildren } from 'react';
2
+ import type { BoxProps } from './Box';
3
3
  type Props = {
4
4
  /**
5
5
  * Current progress as a floating point number between `minValue` (default: 0) and `maxValue` (default: 1).
@@ -1,33 +1 @@
1
- import { jsxs as C, jsx as i } from "react/jsx-runtime";
2
- import { CSS_COLORS as P } from "../common/constants.js";
3
- import { keyOfMatchingRange as h, toFixed as x, clamp01 as _, scale as v } from "../common/math.js";
4
- import { classes as y } from "../common/react.js";
5
- import { computeBoxProps as N, computeBoxClassName as S } from "../common/ui.js";
6
- function k(n) {
7
- const {
8
- className: m,
9
- value: o,
10
- minValue: d = 0,
11
- maxValue: f = 1,
12
- color: u,
13
- ranges: p = {},
14
- empty: g,
15
- children: r,
16
- ...l
17
- } = n, t = v(o, d, f), B = r !== void 0, s = u || h(o, p) || "default", e = N(l), a = ["ProgressBar", m, S(l)], c = {
18
- width: `${_(t) * 100}%`
19
- };
20
- return P.includes(s) || s === "default" ? a.push(`ProgressBar--color--${s}`) : (e.style = { ...e.style, borderColor: s }, c.backgroundColor = s), /* @__PURE__ */ C("div", { className: y(a), ...e, children: [
21
- /* @__PURE__ */ i(
22
- "div",
23
- {
24
- className: "ProgressBar__fill ProgressBar__fill--animated",
25
- style: c
26
- }
27
- ),
28
- /* @__PURE__ */ i("div", { className: "ProgressBar__content", children: B ? r : !g && `${x(t * 100)}%` })
29
- ] });
30
- }
31
- export {
32
- k as ProgressBar
33
- };
1
+ import*as s from"react/jsx-runtime";import*as o from"../common/constants.js";import*as r from"../common/math.js";import*as e from"../common/react.js";import*as a from"../common/ui.js";function m(m){let{className:t,value:c,minValue:l=0,maxValue:i=1,color:n,ranges:d={},empty:f,children:p,...u}=m,g=(0,r.scale)(c,l,i),j=void 0!==p,x=n||(0,r.keyOfMatchingRange)(c,d)||"default",B=(0,a.computeBoxProps)(u),P=["ProgressBar",t,(0,a.computeBoxClassName)(u)],_={width:`${100*(0,r.clamp01)(g)}%`};return o.CSS_COLORS.includes(x)||"default"===x?P.push(`ProgressBar--color--${x}`):(B.style={...B.style,borderColor:x},_.backgroundColor=x),(0,s.jsxs)("div",{className:(0,e.classes)(P),...B,children:[(0,s.jsx)("div",{className:"ProgressBar__fill ProgressBar__fill--animated",style:_}),(0,s.jsx)("div",{className:"ProgressBar__content",children:j?p:!f&&`${(0,r.toFixed)(100*g)}%`})]})}export{m as ProgressBar};
@@ -0,0 +1,29 @@
1
+ import type { BoxProps } from './Box';
2
+ type Props = {
3
+ value: number;
4
+ } & Partial<{
5
+ allowFloats: boolean;
6
+ autoFocus: boolean;
7
+ autoSelect: boolean;
8
+ disabled: boolean;
9
+ fluid: boolean;
10
+ maxValue: number | null;
11
+ minValue: number | null;
12
+ onBlur: (e: Event, value: number) => void;
13
+ onChange: (e: Event, value: number) => void;
14
+ onEnter: (e: Event, value: number) => void;
15
+ }> & BoxProps;
16
+ /**
17
+ * ## RestrictedInput
18
+ * Creates an input which rejects improper keys.
19
+ *
20
+ * @deprecated Use `NumberInput` instead.
21
+ *
22
+ * This will server as a wrapper for NumberInput until removal. This decision was
23
+ * made because it's poor UX. Users should be allowed to type in whatever they
24
+ * want, but have the UI notify them it's invalid after it's entered.
25
+ *
26
+ * It also gives a false sense of security. It's just an annoying input.
27
+ */
28
+ export declare function RestrictedInput(props: Props): import("react/jsx-runtime").JSX.Element;
29
+ export {};
@@ -1,161 +1 @@
1
- import { jsxs as E, jsx as h } from "react/jsx-runtime";
2
- import { Component as N, createRef as S } from "react";
3
- import { KEY_ENTER as I, KEY_ESCAPE as b } from "../common/keycodes.js";
4
- import { clamp as d } from "../common/math.js";
5
- import { classes as v } from "../common/react.js";
6
- import { Box as F } from "./Box.js";
7
- const g = 0, x = 1e4;
8
- function C(s, e, t, n) {
9
- const i = e || g, o = t || t === 0 ? t : x;
10
- let r = n ? s.replace(/[^\-\d.]/g, "") : s.replace(/[^\-\d]/g, "");
11
- return n && (r = V(r, i), r = m(".", r)), e < 0 ? (r = _(r), r = m("-", r)) : r = r.replaceAll("-", ""), i <= 1 && o >= 0 ? M(r, i, o, n) : r;
12
- }
13
- const M = (s, e, t, n) => {
14
- const i = n ? Number.parseFloat(s) : Number.parseInt(s, 10);
15
- if (!Number.isNaN(i) && (s.slice(-1) !== "." || i < Math.floor(e))) {
16
- const o = d(i, e, t);
17
- if (i !== o)
18
- return String(o);
19
- }
20
- return s;
21
- };
22
- function _(s) {
23
- let e = s;
24
- const t = s.indexOf("-");
25
- if (t > 0) {
26
- const n = s.replace("-", "");
27
- e = "-".concat(n);
28
- } else t === 0 && s.indexOf("-", t + 1) > 0 && (e = s.replaceAll("-", ""));
29
- return e;
30
- }
31
- function V(s, e) {
32
- let t = s;
33
- const n = Math.sign(e) * Math.floor(Math.abs(e));
34
- return s.indexOf(".") === 0 ? t = String(n).concat(s) : s.indexOf("-") === 0 && s.indexOf(".") === 1 && (t = n + ".".concat(s.slice(2))), t;
35
- }
36
- function m(s, e) {
37
- const t = e.indexOf(s), n = e.length;
38
- let i = e;
39
- if (t !== -1 && t < n - 1) {
40
- let o = e.slice(t + 1, n);
41
- o = o.replaceAll(s, ""), i = e.slice(0, t + 1).concat(o);
42
- }
43
- return i;
44
- }
45
- function f(s, e, t, n) {
46
- const i = e || g, o = t || t === 0 ? t : x;
47
- if (!s || !s.length)
48
- return String(i);
49
- const r = n ? Number.parseFloat(s.replace(/[^\-\d.]/g, "")) : Number.parseInt(s.replace(/[^\-\d]/g, ""), 10);
50
- return Number.isNaN(r) ? String(i) : String(d(r, i, o));
51
- }
52
- class B extends N {
53
- constructor(e) {
54
- super(e), this.inputRef = S(), this.state = {
55
- editing: !1
56
- }, this.handleBlur = (t) => {
57
- const { maxValue: n, minValue: i, onBlur: o, allowFloats: r } = this.props, { editing: l } = this.state;
58
- l && this.setEditing(!1);
59
- const a = f(
60
- t.target.value,
61
- i,
62
- n,
63
- r
64
- );
65
- o && o(t, +a);
66
- }, this.handleChange = (t) => {
67
- const { maxValue: n, minValue: i, onChange: o, allowFloats: r } = this.props;
68
- t.target.value = C(
69
- t.target.value,
70
- i,
71
- n,
72
- r
73
- ), o && o(t, +t.target.value);
74
- }, this.handleFocus = (t) => {
75
- const { editing: n } = this.state;
76
- n || this.setEditing(!0);
77
- }, this.handleInput = (t) => {
78
- const { editing: n } = this.state, { onInput: i } = this.props;
79
- n || this.setEditing(!0), i && i(t, +t.target.value);
80
- }, this.handleKeyDown = (t) => {
81
- const { maxValue: n, minValue: i, onChange: o, onEnter: r, allowFloats: l } = this.props;
82
- if (t.keyCode === I) {
83
- const a = f(
84
- t.target.value,
85
- i,
86
- n,
87
- l
88
- );
89
- this.setEditing(!1), o && o(t, +a), r && r(t, +a), t.target.blur();
90
- return;
91
- }
92
- if (t.keyCode === b) {
93
- if (this.props.onEscape) {
94
- this.props.onEscape(t);
95
- return;
96
- }
97
- this.setEditing(!1), t.target.value = this.props.value, t.target.blur();
98
- return;
99
- }
100
- };
101
- }
102
- componentDidMount() {
103
- var r;
104
- const { maxValue: e, minValue: t, allowFloats: n } = this.props, i = (r = this.props.value) == null ? void 0 : r.toString(), o = this.inputRef.current;
105
- o && (o.value = f(
106
- i,
107
- t,
108
- e,
109
- n
110
- )), (this.props.autoFocus || this.props.autoSelect) && setTimeout(() => {
111
- o.focus(), this.props.autoSelect && o.select();
112
- }, 1);
113
- }
114
- componentDidUpdate(e, t) {
115
- var c, p;
116
- const { maxValue: n, minValue: i, allowFloats: o } = this.props, { editing: r } = this.state, l = (c = e.value) == null ? void 0 : c.toString(), a = (p = this.props.value) == null ? void 0 : p.toString(), u = this.inputRef.current;
117
- u && !r && a !== l && a !== u.value && (u.value = f(
118
- a,
119
- i,
120
- n,
121
- o
122
- ));
123
- }
124
- setEditing(e) {
125
- this.setState({ editing: e });
126
- }
127
- render() {
128
- const { props: e } = this, { onChange: t, onEnter: n, onInput: i, onBlur: o, value: r, ...l } = e, { className: a, fluid: u, monospace: c, ...p } = l;
129
- return /* @__PURE__ */ E(
130
- F,
131
- {
132
- className: v([
133
- "Input",
134
- u && "Input--fluid",
135
- c && "Input--monospace",
136
- a
137
- ]),
138
- ...p,
139
- children: [
140
- /* @__PURE__ */ h("div", { className: "Input__baseline", children: "." }),
141
- /* @__PURE__ */ h(
142
- "input",
143
- {
144
- className: "Input__input",
145
- onChange: this.handleChange,
146
- onInput: this.handleInput,
147
- onFocus: this.handleFocus,
148
- onBlur: this.handleBlur,
149
- onKeyDown: this.handleKeyDown,
150
- ref: this.inputRef,
151
- type: "number | string"
152
- }
153
- )
154
- ]
155
- }
156
- );
157
- }
158
- }
159
- export {
160
- B as RestrictedInput
161
- };
1
+ import*as e from"react/jsx-runtime";import*as r from"../common/keys.js";import*as t from"./NumberInput.js";function m(m){let{minValue:n,maxValue:u,onChange:o,onEnter:a,onBlur:s,...p}=m;return(0,e.jsx)(t.NumberInput,{...p,minValue:n??0,maxValue:u??Number.POSITIVE_INFINITY,onChange:e=>{o?.({},e)},onKeyDown:e=>{e.key===r.KEY.Enter&&a?.({},Number(e.currentTarget.value))},step:1})}export{m as RestrictedInput};
@@ -1,5 +1,5 @@
1
- import { CSSProperties } from 'react';
2
- import { BoxProps } from './Box';
1
+ import type { CSSProperties } from 'react';
2
+ import type { BoxProps } from './Box';
3
3
  type Props = {
4
4
  /** The current value of the metric. */
5
5
  value: number;
@@ -1,114 +1 @@
1
- import { jsxs as m, jsx as e } from "react/jsx-runtime";
2
- import { scale as d, keyOfMatchingRange as M, clamp01 as v } from "../common/math.js";
3
- import { classes as p } from "../common/react.js";
4
- import { computeBoxProps as k, computeBoxClassName as $ } from "../common/ui.js";
5
- import { AnimatedNumber as B } from "./AnimatedNumber.js";
6
- function b(_) {
7
- const {
8
- alertAfter: a,
9
- alertBefore: t,
10
- className: h,
11
- format: R,
12
- maxValue: c = 1,
13
- minValue: u = 1,
14
- ranges: n,
15
- size: y = 1,
16
- style: G,
17
- value: r,
18
- ...g
19
- } = _, N = d(r, u, c), f = v(N), s = n ? {} : { primary: [0, 1] };
20
- if (n)
21
- for (const o in n) {
22
- const l = n[o];
23
- s[o] = [
24
- d(l[0], u, c),
25
- d(l[1], u, c)
26
- ];
27
- }
28
- function x() {
29
- return !!(a && t && r > a && r < t || a && r > a || t && r < t);
30
- }
31
- const C = x() && M(f, s);
32
- return /* @__PURE__ */ m("div", { className: "RoundGauge__wrapper", children: [
33
- /* @__PURE__ */ e(
34
- "div",
35
- {
36
- className: p([
37
- "RoundGauge",
38
- h,
39
- $(g)
40
- ]),
41
- ...k({
42
- style: {
43
- fontSize: `${y}em`,
44
- ...G
45
- },
46
- ...g
47
- }),
48
- children: /* @__PURE__ */ m("svg", { viewBox: "0 0 100 50", children: [
49
- (a || t) && /* @__PURE__ */ e(
50
- "g",
51
- {
52
- className: p([
53
- "RoundGauge__alert",
54
- C ? `active RoundGauge__alert--${C}` : ""
55
- ]),
56
- children: /* @__PURE__ */ e("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" })
57
- }
58
- ),
59
- /* @__PURE__ */ e("g", { children: /* @__PURE__ */ e("circle", { className: "RoundGauge__ringTrack", cx: "50", cy: "50", r: "45" }) }),
60
- /* @__PURE__ */ e("g", { children: Object.keys(s).map((o, l) => {
61
- const i = s[o];
62
- return /* @__PURE__ */ e(
63
- "circle",
64
- {
65
- className: `RoundGauge__ringFill RoundGauge--color--${o}`,
66
- style: {
67
- strokeDashoffset: Math.max(
68
- (2 - (i[1] - i[0])) * Math.PI * 50,
69
- 0
70
- )
71
- },
72
- transform: `rotate(${180 + 180 * i[0]} 50 50)`,
73
- cx: "50",
74
- cy: "50",
75
- r: "45"
76
- },
77
- l
78
- );
79
- }) }),
80
- /* @__PURE__ */ m(
81
- "g",
82
- {
83
- className: "RoundGauge__needle",
84
- transform: `rotate(${f * 180 - 90} 50 50)`,
85
- children: [
86
- /* @__PURE__ */ e(
87
- "polygon",
88
- {
89
- className: "RoundGauge__needleLine",
90
- points: "46,50 50,0 54,50"
91
- }
92
- ),
93
- /* @__PURE__ */ e(
94
- "circle",
95
- {
96
- className: "RoundGauge__needleMiddle",
97
- cx: "50",
98
- cy: "50",
99
- r: "8"
100
- }
101
- )
102
- ]
103
- }
104
- ),
105
- /* @__PURE__ */ e("title", { children: "alert" })
106
- ] })
107
- }
108
- ),
109
- /* @__PURE__ */ e(B, { value: r, format: R })
110
- ] });
111
- }
112
- export {
113
- b as RoundGauge
114
- };
1
+ import*as e from"react/jsx-runtime";import*as a from"../common/math.js";import*as s from"../common/react.js";import*as r from"../common/ui.js";import*as o from"./AnimatedNumber.js";function c(c){let{alertAfter:l,alertBefore:t,className:n,format:m,maxValue:i=1,minValue:u=1,ranges:d,size:x=1,style:g,value:j,...C}=c,p=(0,a.scale)(j,u,i),_=(0,a.clamp01)(p),f=d?{}:{primary:[0,1]};if(d)for(let e in d){let s=d[e];f[e]=[(0,a.scale)(s[0],u,i),(0,a.scale)(s[1],u,i)]}let h=(!!l&&!!t&&!!(j>l)&&!!(j<t)||!!l&&!!(j>l)||!!t&&!!(j<t))&&(0,a.keyOfMatchingRange)(_,f);return(0,e.jsxs)("div",{className:"RoundGauge__wrapper",children:[(0,e.jsx)("div",{className:(0,s.classes)(["RoundGauge",n,(0,r.computeBoxClassName)(C)]),...(0,r.computeBoxProps)({style:{fontSize:`${x}em`,...g},...C}),children:(0,e.jsxs)("svg",{viewBox:"0 0 100 50",children:[(l||t)&&(0,e.jsx)("g",{className:(0,s.classes)(["RoundGauge__alert",h?`active RoundGauge__alert--${h}`:""]),children:(0,e.jsx)("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"})}),(0,e.jsx)("g",{children:(0,e.jsx)("circle",{className:"RoundGauge__ringTrack",cx:"50",cy:"50",r:"45"})}),(0,e.jsx)("g",{children:Object.keys(f).map((a,s)=>{let r=f[a];return(0,e.jsx)("circle",{className:`RoundGauge__ringFill RoundGauge--color--${a}`,style:{strokeDashoffset:Math.max((2-(r[1]-r[0]))*Math.PI*50,0)},transform:`rotate(${180+180*r[0]} 50 50)`,cx:"50",cy:"50",r:"45"},s)})}),(0,e.jsxs)("g",{className:"RoundGauge__needle",transform:`rotate(${180*_-90} 50 50)`,children:[(0,e.jsx)("polygon",{className:"RoundGauge__needleLine",points:"46,50 50,0 54,50"}),(0,e.jsx)("circle",{className:"RoundGauge__needleMiddle",cx:"50",cy:"50",r:"8"})]}),(0,e.jsx)("title",{children:"alert"})]})}),(0,e.jsx)(o.AnimatedNumber,{value:j,format:m})]})}export{c as RoundGauge};
@@ -1,4 +1,31 @@
1
- import { ReactNode } from 'react';
1
+ import { type ReactNode, type RefObject } from 'react';
2
+ import type { 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
+ /** Ref to the section element. */
19
+ ref: RefObject<HTMLDivElement | null>;
20
+ /** Shows or hides the scrollbar. */
21
+ scrollable: boolean;
22
+ /** Shows or hides the horizontal scrollbar. */
23
+ scrollableHorizontal: boolean;
24
+ /** If true, filly the area except for -3rem */
25
+ stretchContents: boolean;
26
+ /** Title of the section. */
27
+ title: ReactNode;
28
+ }> & BoxProps;
2
29
  /**
3
30
  * ## Section
4
31
  * Section is a surface that displays content and actions on a single topic.
@@ -26,46 +53,5 @@ import { ReactNode } from 'react';
26
53
  * </Section>
27
54
  * ```
28
55
  */
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>>;
56
+ export declare function Section(props: Props): import("react/jsx-runtime").JSX.Element;
57
+ export {};
@@ -1,66 +1 @@
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 { canRender as s, classes as a } from "../common/react.js";
5
- import { computeBoxProps as z, computeBoxClassName 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 = s(r) || s(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: a([
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
- B(l)
39
- ]),
40
- ...z(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: a([
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
- );
64
- export {
65
- q as Section
66
- };
1
+ import*as e from"react/jsx-runtime";import*as t from"react";import*as o from"../common/events.js";import*as c from"../common/react.js";import*as n from"../common/ui.js";function s(s){let{buttons:r,children:i,className:l,container_id:a="",fill:m,fitted:d,flexGrow:S,noTopPadding:u,onScroll:_,ref:f,scrollable:x,scrollableHorizontal:p,stretchContents:j,title:N,...h}=s,v=(0,c.canRender)(N)||(0,c.canRender)(r),b=(0,t.useRef)(null),R=f??b;return(0,t.useEffect)(()=>(R.current&&(x||p)&&(0,o.addScrollableNode)(R.current),()=>{R.current&&(0,o.removeScrollableNode)(R.current)}),[]),(0,e.jsxs)("div",{id:a,className:(0,c.classes)(["Section",m&&"Section--fill",d&&"Section--fitted",x&&"Section--scrollable",p&&"Section--scrollableHorizontal",S&&"Section--flex",l,(0,n.computeBoxClassName)(h)]),...(0,n.computeBoxProps)(h),children:[v&&(0,e.jsxs)("div",{className:"Section__title",children:[(0,e.jsx)("span",{className:"Section__titleText",children:N}),(0,e.jsx)("div",{className:"Section__buttons",children:r})]}),(0,e.jsx)("div",{className:"Section__rest",children:(0,e.jsx)("div",{className:(0,c.classes)(["Section__content",j&&"Section__content--stretchContents",u&&"Section__content--noTopPadding"]),onScroll:_,ref:R,children:i})})]})}export{s as Section};
@@ -1,5 +1,5 @@
1
- import { PropsWithChildren } from 'react';
2
- import { BoxProps } from './Box';
1
+ import type { PropsWithChildren } from 'react';
2
+ import type { BoxProps } from './Box';
3
3
  type Props = {
4
4
  /** Highest possible value. */
5
5
  maxValue: number;
@@ -1,113 +1 @@
1
- import { jsx as e, jsxs as u } from "react/jsx-runtime";
2
- import { keyOfMatchingRange as F, clamp01 as s, scale as p } from "../common/math.js";
3
- import { classes as g } from "../common/react.js";
4
- import { computeBoxProps as O, computeBoxClassName as b } from "../common/ui.js";
5
- import { DraggableControl as k } from "./DraggableControl.js";
6
- function H(f) {
7
- const {
8
- // Draggable props (passthrough)
9
- animated: _,
10
- format: h,
11
- maxValue: l,
12
- minValue: r,
13
- onChange: v,
14
- onDrag: N,
15
- step: x,
16
- stepPixelSize: y,
17
- unit: B,
18
- value: i,
19
- // Own props
20
- className: P,
21
- fillValue: a,
22
- color: S,
23
- ranges: V = {},
24
- children: o,
25
- ...t
26
- } = f, C = o !== void 0;
27
- return /* @__PURE__ */ e(
28
- k,
29
- {
30
- dragMatrix: [1, 0],
31
- animated: _,
32
- format: h,
33
- maxValue: l,
34
- minValue: r,
35
- onChange: v,
36
- onDrag: N,
37
- step: x,
38
- stepPixelSize: y,
39
- unit: B,
40
- value: i,
41
- children: (D) => {
42
- const {
43
- displayElement: n,
44
- displayValue: c,
45
- dragging: w,
46
- handleDragStart: M,
47
- inputElement: $
48
- } = D, j = a != null, d = p(
49
- a ?? c,
50
- r,
51
- l
52
- ), m = p(c, r, l), E = S || F(a ?? i, V) || "default";
53
- return /* @__PURE__ */ u(
54
- "div",
55
- {
56
- className: g([
57
- "Slider",
58
- "ProgressBar",
59
- `ProgressBar--color--${E}`,
60
- P,
61
- b(t)
62
- ]),
63
- ...O(t),
64
- onMouseDown: M,
65
- children: [
66
- /* @__PURE__ */ e(
67
- "div",
68
- {
69
- className: g([
70
- "ProgressBar__fill",
71
- j && "ProgressBar__fill--animated"
72
- ]),
73
- style: {
74
- width: `${s(d) * 100}%`,
75
- opacity: 0.4
76
- }
77
- }
78
- ),
79
- /* @__PURE__ */ e(
80
- "div",
81
- {
82
- className: "ProgressBar__fill",
83
- style: {
84
- width: `${s(Math.min(d, m)) * 100}%`
85
- }
86
- }
87
- ),
88
- /* @__PURE__ */ u(
89
- "div",
90
- {
91
- className: "Slider__cursorOffset",
92
- style: {
93
- width: `${s(m) * 100}%`
94
- },
95
- children: [
96
- /* @__PURE__ */ e("div", { className: "Slider__cursor" }),
97
- /* @__PURE__ */ e("div", { className: "Slider__pointer" }),
98
- w && /* @__PURE__ */ e("div", { className: "Slider__popupValue", children: n })
99
- ]
100
- }
101
- ),
102
- /* @__PURE__ */ e("div", { className: "ProgressBar__content", children: C ? o : n }),
103
- $
104
- ]
105
- }
106
- );
107
- }
108
- }
109
- );
110
- }
111
- export {
112
- H as Slider
113
- };
1
+ import*as s from"react/jsx-runtime";import*as r from"../common/math.js";import*as e from"../common/react.js";import*as a from"../common/ui.js";import*as l from"./DraggableControl.js";function o(o){let{animated:i,format:t,maxValue:c,minValue:m,onChange:d,onDrag:n,step:p,stepPixelSize:_,unit:j,value:u,className:x,fillValue:f,color:g,ranges:h={},children:v,...N}=o,B=void 0!==v;return(0,s.jsx)(l.DraggableControl,{dragMatrix:[1,0],animated:i,format:t,maxValue:c,minValue:m,onChange:d,onDrag:n,step:p,stepPixelSize:_,unit:j,value:u,children:l=>{let{displayElement:o,displayValue:i,dragging:t,handleDragStart:d,inputElement:n}=l,p=null!=f,_=(0,r.scale)(f??i,m,c),j=(0,r.scale)(i,m,c),P=g||(0,r.keyOfMatchingRange)(f??u,h)||"default";return(0,s.jsxs)("div",{className:(0,e.classes)(["Slider","ProgressBar",`ProgressBar--color--${P}`,x,(0,a.computeBoxClassName)(N)]),...(0,a.computeBoxProps)(N),onMouseDown:d,children:[(0,s.jsx)("div",{className:(0,e.classes)(["ProgressBar__fill",p&&"ProgressBar__fill--animated"]),style:{width:`${100*(0,r.clamp01)(_)}%`,opacity:.4}}),(0,s.jsx)("div",{className:"ProgressBar__fill",style:{width:`${100*(0,r.clamp01)(Math.min(_,j))}%`}}),(0,s.jsxs)("div",{className:"Slider__cursorOffset",style:{width:`${100*(0,r.clamp01)(j)}%`},children:[(0,s.jsx)("div",{className:"Slider__cursor"}),(0,s.jsx)("div",{className:"Slider__pointer"}),t&&(0,s.jsx)("div",{className:"Slider__popupValue",children:o})]}),(0,s.jsx)("div",{className:"ProgressBar__content",children:B?v:o}),n]})}})}export{o as Slider};
@@ -1,5 +1,5 @@
1
- import { RefObject } from 'react';
2
- import { FlexItemProps, FlexProps } from './Flex';
1
+ import { type RefObject } from 'react';
2
+ import { type FlexItemProps, type FlexProps } from './Flex';
3
3
  type Props = Partial<{
4
4
  /** Fills available space. */
5
5
  fill: boolean;