tgui-core 1.1.11 → 1.1.13
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/dist/ProgressBar.module-BkAFfFy0.js +29 -0
- package/dist/Section.module-CLVHJ4yA.js +15 -0
- package/dist/assets/BlockQuote.css +1 -0
- package/dist/assets/Button.css +1 -0
- package/dist/assets/ColorBox.css +1 -0
- package/dist/assets/Dialog.css +1 -0
- package/dist/assets/Dimmer.css +1 -0
- package/dist/assets/Divider.css +1 -0
- package/dist/assets/Flex.css +1 -0
- package/dist/assets/Icon.css +6 -0
- package/dist/assets/Input.css +1 -0
- package/dist/assets/Knob.css +1 -0
- package/dist/assets/LabeledList.css +1 -0
- package/dist/assets/MenuBar.css +1 -0
- package/dist/assets/Modal.css +1 -0
- package/dist/assets/NoticeBox.css +1 -0
- package/dist/assets/NumberInput.css +1 -0
- package/dist/assets/ProgressBar.css +1 -0
- package/dist/assets/RoundGauge.css +1 -0
- package/dist/assets/Section.css +1 -0
- package/dist/assets/Slider.css +1 -0
- package/dist/assets/Stack.css +1 -0
- package/dist/assets/Table.css +1 -0
- package/dist/assets/Tabs.css +1 -0
- package/dist/assets/TextArea.css +1 -0
- package/dist/assets/Tooltip.css +1 -0
- package/dist/common/assets.d.ts +4 -0
- package/dist/common/assets.js +25 -0
- package/dist/common/collections.d.ts +10 -0
- package/dist/common/collections.js +15 -0
- package/dist/common/color.d.ts +25 -0
- package/dist/common/color.js +69 -0
- package/dist/common/constants.d.ts +102 -0
- package/dist/common/constants.js +312 -0
- package/dist/common/events.d.ts +33 -0
- package/dist/common/events.js +147 -0
- package/{lib/common/exhaustive.ts → dist/common/exhaustive.d.ts} +1 -3
- package/dist/common/exhaustive.js +6 -0
- package/dist/common/format.d.ts +11 -0
- package/dist/common/format.js +114 -0
- package/{lib/common/fp.ts → dist/common/fp.d.ts} +2 -16
- package/dist/common/fp.js +9 -0
- package/dist/common/hotkeys.d.ts +25 -0
- package/dist/common/hotkeys.js +112 -0
- package/dist/common/http.d.ts +4 -0
- package/dist/common/http.js +10 -0
- package/dist/common/keycodes.d.ts +85 -0
- package/dist/common/keycodes.js +88 -0
- package/{lib/common/keys.ts → dist/common/keys.d.ts} +21 -24
- package/dist/common/keys.js +8 -0
- package/dist/common/math.d.ts +39 -0
- package/dist/common/math.js +41 -0
- package/dist/common/perf.d.ts +24 -0
- package/dist/common/perf.js +33 -0
- package/dist/common/random.d.ts +16 -0
- package/dist/common/random.js +18 -0
- package/dist/common/react.d.ts +23 -0
- package/dist/common/react.js +30 -0
- package/dist/common/redux.d.ts +64 -0
- package/dist/common/redux.js +72 -0
- package/dist/common/storage.d.ts +24 -0
- package/dist/common/storage.js +133 -0
- package/dist/common/string.d.ts +65 -0
- package/dist/common/string.js +83 -0
- package/dist/common/timer.d.ts +18 -0
- package/dist/common/timer.js +28 -0
- package/dist/common/type-utils.d.ts +9 -0
- package/dist/common/type-utils.js +25 -0
- package/dist/common/uuid.d.ts +9 -0
- package/dist/common/uuid.js +10 -0
- package/dist/components/AnimatedNumber.d.ts +60 -0
- package/dist/components/AnimatedNumber.js +76 -0
- package/dist/components/Autofocus.d.ts +4 -0
- package/dist/components/Autofocus.js +17 -0
- package/dist/components/Blink.d.ts +26 -0
- package/dist/components/Blink.js +56 -0
- package/dist/components/BlockQuote.d.ts +3 -0
- package/dist/components/BlockQuote.js +13 -0
- package/dist/components/BodyZoneSelector.d.ts +28 -0
- package/dist/components/BodyZoneSelector.js +115 -0
- package/dist/components/Box.d.ts +91 -0
- package/dist/components/Box.js +133 -0
- package/dist/components/Button.d.ts +93 -0
- package/dist/components/Button.js +298 -0
- package/dist/components/ByondUi.js +73 -0
- package/dist/components/Chart.d.ts +28 -0
- package/dist/components/Chart.js +95 -0
- package/dist/components/Collapsible.d.ts +15 -0
- package/dist/components/Collapsible.js +27 -0
- package/dist/components/ColorBox.d.ts +8 -0
- package/dist/components/ColorBox.js +24 -0
- package/dist/components/Dialog.d.ts +24 -0
- package/dist/components/Dialog.js +67 -0
- package/dist/components/Dimmer.d.ts +3 -0
- package/dist/components/Dimmer.js +13 -0
- package/dist/components/Divider.d.ts +6 -0
- package/dist/components/Divider.js +22 -0
- package/dist/components/DmIcon.d.ts +33 -0
- package/dist/components/DmIcon.js +29 -0
- package/dist/components/DraggableControl.js +176 -0
- package/dist/components/Dropdown.d.ts +48 -0
- package/dist/components/Dropdown.js +152 -0
- package/dist/components/FakeTerminal.js +38 -0
- package/dist/components/FitText.d.ts +22 -0
- package/dist/components/FitText.js +63 -0
- package/dist/components/Flex.d.ts +93 -0
- package/dist/components/Flex.js +72 -0
- package/dist/components/Icon.d.ts +30 -0
- package/dist/components/Icon.js +51 -0
- package/dist/components/Image.d.ts +14 -0
- package/dist/components/Image.js +35 -0
- package/dist/components/InfinitePlane.js +139 -0
- package/dist/components/Input.d.ts +61 -0
- package/dist/components/Input.js +89 -0
- package/dist/components/KeyListener.d.ts +15 -0
- package/dist/components/KeyListener.js +23 -0
- package/dist/components/Knob.d.ts +49 -0
- package/dist/components/Knob.js +162 -0
- package/dist/components/LabeledControls.d.ts +11 -0
- package/dist/components/LabeledControls.js +39 -0
- package/dist/components/LabeledList.d.ts +57 -0
- package/dist/components/LabeledList.js +94 -0
- package/dist/components/MenuBar.d.ts +28 -0
- package/dist/components/MenuBar.js +174 -0
- package/dist/components/Modal.d.ts +3 -0
- package/dist/components/Modal.js +25 -0
- package/dist/components/NoticeBox.d.ts +20 -0
- package/dist/components/NoticeBox.js +49 -0
- package/dist/components/NumberInput.d.ts +45 -0
- package/dist/components/NumberInput.js +221 -0
- package/dist/components/Popper.d.ts +27 -0
- package/dist/components/Popper.js +177 -0
- package/dist/components/ProgressBar.d.ts +46 -0
- package/dist/components/ProgressBar.js +37 -0
- package/dist/components/RestrictedInput.js +155 -0
- package/dist/components/RoundGauge.d.ts +53 -0
- package/dist/components/RoundGauge.js +147 -0
- package/dist/components/Section.d.ts +63 -0
- package/dist/components/Section.js +62 -0
- package/dist/components/Slider.d.ts +46 -0
- package/dist/components/Slider.js +124 -0
- package/dist/components/Stack.d.ts +27 -0
- package/dist/components/Stack.js +67 -0
- package/dist/components/StyleableSection.d.ts +11 -0
- package/dist/components/StyleableSection.js +16 -0
- package/dist/components/Table.d.ts +29 -0
- package/dist/components/Table.js +67 -0
- package/dist/components/Tabs.d.ts +23 -0
- package/dist/components/Tabs.js +89 -0
- package/dist/components/TextArea.d.ts +39 -0
- package/dist/components/TextArea.js +118 -0
- package/dist/components/TimeDisplay.js +34 -0
- package/dist/components/Tooltip.d.ts +29 -0
- package/dist/components/Tooltip.js +83 -0
- package/dist/components/TrackOutsideClicks.d.ts +13 -0
- package/dist/components/TrackOutsideClicks.js +24 -0
- package/dist/components/VirtualList.d.ts +8 -0
- package/dist/components/VirtualList.js +34 -0
- package/dist/components/index.js +92 -0
- package/dist/popper-CiqSDJTE.js +906 -0
- package/package.json +8 -10
- package/lib/common/assets.ts +0 -38
- package/lib/common/collections.ts +0 -27
- package/lib/common/color.ts +0 -88
- package/lib/common/constants.ts +0 -349
- package/lib/common/events.ts +0 -262
- package/lib/common/format.ts +0 -167
- package/lib/common/hotkeys.ts +0 -207
- package/lib/common/http.ts +0 -16
- package/lib/common/keycodes.ts +0 -86
- package/lib/common/math.ts +0 -76
- package/lib/common/perf.ts +0 -72
- package/lib/common/random.ts +0 -32
- package/lib/common/react.ts +0 -59
- package/lib/common/redux.ts +0 -187
- package/lib/common/storage.ts +0 -207
- package/lib/common/string.ts +0 -169
- package/lib/common/timer.ts +0 -63
- package/lib/common/type-utils.ts +0 -41
- package/lib/common/types.d.ts +0 -12
- package/lib/common/uuid.ts +0 -18
- package/lib/components/AnimatedNumber.tsx +0 -180
- package/lib/components/Autofocus.tsx +0 -23
- package/lib/components/Blink.tsx +0 -91
- package/lib/components/BlockQuote.tsx +0 -9
- package/lib/components/BodyZoneSelector.tsx +0 -149
- package/lib/components/Box.tsx +0 -252
- package/lib/components/Button.tsx +0 -425
- package/lib/components/ByondUi.jsx +0 -110
- package/lib/components/Chart.tsx +0 -155
- package/lib/components/Collapsible.tsx +0 -43
- package/lib/components/ColorBox.tsx +0 -29
- package/lib/components/Dialog.tsx +0 -81
- package/lib/components/Dimmer.tsx +0 -13
- package/lib/components/Divider.tsx +0 -20
- package/lib/components/DmIcon.tsx +0 -86
- package/lib/components/DraggableControl.jsx +0 -276
- package/lib/components/Dropdown.tsx +0 -246
- package/lib/components/FakeTerminal.jsx +0 -52
- package/lib/components/FitText.tsx +0 -99
- package/lib/components/Flex.tsx +0 -159
- package/lib/components/Icon.tsx +0 -95
- package/lib/components/Image.tsx +0 -54
- package/lib/components/InfinitePlane.jsx +0 -192
- package/lib/components/Input.tsx +0 -176
- package/lib/components/KeyListener.tsx +0 -40
- package/lib/components/Knob.tsx +0 -178
- package/lib/components/LabeledControls.tsx +0 -44
- package/lib/components/LabeledList.tsx +0 -154
- package/lib/components/MenuBar.tsx +0 -228
- package/lib/components/Modal.tsx +0 -23
- package/lib/components/NoticeBox.tsx +0 -45
- package/lib/components/NumberInput.tsx +0 -328
- package/lib/components/Popper.tsx +0 -100
- package/lib/components/ProgressBar.tsx +0 -105
- package/lib/components/RestrictedInput.jsx +0 -301
- package/lib/components/RoundGauge.tsx +0 -180
- package/lib/components/Section.tsx +0 -120
- package/lib/components/Slider.tsx +0 -169
- package/lib/components/Stack.tsx +0 -96
- package/lib/components/StyleableSection.tsx +0 -33
- package/lib/components/Table.tsx +0 -84
- package/lib/components/Tabs.tsx +0 -89
- package/lib/components/TextArea.tsx +0 -182
- package/lib/components/TimeDisplay.jsx +0 -64
- package/lib/components/Tooltip.tsx +0 -152
- package/lib/components/TrackOutsideClicks.tsx +0 -35
- package/lib/components/VirtualList.tsx +0 -69
- package/lib/styles/atomic/candystripe.scss +0 -8
- package/lib/styles/atomic/centered-image.scss +0 -7
- package/lib/styles/atomic/color.scss +0 -21
- package/lib/styles/atomic/debug-layout.scss +0 -17
- package/lib/styles/atomic/fit-text.scss +0 -14
- package/lib/styles/atomic/links.scss +0 -12
- package/lib/styles/atomic/outline.scss +0 -47
- package/lib/styles/atomic/text.scss +0 -44
- package/lib/styles/base.scss +0 -32
- package/lib/styles/colors.scss +0 -92
- package/lib/styles/components/BlockQuote.module.scss +0 -20
- package/lib/styles/components/BlockQuote.module.scss.d.ts +0 -4
- package/lib/styles/components/Button.module.scss +0 -157
- package/lib/styles/components/Button.module.scss.d.ts +0 -46
- package/lib/styles/components/ColorBox.module.scss +0 -12
- package/lib/styles/components/ColorBox.module.scss.d.ts +0 -4
- package/lib/styles/components/Dialog.module.scss +0 -60
- package/lib/styles/components/Dialog.module.scss.d.ts +0 -10
- package/lib/styles/components/Dimmer.module.scss +0 -22
- package/lib/styles/components/Dimmer.module.scss.d.ts +0 -4
- package/lib/styles/components/Divider.module.scss +0 -27
- package/lib/styles/components/Divider.module.scss.d.ts +0 -6
- package/lib/styles/components/Dropdown.scss +0 -72
- package/lib/styles/components/Flex.module.scss +0 -13
- package/lib/styles/components/Flex.module.scss.d.ts +0 -5
- package/lib/styles/components/Icon.module.scss +0 -25
- package/lib/styles/components/Icon.module.scss.d.ts +0 -5
- package/lib/styles/components/Input.module.scss +0 -64
- package/lib/styles/components/Input.module.scss.d.ts +0 -8
- package/lib/styles/components/Knob.module.scss +0 -131
- package/lib/styles/components/Knob.module.scss.d.ts +0 -33
- package/lib/styles/components/LabeledList.module.scss +0 -49
- package/lib/styles/components/LabeledList.module.scss.d.ts +0 -8
- package/lib/styles/components/MenuBar.module.scss +0 -75
- package/lib/styles/components/MenuBar.module.scss.d.ts +0 -14
- package/lib/styles/components/Modal.module.scss +0 -14
- package/lib/styles/components/Modal.module.scss.d.ts +0 -4
- package/lib/styles/components/NoticeBox.module.scss +0 -65
- package/lib/styles/components/NoticeBox.module.scss.d.ts +0 -27
- package/lib/styles/components/NumberInput.module.scss +0 -71
- package/lib/styles/components/NumberInput.module.scss.d.ts +0 -9
- package/lib/styles/components/ProgressBar.module.scss +0 -63
- package/lib/styles/components/ProgressBar.module.scss.d.ts +0 -27
- package/lib/styles/components/RoundGauge.module.scss +0 -85
- package/lib/styles/components/RoundGauge.module.scss.d.ts +0 -49
- package/lib/styles/components/Section.module.scss +0 -130
- package/lib/styles/components/Section.module.scss.d.ts +0 -13
- package/lib/styles/components/Slider.module.scss +0 -54
- package/lib/styles/components/Slider.module.scss.d.ts +0 -8
- package/lib/styles/components/Stack.module.scss +0 -60
- package/lib/styles/components/Stack.module.scss.d.ts +0 -12
- package/lib/styles/components/Table.module.scss +0 -44
- package/lib/styles/components/Table.module.scss.d.ts +0 -10
- package/lib/styles/components/Tabs.module.scss +0 -144
- package/lib/styles/components/Tabs.module.scss.d.ts +0 -35
- package/lib/styles/components/TextArea.module.scss +0 -86
- package/lib/styles/components/TextArea.module.scss.d.ts +0 -11
- package/lib/styles/components/Tooltip.module.scss +0 -24
- package/lib/styles/components/Tooltip.module.scss.d.ts +0 -4
- package/lib/styles/functions.scss +0 -79
- package/lib/styles/input.scss +0 -9
- package/lib/styles/main.scss +0 -20
- package/lib/styles/reset.scss +0 -68
- /package/{lib/components/index.ts → dist/components/index.d.ts} +0 -0
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { ReactNode, useState } from 'react';
|
|
2
|
-
|
|
3
|
-
import { Box, BoxProps } from './Box';
|
|
4
|
-
import { Button } from './Button';
|
|
5
|
-
|
|
6
|
-
type Props = Partial<{
|
|
7
|
-
/** Buttons or other content to render inline with the button */
|
|
8
|
-
buttons: ReactNode;
|
|
9
|
-
/** Icon to display with the collapsible */
|
|
10
|
-
icon: string;
|
|
11
|
-
/** Whether the collapsible is open */
|
|
12
|
-
open: boolean;
|
|
13
|
-
/** Text to display on the button for collapsing */
|
|
14
|
-
title: ReactNode;
|
|
15
|
-
}> &
|
|
16
|
-
BoxProps;
|
|
17
|
-
|
|
18
|
-
export function Collapsible(props: Props) {
|
|
19
|
-
const { children, color, title, buttons, icon, ...rest } = props;
|
|
20
|
-
const [open, setOpen] = useState(props.open);
|
|
21
|
-
|
|
22
|
-
return (
|
|
23
|
-
<Box mb={1}>
|
|
24
|
-
<div className="Table">
|
|
25
|
-
<div className="Table__cell">
|
|
26
|
-
<Button
|
|
27
|
-
fluid
|
|
28
|
-
color={color}
|
|
29
|
-
icon={icon ? icon : open ? 'chevron-down' : 'chevron-right'}
|
|
30
|
-
onClick={() => setOpen(!open)}
|
|
31
|
-
{...rest}
|
|
32
|
-
>
|
|
33
|
-
{title}
|
|
34
|
-
</Button>
|
|
35
|
-
</div>
|
|
36
|
-
{buttons && (
|
|
37
|
-
<div className="Table__cell Table__cell--collapsing">{buttons}</div>
|
|
38
|
-
)}
|
|
39
|
-
</div>
|
|
40
|
-
{open && <Box mt={1}>{children}</Box>}
|
|
41
|
-
</Box>
|
|
42
|
-
);
|
|
43
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
|
|
3
|
-
import { classes } from '../common/react';
|
|
4
|
-
import styles from '../styles/components/ColorBox.module.scss';
|
|
5
|
-
import { BoxProps, computeBoxClassName, computeBoxProps } from './Box';
|
|
6
|
-
|
|
7
|
-
type Props = {
|
|
8
|
-
content?: ReactNode;
|
|
9
|
-
} & BoxProps;
|
|
10
|
-
|
|
11
|
-
export function ColorBox(props: Props) {
|
|
12
|
-
const { content, children, className, ...rest } = props;
|
|
13
|
-
|
|
14
|
-
rest.color = content ? null : 'default';
|
|
15
|
-
rest.backgroundColor = props.color || 'default';
|
|
16
|
-
|
|
17
|
-
return (
|
|
18
|
-
<div
|
|
19
|
-
className={classes([
|
|
20
|
-
styles.colorBox,
|
|
21
|
-
className,
|
|
22
|
-
computeBoxClassName(rest),
|
|
23
|
-
])}
|
|
24
|
-
{...computeBoxProps(rest)}
|
|
25
|
-
>
|
|
26
|
-
{content || '.'}
|
|
27
|
-
</div>
|
|
28
|
-
);
|
|
29
|
-
}
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import styles from '../styles/components/Dialog.module.scss';
|
|
2
|
-
import { Box } from './Box';
|
|
3
|
-
import { Button } from './Button';
|
|
4
|
-
|
|
5
|
-
type DialogProps = {
|
|
6
|
-
children: any;
|
|
7
|
-
height?: string;
|
|
8
|
-
onClose: () => void;
|
|
9
|
-
title: any;
|
|
10
|
-
width?: string;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export function Dialog(props: DialogProps) {
|
|
14
|
-
const { title, onClose, children, width, height } = props;
|
|
15
|
-
return (
|
|
16
|
-
<div className={styles.dialog}>
|
|
17
|
-
<Box className={styles.content} width={width || '370px'} height={height}>
|
|
18
|
-
<div className={styles.header}>
|
|
19
|
-
<div className={styles.title}>{title}</div>
|
|
20
|
-
<Box mr={2}>
|
|
21
|
-
<Button
|
|
22
|
-
mr="-3px"
|
|
23
|
-
width="26px"
|
|
24
|
-
lineHeight="22px"
|
|
25
|
-
textAlign="center"
|
|
26
|
-
color="transparent"
|
|
27
|
-
icon="window-close-o"
|
|
28
|
-
tooltip="Close"
|
|
29
|
-
tooltipPosition="bottom-start"
|
|
30
|
-
onClick={onClose}
|
|
31
|
-
/>
|
|
32
|
-
</Box>
|
|
33
|
-
</div>
|
|
34
|
-
{children}
|
|
35
|
-
</Box>
|
|
36
|
-
</div>
|
|
37
|
-
);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
type DialogButtonProps = {
|
|
41
|
-
children: any;
|
|
42
|
-
onClick: () => void;
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
function DialogButton(props: DialogButtonProps) {
|
|
46
|
-
const { onClick, children } = props;
|
|
47
|
-
return (
|
|
48
|
-
<Button
|
|
49
|
-
onClick={onClick}
|
|
50
|
-
className={styles.button}
|
|
51
|
-
verticalAlignContent="middle"
|
|
52
|
-
>
|
|
53
|
-
{children}
|
|
54
|
-
</Button>
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
Dialog.Button = DialogButton;
|
|
59
|
-
|
|
60
|
-
type UnsavedChangesDialogProps = {
|
|
61
|
-
documentName: string;
|
|
62
|
-
onClose: () => void;
|
|
63
|
-
onDiscard: () => void;
|
|
64
|
-
onSave: () => void;
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
export function UnsavedChangesDialog(props: UnsavedChangesDialogProps) {
|
|
68
|
-
const { documentName, onSave, onDiscard, onClose } = props;
|
|
69
|
-
return (
|
|
70
|
-
<Dialog title="Notepad" onClose={onClose}>
|
|
71
|
-
<div className={styles.body}>
|
|
72
|
-
Do you want to save changes to {documentName}?
|
|
73
|
-
</div>
|
|
74
|
-
<div className={styles.footer}>
|
|
75
|
-
<DialogButton onClick={onSave}>Save</DialogButton>
|
|
76
|
-
<DialogButton onClick={onDiscard}>Don't Save</DialogButton>
|
|
77
|
-
<DialogButton onClick={onClose}>Cancel</DialogButton>
|
|
78
|
-
</div>
|
|
79
|
-
</Dialog>
|
|
80
|
-
);
|
|
81
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { classes } from '../common/react';
|
|
2
|
-
import styles from '../styles/components/Dimmer.module.scss';
|
|
3
|
-
import { Box, BoxProps } from './Box';
|
|
4
|
-
|
|
5
|
-
export function Dimmer(props: BoxProps) {
|
|
6
|
-
const { className, children, ...rest } = props;
|
|
7
|
-
|
|
8
|
-
return (
|
|
9
|
-
<Box className={classes([styles.dimmer, className])} {...rest}>
|
|
10
|
-
<div className="Dimmer__inner">{children}</div>
|
|
11
|
-
</Box>
|
|
12
|
-
);
|
|
13
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { classes } from '../common/react';
|
|
2
|
-
import styles from '../styles/components/Divider.module.scss';
|
|
3
|
-
|
|
4
|
-
type Props = Partial<{
|
|
5
|
-
hidden: boolean;
|
|
6
|
-
vertical: boolean;
|
|
7
|
-
}>;
|
|
8
|
-
|
|
9
|
-
export function Divider(props: Props) {
|
|
10
|
-
const { hidden, vertical } = props;
|
|
11
|
-
|
|
12
|
-
return (
|
|
13
|
-
<div
|
|
14
|
-
className={classes([
|
|
15
|
-
hidden && styles.hidden,
|
|
16
|
-
vertical ? styles.vertical : styles.horizontal,
|
|
17
|
-
])}
|
|
18
|
-
/>
|
|
19
|
-
);
|
|
20
|
-
}
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { ReactNode, useEffect, useState } from 'react';
|
|
2
|
-
|
|
3
|
-
import { resolveAsset } from '../common/assets';
|
|
4
|
-
import { fetchRetry } from '../common/http';
|
|
5
|
-
import { BooleanLike } from '../common/react';
|
|
6
|
-
import { BoxProps } from './Box';
|
|
7
|
-
import { Image } from './Image';
|
|
8
|
-
|
|
9
|
-
enum Direction {
|
|
10
|
-
NORTH = 1,
|
|
11
|
-
SOUTH = 2,
|
|
12
|
-
EAST = 4,
|
|
13
|
-
WEST = 8,
|
|
14
|
-
NORTHEAST = NORTH | EAST,
|
|
15
|
-
NORTHWEST = NORTH | WEST,
|
|
16
|
-
SOUTHEAST = SOUTH | EAST,
|
|
17
|
-
SOUTHWEST = SOUTH | WEST,
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
type Props = {
|
|
21
|
-
/** Required: The path of the icon */
|
|
22
|
-
icon: string;
|
|
23
|
-
/** Required: The state of the icon */
|
|
24
|
-
icon_state: string;
|
|
25
|
-
} & Partial<{
|
|
26
|
-
/** Facing direction. See direction enum. Default is South */
|
|
27
|
-
direction: Direction;
|
|
28
|
-
/** Fallback icon. */
|
|
29
|
-
fallback: ReactNode;
|
|
30
|
-
/** Frame number. Default is 1 */
|
|
31
|
-
frame: number;
|
|
32
|
-
/** Movement state. Default is false */
|
|
33
|
-
movement: BooleanLike;
|
|
34
|
-
}> &
|
|
35
|
-
BoxProps;
|
|
36
|
-
|
|
37
|
-
let refMap: Record<string, string> | undefined;
|
|
38
|
-
|
|
39
|
-
export function DmIcon(props: Props) {
|
|
40
|
-
const {
|
|
41
|
-
className,
|
|
42
|
-
direction = Direction.SOUTH,
|
|
43
|
-
fallback,
|
|
44
|
-
frame = 1,
|
|
45
|
-
icon_state,
|
|
46
|
-
icon,
|
|
47
|
-
movement = false,
|
|
48
|
-
...rest
|
|
49
|
-
} = props;
|
|
50
|
-
|
|
51
|
-
const [iconRef, setIconRef] = useState('');
|
|
52
|
-
const [toDisplay, setToDisplay] = useState('');
|
|
53
|
-
|
|
54
|
-
const query = `${iconRef}?state=${icon_state}&dir=${direction}&movement=${movement}&frame=${frame}`;
|
|
55
|
-
|
|
56
|
-
useEffect(() => {
|
|
57
|
-
if (refMap) {
|
|
58
|
-
setToDisplay(Object.keys(refMap).length.toString());
|
|
59
|
-
setIconRef(refMap[icon]);
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
fetchRetry(resolveAsset('icon_ref_map.json'))
|
|
64
|
-
.then((response) => {
|
|
65
|
-
setToDisplay('!');
|
|
66
|
-
return response.json();
|
|
67
|
-
})
|
|
68
|
-
.then((data) => {
|
|
69
|
-
refMap = data;
|
|
70
|
-
setIconRef(data[icon]);
|
|
71
|
-
setToDisplay('!!');
|
|
72
|
-
})
|
|
73
|
-
.catch(() => {
|
|
74
|
-
// Ignore errors
|
|
75
|
-
});
|
|
76
|
-
}, []);
|
|
77
|
-
|
|
78
|
-
if (!iconRef) return fallback;
|
|
79
|
-
|
|
80
|
-
return (
|
|
81
|
-
<>
|
|
82
|
-
<Image fixErrors src={query} {...rest} />
|
|
83
|
-
{toDisplay}
|
|
84
|
-
</>
|
|
85
|
-
);
|
|
86
|
-
}
|
|
@@ -1,276 +0,0 @@
|
|
|
1
|
-
import { clamp } from '../common/math';
|
|
2
|
-
import { Component, createRef } from 'react';
|
|
3
|
-
|
|
4
|
-
import { AnimatedNumber } from './AnimatedNumber';
|
|
5
|
-
|
|
6
|
-
const DEFAULT_UPDATE_RATE = 400;
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Reduces screen offset to a single number based on the matrix provided.
|
|
10
|
-
*/
|
|
11
|
-
function getScalarScreenOffset(e, matrix) {
|
|
12
|
-
return e.screenX * matrix[0] + e.screenY * matrix[1];
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export class DraggableControl extends Component {
|
|
16
|
-
constructor(props) {
|
|
17
|
-
super(props);
|
|
18
|
-
this.inputRef = createRef();
|
|
19
|
-
this.state = {
|
|
20
|
-
value: props.value,
|
|
21
|
-
dragging: false,
|
|
22
|
-
editing: false,
|
|
23
|
-
internalValue: null,
|
|
24
|
-
origin: null,
|
|
25
|
-
suppressingFlicker: false,
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
// Suppresses flickering while the value propagates through the backend
|
|
29
|
-
this.flickerTimer = null;
|
|
30
|
-
this.suppressFlicker = () => {
|
|
31
|
-
const { suppressFlicker } = this.props;
|
|
32
|
-
if (suppressFlicker > 0) {
|
|
33
|
-
this.setState({
|
|
34
|
-
suppressingFlicker: true,
|
|
35
|
-
});
|
|
36
|
-
clearTimeout(this.flickerTimer);
|
|
37
|
-
this.flickerTimer = setTimeout(() => {
|
|
38
|
-
this.setState({
|
|
39
|
-
suppressingFlicker: false,
|
|
40
|
-
});
|
|
41
|
-
}, suppressFlicker);
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
this.handleDragStart = (e) => {
|
|
46
|
-
const { value, dragMatrix } = this.props;
|
|
47
|
-
const { editing } = this.state;
|
|
48
|
-
if (editing) {
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
document.body.style['pointer-events'] = 'none';
|
|
52
|
-
this.ref = e.target;
|
|
53
|
-
this.setState({
|
|
54
|
-
dragging: false,
|
|
55
|
-
origin: getScalarScreenOffset(e, dragMatrix),
|
|
56
|
-
value,
|
|
57
|
-
internalValue: value,
|
|
58
|
-
});
|
|
59
|
-
this.timer = setTimeout(() => {
|
|
60
|
-
this.setState({
|
|
61
|
-
dragging: true,
|
|
62
|
-
});
|
|
63
|
-
}, 250);
|
|
64
|
-
this.dragInterval = setInterval(() => {
|
|
65
|
-
const { dragging, value } = this.state;
|
|
66
|
-
const { onDrag } = this.props;
|
|
67
|
-
if (dragging && onDrag) {
|
|
68
|
-
onDrag(e, value);
|
|
69
|
-
}
|
|
70
|
-
}, this.props.updateRate || DEFAULT_UPDATE_RATE);
|
|
71
|
-
document.addEventListener('mousemove', this.handleDragMove);
|
|
72
|
-
document.addEventListener('mouseup', this.handleDragEnd);
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
this.handleDragMove = (e) => {
|
|
76
|
-
const { minValue, maxValue, step, stepPixelSize, dragMatrix } =
|
|
77
|
-
this.props;
|
|
78
|
-
this.setState((prevState) => {
|
|
79
|
-
const state = { ...prevState };
|
|
80
|
-
const offset = getScalarScreenOffset(e, dragMatrix) - state.origin;
|
|
81
|
-
if (prevState.dragging) {
|
|
82
|
-
const stepOffset = Number.isFinite(minValue) ? minValue % step : 0;
|
|
83
|
-
// Translate mouse movement to value
|
|
84
|
-
// Give it some headroom (by increasing clamp range by 1 step)
|
|
85
|
-
state.internalValue = clamp(
|
|
86
|
-
state.internalValue + (offset * step) / stepPixelSize,
|
|
87
|
-
minValue - step,
|
|
88
|
-
maxValue + step,
|
|
89
|
-
);
|
|
90
|
-
// Clamp the final value
|
|
91
|
-
state.value = clamp(
|
|
92
|
-
state.internalValue - (state.internalValue % step) + stepOffset,
|
|
93
|
-
minValue,
|
|
94
|
-
maxValue,
|
|
95
|
-
);
|
|
96
|
-
state.origin = getScalarScreenOffset(e, dragMatrix);
|
|
97
|
-
} else if (Math.abs(offset) > 4) {
|
|
98
|
-
state.dragging = true;
|
|
99
|
-
}
|
|
100
|
-
return state;
|
|
101
|
-
});
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
this.handleDragEnd = (e) => {
|
|
105
|
-
const { onChange, onDrag } = this.props;
|
|
106
|
-
const { dragging, value, internalValue } = this.state;
|
|
107
|
-
document.body.style['pointer-events'] = 'auto';
|
|
108
|
-
clearTimeout(this.timer);
|
|
109
|
-
clearInterval(this.dragInterval);
|
|
110
|
-
this.setState({
|
|
111
|
-
dragging: false,
|
|
112
|
-
editing: !dragging,
|
|
113
|
-
origin: null,
|
|
114
|
-
});
|
|
115
|
-
document.removeEventListener('mousemove', this.handleDragMove);
|
|
116
|
-
document.removeEventListener('mouseup', this.handleDragEnd);
|
|
117
|
-
if (dragging) {
|
|
118
|
-
this.suppressFlicker();
|
|
119
|
-
if (onChange) {
|
|
120
|
-
onChange(e, value);
|
|
121
|
-
}
|
|
122
|
-
if (onDrag) {
|
|
123
|
-
onDrag(e, value);
|
|
124
|
-
}
|
|
125
|
-
} else if (this.inputRef) {
|
|
126
|
-
const input = this.inputRef.current;
|
|
127
|
-
input.value = internalValue;
|
|
128
|
-
// IE8: Dies when trying to focus a hidden element
|
|
129
|
-
// (Error: Object does not support this action)
|
|
130
|
-
try {
|
|
131
|
-
input.focus();
|
|
132
|
-
input.select();
|
|
133
|
-
} catch {}
|
|
134
|
-
}
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
render() {
|
|
139
|
-
const {
|
|
140
|
-
dragging,
|
|
141
|
-
editing,
|
|
142
|
-
value: intermediateValue,
|
|
143
|
-
suppressingFlicker,
|
|
144
|
-
} = this.state;
|
|
145
|
-
const {
|
|
146
|
-
animated,
|
|
147
|
-
value,
|
|
148
|
-
unit,
|
|
149
|
-
minValue,
|
|
150
|
-
maxValue,
|
|
151
|
-
unclamped,
|
|
152
|
-
format,
|
|
153
|
-
onChange,
|
|
154
|
-
onDrag,
|
|
155
|
-
children,
|
|
156
|
-
// Input props
|
|
157
|
-
height,
|
|
158
|
-
lineHeight,
|
|
159
|
-
fontSize,
|
|
160
|
-
} = this.props;
|
|
161
|
-
let displayValue = value;
|
|
162
|
-
if (dragging || suppressingFlicker) {
|
|
163
|
-
displayValue = intermediateValue;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
const displayElement = (
|
|
167
|
-
<>
|
|
168
|
-
{animated && !dragging && !suppressingFlicker ? (
|
|
169
|
-
<AnimatedNumber value={displayValue} format={format} />
|
|
170
|
-
) : format ? (
|
|
171
|
-
format(displayValue)
|
|
172
|
-
) : (
|
|
173
|
-
displayValue
|
|
174
|
-
)}
|
|
175
|
-
|
|
176
|
-
{unit ? ' ' + unit : ''}
|
|
177
|
-
</>
|
|
178
|
-
);
|
|
179
|
-
|
|
180
|
-
// Setup an input element
|
|
181
|
-
// Handles direct input via the keyboard
|
|
182
|
-
const inputElement = (
|
|
183
|
-
<input
|
|
184
|
-
ref={this.inputRef}
|
|
185
|
-
className="NumberInput__input"
|
|
186
|
-
style={{
|
|
187
|
-
display: !editing ? 'none' : undefined,
|
|
188
|
-
height: height,
|
|
189
|
-
lineHeight: lineHeight,
|
|
190
|
-
fontsize: fontSize,
|
|
191
|
-
}}
|
|
192
|
-
onBlur={(e) => {
|
|
193
|
-
if (!editing) {
|
|
194
|
-
return;
|
|
195
|
-
}
|
|
196
|
-
let value;
|
|
197
|
-
if (unclamped) {
|
|
198
|
-
value = parseFloat(e.target.value);
|
|
199
|
-
} else {
|
|
200
|
-
value = clamp(parseFloat(e.target.value), minValue, maxValue);
|
|
201
|
-
}
|
|
202
|
-
if (Number.isNaN(value)) {
|
|
203
|
-
this.setState({
|
|
204
|
-
editing: false,
|
|
205
|
-
});
|
|
206
|
-
return;
|
|
207
|
-
}
|
|
208
|
-
this.setState({
|
|
209
|
-
editing: false,
|
|
210
|
-
value,
|
|
211
|
-
});
|
|
212
|
-
this.suppressFlicker();
|
|
213
|
-
if (onChange) {
|
|
214
|
-
onChange(e, value);
|
|
215
|
-
}
|
|
216
|
-
if (onDrag) {
|
|
217
|
-
onDrag(e, value);
|
|
218
|
-
}
|
|
219
|
-
}}
|
|
220
|
-
onKeyDown={(e) => {
|
|
221
|
-
if (e.keyCode === 13) {
|
|
222
|
-
let value;
|
|
223
|
-
if (unclamped) {
|
|
224
|
-
value = parseFloat(e.target.value);
|
|
225
|
-
} else {
|
|
226
|
-
value = clamp(parseFloat(e.target.value), minValue, maxValue);
|
|
227
|
-
}
|
|
228
|
-
if (Number.isNaN(value)) {
|
|
229
|
-
this.setState({
|
|
230
|
-
editing: false,
|
|
231
|
-
});
|
|
232
|
-
return;
|
|
233
|
-
}
|
|
234
|
-
this.setState({
|
|
235
|
-
editing: false,
|
|
236
|
-
value,
|
|
237
|
-
});
|
|
238
|
-
this.suppressFlicker();
|
|
239
|
-
if (onChange) {
|
|
240
|
-
onChange(e, value);
|
|
241
|
-
}
|
|
242
|
-
if (onDrag) {
|
|
243
|
-
onDrag(e, value);
|
|
244
|
-
}
|
|
245
|
-
return;
|
|
246
|
-
}
|
|
247
|
-
if (e.keyCode === 27) {
|
|
248
|
-
this.setState({
|
|
249
|
-
editing: false,
|
|
250
|
-
});
|
|
251
|
-
return;
|
|
252
|
-
}
|
|
253
|
-
}}
|
|
254
|
-
/>
|
|
255
|
-
);
|
|
256
|
-
// Return a part of the state for higher-level components to use.
|
|
257
|
-
return children({
|
|
258
|
-
dragging,
|
|
259
|
-
editing,
|
|
260
|
-
value,
|
|
261
|
-
displayValue,
|
|
262
|
-
displayElement,
|
|
263
|
-
inputElement,
|
|
264
|
-
handleDragStart: this.handleDragStart,
|
|
265
|
-
});
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
DraggableControl.defaultProps = {
|
|
270
|
-
minValue: -Infinity,
|
|
271
|
-
maxValue: +Infinity,
|
|
272
|
-
step: 1,
|
|
273
|
-
stepPixelSize: 1,
|
|
274
|
-
suppressFlicker: 50,
|
|
275
|
-
dragMatrix: [1, 0],
|
|
276
|
-
};
|