tgui-core 1.1.8 → 1.1.9
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/lib/common/assets.ts +38 -0
- package/lib/common/collections.ts +27 -0
- package/lib/common/color.ts +88 -0
- package/lib/common/constants.ts +349 -0
- package/lib/common/events.ts +262 -0
- package/{dist/common/exhaustive.d.ts → lib/common/exhaustive.ts} +3 -1
- package/lib/common/format.ts +167 -0
- package/{dist/common/fp.d.ts → lib/common/fp.ts} +16 -2
- package/lib/common/hotkeys.ts +207 -0
- package/lib/common/http.ts +16 -0
- package/lib/common/keycodes.ts +86 -0
- package/{dist/common/keys.d.ts → lib/common/keys.ts} +24 -21
- package/lib/common/math.ts +76 -0
- package/lib/common/perf.ts +72 -0
- package/lib/common/random.ts +32 -0
- package/lib/common/react.ts +59 -0
- package/lib/common/redux.ts +187 -0
- package/lib/common/storage.ts +207 -0
- package/lib/common/string.ts +169 -0
- package/lib/common/timer.ts +63 -0
- package/lib/common/type-utils.ts +41 -0
- package/lib/common/types.d.ts +12 -0
- package/lib/common/uuid.ts +18 -0
- package/lib/components/AnimatedNumber.tsx +180 -0
- package/lib/components/Autofocus.tsx +23 -0
- package/lib/components/Blink.tsx +91 -0
- package/lib/components/BlockQuote.tsx +9 -0
- package/lib/components/BodyZoneSelector.tsx +149 -0
- package/lib/components/Box.tsx +252 -0
- package/lib/components/Button.tsx +425 -0
- package/lib/components/ByondUi.jsx +110 -0
- package/lib/components/Chart.tsx +155 -0
- package/lib/components/Collapsible.tsx +43 -0
- package/lib/components/ColorBox.tsx +29 -0
- package/lib/components/Dialog.tsx +81 -0
- package/lib/components/Dimmer.tsx +13 -0
- package/lib/components/Divider.tsx +20 -0
- package/lib/components/DmIcon.tsx +86 -0
- package/lib/components/DraggableControl.jsx +276 -0
- package/lib/components/Dropdown.tsx +246 -0
- package/lib/components/FakeTerminal.jsx +52 -0
- package/lib/components/FitText.tsx +99 -0
- package/lib/components/Flex.tsx +159 -0
- package/lib/components/Icon.tsx +95 -0
- package/lib/components/Image.tsx +54 -0
- package/lib/components/InfinitePlane.jsx +192 -0
- package/lib/components/Input.tsx +176 -0
- package/lib/components/KeyListener.tsx +40 -0
- package/lib/components/Knob.tsx +178 -0
- package/lib/components/LabeledControls.tsx +44 -0
- package/lib/components/LabeledList.tsx +154 -0
- package/lib/components/MenuBar.tsx +228 -0
- package/lib/components/Modal.tsx +23 -0
- package/lib/components/NoticeBox.tsx +45 -0
- package/lib/components/NumberInput.tsx +328 -0
- package/lib/components/Popper.tsx +100 -0
- package/lib/components/ProgressBar.tsx +105 -0
- package/lib/components/RestrictedInput.jsx +301 -0
- package/lib/components/RoundGauge.tsx +180 -0
- package/lib/components/Section.tsx +120 -0
- package/lib/components/Slider.tsx +169 -0
- package/lib/components/Stack.tsx +96 -0
- package/lib/components/StyleableSection.tsx +33 -0
- package/lib/components/Table.tsx +84 -0
- package/lib/components/Tabs.tsx +89 -0
- package/lib/components/TextArea.tsx +182 -0
- package/lib/components/TimeDisplay.jsx +64 -0
- package/lib/components/Tooltip.tsx +152 -0
- package/lib/components/TrackOutsideClicks.tsx +35 -0
- package/lib/components/VirtualList.tsx +69 -0
- package/lib/styles/atomic/candystripe.scss +8 -0
- package/lib/styles/atomic/centered-image.scss +7 -0
- package/lib/styles/atomic/color.scss +21 -0
- package/lib/styles/atomic/debug-layout.scss +17 -0
- package/lib/styles/atomic/fit-text.scss +14 -0
- package/lib/styles/atomic/links.scss +12 -0
- package/lib/styles/atomic/outline.scss +47 -0
- package/lib/styles/atomic/text.scss +44 -0
- package/lib/styles/base.scss +32 -0
- package/lib/styles/colors.scss +92 -0
- package/lib/styles/components/BlockQuote.module.scss +20 -0
- package/lib/styles/components/BlockQuote.module.scss.d.ts +4 -0
- package/lib/styles/components/Button.module.scss +157 -0
- package/lib/styles/components/Button.module.scss.d.ts +46 -0
- package/lib/styles/components/ColorBox.module.scss +12 -0
- package/lib/styles/components/ColorBox.module.scss.d.ts +4 -0
- package/lib/styles/components/Dialog.module.scss +60 -0
- package/lib/styles/components/Dialog.module.scss.d.ts +10 -0
- package/lib/styles/components/Dimmer.module.scss +22 -0
- package/lib/styles/components/Dimmer.module.scss.d.ts +4 -0
- package/lib/styles/components/Divider.module.scss +27 -0
- package/lib/styles/components/Divider.module.scss.d.ts +6 -0
- package/lib/styles/components/Dropdown.scss +72 -0
- package/lib/styles/components/Flex.module.scss +13 -0
- package/lib/styles/components/Flex.module.scss.d.ts +5 -0
- package/lib/styles/components/Icon.module.scss +25 -0
- package/lib/styles/components/Icon.module.scss.d.ts +5 -0
- package/lib/styles/components/Input.module.scss +64 -0
- package/lib/styles/components/Input.module.scss.d.ts +8 -0
- package/lib/styles/components/Knob.module.scss +131 -0
- package/lib/styles/components/Knob.module.scss.d.ts +33 -0
- package/lib/styles/components/LabeledList.module.scss +49 -0
- package/lib/styles/components/LabeledList.module.scss.d.ts +8 -0
- package/lib/styles/components/MenuBar.module.scss +75 -0
- package/lib/styles/components/MenuBar.module.scss.d.ts +14 -0
- package/lib/styles/components/Modal.module.scss +14 -0
- package/lib/styles/components/Modal.module.scss.d.ts +4 -0
- package/lib/styles/components/NoticeBox.module.scss +65 -0
- package/lib/styles/components/NoticeBox.module.scss.d.ts +27 -0
- package/lib/styles/components/NumberInput.module.scss +71 -0
- package/lib/styles/components/NumberInput.module.scss.d.ts +9 -0
- package/lib/styles/components/ProgressBar.module.scss +63 -0
- package/lib/styles/components/ProgressBar.module.scss.d.ts +27 -0
- package/lib/styles/components/RoundGauge.module.scss +85 -0
- package/lib/styles/components/RoundGauge.module.scss.d.ts +49 -0
- package/lib/styles/components/Section.module.scss +130 -0
- package/lib/styles/components/Section.module.scss.d.ts +13 -0
- package/lib/styles/components/Slider.module.scss +54 -0
- package/lib/styles/components/Slider.module.scss.d.ts +8 -0
- package/lib/styles/components/Stack.module.scss +60 -0
- package/lib/styles/components/Stack.module.scss.d.ts +12 -0
- package/lib/styles/components/Table.module.scss +44 -0
- package/lib/styles/components/Table.module.scss.d.ts +10 -0
- package/lib/styles/components/Tabs.module.scss +144 -0
- package/lib/styles/components/Tabs.module.scss.d.ts +35 -0
- package/lib/styles/components/TextArea.module.scss +86 -0
- package/lib/styles/components/TextArea.module.scss.d.ts +11 -0
- package/lib/styles/components/Tooltip.module.scss +24 -0
- package/lib/styles/components/Tooltip.module.scss.d.ts +4 -0
- package/lib/styles/functions.scss +79 -0
- package/lib/styles/input.scss +9 -0
- package/lib/styles/main.scss +20 -0
- package/lib/styles/reset.scss +68 -0
- package/package.json +6 -6
- package/dist/ProgressBar.module-BkAFfFy0.js +0 -29
- package/dist/Section.module-CLVHJ4yA.js +0 -15
- package/dist/assets/BlockQuote.css +0 -1
- package/dist/assets/Button.css +0 -1
- package/dist/assets/ColorBox.css +0 -1
- package/dist/assets/Dialog.css +0 -1
- package/dist/assets/Dimmer.css +0 -1
- package/dist/assets/Divider.css +0 -1
- package/dist/assets/Flex.css +0 -1
- package/dist/assets/Icon.css +0 -6
- package/dist/assets/Input.css +0 -1
- package/dist/assets/Knob.css +0 -1
- package/dist/assets/LabeledList.css +0 -1
- package/dist/assets/MenuBar.css +0 -1
- package/dist/assets/Modal.css +0 -1
- package/dist/assets/NoticeBox.css +0 -1
- package/dist/assets/NumberInput.css +0 -1
- package/dist/assets/ProgressBar.css +0 -1
- package/dist/assets/RoundGauge.css +0 -1
- package/dist/assets/Section.css +0 -1
- package/dist/assets/Slider.css +0 -1
- package/dist/assets/Stack.css +0 -1
- package/dist/assets/Table.css +0 -1
- package/dist/assets/Tabs.css +0 -1
- package/dist/assets/TextArea.css +0 -1
- package/dist/assets/Tooltip.css +0 -1
- package/dist/common/assets.d.ts +0 -4
- package/dist/common/assets.js +0 -25
- package/dist/common/collections.d.ts +0 -10
- package/dist/common/collections.js +0 -15
- package/dist/common/color.d.ts +0 -25
- package/dist/common/color.js +0 -69
- package/dist/common/constants.d.ts +0 -102
- package/dist/common/constants.js +0 -312
- package/dist/common/events.d.ts +0 -33
- package/dist/common/events.js +0 -147
- package/dist/common/exhaustive.js +0 -6
- package/dist/common/format.d.ts +0 -11
- package/dist/common/format.js +0 -114
- package/dist/common/fp.js +0 -9
- package/dist/common/hotkeys.d.ts +0 -25
- package/dist/common/hotkeys.js +0 -112
- package/dist/common/http.d.ts +0 -4
- package/dist/common/http.js +0 -10
- package/dist/common/keycodes.d.ts +0 -85
- package/dist/common/keycodes.js +0 -88
- package/dist/common/keys.js +0 -8
- package/dist/common/math.d.ts +0 -39
- package/dist/common/math.js +0 -41
- package/dist/common/perf.d.ts +0 -24
- package/dist/common/perf.js +0 -33
- package/dist/common/random.d.ts +0 -16
- package/dist/common/random.js +0 -18
- package/dist/common/react.d.ts +0 -23
- package/dist/common/react.js +0 -30
- package/dist/common/redux.d.ts +0 -64
- package/dist/common/redux.js +0 -72
- package/dist/common/storage.js +0 -124
- package/dist/common/string.d.ts +0 -65
- package/dist/common/string.js +0 -83
- package/dist/common/timer.d.ts +0 -18
- package/dist/common/timer.js +0 -28
- package/dist/common/type-utils.d.ts +0 -9
- package/dist/common/type-utils.js +0 -25
- package/dist/common/uuid.d.ts +0 -9
- package/dist/common/uuid.js +0 -10
- package/dist/components/AnimatedNumber.d.ts +0 -60
- package/dist/components/AnimatedNumber.js +0 -76
- package/dist/components/Autofocus.d.ts +0 -4
- package/dist/components/Autofocus.js +0 -17
- package/dist/components/Blink.d.ts +0 -26
- package/dist/components/Blink.js +0 -56
- package/dist/components/BlockQuote.d.ts +0 -3
- package/dist/components/BlockQuote.js +0 -13
- package/dist/components/BodyZoneSelector.d.ts +0 -28
- package/dist/components/BodyZoneSelector.js +0 -115
- package/dist/components/Box.d.ts +0 -91
- package/dist/components/Box.js +0 -133
- package/dist/components/Button.d.ts +0 -93
- package/dist/components/Button.js +0 -298
- package/dist/components/ByondUi.js +0 -73
- package/dist/components/Chart.d.ts +0 -28
- package/dist/components/Chart.js +0 -95
- package/dist/components/Collapsible.d.ts +0 -15
- package/dist/components/Collapsible.js +0 -27
- package/dist/components/ColorBox.d.ts +0 -8
- package/dist/components/ColorBox.js +0 -24
- package/dist/components/Dialog.d.ts +0 -24
- package/dist/components/Dialog.js +0 -67
- package/dist/components/Dimmer.d.ts +0 -3
- package/dist/components/Dimmer.js +0 -13
- package/dist/components/Divider.d.ts +0 -6
- package/dist/components/Divider.js +0 -22
- package/dist/components/DmIcon.d.ts +0 -31
- package/dist/components/DmIcon.js +0 -34
- package/dist/components/DraggableControl.js +0 -176
- package/dist/components/Dropdown.d.ts +0 -48
- package/dist/components/Dropdown.js +0 -152
- package/dist/components/FakeTerminal.js +0 -38
- package/dist/components/FitText.d.ts +0 -22
- package/dist/components/FitText.js +0 -63
- package/dist/components/Flex.d.ts +0 -93
- package/dist/components/Flex.js +0 -72
- package/dist/components/Icon.d.ts +0 -30
- package/dist/components/Icon.js +0 -51
- package/dist/components/Image.d.ts +0 -14
- package/dist/components/Image.js +0 -35
- package/dist/components/InfinitePlane.js +0 -139
- package/dist/components/Input.d.ts +0 -61
- package/dist/components/Input.js +0 -89
- package/dist/components/KeyListener.d.ts +0 -15
- package/dist/components/KeyListener.js +0 -23
- package/dist/components/Knob.d.ts +0 -49
- package/dist/components/Knob.js +0 -162
- package/dist/components/LabeledControls.d.ts +0 -11
- package/dist/components/LabeledControls.js +0 -39
- package/dist/components/LabeledList.d.ts +0 -57
- package/dist/components/LabeledList.js +0 -94
- package/dist/components/MenuBar.d.ts +0 -28
- package/dist/components/MenuBar.js +0 -174
- package/dist/components/Modal.d.ts +0 -3
- package/dist/components/Modal.js +0 -25
- package/dist/components/NoticeBox.d.ts +0 -20
- package/dist/components/NoticeBox.js +0 -49
- package/dist/components/NumberInput.d.ts +0 -45
- package/dist/components/NumberInput.js +0 -221
- package/dist/components/Popper.d.ts +0 -27
- package/dist/components/Popper.js +0 -177
- package/dist/components/ProgressBar.d.ts +0 -46
- package/dist/components/ProgressBar.js +0 -37
- package/dist/components/RestrictedInput.js +0 -155
- package/dist/components/RoundGauge.d.ts +0 -53
- package/dist/components/RoundGauge.js +0 -147
- package/dist/components/Section.d.ts +0 -63
- package/dist/components/Section.js +0 -62
- package/dist/components/Slider.d.ts +0 -46
- package/dist/components/Slider.js +0 -124
- package/dist/components/Stack.d.ts +0 -27
- package/dist/components/Stack.js +0 -67
- package/dist/components/StyleableSection.d.ts +0 -11
- package/dist/components/StyleableSection.js +0 -16
- package/dist/components/Table.d.ts +0 -29
- package/dist/components/Table.js +0 -67
- package/dist/components/Tabs.d.ts +0 -23
- package/dist/components/Tabs.js +0 -89
- package/dist/components/TextArea.d.ts +0 -39
- package/dist/components/TextArea.js +0 -118
- package/dist/components/TimeDisplay.js +0 -34
- package/dist/components/Tooltip.d.ts +0 -29
- package/dist/components/Tooltip.js +0 -83
- package/dist/components/TrackOutsideClicks.d.ts +0 -13
- package/dist/components/TrackOutsideClicks.js +0 -24
- package/dist/components/VirtualList.d.ts +0 -8
- package/dist/components/VirtualList.js +0 -34
- package/dist/components/index.js +0 -92
- package/dist/popper-CiqSDJTE.js +0 -906
- /package/{dist/components/index.d.ts → lib/components/index.ts} +0 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { Component } from 'react';
|
|
2
|
+
|
|
3
|
+
import { formatTime } from '../common/format';
|
|
4
|
+
|
|
5
|
+
// AnimatedNumber Copypaste
|
|
6
|
+
function isSafeNumber(value) {
|
|
7
|
+
return (
|
|
8
|
+
typeof value === 'number' && Number.isFinite(value) && !Number.isNaN(value)
|
|
9
|
+
);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export class TimeDisplay extends Component {
|
|
13
|
+
constructor(props) {
|
|
14
|
+
super(props);
|
|
15
|
+
this.timer = null;
|
|
16
|
+
this.last_seen_value = undefined;
|
|
17
|
+
this.state = {
|
|
18
|
+
value: 0,
|
|
19
|
+
};
|
|
20
|
+
// Set initial state with value provided in props
|
|
21
|
+
if (isSafeNumber(props.value)) {
|
|
22
|
+
this.state.value = Number(props.value);
|
|
23
|
+
this.last_seen_value = Number(props.value);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
componentDidUpdate() {
|
|
28
|
+
if (this.props.auto !== undefined) {
|
|
29
|
+
clearInterval(this.timer);
|
|
30
|
+
this.timer = setInterval(() => this.tick(), 1000); // every 1 s
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
tick() {
|
|
35
|
+
let current = Number(this.state.value);
|
|
36
|
+
if (this.props.value !== this.last_seen_value) {
|
|
37
|
+
this.last_seen_value = this.props.value;
|
|
38
|
+
current = this.props.value;
|
|
39
|
+
}
|
|
40
|
+
const mod = this.props.auto === 'up' ? 10 : -10; // Time down by default.
|
|
41
|
+
const value = Math.max(0, current + mod); // one sec tick
|
|
42
|
+
this.setState({ value });
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
componentDidMount() {
|
|
46
|
+
if (this.props.auto !== undefined) {
|
|
47
|
+
this.timer = setInterval(() => this.tick(), 1000); // every 1 s
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
componentWillUnmount() {
|
|
52
|
+
clearInterval(this.timer);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
render() {
|
|
56
|
+
const val = this.state.value;
|
|
57
|
+
// Directly display weird stuff
|
|
58
|
+
if (!isSafeNumber(val)) {
|
|
59
|
+
return this.state.value || null;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return formatTime(val);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
// TODO: Rewrite as an FC, remove this lint disable
|
|
2
|
+
import { createPopper, Placement, VirtualElement } from '@popperjs/core';
|
|
3
|
+
import { Component, ReactNode } from 'react';
|
|
4
|
+
import { findDOMNode, render } from 'react-dom';
|
|
5
|
+
|
|
6
|
+
import styles from '../styles/components/Tooltip.module.scss';
|
|
7
|
+
|
|
8
|
+
type Props = {
|
|
9
|
+
/** The content to display in the tooltip */
|
|
10
|
+
content: ReactNode;
|
|
11
|
+
} & Partial<{
|
|
12
|
+
/** Hovering this element will show the tooltip */
|
|
13
|
+
children: ReactNode;
|
|
14
|
+
/** Where to place the tooltip relative to the reference element */
|
|
15
|
+
position: Placement;
|
|
16
|
+
}>;
|
|
17
|
+
|
|
18
|
+
type State = {
|
|
19
|
+
hovered: boolean;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const DEFAULT_OPTIONS = {
|
|
23
|
+
modifiers: [
|
|
24
|
+
{
|
|
25
|
+
name: 'eventListeners',
|
|
26
|
+
enabled: false,
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const NULL_RECT: DOMRect = {
|
|
32
|
+
width: 0,
|
|
33
|
+
height: 0,
|
|
34
|
+
top: 0,
|
|
35
|
+
right: 0,
|
|
36
|
+
bottom: 0,
|
|
37
|
+
left: 0,
|
|
38
|
+
x: 0,
|
|
39
|
+
y: 0,
|
|
40
|
+
toJSON: () => null,
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export class Tooltip extends Component<Props, State> {
|
|
44
|
+
// Mounting poppers is really laggy because popper.js is very slow.
|
|
45
|
+
// Thus, instead of using the Popper component, Tooltip creates ONE popper
|
|
46
|
+
// and stores every tooltip inside that.
|
|
47
|
+
// This means you can never have two tooltips at once, for instance.
|
|
48
|
+
static renderedTooltip: HTMLDivElement | undefined;
|
|
49
|
+
static singletonPopper: ReturnType<typeof createPopper> | undefined;
|
|
50
|
+
static currentHoveredElement: Element | undefined;
|
|
51
|
+
static virtualElement: VirtualElement = {
|
|
52
|
+
getBoundingClientRect: () =>
|
|
53
|
+
Tooltip.currentHoveredElement?.getBoundingClientRect() ?? NULL_RECT,
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
getDOMNode() {
|
|
57
|
+
// HACK: We don't want to create a wrapper, as it could break the layout
|
|
58
|
+
// of consumers, so we use findDOMNode.
|
|
59
|
+
// This is usually bad as refs are usually better, but refs did
|
|
60
|
+
// not work in this case, as they weren't propagating correctly.
|
|
61
|
+
// A previous attempt was made as a render prop that passed an ID,
|
|
62
|
+
// but this made consuming use too unwieldly.
|
|
63
|
+
// Because this component is written in TypeScript, we will know
|
|
64
|
+
// immediately if this internal variable is removed.
|
|
65
|
+
//
|
|
66
|
+
|
|
67
|
+
return findDOMNode(this) as Element;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
componentDidMount() {
|
|
71
|
+
const domNode = this.getDOMNode();
|
|
72
|
+
|
|
73
|
+
if (!domNode) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
domNode.addEventListener('mouseenter', () => {
|
|
78
|
+
let renderedTooltip = Tooltip.renderedTooltip;
|
|
79
|
+
if (renderedTooltip === undefined) {
|
|
80
|
+
renderedTooltip = document.createElement('div');
|
|
81
|
+
renderedTooltip.className = styles.tooltip;
|
|
82
|
+
document.body.appendChild(renderedTooltip);
|
|
83
|
+
Tooltip.renderedTooltip = renderedTooltip;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
Tooltip.currentHoveredElement = domNode;
|
|
87
|
+
|
|
88
|
+
renderedTooltip.style.opacity = '1';
|
|
89
|
+
|
|
90
|
+
this.renderPopperContent();
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
domNode.addEventListener('mouseleave', () => {
|
|
94
|
+
this.fadeOut();
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
fadeOut() {
|
|
99
|
+
if (Tooltip.currentHoveredElement !== this.getDOMNode()) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
Tooltip.currentHoveredElement = undefined;
|
|
104
|
+
Tooltip.renderedTooltip!.style.opacity = '0';
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
renderPopperContent() {
|
|
108
|
+
const renderedTooltip = Tooltip.renderedTooltip;
|
|
109
|
+
if (!renderedTooltip) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
render(<span>{this.props.content}</span>, renderedTooltip, () => {
|
|
114
|
+
let singletonPopper = Tooltip.singletonPopper;
|
|
115
|
+
if (singletonPopper === undefined) {
|
|
116
|
+
singletonPopper = createPopper(
|
|
117
|
+
Tooltip.virtualElement,
|
|
118
|
+
renderedTooltip!,
|
|
119
|
+
{
|
|
120
|
+
...DEFAULT_OPTIONS,
|
|
121
|
+
placement: this.props.position || 'auto',
|
|
122
|
+
},
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
Tooltip.singletonPopper = singletonPopper;
|
|
126
|
+
} else {
|
|
127
|
+
singletonPopper.setOptions({
|
|
128
|
+
...DEFAULT_OPTIONS,
|
|
129
|
+
placement: this.props.position || 'auto',
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
singletonPopper.update();
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
componentDidUpdate() {
|
|
138
|
+
if (Tooltip.currentHoveredElement !== this.getDOMNode()) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
this.renderPopperContent();
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
componentWillUnmount() {
|
|
146
|
+
this.fadeOut();
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
render() {
|
|
150
|
+
return this.props.children;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Component, createRef, PropsWithChildren } from 'react';
|
|
2
|
+
|
|
3
|
+
type Props = {
|
|
4
|
+
onOutsideClick: () => void;
|
|
5
|
+
} & PropsWithChildren;
|
|
6
|
+
|
|
7
|
+
export class TrackOutsideClicks extends Component<Props> {
|
|
8
|
+
ref = createRef<HTMLDivElement>();
|
|
9
|
+
|
|
10
|
+
constructor(props) {
|
|
11
|
+
super(props);
|
|
12
|
+
|
|
13
|
+
this.handleOutsideClick = this.handleOutsideClick.bind(this);
|
|
14
|
+
|
|
15
|
+
document.addEventListener('click', this.handleOutsideClick);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
componentWillUnmount() {
|
|
19
|
+
document.removeEventListener('click', this.handleOutsideClick);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
handleOutsideClick(event: MouseEvent) {
|
|
23
|
+
if (!(event.target instanceof Node)) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (this.ref.current && !this.ref.current.contains(event.target)) {
|
|
28
|
+
this.props.onOutsideClick();
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
render() {
|
|
33
|
+
return <div ref={this.ref}>{this.props.children}</div>;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import {
|
|
2
|
+
PropsWithChildren,
|
|
3
|
+
useCallback,
|
|
4
|
+
useEffect,
|
|
5
|
+
useRef,
|
|
6
|
+
useState,
|
|
7
|
+
} from 'react';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* A vertical list that renders items to fill space up to the extents of the
|
|
11
|
+
* current window, and then defers rendering of other items until they come
|
|
12
|
+
* into view.
|
|
13
|
+
*/
|
|
14
|
+
export function VirtualList(props: PropsWithChildren) {
|
|
15
|
+
const { children } = props;
|
|
16
|
+
const containerRef = useRef(null as HTMLDivElement | null);
|
|
17
|
+
const [visibleElements, setVisibleElements] = useState(1);
|
|
18
|
+
const [padding, setPadding] = useState(0);
|
|
19
|
+
|
|
20
|
+
const adjustExtents = useCallback(() => {
|
|
21
|
+
const { current } = containerRef;
|
|
22
|
+
|
|
23
|
+
if (
|
|
24
|
+
!children ||
|
|
25
|
+
!Array.isArray(children) ||
|
|
26
|
+
!current ||
|
|
27
|
+
visibleElements >= children.length
|
|
28
|
+
) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const unusedArea =
|
|
33
|
+
document.body.offsetHeight - current.getBoundingClientRect().bottom;
|
|
34
|
+
|
|
35
|
+
const averageItemHeight = Math.ceil(current.offsetHeight / visibleElements);
|
|
36
|
+
|
|
37
|
+
if (unusedArea > 0) {
|
|
38
|
+
const newVisibleElements = Math.min(
|
|
39
|
+
children.length,
|
|
40
|
+
visibleElements +
|
|
41
|
+
Math.max(1, Math.ceil(unusedArea / averageItemHeight)),
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
setVisibleElements(newVisibleElements);
|
|
45
|
+
|
|
46
|
+
setPadding((children.length - newVisibleElements) * averageItemHeight);
|
|
47
|
+
}
|
|
48
|
+
}, [containerRef, visibleElements, children]);
|
|
49
|
+
|
|
50
|
+
useEffect(() => {
|
|
51
|
+
adjustExtents();
|
|
52
|
+
|
|
53
|
+
const interval = setInterval(adjustExtents, 100);
|
|
54
|
+
|
|
55
|
+
return () => clearInterval(interval);
|
|
56
|
+
}, [adjustExtents]);
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<div className={'VirtualList'}>
|
|
60
|
+
<div className={'VirtualList__Container'} ref={containerRef}>
|
|
61
|
+
{Array.isArray(children) ? children.slice(0, visibleElements) : null}
|
|
62
|
+
</div>
|
|
63
|
+
<div
|
|
64
|
+
className={'VirtualList__Padding'}
|
|
65
|
+
style={{ paddingBottom: `${padding}px` }}
|
|
66
|
+
/>
|
|
67
|
+
</div>
|
|
68
|
+
);
|
|
69
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2020 Aleksej Komarov
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
@use '../colors.scss';
|
|
7
|
+
|
|
8
|
+
$fg-map: colors.$fg-map !default;
|
|
9
|
+
$bg-map: colors.$bg-map !default;
|
|
10
|
+
|
|
11
|
+
@each $color-name, $color-value in $fg-map {
|
|
12
|
+
.color-#{$color-name} {
|
|
13
|
+
color: $color-value !important;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
@each $color-name, $color-value in $bg-map {
|
|
18
|
+
.color-bg-#{$color-name} {
|
|
19
|
+
background-color: $color-value !important;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2020 Aleksej Komarov
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
.debug-layout,
|
|
7
|
+
.debug-layout *:not(g):not(path) {
|
|
8
|
+
color: rgba(255, 255, 255, 0.9) !important;
|
|
9
|
+
background: transparent !important;
|
|
10
|
+
outline: 1px solid rgba(255, 255, 255, 0.5) !important;
|
|
11
|
+
box-shadow: none !important;
|
|
12
|
+
filter: none !important;
|
|
13
|
+
|
|
14
|
+
&:hover {
|
|
15
|
+
outline-color: rgba(255, 255, 255, 0.8) !important;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2020 Aleksej Komarov
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
@use '../colors.scss';
|
|
7
|
+
|
|
8
|
+
.outline-dotted {
|
|
9
|
+
outline-style: dotted !important;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.outline-dashed {
|
|
13
|
+
outline-style: dashed !important;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.outline-solid {
|
|
17
|
+
outline-style: solid !important;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.outline-double {
|
|
21
|
+
outline-style: double !important;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.outline-groove {
|
|
25
|
+
outline-style: groove !important;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.outline-ridge {
|
|
29
|
+
outline-style: ridge !important;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.outline-inset {
|
|
33
|
+
outline-style: inset !important;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.outline-outset {
|
|
37
|
+
outline-style: outset !important;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
$fg-map: colors.$fg-map !default;
|
|
41
|
+
$bg-map: colors.$bg-map !default;
|
|
42
|
+
|
|
43
|
+
@each $color-name, $color-value in $fg-map {
|
|
44
|
+
.outline-color-#{$color-name} {
|
|
45
|
+
outline: 0.167rem solid $color-value !important;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2020 Aleksej Komarov
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
.text-left {
|
|
7
|
+
text-align: left;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.text-center {
|
|
11
|
+
text-align: center;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.text-right {
|
|
15
|
+
text-align: right;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.text-baseline {
|
|
19
|
+
text-align: baseline;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.text-justify {
|
|
23
|
+
text-align: justify;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.text-nowrap {
|
|
27
|
+
white-space: nowrap;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.text-pre {
|
|
31
|
+
white-space: pre;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.text-bold {
|
|
35
|
+
font-weight: bold;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.text-italic {
|
|
39
|
+
font-style: italic;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.text-underline {
|
|
43
|
+
text-decoration: underline;
|
|
44
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2020 Aleksej Komarov
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
@use 'sass:color';
|
|
7
|
+
@use 'sass:math';
|
|
8
|
+
|
|
9
|
+
$color-fg: #ffffff !default;
|
|
10
|
+
$color-bg: #252525 !default;
|
|
11
|
+
$color-bg-section: rgba(0, 0, 0, 0.33) !default;
|
|
12
|
+
$color-bg-grad-spread: 2% !default;
|
|
13
|
+
$color-bg-start: color.adjust(
|
|
14
|
+
$color-bg,
|
|
15
|
+
$lightness: $color-bg-grad-spread
|
|
16
|
+
) !default;
|
|
17
|
+
$color-bg-end: color.adjust(
|
|
18
|
+
$color-bg,
|
|
19
|
+
$lightness: -$color-bg-grad-spread
|
|
20
|
+
) !default;
|
|
21
|
+
|
|
22
|
+
$unit: 12px;
|
|
23
|
+
$font-size: 1 * $unit !default;
|
|
24
|
+
$border-radius: 0.16em !default;
|
|
25
|
+
|
|
26
|
+
@function em($px) {
|
|
27
|
+
@return 1em * math.div($px, $unit);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@function rem($px) {
|
|
31
|
+
@return 1rem * math.div($px, $unit);
|
|
32
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2020 Aleksej Komarov
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
@use "sass:color";
|
|
7
|
+
@use "sass:map";
|
|
8
|
+
@use "sass:meta";
|
|
9
|
+
|
|
10
|
+
// Base colors
|
|
11
|
+
$black: #000000 !default;
|
|
12
|
+
$white: #ffffff !default;
|
|
13
|
+
$red: #db2828 !default;
|
|
14
|
+
$orange: #f2711c !default;
|
|
15
|
+
$yellow: #fbd608 !default;
|
|
16
|
+
$olive: #b5cc18 !default;
|
|
17
|
+
$green: #20b142 !default;
|
|
18
|
+
$teal: #00b5ad !default;
|
|
19
|
+
$blue: #2185d0 !default;
|
|
20
|
+
$violet: #6435c9 !default;
|
|
21
|
+
$purple: #a333c8 !default;
|
|
22
|
+
$pink: #e03997 !default;
|
|
23
|
+
$brown: #a5673f !default;
|
|
24
|
+
$grey: #767676 !default;
|
|
25
|
+
$light-grey: #aaa !default;
|
|
26
|
+
|
|
27
|
+
$primary: #4972a1 !default;
|
|
28
|
+
$good: #5baa27 !default;
|
|
29
|
+
$average: #f08f11 !default;
|
|
30
|
+
$bad: #db2828 !default;
|
|
31
|
+
$label: #7e90a7 !default;
|
|
32
|
+
|
|
33
|
+
// Background and foreground color lightness ratios
|
|
34
|
+
$bg-lightness: -15% !default;
|
|
35
|
+
$fg-lightness: 10% !default;
|
|
36
|
+
|
|
37
|
+
@function bg($color) {
|
|
38
|
+
@return color.scale($color, $lightness: $bg-lightness);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@function fg($color) {
|
|
42
|
+
@return color.scale($color, $lightness: $fg-lightness);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Mappings of color names
|
|
46
|
+
|
|
47
|
+
$_gen_map: (
|
|
48
|
+
"black": $black,
|
|
49
|
+
"white": $white,
|
|
50
|
+
"red": $red,
|
|
51
|
+
"orange": $orange,
|
|
52
|
+
"yellow": $yellow,
|
|
53
|
+
"olive": $olive,
|
|
54
|
+
"green": $green,
|
|
55
|
+
"teal": $teal,
|
|
56
|
+
"blue": $blue,
|
|
57
|
+
"violet": $violet,
|
|
58
|
+
"purple": $purple,
|
|
59
|
+
"pink": $pink,
|
|
60
|
+
"brown": $brown,
|
|
61
|
+
"grey": $grey,
|
|
62
|
+
"light-grey": $light-grey,
|
|
63
|
+
"good": $good,
|
|
64
|
+
"average": $average,
|
|
65
|
+
"bad": $bad,
|
|
66
|
+
"label": $label,
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
// Foreground color names for which to generate a color map
|
|
70
|
+
$fg-map-keys: map.keys($_gen_map) !default;
|
|
71
|
+
// Background color names for which to generate a color map
|
|
72
|
+
$bg-map-keys: map.keys($_gen_map) !default;
|
|
73
|
+
|
|
74
|
+
$fg-map: ();
|
|
75
|
+
@each $color-name in $fg-map-keys {
|
|
76
|
+
$fg-map: map-merge(
|
|
77
|
+
$fg-map,
|
|
78
|
+
(
|
|
79
|
+
$color-name: fg(map.get($_gen_map, $color-name)),
|
|
80
|
+
)
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
$bg-map: ();
|
|
85
|
+
@each $color-name in $bg-map-keys {
|
|
86
|
+
$bg-map: map-merge(
|
|
87
|
+
$bg-map,
|
|
88
|
+
(
|
|
89
|
+
$color-name: bg(map.get($_gen_map, $color-name)),
|
|
90
|
+
)
|
|
91
|
+
);
|
|
92
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2020 Aleksej Komarov
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
@use '../base.scss';
|
|
7
|
+
@use '../colors.scss';
|
|
8
|
+
|
|
9
|
+
$color-default: colors.fg(colors.$label) !default;
|
|
10
|
+
|
|
11
|
+
.blockQuote {
|
|
12
|
+
color: $color-default;
|
|
13
|
+
border-left: base.em(2px) solid $color-default;
|
|
14
|
+
padding-left: 0.5em;
|
|
15
|
+
margin-bottom: 0.5em;
|
|
16
|
+
|
|
17
|
+
&:last-child {
|
|
18
|
+
margin-bottom: 0;
|
|
19
|
+
}
|
|
20
|
+
}
|