blob: 4615940bddadfe89f8e015a918c813c5583a1b95 (
plain)
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
|
import { Key } from "../../fields/Key";
import { Document } from "../../fields/Document";
import { observer } from "mobx-react";
import { TextField } from "../../fields/TextField";
import React = require("react")
import { action, observable } from "mobx";
interface IProps {
fieldKey:Key;
doc:Document;
test:string;
}
@observer
export class FieldTextBox extends React.Component<IProps, IProps> {
readonly doc:Document;
readonly fieldKey:Key;
constructor(props:IProps) {
super(props);
this.doc = props.doc;
this.fieldKey = props.fieldKey;
this.onChange = this.onChange.bind(this);
}
@action
onChange(e: React.ChangeEvent<HTMLInputElement>) {
const {fieldKey, doc} = this.props;
doc.SetFieldValue(fieldKey, e.target.value, TextField);
}
render() {
const {fieldKey, doc} = this.props;
const value = doc.GetFieldValue(fieldKey, TextField, String(""));
return (<input value={value} onChange={this.onChange} />)
}
}
|