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,173 +1,173 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file
|
|
3
|
-
* @copyright 2020 Aleksej Komarov
|
|
4
|
-
* @license MIT
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { clamp01, keyOfMatchingRange, scale } from '../common/math';
|
|
8
|
-
import { classes } from '../common/react';
|
|
9
|
-
import { PropsWithChildren } from 'react';
|
|
10
|
-
|
|
11
|
-
import { BoxProps, computeBoxClassName, computeBoxProps } from './Box';
|
|
12
|
-
import { DraggableControl } from './DraggableControl';
|
|
13
|
-
|
|
14
|
-
type Props = {
|
|
15
|
-
/** Highest possible value. */
|
|
16
|
-
maxValue: number;
|
|
17
|
-
/** Lowest possible value. */
|
|
18
|
-
minValue: number;
|
|
19
|
-
/** Value itself, controls the position of the cursor. */
|
|
20
|
-
value: number;
|
|
21
|
-
} & Partial<{
|
|
22
|
-
/** Animates the value if it was changed externally. */
|
|
23
|
-
animated: boolean;
|
|
24
|
-
/** Custom css */
|
|
25
|
-
className: string;
|
|
26
|
-
/** Color of the slider. */
|
|
27
|
-
color: string;
|
|
28
|
-
/** If set, this value will be used to set the fill percentage of the progress bar filler independently of the main value. */
|
|
29
|
-
fillValue: number;
|
|
30
|
-
/** Format value using this function before displaying it. */
|
|
31
|
-
format: (value: number) => string;
|
|
32
|
-
/** Adjust value by this amount when dragging the input. */
|
|
33
|
-
onChange: (event: Event, value: number) => void;
|
|
34
|
-
/** An event, which fires when you release the input, or successfully enter a number. */
|
|
35
|
-
onDrag: (event: Event, value: number) => void;
|
|
36
|
-
/** Applies a `color` to the slider based on whether the value lands in the range between `from` and `to`. */
|
|
37
|
-
ranges: Record<string, [number, number]>;
|
|
38
|
-
/** Screen distance mouse needs to travel to adjust value by one `step`. */
|
|
39
|
-
step: number;
|
|
40
|
-
/** 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. */
|
|
41
|
-
stepPixelSize: number;
|
|
42
|
-
/** Adjust value by this amount when dragging the input. */
|
|
43
|
-
suppressFlicker: boolean;
|
|
44
|
-
/** Unit to display to the right of value. */
|
|
45
|
-
unit: string;
|
|
46
|
-
}> &
|
|
47
|
-
BoxProps &
|
|
48
|
-
PropsWithChildren;
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* ## Slider
|
|
52
|
-
* A horizontal, progressbar-like control which allows dialing
|
|
53
|
-
* in precise values by dragging it left and right.
|
|
54
|
-
*
|
|
55
|
-
* Single click opens an input box to manually type in a number.
|
|
56
|
-
*
|
|
57
|
-
*/
|
|
58
|
-
export function Slider(props: Props) {
|
|
59
|
-
const {
|
|
60
|
-
// Draggable props (passthrough)
|
|
61
|
-
animated,
|
|
62
|
-
format,
|
|
63
|
-
maxValue,
|
|
64
|
-
minValue,
|
|
65
|
-
onChange,
|
|
66
|
-
onDrag,
|
|
67
|
-
step,
|
|
68
|
-
stepPixelSize,
|
|
69
|
-
suppressFlicker,
|
|
70
|
-
unit,
|
|
71
|
-
value,
|
|
72
|
-
// Own props
|
|
73
|
-
className,
|
|
74
|
-
fillValue,
|
|
75
|
-
color,
|
|
76
|
-
ranges = {},
|
|
77
|
-
children,
|
|
78
|
-
...rest
|
|
79
|
-
} = props;
|
|
80
|
-
|
|
81
|
-
const hasContent = children !== undefined;
|
|
82
|
-
|
|
83
|
-
return (
|
|
84
|
-
<DraggableControl
|
|
85
|
-
dragMatrix={[1, 0]}
|
|
86
|
-
{...{
|
|
87
|
-
animated,
|
|
88
|
-
format,
|
|
89
|
-
maxValue,
|
|
90
|
-
minValue,
|
|
91
|
-
onChange,
|
|
92
|
-
onDrag,
|
|
93
|
-
step,
|
|
94
|
-
stepPixelSize,
|
|
95
|
-
suppressFlicker,
|
|
96
|
-
unit,
|
|
97
|
-
value,
|
|
98
|
-
}}
|
|
99
|
-
>
|
|
100
|
-
{(control) => {
|
|
101
|
-
const {
|
|
102
|
-
displayElement,
|
|
103
|
-
displayValue,
|
|
104
|
-
dragging,
|
|
105
|
-
handleDragStart,
|
|
106
|
-
inputElement,
|
|
107
|
-
value,
|
|
108
|
-
} = control;
|
|
109
|
-
|
|
110
|
-
const hasFillValue = fillValue !== undefined && fillValue !== null;
|
|
111
|
-
|
|
112
|
-
const scaledFillValue = scale(
|
|
113
|
-
fillValue ?? displayValue,
|
|
114
|
-
minValue,
|
|
115
|
-
maxValue
|
|
116
|
-
);
|
|
117
|
-
const scaledDisplayValue = scale(displayValue, minValue, maxValue);
|
|
118
|
-
|
|
119
|
-
const effectiveColor =
|
|
120
|
-
color || keyOfMatchingRange(fillValue ?? value, ranges) || 'default';
|
|
121
|
-
|
|
122
|
-
return (
|
|
123
|
-
<div
|
|
124
|
-
className={classes([
|
|
125
|
-
'Slider',
|
|
126
|
-
'ProgressBar',
|
|
127
|
-
'ProgressBar--color--' + effectiveColor,
|
|
128
|
-
className,
|
|
129
|
-
computeBoxClassName(rest),
|
|
130
|
-
])}
|
|
131
|
-
{...computeBoxProps(rest)}
|
|
132
|
-
onMouseDown={handleDragStart}
|
|
133
|
-
>
|
|
134
|
-
<div
|
|
135
|
-
className={classes([
|
|
136
|
-
'ProgressBar__fill',
|
|
137
|
-
hasFillValue && 'ProgressBar__fill--animated',
|
|
138
|
-
])}
|
|
139
|
-
style={{
|
|
140
|
-
width: clamp01(scaledFillValue) * 100 + '%',
|
|
141
|
-
opacity: 0.4,
|
|
142
|
-
}}
|
|
143
|
-
/>
|
|
144
|
-
<div
|
|
145
|
-
className="ProgressBar__fill"
|
|
146
|
-
style={{
|
|
147
|
-
width:
|
|
148
|
-
clamp01(Math.min(scaledFillValue, scaledDisplayValue)) * 100 +
|
|
149
|
-
'%',
|
|
150
|
-
}}
|
|
151
|
-
/>
|
|
152
|
-
<div
|
|
153
|
-
className="Slider__cursorOffset"
|
|
154
|
-
style={{
|
|
155
|
-
width: clamp01(scaledDisplayValue) * 100 + '%',
|
|
156
|
-
}}
|
|
157
|
-
>
|
|
158
|
-
<div className="Slider__cursor" />
|
|
159
|
-
<div className="Slider__pointer" />
|
|
160
|
-
{dragging && (
|
|
161
|
-
<div className="Slider__popupValue">{displayElement}</div>
|
|
162
|
-
)}
|
|
163
|
-
</div>
|
|
164
|
-
<div className="ProgressBar__content">
|
|
165
|
-
{hasContent ? children : displayElement}
|
|
166
|
-
</div>
|
|
167
|
-
{inputElement}
|
|
168
|
-
</div>
|
|
169
|
-
);
|
|
170
|
-
}}
|
|
171
|
-
</DraggableControl>
|
|
172
|
-
);
|
|
173
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @file
|
|
3
|
+
* @copyright 2020 Aleksej Komarov
|
|
4
|
+
* @license MIT
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { clamp01, keyOfMatchingRange, scale } from '../common/math';
|
|
8
|
+
import { classes } from '../common/react';
|
|
9
|
+
import { PropsWithChildren } from 'react';
|
|
10
|
+
|
|
11
|
+
import { BoxProps, computeBoxClassName, computeBoxProps } from './Box';
|
|
12
|
+
import { DraggableControl } from './DraggableControl';
|
|
13
|
+
|
|
14
|
+
type Props = {
|
|
15
|
+
/** Highest possible value. */
|
|
16
|
+
maxValue: number;
|
|
17
|
+
/** Lowest possible value. */
|
|
18
|
+
minValue: number;
|
|
19
|
+
/** Value itself, controls the position of the cursor. */
|
|
20
|
+
value: number;
|
|
21
|
+
} & Partial<{
|
|
22
|
+
/** Animates the value if it was changed externally. */
|
|
23
|
+
animated: boolean;
|
|
24
|
+
/** Custom css */
|
|
25
|
+
className: string;
|
|
26
|
+
/** Color of the slider. */
|
|
27
|
+
color: string;
|
|
28
|
+
/** If set, this value will be used to set the fill percentage of the progress bar filler independently of the main value. */
|
|
29
|
+
fillValue: number;
|
|
30
|
+
/** Format value using this function before displaying it. */
|
|
31
|
+
format: (value: number) => string;
|
|
32
|
+
/** Adjust value by this amount when dragging the input. */
|
|
33
|
+
onChange: (event: Event, value: number) => void;
|
|
34
|
+
/** An event, which fires when you release the input, or successfully enter a number. */
|
|
35
|
+
onDrag: (event: Event, value: number) => void;
|
|
36
|
+
/** Applies a `color` to the slider based on whether the value lands in the range between `from` and `to`. */
|
|
37
|
+
ranges: Record<string, [number, number]>;
|
|
38
|
+
/** Screen distance mouse needs to travel to adjust value by one `step`. */
|
|
39
|
+
step: number;
|
|
40
|
+
/** 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. */
|
|
41
|
+
stepPixelSize: number;
|
|
42
|
+
/** Adjust value by this amount when dragging the input. */
|
|
43
|
+
suppressFlicker: boolean;
|
|
44
|
+
/** Unit to display to the right of value. */
|
|
45
|
+
unit: string;
|
|
46
|
+
}> &
|
|
47
|
+
BoxProps &
|
|
48
|
+
PropsWithChildren;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* ## Slider
|
|
52
|
+
* A horizontal, progressbar-like control which allows dialing
|
|
53
|
+
* in precise values by dragging it left and right.
|
|
54
|
+
*
|
|
55
|
+
* Single click opens an input box to manually type in a number.
|
|
56
|
+
*
|
|
57
|
+
*/
|
|
58
|
+
export function Slider(props: Props) {
|
|
59
|
+
const {
|
|
60
|
+
// Draggable props (passthrough)
|
|
61
|
+
animated,
|
|
62
|
+
format,
|
|
63
|
+
maxValue,
|
|
64
|
+
minValue,
|
|
65
|
+
onChange,
|
|
66
|
+
onDrag,
|
|
67
|
+
step,
|
|
68
|
+
stepPixelSize,
|
|
69
|
+
suppressFlicker,
|
|
70
|
+
unit,
|
|
71
|
+
value,
|
|
72
|
+
// Own props
|
|
73
|
+
className,
|
|
74
|
+
fillValue,
|
|
75
|
+
color,
|
|
76
|
+
ranges = {},
|
|
77
|
+
children,
|
|
78
|
+
...rest
|
|
79
|
+
} = props;
|
|
80
|
+
|
|
81
|
+
const hasContent = children !== undefined;
|
|
82
|
+
|
|
83
|
+
return (
|
|
84
|
+
<DraggableControl
|
|
85
|
+
dragMatrix={[1, 0]}
|
|
86
|
+
{...{
|
|
87
|
+
animated,
|
|
88
|
+
format,
|
|
89
|
+
maxValue,
|
|
90
|
+
minValue,
|
|
91
|
+
onChange,
|
|
92
|
+
onDrag,
|
|
93
|
+
step,
|
|
94
|
+
stepPixelSize,
|
|
95
|
+
suppressFlicker,
|
|
96
|
+
unit,
|
|
97
|
+
value,
|
|
98
|
+
}}
|
|
99
|
+
>
|
|
100
|
+
{(control) => {
|
|
101
|
+
const {
|
|
102
|
+
displayElement,
|
|
103
|
+
displayValue,
|
|
104
|
+
dragging,
|
|
105
|
+
handleDragStart,
|
|
106
|
+
inputElement,
|
|
107
|
+
value,
|
|
108
|
+
} = control;
|
|
109
|
+
|
|
110
|
+
const hasFillValue = fillValue !== undefined && fillValue !== null;
|
|
111
|
+
|
|
112
|
+
const scaledFillValue = scale(
|
|
113
|
+
fillValue ?? displayValue,
|
|
114
|
+
minValue,
|
|
115
|
+
maxValue
|
|
116
|
+
);
|
|
117
|
+
const scaledDisplayValue = scale(displayValue, minValue, maxValue);
|
|
118
|
+
|
|
119
|
+
const effectiveColor =
|
|
120
|
+
color || keyOfMatchingRange(fillValue ?? value, ranges) || 'default';
|
|
121
|
+
|
|
122
|
+
return (
|
|
123
|
+
<div
|
|
124
|
+
className={classes([
|
|
125
|
+
'Slider',
|
|
126
|
+
'ProgressBar',
|
|
127
|
+
'ProgressBar--color--' + effectiveColor,
|
|
128
|
+
className,
|
|
129
|
+
computeBoxClassName(rest),
|
|
130
|
+
])}
|
|
131
|
+
{...computeBoxProps(rest)}
|
|
132
|
+
onMouseDown={handleDragStart}
|
|
133
|
+
>
|
|
134
|
+
<div
|
|
135
|
+
className={classes([
|
|
136
|
+
'ProgressBar__fill',
|
|
137
|
+
hasFillValue && 'ProgressBar__fill--animated',
|
|
138
|
+
])}
|
|
139
|
+
style={{
|
|
140
|
+
width: clamp01(scaledFillValue) * 100 + '%',
|
|
141
|
+
opacity: 0.4,
|
|
142
|
+
}}
|
|
143
|
+
/>
|
|
144
|
+
<div
|
|
145
|
+
className="ProgressBar__fill"
|
|
146
|
+
style={{
|
|
147
|
+
width:
|
|
148
|
+
clamp01(Math.min(scaledFillValue, scaledDisplayValue)) * 100 +
|
|
149
|
+
'%',
|
|
150
|
+
}}
|
|
151
|
+
/>
|
|
152
|
+
<div
|
|
153
|
+
className="Slider__cursorOffset"
|
|
154
|
+
style={{
|
|
155
|
+
width: clamp01(scaledDisplayValue) * 100 + '%',
|
|
156
|
+
}}
|
|
157
|
+
>
|
|
158
|
+
<div className="Slider__cursor" />
|
|
159
|
+
<div className="Slider__pointer" />
|
|
160
|
+
{dragging && (
|
|
161
|
+
<div className="Slider__popupValue">{displayElement}</div>
|
|
162
|
+
)}
|
|
163
|
+
</div>
|
|
164
|
+
<div className="ProgressBar__content">
|
|
165
|
+
{hasContent ? children : displayElement}
|
|
166
|
+
</div>
|
|
167
|
+
{inputElement}
|
|
168
|
+
</div>
|
|
169
|
+
);
|
|
170
|
+
}}
|
|
171
|
+
</DraggableControl>
|
|
172
|
+
);
|
|
173
|
+
}
|
|
@@ -1,101 +1,101 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file
|
|
3
|
-
* @copyright 2021 Aleksej Komarov
|
|
4
|
-
* @license MIT
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { classes } from '../common/react';
|
|
8
|
-
import { RefObject } from 'react';
|
|
9
|
-
|
|
10
|
-
import {
|
|
11
|
-
computeFlexClassName,
|
|
12
|
-
computeFlexItemClassName,
|
|
13
|
-
computeFlexItemProps,
|
|
14
|
-
computeFlexProps,
|
|
15
|
-
FlexItemProps,
|
|
16
|
-
FlexProps,
|
|
17
|
-
} from './Flex';
|
|
18
|
-
|
|
19
|
-
type Props = Partial<{
|
|
20
|
-
/** Fills available space. */
|
|
21
|
-
fill: boolean;
|
|
22
|
-
/** Reverses the stack. */
|
|
23
|
-
reverse: boolean;
|
|
24
|
-
/** Flex column */
|
|
25
|
-
vertical: boolean;
|
|
26
|
-
/** Adds zebra striping to the stack. */
|
|
27
|
-
zebra: boolean;
|
|
28
|
-
}> &
|
|
29
|
-
FlexProps;
|
|
30
|
-
|
|
31
|
-
export function Stack(props: Props) {
|
|
32
|
-
const { className, vertical, fill, reverse, zebra, ...rest } = props;
|
|
33
|
-
|
|
34
|
-
const directionPrefix = vertical ? 'column' : 'row';
|
|
35
|
-
const directionSuffix = reverse ? '-reverse' : '';
|
|
36
|
-
|
|
37
|
-
return (
|
|
38
|
-
<div
|
|
39
|
-
className={classes([
|
|
40
|
-
'Stack',
|
|
41
|
-
fill && 'Stack--fill',
|
|
42
|
-
vertical ? 'Stack--vertical' : 'Stack--horizontal',
|
|
43
|
-
zebra && 'Stack--zebra',
|
|
44
|
-
reverse && `Stack--reverse${vertical ? '--vertical' : ''}`,
|
|
45
|
-
className,
|
|
46
|
-
computeFlexClassName(props),
|
|
47
|
-
])}
|
|
48
|
-
{...computeFlexProps({
|
|
49
|
-
direction: `${directionPrefix}${directionSuffix}`,
|
|
50
|
-
...rest,
|
|
51
|
-
})}
|
|
52
|
-
/>
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
type StackItemProps = FlexItemProps &
|
|
57
|
-
Partial<{
|
|
58
|
-
innerRef: RefObject<HTMLDivElement>;
|
|
59
|
-
}>;
|
|
60
|
-
|
|
61
|
-
function StackItem(props: StackItemProps) {
|
|
62
|
-
const { className, innerRef, ...rest } = props;
|
|
63
|
-
|
|
64
|
-
return (
|
|
65
|
-
<div
|
|
66
|
-
className={classes([
|
|
67
|
-
'Stack__item',
|
|
68
|
-
className,
|
|
69
|
-
computeFlexItemClassName(rest),
|
|
70
|
-
])}
|
|
71
|
-
ref={innerRef}
|
|
72
|
-
{...computeFlexItemProps(rest)}
|
|
73
|
-
/>
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
Stack.Item = StackItem;
|
|
78
|
-
|
|
79
|
-
type StackDividerProps = FlexItemProps &
|
|
80
|
-
Partial<{
|
|
81
|
-
hidden: boolean;
|
|
82
|
-
}>;
|
|
83
|
-
|
|
84
|
-
function StackDivider(props: StackDividerProps) {
|
|
85
|
-
const { className, hidden, ...rest } = props;
|
|
86
|
-
|
|
87
|
-
return (
|
|
88
|
-
<div
|
|
89
|
-
className={classes([
|
|
90
|
-
'Stack__item',
|
|
91
|
-
'Stack__divider',
|
|
92
|
-
hidden && 'Stack__divider--hidden',
|
|
93
|
-
className,
|
|
94
|
-
computeFlexItemClassName(rest),
|
|
95
|
-
])}
|
|
96
|
-
{...computeFlexItemProps(rest)}
|
|
97
|
-
/>
|
|
98
|
-
);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
Stack.Divider = StackDivider;
|
|
1
|
+
/**
|
|
2
|
+
* @file
|
|
3
|
+
* @copyright 2021 Aleksej Komarov
|
|
4
|
+
* @license MIT
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { classes } from '../common/react';
|
|
8
|
+
import { RefObject } from 'react';
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
computeFlexClassName,
|
|
12
|
+
computeFlexItemClassName,
|
|
13
|
+
computeFlexItemProps,
|
|
14
|
+
computeFlexProps,
|
|
15
|
+
FlexItemProps,
|
|
16
|
+
FlexProps,
|
|
17
|
+
} from './Flex';
|
|
18
|
+
|
|
19
|
+
type Props = Partial<{
|
|
20
|
+
/** Fills available space. */
|
|
21
|
+
fill: boolean;
|
|
22
|
+
/** Reverses the stack. */
|
|
23
|
+
reverse: boolean;
|
|
24
|
+
/** Flex column */
|
|
25
|
+
vertical: boolean;
|
|
26
|
+
/** Adds zebra striping to the stack. */
|
|
27
|
+
zebra: boolean;
|
|
28
|
+
}> &
|
|
29
|
+
FlexProps;
|
|
30
|
+
|
|
31
|
+
export function Stack(props: Props) {
|
|
32
|
+
const { className, vertical, fill, reverse, zebra, ...rest } = props;
|
|
33
|
+
|
|
34
|
+
const directionPrefix = vertical ? 'column' : 'row';
|
|
35
|
+
const directionSuffix = reverse ? '-reverse' : '';
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<div
|
|
39
|
+
className={classes([
|
|
40
|
+
'Stack',
|
|
41
|
+
fill && 'Stack--fill',
|
|
42
|
+
vertical ? 'Stack--vertical' : 'Stack--horizontal',
|
|
43
|
+
zebra && 'Stack--zebra',
|
|
44
|
+
reverse && `Stack--reverse${vertical ? '--vertical' : ''}`,
|
|
45
|
+
className,
|
|
46
|
+
computeFlexClassName(props),
|
|
47
|
+
])}
|
|
48
|
+
{...computeFlexProps({
|
|
49
|
+
direction: `${directionPrefix}${directionSuffix}`,
|
|
50
|
+
...rest,
|
|
51
|
+
})}
|
|
52
|
+
/>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
type StackItemProps = FlexItemProps &
|
|
57
|
+
Partial<{
|
|
58
|
+
innerRef: RefObject<HTMLDivElement>;
|
|
59
|
+
}>;
|
|
60
|
+
|
|
61
|
+
function StackItem(props: StackItemProps) {
|
|
62
|
+
const { className, innerRef, ...rest } = props;
|
|
63
|
+
|
|
64
|
+
return (
|
|
65
|
+
<div
|
|
66
|
+
className={classes([
|
|
67
|
+
'Stack__item',
|
|
68
|
+
className,
|
|
69
|
+
computeFlexItemClassName(rest),
|
|
70
|
+
])}
|
|
71
|
+
ref={innerRef}
|
|
72
|
+
{...computeFlexItemProps(rest)}
|
|
73
|
+
/>
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
Stack.Item = StackItem;
|
|
78
|
+
|
|
79
|
+
type StackDividerProps = FlexItemProps &
|
|
80
|
+
Partial<{
|
|
81
|
+
hidden: boolean;
|
|
82
|
+
}>;
|
|
83
|
+
|
|
84
|
+
function StackDivider(props: StackDividerProps) {
|
|
85
|
+
const { className, hidden, ...rest } = props;
|
|
86
|
+
|
|
87
|
+
return (
|
|
88
|
+
<div
|
|
89
|
+
className={classes([
|
|
90
|
+
'Stack__item',
|
|
91
|
+
'Stack__divider',
|
|
92
|
+
hidden && 'Stack__divider--hidden',
|
|
93
|
+
className,
|
|
94
|
+
computeFlexItemClassName(rest),
|
|
95
|
+
])}
|
|
96
|
+
{...computeFlexItemProps(rest)}
|
|
97
|
+
/>
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
Stack.Divider = StackDivider;
|