git ssb

0+

Rômulo Alves / plainbudget-next



Tree: 83be8b8f43a8989f425e4948524233cb63983146

Files: 83be8b8f43a8989f425e4948524233cb63983146 / components / textarea.js

1262 bytesRaw
1import { Component, Fragment } from 'react';
2import { func, string } from 'prop-types';
3
4export default class Textarea extends Component {
5 static propTypes = {
6 value: string,
7 onChange: func,
8 onKeyDown: func,
9 onClick: func
10 }
11
12 static defaultProps = {
13 value: ''
14 }
15
16 constructor (props) {
17 super(props);
18
19 this.onChangeText = this.onChangeText.bind(this);
20 this.onKeyDown = this.onKeyDown.bind(this);
21 this.onClick = this.onClick.bind(this);
22 }
23
24 onChangeText (event) {
25 event.preventDefault();
26
27 const { onChange } = this.props;
28
29 if (!onChange) {
30 return;
31 }
32
33 const { value } = event.target;
34
35 return onChange(value);
36 }
37
38 onKeyDown (event) {
39 const { onKeyDown: onPropKeyDown } = this.props;
40
41 if (!onPropKeyDown) {
42 return;
43 }
44
45 return onPropKeyDown(event);
46 }
47
48 onClick (event) {
49 event.preventDefault()
50
51 const { onClick: onPropClick } = this.props;
52
53 if (!onPropClick) {
54 return;
55 }
56
57 return onPropClick(event);
58 }
59
60 render () {
61 const { value } = this.props;
62
63 return (
64 <textarea onChange={ this.onChangeText }
65 onKeyDown={ this.onKeyDown }
66 onClick={ this.onClick }
67 value={ value }>
68 </textarea>
69 );
70 }
71}

Built with git-ssb-web