tgui-core 1.0.2 → 1.0.4
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.
- package/{src/components → components}/AnimatedNumber.tsx +185 -185
- package/{src/components → components}/BlockQuote.tsx +15 -15
- package/{src/components → components}/BodyZoneSelector.tsx +149 -149
- package/{src/components → components}/Box.tsx +255 -255
- package/{src/components → components}/Button.tsx +415 -415
- package/{src/components → components}/ByondUi.jsx +121 -121
- package/{src/components → components}/Chart.tsx +160 -160
- package/{src/components → components}/ColorBox.tsx +30 -30
- package/{src/components → components}/Dimmer.tsx +19 -19
- package/{src/components → components}/Divider.tsx +26 -26
- package/{src/components → components}/DmIcon.tsx +72 -72
- package/{src/components → components}/DraggableControl.jsx +282 -282
- package/{src/components → components}/Dropdown.tsx +246 -246
- package/{src/components → components}/Flex.tsx +105 -105
- package/{src/components → components}/Icon.tsx +91 -91
- package/{src/components → components}/Input.tsx +181 -181
- package/{src/components → components}/KeyListener.tsx +40 -40
- package/{src/components → components}/Knob.tsx +185 -185
- package/{src/components → components}/LabeledList.tsx +130 -130
- package/{src/components → components}/MenuBar.tsx +233 -238
- package/{src/components → components}/Modal.tsx +25 -25
- package/{src/components → components}/NoticeBox.tsx +48 -48
- package/{src/components → components}/NumberInput.tsx +328 -328
- package/{src/components → components}/ProgressBar.tsx +79 -79
- package/{src/components → components}/RestrictedInput.jsx +301 -301
- package/{src/components → components}/RoundGauge.tsx +189 -189
- package/{src/components → components}/Section.tsx +125 -125
- package/{src/components → components}/Slider.tsx +173 -173
- package/{src/components → components}/Stack.tsx +101 -101
- package/{src/components → components}/Table.tsx +90 -90
- package/{src/components → components}/Tabs.tsx +90 -90
- package/{src/components → components}/TextArea.tsx +198 -198
- package/{src/components → components}/TimeDisplay.jsx +64 -64
- package/components/index.ts +51 -0
- package/{src/debug/KitchenSink.jsx → debug/KitchenSink.tsx} +56 -56
- package/{src/debug/actions.js → debug/actions.ts} +11 -11
- package/{src/debug/hooks.js → debug/hooks.ts} +10 -10
- package/{src/debug/middleware.js → debug/middleware.ts} +67 -86
- package/{src/debug/reducer.js → debug/reducer.ts} +27 -22
- package/{src/debug/selectors.js → debug/selectors.ts} +7 -7
- package/{src/layouts → layouts}/Layout.tsx +75 -75
- package/{src/layouts → layouts}/NtosWindow.tsx +162 -162
- package/{src/layouts → layouts}/Pane.tsx +56 -56
- package/{src/layouts → layouts}/Window.tsx +227 -227
- package/layouts/index.ts +10 -0
- package/package.json +3 -2
- package/src/assets.ts +43 -43
- package/src/backend.ts +368 -369
- package/src/drag.ts +280 -280
- package/src/events.ts +237 -237
- package/src/hotkeys.ts +212 -212
- package/src/renderer.ts +50 -50
- package/stories/Blink.stories.tsx +20 -0
- package/stories/BlockQuote.stories.tsx +23 -0
- package/stories/Box.stories.tsx +27 -0
- package/stories/Button.stories.tsx +68 -0
- package/stories/ByondUi.stories.tsx +45 -0
- package/stories/Collapsible.stories.tsx +23 -0
- package/stories/Flex.stories.tsx +68 -0
- package/stories/Input.stories.tsx +124 -0
- package/stories/LabeledList.stories.tsx +73 -0
- package/stories/Popper.stories.tsx +58 -0
- package/stories/ProgressBar.stories.tsx +58 -0
- package/stories/Stack.stories.tsx +55 -0
- package/stories/Storage.stories.tsx +46 -0
- package/stories/Themes.stories.tsx +30 -0
- package/stories/Tooltip.stories.tsx +48 -0
- package/stories/common.tsx +19 -0
- package/tsconfig.json +0 -21
- package/src/components/Grid.tsx +0 -44
- /package/{src/common → common}/collections.ts +0 -0
- /package/{src/common → common}/color.ts +0 -0
- /package/{src/common → common}/events.ts +0 -0
- /package/{src/common → common}/exhaustive.ts +0 -0
- /package/{src/common → common}/fp.ts +0 -0
- /package/{src/common → common}/keycodes.ts +0 -0
- /package/{src/common → common}/keys.ts +0 -0
- /package/{src/common → common}/math.ts +0 -0
- /package/{src/common → common}/perf.ts +0 -0
- /package/{src/common → common}/random.ts +0 -0
- /package/{src/common → common}/react.ts +0 -0
- /package/{src/common → common}/redux.ts +0 -0
- /package/{src/common → common}/storage.js +0 -0
- /package/{src/common → common}/string.ts +0 -0
- /package/{src/common → common}/timer.ts +0 -0
- /package/{src/common → common}/type-utils.ts +0 -0
- /package/{src/common → common}/types.ts +0 -0
- /package/{src/common → common}/uuid.ts +0 -0
- /package/{src/common → common}/vector.ts +0 -0
- /package/{src/components → components}/Autofocus.tsx +0 -0
- /package/{src/components → components}/Blink.jsx +0 -0
- /package/{src/components → components}/Collapsible.tsx +0 -0
- /package/{src/components → components}/Dialog.tsx +0 -0
- /package/{src/components → components}/FakeTerminal.jsx +0 -0
- /package/{src/components → components}/FitText.tsx +0 -0
- /package/{src/components → components}/Image.tsx +0 -0
- /package/{src/components → components}/InfinitePlane.jsx +0 -0
- /package/{src/components → components}/LabeledControls.tsx +0 -0
- /package/{src/components → components}/Popper.tsx +0 -0
- /package/{src/components → components}/StyleableSection.tsx +0 -0
- /package/{src/components → components}/Tooltip.tsx +0 -0
- /package/{src/components → components}/TrackOutsideClicks.tsx +0 -0
- /package/{src/components → components}/VirtualList.tsx +0 -0
- /package/{src/debug → debug}/index.ts +0 -0
- /package/{src/styles → styles}/base.scss +0 -0
- /package/{src/styles → styles}/colors.scss +0 -0
- /package/{src/styles → styles}/components/BlockQuote.scss +0 -0
- /package/{src/styles → styles}/components/Button.scss +0 -0
- /package/{src/styles → styles}/components/ColorBox.scss +0 -0
- /package/{src/styles → styles}/components/Dialog.scss +0 -0
- /package/{src/styles → styles}/components/Dimmer.scss +0 -0
- /package/{src/styles → styles}/components/Divider.scss +0 -0
- /package/{src/styles → styles}/components/Dropdown.scss +0 -0
- /package/{src/styles → styles}/components/Flex.scss +0 -0
- /package/{src/styles → styles}/components/Icon.scss +0 -0
- /package/{src/styles → styles}/components/Input.scss +0 -0
- /package/{src/styles → styles}/components/Knob.scss +0 -0
- /package/{src/styles → styles}/components/LabeledList.scss +0 -0
- /package/{src/styles → styles}/components/MenuBar.scss +0 -0
- /package/{src/styles → styles}/components/Modal.scss +0 -0
- /package/{src/styles → styles}/components/NoticeBox.scss +0 -0
- /package/{src/styles → styles}/components/NumberInput.scss +0 -0
- /package/{src/styles → styles}/components/ProgressBar.scss +0 -0
- /package/{src/styles → styles}/components/RoundGauge.scss +0 -0
- /package/{src/styles → styles}/components/Section.scss +0 -0
- /package/{src/styles → styles}/components/Slider.scss +0 -0
- /package/{src/styles → styles}/components/Stack.scss +0 -0
- /package/{src/styles → styles}/components/Table.scss +0 -0
- /package/{src/styles → styles}/components/Tabs.scss +0 -0
- /package/{src/styles → styles}/components/TextArea.scss +0 -0
- /package/{src/styles → styles}/components/Tooltip.scss +0 -0
- /package/{src/styles → styles}/functions.scss +0 -0
- /package/{src/styles → styles}/layouts/Layout.scss +0 -0
- /package/{src/styles → styles}/layouts/NtosHeader.scss +0 -0
- /package/{src/styles → styles}/layouts/NtosWindow.scss +0 -0
- /package/{src/styles → styles}/layouts/TitleBar.scss +0 -0
- /package/{src/styles → styles}/layouts/Window.scss +0 -0
- /package/{src/styles → styles}/main.scss +0 -0
- /package/{src/styles → styles}/reset.scss +0 -0
- /package/{src/styles → styles}/themes/abductor.scss +0 -0
- /package/{src/styles → styles}/themes/admin.scss +0 -0
- /package/{src/styles → styles}/themes/cardtable.scss +0 -0
- /package/{src/styles → styles}/themes/hackerman.scss +0 -0
- /package/{src/styles → styles}/themes/malfunction.scss +0 -0
- /package/{src/styles → styles}/themes/neutral.scss +0 -0
- /package/{src/styles → styles}/themes/ntOS95.scss +0 -0
- /package/{src/styles → styles}/themes/ntos.scss +0 -0
- /package/{src/styles → styles}/themes/ntos_cat.scss +0 -0
- /package/{src/styles → styles}/themes/ntos_darkmode.scss +0 -0
- /package/{src/styles → styles}/themes/ntos_lightmode.scss +0 -0
- /package/{src/styles → styles}/themes/ntos_spooky.scss +0 -0
- /package/{src/styles → styles}/themes/ntos_synth.scss +0 -0
- /package/{src/styles → styles}/themes/ntos_terminal.scss +0 -0
- /package/{src/styles → styles}/themes/paper.scss +0 -0
- /package/{src/styles → styles}/themes/retro.scss +0 -0
- /package/{src/styles → styles}/themes/spookyconsole.scss +0 -0
- /package/{src/styles → styles}/themes/syndicate.scss +0 -0
- /package/{src/styles → styles}/themes/wizard.scss +0 -0
|
@@ -1,185 +1,185 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file
|
|
3
|
-
* @copyright 2020 Aleksej Komarov
|
|
4
|
-
* @license MIT
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { keyOfMatchingRange, scale } from '../common/math';
|
|
8
|
-
import { BooleanLike, classes } from '../common/react';
|
|
9
|
-
|
|
10
|
-
import { BoxProps, computeBoxClassName, computeBoxProps } from './Box';
|
|
11
|
-
import { DraggableControl } from './DraggableControl';
|
|
12
|
-
|
|
13
|
-
type Props = {
|
|
14
|
-
/** Value itself, controls the position of the cursor. */
|
|
15
|
-
value: number;
|
|
16
|
-
} & Partial<{
|
|
17
|
-
/** Animates the value if it was changed externally. */
|
|
18
|
-
animated: boolean;
|
|
19
|
-
/** Knob can be bipolar or unipolar. */
|
|
20
|
-
bipolar: boolean;
|
|
21
|
-
/** Color of the outer ring around the knob. */
|
|
22
|
-
color: string | BooleanLike;
|
|
23
|
-
/** If set, this value will be used to set the fill percentage of the outer ring independently of the main value. */
|
|
24
|
-
fillValue: number;
|
|
25
|
-
/** Format value using this function before displaying it. */
|
|
26
|
-
format: (value: number) => string;
|
|
27
|
-
/** Highest possible value. */
|
|
28
|
-
maxValue: number;
|
|
29
|
-
/** Lowest possible value. */
|
|
30
|
-
minValue: number;
|
|
31
|
-
/** Adjust value by this amount when dragging the input. */
|
|
32
|
-
onChange: (event: Event, value: number) => void;
|
|
33
|
-
/** An event, which fires about every 500ms when you drag the input up and down, on release and on manual editing. */
|
|
34
|
-
onDrag: (event: Event, value: number) => void;
|
|
35
|
-
/** Applies a `color` to the outer ring around the knob based on whether the value lands in the range between `from` and `to`. */
|
|
36
|
-
ranges: Record<string, [number, number]>;
|
|
37
|
-
/** Relative size of the knob. `1` is normal size, `2` is two times bigger. Fractional numbers are supported. */
|
|
38
|
-
size: number;
|
|
39
|
-
/** Adjust value by this amount when dragging the input. */
|
|
40
|
-
step: number;
|
|
41
|
-
/** Screen distance mouse needs to travel to adjust value by one `step`. */
|
|
42
|
-
stepPixelSize: number;
|
|
43
|
-
/** A number in milliseconds, for which the input will hold off from updating while events propagate through the backend. Default is about 250ms, increase it if you still see flickering. */
|
|
44
|
-
suppressFlicker: boolean;
|
|
45
|
-
/** Unit to display to the right of value. */
|
|
46
|
-
unit: string;
|
|
47
|
-
/** Whether to clamp the value to the range. */
|
|
48
|
-
unclamped: boolean;
|
|
49
|
-
}> &
|
|
50
|
-
BoxProps;
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* ## Knob
|
|
54
|
-
* A radial control which allows dialing in precise values by dragging it
|
|
55
|
-
* up and down.
|
|
56
|
-
*
|
|
57
|
-
* Single click opens an input box to manually type in a number.
|
|
58
|
-
*/
|
|
59
|
-
export function Knob(props: Props) {
|
|
60
|
-
const {
|
|
61
|
-
// Draggable props (passthrough)
|
|
62
|
-
animated,
|
|
63
|
-
format,
|
|
64
|
-
maxValue,
|
|
65
|
-
minValue,
|
|
66
|
-
onChange,
|
|
67
|
-
onDrag,
|
|
68
|
-
step,
|
|
69
|
-
stepPixelSize,
|
|
70
|
-
suppressFlicker,
|
|
71
|
-
unclamped,
|
|
72
|
-
unit,
|
|
73
|
-
value,
|
|
74
|
-
// Own props
|
|
75
|
-
bipolar,
|
|
76
|
-
children,
|
|
77
|
-
className,
|
|
78
|
-
color,
|
|
79
|
-
fillValue,
|
|
80
|
-
ranges = {},
|
|
81
|
-
size = 1,
|
|
82
|
-
style,
|
|
83
|
-
...rest
|
|
84
|
-
} = props;
|
|
85
|
-
|
|
86
|
-
return (
|
|
87
|
-
<DraggableControl
|
|
88
|
-
dragMatrix={[0, -1]}
|
|
89
|
-
{...{
|
|
90
|
-
animated,
|
|
91
|
-
format,
|
|
92
|
-
maxValue,
|
|
93
|
-
minValue,
|
|
94
|
-
onChange,
|
|
95
|
-
onDrag,
|
|
96
|
-
step,
|
|
97
|
-
stepPixelSize,
|
|
98
|
-
suppressFlicker,
|
|
99
|
-
unclamped,
|
|
100
|
-
unit,
|
|
101
|
-
value,
|
|
102
|
-
}}
|
|
103
|
-
>
|
|
104
|
-
{(control) => {
|
|
105
|
-
const {
|
|
106
|
-
displayElement,
|
|
107
|
-
displayValue,
|
|
108
|
-
dragging,
|
|
109
|
-
handleDragStart,
|
|
110
|
-
inputElement,
|
|
111
|
-
value,
|
|
112
|
-
} = control;
|
|
113
|
-
const scaledFillValue = scale(
|
|
114
|
-
fillValue ?? displayValue,
|
|
115
|
-
minValue,
|
|
116
|
-
maxValue
|
|
117
|
-
);
|
|
118
|
-
const scaledDisplayValue = scale(displayValue, minValue, maxValue);
|
|
119
|
-
const effectiveColor =
|
|
120
|
-
color || keyOfMatchingRange(fillValue ?? value, ranges) || 'default';
|
|
121
|
-
const rotation = Math.min((scaledDisplayValue - 0.5) * 270, 225);
|
|
122
|
-
|
|
123
|
-
return (
|
|
124
|
-
<div
|
|
125
|
-
className={classes([
|
|
126
|
-
'Knob',
|
|
127
|
-
'Knob--color--' + effectiveColor,
|
|
128
|
-
bipolar && 'Knob--bipolar',
|
|
129
|
-
className,
|
|
130
|
-
computeBoxClassName(rest),
|
|
131
|
-
])}
|
|
132
|
-
{...computeBoxProps({
|
|
133
|
-
style: {
|
|
134
|
-
fontSize: size + 'em',
|
|
135
|
-
...style,
|
|
136
|
-
},
|
|
137
|
-
...rest,
|
|
138
|
-
})}
|
|
139
|
-
onMouseDown={handleDragStart}
|
|
140
|
-
>
|
|
141
|
-
<div className="Knob__circle">
|
|
142
|
-
<div
|
|
143
|
-
className="Knob__cursorBox"
|
|
144
|
-
style={{
|
|
145
|
-
transform: `rotate(${rotation}deg)`,
|
|
146
|
-
}}
|
|
147
|
-
>
|
|
148
|
-
<div className="Knob__cursor" />
|
|
149
|
-
</div>
|
|
150
|
-
</div>
|
|
151
|
-
{dragging && (
|
|
152
|
-
<div className="Knob__popupValue">{displayElement}</div>
|
|
153
|
-
)}
|
|
154
|
-
<svg
|
|
155
|
-
className="Knob__ring Knob__ringTrackPivot"
|
|
156
|
-
viewBox="0 0 100 100"
|
|
157
|
-
>
|
|
158
|
-
<circle className="Knob__ringTrack" cx="50" cy="50" r="50" />
|
|
159
|
-
</svg>
|
|
160
|
-
<svg
|
|
161
|
-
className="Knob__ring Knob__ringFillPivot"
|
|
162
|
-
viewBox="0 0 100 100"
|
|
163
|
-
>
|
|
164
|
-
<circle
|
|
165
|
-
className="Knob__ringFill"
|
|
166
|
-
style={{
|
|
167
|
-
strokeDashoffset: Math.max(
|
|
168
|
-
((bipolar ? 2.75 : 2.0) - scaledFillValue * 1.5) *
|
|
169
|
-
Math.PI *
|
|
170
|
-
50,
|
|
171
|
-
0
|
|
172
|
-
),
|
|
173
|
-
}}
|
|
174
|
-
cx="50"
|
|
175
|
-
cy="50"
|
|
176
|
-
r="50"
|
|
177
|
-
/>
|
|
178
|
-
</svg>
|
|
179
|
-
{inputElement}
|
|
180
|
-
</div>
|
|
181
|
-
);
|
|
182
|
-
}}
|
|
183
|
-
</DraggableControl>
|
|
184
|
-
);
|
|
185
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @file
|
|
3
|
+
* @copyright 2020 Aleksej Komarov
|
|
4
|
+
* @license MIT
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { keyOfMatchingRange, scale } from '../common/math';
|
|
8
|
+
import { BooleanLike, classes } from '../common/react';
|
|
9
|
+
|
|
10
|
+
import { BoxProps, computeBoxClassName, computeBoxProps } from './Box';
|
|
11
|
+
import { DraggableControl } from './DraggableControl';
|
|
12
|
+
|
|
13
|
+
type Props = {
|
|
14
|
+
/** Value itself, controls the position of the cursor. */
|
|
15
|
+
value: number;
|
|
16
|
+
} & Partial<{
|
|
17
|
+
/** Animates the value if it was changed externally. */
|
|
18
|
+
animated: boolean;
|
|
19
|
+
/** Knob can be bipolar or unipolar. */
|
|
20
|
+
bipolar: boolean;
|
|
21
|
+
/** Color of the outer ring around the knob. */
|
|
22
|
+
color: string | BooleanLike;
|
|
23
|
+
/** If set, this value will be used to set the fill percentage of the outer ring independently of the main value. */
|
|
24
|
+
fillValue: number;
|
|
25
|
+
/** Format value using this function before displaying it. */
|
|
26
|
+
format: (value: number) => string;
|
|
27
|
+
/** Highest possible value. */
|
|
28
|
+
maxValue: number;
|
|
29
|
+
/** Lowest possible value. */
|
|
30
|
+
minValue: number;
|
|
31
|
+
/** Adjust value by this amount when dragging the input. */
|
|
32
|
+
onChange: (event: Event, value: number) => void;
|
|
33
|
+
/** An event, which fires about every 500ms when you drag the input up and down, on release and on manual editing. */
|
|
34
|
+
onDrag: (event: Event, value: number) => void;
|
|
35
|
+
/** Applies a `color` to the outer ring around the knob based on whether the value lands in the range between `from` and `to`. */
|
|
36
|
+
ranges: Record<string, [number, number]>;
|
|
37
|
+
/** Relative size of the knob. `1` is normal size, `2` is two times bigger. Fractional numbers are supported. */
|
|
38
|
+
size: number;
|
|
39
|
+
/** Adjust value by this amount when dragging the input. */
|
|
40
|
+
step: number;
|
|
41
|
+
/** Screen distance mouse needs to travel to adjust value by one `step`. */
|
|
42
|
+
stepPixelSize: number;
|
|
43
|
+
/** A number in milliseconds, for which the input will hold off from updating while events propagate through the backend. Default is about 250ms, increase it if you still see flickering. */
|
|
44
|
+
suppressFlicker: boolean;
|
|
45
|
+
/** Unit to display to the right of value. */
|
|
46
|
+
unit: string;
|
|
47
|
+
/** Whether to clamp the value to the range. */
|
|
48
|
+
unclamped: boolean;
|
|
49
|
+
}> &
|
|
50
|
+
BoxProps;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* ## Knob
|
|
54
|
+
* A radial control which allows dialing in precise values by dragging it
|
|
55
|
+
* up and down.
|
|
56
|
+
*
|
|
57
|
+
* Single click opens an input box to manually type in a number.
|
|
58
|
+
*/
|
|
59
|
+
export function Knob(props: Props) {
|
|
60
|
+
const {
|
|
61
|
+
// Draggable props (passthrough)
|
|
62
|
+
animated,
|
|
63
|
+
format,
|
|
64
|
+
maxValue,
|
|
65
|
+
minValue,
|
|
66
|
+
onChange,
|
|
67
|
+
onDrag,
|
|
68
|
+
step,
|
|
69
|
+
stepPixelSize,
|
|
70
|
+
suppressFlicker,
|
|
71
|
+
unclamped,
|
|
72
|
+
unit,
|
|
73
|
+
value,
|
|
74
|
+
// Own props
|
|
75
|
+
bipolar,
|
|
76
|
+
children,
|
|
77
|
+
className,
|
|
78
|
+
color,
|
|
79
|
+
fillValue,
|
|
80
|
+
ranges = {},
|
|
81
|
+
size = 1,
|
|
82
|
+
style,
|
|
83
|
+
...rest
|
|
84
|
+
} = props;
|
|
85
|
+
|
|
86
|
+
return (
|
|
87
|
+
<DraggableControl
|
|
88
|
+
dragMatrix={[0, -1]}
|
|
89
|
+
{...{
|
|
90
|
+
animated,
|
|
91
|
+
format,
|
|
92
|
+
maxValue,
|
|
93
|
+
minValue,
|
|
94
|
+
onChange,
|
|
95
|
+
onDrag,
|
|
96
|
+
step,
|
|
97
|
+
stepPixelSize,
|
|
98
|
+
suppressFlicker,
|
|
99
|
+
unclamped,
|
|
100
|
+
unit,
|
|
101
|
+
value,
|
|
102
|
+
}}
|
|
103
|
+
>
|
|
104
|
+
{(control) => {
|
|
105
|
+
const {
|
|
106
|
+
displayElement,
|
|
107
|
+
displayValue,
|
|
108
|
+
dragging,
|
|
109
|
+
handleDragStart,
|
|
110
|
+
inputElement,
|
|
111
|
+
value,
|
|
112
|
+
} = control;
|
|
113
|
+
const scaledFillValue = scale(
|
|
114
|
+
fillValue ?? displayValue,
|
|
115
|
+
minValue,
|
|
116
|
+
maxValue
|
|
117
|
+
);
|
|
118
|
+
const scaledDisplayValue = scale(displayValue, minValue, maxValue);
|
|
119
|
+
const effectiveColor =
|
|
120
|
+
color || keyOfMatchingRange(fillValue ?? value, ranges) || 'default';
|
|
121
|
+
const rotation = Math.min((scaledDisplayValue - 0.5) * 270, 225);
|
|
122
|
+
|
|
123
|
+
return (
|
|
124
|
+
<div
|
|
125
|
+
className={classes([
|
|
126
|
+
'Knob',
|
|
127
|
+
'Knob--color--' + effectiveColor,
|
|
128
|
+
bipolar && 'Knob--bipolar',
|
|
129
|
+
className,
|
|
130
|
+
computeBoxClassName(rest),
|
|
131
|
+
])}
|
|
132
|
+
{...computeBoxProps({
|
|
133
|
+
style: {
|
|
134
|
+
fontSize: size + 'em',
|
|
135
|
+
...style,
|
|
136
|
+
},
|
|
137
|
+
...rest,
|
|
138
|
+
})}
|
|
139
|
+
onMouseDown={handleDragStart}
|
|
140
|
+
>
|
|
141
|
+
<div className="Knob__circle">
|
|
142
|
+
<div
|
|
143
|
+
className="Knob__cursorBox"
|
|
144
|
+
style={{
|
|
145
|
+
transform: `rotate(${rotation}deg)`,
|
|
146
|
+
}}
|
|
147
|
+
>
|
|
148
|
+
<div className="Knob__cursor" />
|
|
149
|
+
</div>
|
|
150
|
+
</div>
|
|
151
|
+
{dragging && (
|
|
152
|
+
<div className="Knob__popupValue">{displayElement}</div>
|
|
153
|
+
)}
|
|
154
|
+
<svg
|
|
155
|
+
className="Knob__ring Knob__ringTrackPivot"
|
|
156
|
+
viewBox="0 0 100 100"
|
|
157
|
+
>
|
|
158
|
+
<circle className="Knob__ringTrack" cx="50" cy="50" r="50" />
|
|
159
|
+
</svg>
|
|
160
|
+
<svg
|
|
161
|
+
className="Knob__ring Knob__ringFillPivot"
|
|
162
|
+
viewBox="0 0 100 100"
|
|
163
|
+
>
|
|
164
|
+
<circle
|
|
165
|
+
className="Knob__ringFill"
|
|
166
|
+
style={{
|
|
167
|
+
strokeDashoffset: Math.max(
|
|
168
|
+
((bipolar ? 2.75 : 2.0) - scaledFillValue * 1.5) *
|
|
169
|
+
Math.PI *
|
|
170
|
+
50,
|
|
171
|
+
0
|
|
172
|
+
),
|
|
173
|
+
}}
|
|
174
|
+
cx="50"
|
|
175
|
+
cy="50"
|
|
176
|
+
r="50"
|
|
177
|
+
/>
|
|
178
|
+
</svg>
|
|
179
|
+
{inputElement}
|
|
180
|
+
</div>
|
|
181
|
+
);
|
|
182
|
+
}}
|
|
183
|
+
</DraggableControl>
|
|
184
|
+
);
|
|
185
|
+
}
|
|
@@ -1,130 +1,130 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file
|
|
3
|
-
* @copyright 2020 Aleksej Komarov
|
|
4
|
-
* @license MIT
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { BooleanLike, classes } from '../common/react';
|
|
8
|
-
import { PropsWithChildren, ReactNode } from 'react';
|
|
9
|
-
|
|
10
|
-
import { Box, unit } from './Box';
|
|
11
|
-
import { Divider } from './Divider';
|
|
12
|
-
import { Tooltip } from './Tooltip';
|
|
13
|
-
|
|
14
|
-
export const LabeledList = (props: PropsWithChildren) => {
|
|
15
|
-
const { children } = props;
|
|
16
|
-
return <table className="LabeledList">{children}</table>;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
type LabeledListItemProps = Partial<{
|
|
20
|
-
buttons: ReactNode;
|
|
21
|
-
className: string | BooleanLike;
|
|
22
|
-
color: string;
|
|
23
|
-
key: string | number;
|
|
24
|
-
label: string | ReactNode | BooleanLike;
|
|
25
|
-
labelColor: string;
|
|
26
|
-
labelWrap: boolean;
|
|
27
|
-
textAlign: string;
|
|
28
|
-
/** @deprecated */
|
|
29
|
-
content: any;
|
|
30
|
-
children: ReactNode;
|
|
31
|
-
verticalAlign: string;
|
|
32
|
-
tooltip: string;
|
|
33
|
-
}>;
|
|
34
|
-
|
|
35
|
-
const LabeledListItem = (props: LabeledListItemProps) => {
|
|
36
|
-
const {
|
|
37
|
-
className,
|
|
38
|
-
label,
|
|
39
|
-
labelColor = 'label',
|
|
40
|
-
labelWrap,
|
|
41
|
-
color,
|
|
42
|
-
textAlign,
|
|
43
|
-
buttons,
|
|
44
|
-
content,
|
|
45
|
-
children,
|
|
46
|
-
verticalAlign = 'baseline',
|
|
47
|
-
tooltip,
|
|
48
|
-
} = props;
|
|
49
|
-
|
|
50
|
-
let innerLabel;
|
|
51
|
-
if (label) {
|
|
52
|
-
innerLabel = label;
|
|
53
|
-
if (typeof label === 'string') innerLabel += ':';
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
if (tooltip !== undefined) {
|
|
57
|
-
innerLabel = (
|
|
58
|
-
<Tooltip content={tooltip}>
|
|
59
|
-
<Box
|
|
60
|
-
as="span"
|
|
61
|
-
style={{
|
|
62
|
-
borderBottom: '2px dotted rgba(255, 255, 255, 0.8)',
|
|
63
|
-
}}
|
|
64
|
-
>
|
|
65
|
-
{innerLabel}
|
|
66
|
-
</Box>
|
|
67
|
-
</Tooltip>
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
let labelChild = (
|
|
72
|
-
<Box
|
|
73
|
-
as="td"
|
|
74
|
-
color={labelColor}
|
|
75
|
-
className={classes([
|
|
76
|
-
'LabeledList__cell',
|
|
77
|
-
// Kinda flipped because we want nowrap as default. Cleaner CSS this way though.
|
|
78
|
-
!labelWrap && 'LabeledList__label--nowrap',
|
|
79
|
-
])}
|
|
80
|
-
verticalAlign={verticalAlign}
|
|
81
|
-
>
|
|
82
|
-
{innerLabel}
|
|
83
|
-
</Box>
|
|
84
|
-
);
|
|
85
|
-
|
|
86
|
-
return (
|
|
87
|
-
<tr className={classes(['LabeledList__row', className])}>
|
|
88
|
-
{labelChild}
|
|
89
|
-
<Box
|
|
90
|
-
as="td"
|
|
91
|
-
color={color}
|
|
92
|
-
textAlign={textAlign}
|
|
93
|
-
className={classes(['LabeledList__cell', 'LabeledList__content'])}
|
|
94
|
-
// @ts-ignore
|
|
95
|
-
colSpan={buttons ? undefined : 2}
|
|
96
|
-
verticalAlign={verticalAlign}
|
|
97
|
-
>
|
|
98
|
-
{content}
|
|
99
|
-
{children}
|
|
100
|
-
</Box>
|
|
101
|
-
{buttons && (
|
|
102
|
-
<td className="LabeledList__cell LabeledList__buttons">{buttons}</td>
|
|
103
|
-
)}
|
|
104
|
-
</tr>
|
|
105
|
-
);
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
type LabeledListDividerProps = {
|
|
109
|
-
size?: number;
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
const LabeledListDivider = (props: LabeledListDividerProps) => {
|
|
113
|
-
const padding = props.size ? unit(Math.max(0, props.size - 1)) : 0;
|
|
114
|
-
return (
|
|
115
|
-
<tr className="LabeledList__row">
|
|
116
|
-
<td
|
|
117
|
-
colSpan={3}
|
|
118
|
-
style={{
|
|
119
|
-
paddingTop: padding,
|
|
120
|
-
paddingBottom: padding,
|
|
121
|
-
}}
|
|
122
|
-
>
|
|
123
|
-
<Divider />
|
|
124
|
-
</td>
|
|
125
|
-
</tr>
|
|
126
|
-
);
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
LabeledList.Item = LabeledListItem;
|
|
130
|
-
LabeledList.Divider = LabeledListDivider;
|
|
1
|
+
/**
|
|
2
|
+
* @file
|
|
3
|
+
* @copyright 2020 Aleksej Komarov
|
|
4
|
+
* @license MIT
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { BooleanLike, classes } from '../common/react';
|
|
8
|
+
import { PropsWithChildren, ReactNode } from 'react';
|
|
9
|
+
|
|
10
|
+
import { Box, unit } from './Box';
|
|
11
|
+
import { Divider } from './Divider';
|
|
12
|
+
import { Tooltip } from './Tooltip';
|
|
13
|
+
|
|
14
|
+
export const LabeledList = (props: PropsWithChildren) => {
|
|
15
|
+
const { children } = props;
|
|
16
|
+
return <table className="LabeledList">{children}</table>;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
type LabeledListItemProps = Partial<{
|
|
20
|
+
buttons: ReactNode;
|
|
21
|
+
className: string | BooleanLike;
|
|
22
|
+
color: string;
|
|
23
|
+
key: string | number;
|
|
24
|
+
label: string | ReactNode | BooleanLike;
|
|
25
|
+
labelColor: string;
|
|
26
|
+
labelWrap: boolean;
|
|
27
|
+
textAlign: string;
|
|
28
|
+
/** @deprecated */
|
|
29
|
+
content: any;
|
|
30
|
+
children: ReactNode;
|
|
31
|
+
verticalAlign: string;
|
|
32
|
+
tooltip: string;
|
|
33
|
+
}>;
|
|
34
|
+
|
|
35
|
+
const LabeledListItem = (props: LabeledListItemProps) => {
|
|
36
|
+
const {
|
|
37
|
+
className,
|
|
38
|
+
label,
|
|
39
|
+
labelColor = 'label',
|
|
40
|
+
labelWrap,
|
|
41
|
+
color,
|
|
42
|
+
textAlign,
|
|
43
|
+
buttons,
|
|
44
|
+
content,
|
|
45
|
+
children,
|
|
46
|
+
verticalAlign = 'baseline',
|
|
47
|
+
tooltip,
|
|
48
|
+
} = props;
|
|
49
|
+
|
|
50
|
+
let innerLabel;
|
|
51
|
+
if (label) {
|
|
52
|
+
innerLabel = label;
|
|
53
|
+
if (typeof label === 'string') innerLabel += ':';
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (tooltip !== undefined) {
|
|
57
|
+
innerLabel = (
|
|
58
|
+
<Tooltip content={tooltip}>
|
|
59
|
+
<Box
|
|
60
|
+
as="span"
|
|
61
|
+
style={{
|
|
62
|
+
borderBottom: '2px dotted rgba(255, 255, 255, 0.8)',
|
|
63
|
+
}}
|
|
64
|
+
>
|
|
65
|
+
{innerLabel}
|
|
66
|
+
</Box>
|
|
67
|
+
</Tooltip>
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
let labelChild = (
|
|
72
|
+
<Box
|
|
73
|
+
as="td"
|
|
74
|
+
color={labelColor}
|
|
75
|
+
className={classes([
|
|
76
|
+
'LabeledList__cell',
|
|
77
|
+
// Kinda flipped because we want nowrap as default. Cleaner CSS this way though.
|
|
78
|
+
!labelWrap && 'LabeledList__label--nowrap',
|
|
79
|
+
])}
|
|
80
|
+
verticalAlign={verticalAlign}
|
|
81
|
+
>
|
|
82
|
+
{innerLabel}
|
|
83
|
+
</Box>
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
return (
|
|
87
|
+
<tr className={classes(['LabeledList__row', className])}>
|
|
88
|
+
{labelChild}
|
|
89
|
+
<Box
|
|
90
|
+
as="td"
|
|
91
|
+
color={color}
|
|
92
|
+
textAlign={textAlign}
|
|
93
|
+
className={classes(['LabeledList__cell', 'LabeledList__content'])}
|
|
94
|
+
// @ts-ignore
|
|
95
|
+
colSpan={buttons ? undefined : 2}
|
|
96
|
+
verticalAlign={verticalAlign}
|
|
97
|
+
>
|
|
98
|
+
{content}
|
|
99
|
+
{children}
|
|
100
|
+
</Box>
|
|
101
|
+
{buttons && (
|
|
102
|
+
<td className="LabeledList__cell LabeledList__buttons">{buttons}</td>
|
|
103
|
+
)}
|
|
104
|
+
</tr>
|
|
105
|
+
);
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
type LabeledListDividerProps = {
|
|
109
|
+
size?: number;
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
const LabeledListDivider = (props: LabeledListDividerProps) => {
|
|
113
|
+
const padding = props.size ? unit(Math.max(0, props.size - 1)) : 0;
|
|
114
|
+
return (
|
|
115
|
+
<tr className="LabeledList__row">
|
|
116
|
+
<td
|
|
117
|
+
colSpan={3}
|
|
118
|
+
style={{
|
|
119
|
+
paddingTop: padding,
|
|
120
|
+
paddingBottom: padding,
|
|
121
|
+
}}
|
|
122
|
+
>
|
|
123
|
+
<Divider />
|
|
124
|
+
</td>
|
|
125
|
+
</tr>
|
|
126
|
+
);
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
LabeledList.Item = LabeledListItem;
|
|
130
|
+
LabeledList.Divider = LabeledListDivider;
|