1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
import React = require("react");
import { observer } from "mobx-react";
import { EditableView } from "../../views/EditableView";
import { observable, action } from "mobx";
interface KeyValueProps {
remove: (self: KeyValue) => void;
}
@observer
export default class KeyValue extends React.Component<KeyValueProps> {
@observable public key = "Key";
@observable public value = "Value";
@action
updateKey = (newKey: string) => {
this.key = newKey;
return true;
}
@action
updateValue = (newValue: string) => {
this.value = newValue;
return true;
}
render() {
let keyValueStyle = { paddingLeft: 10, width: "50%" };
let keySpecified = (this.key.length > 0 && this.key !== "Key");
return (
<div
style={{
display: "flex",
flexDirection: "row",
paddingBottom: 5,
paddingRight: 5,
justifyContent: "center",
alignItems: "center",
alignContent: "center"
}}
onClick={() => this.props.remove(this)}
>
<input type="checkbox" />
<div className={"key_container"} style={keyValueStyle}>
<EditableView
contents={this.key}
SetValue={this.updateKey}
GetValue={() => this.key}
oneLine={true}
/>
</div>
<div
className={"value_container"}
style={{
opacity: keySpecified ? 1 : 0.5,
pointerEvents: keySpecified ? "all" : "none",
...keyValueStyle
}}>
<EditableView
contents={this.value}
SetValue={this.updateValue}
GetValue={() => this.value}
oneLine={true}
/>
</div>
<div style={{
borderRadius: "50%",
width: 10,
height: 10,
background: "red",
marginLeft: 15,
marginRight: 15
}} />
</div>
);
}
}
|