on ee3c56d help sign in
bridge/src/components/ProtoTextarea.js
64 lines 1.9 kB history raw
1import React from 'react';
2import PropTypes from 'prop-types';
4import { getDomProps } from '../lib/base'
6const ProtoTextarea = props => {
7 return (
8 <textarea
9 // getDomProps gets any prop prepended with 'prop-'. Useful here because
10 // one cannot simply pass props like {...props} because the input elem
11 // cannot accept children nodes, which are included in the props arg. It
12 // is doubly useful because it lets the developer control which props are
13 // added to the real DOM.
14 {...getDomProps(props)}
15 className={props.className}
16 onChange={e => props.onChange(e)}
17 onKeyPress={e => props.onKeyPress(e)}
18 onFocus={e => props.onFocus(e)}
19 onBlur={e => props.onBlur(e)}
20 placeholder={props.placeholder}
21 name={props.name}
22 style={props.style}
23 value={props.value}
24 autoFocus={props.autoFocus}
25 readOnly={props.readOnly}
26 maxLength={props.maxLength}
27 autoComplete={props.autoComplete} />
28 );
32ProtoTextarea.propTypes = {
33 disabled: PropTypes.bool,
34 onChange: PropTypes.func,
35 onBlur: PropTypes.func,
36 onFocus: PropTypes.func,
37 onKeyPress: PropTypes.func,
38 className: PropTypes.string,
39 style: PropTypes.object,
40 children: PropTypes.node,
41 autoFocus: PropTypes.bool,
42 readOnly: PropTypes.bool,
43 name: PropTypes.string,
44 value: PropTypes.string,
45 autoComplete: PropTypes.string,
46};
49ProtoTextarea.defaultProps = {
50 disabled: false,
51 autoFocus: false,
52 onChange: () => {},
53 onBlur: () => {},
54 onFocus: () => {},
55 onKeyPress: () => {},
56 style: {},
57 className: '',
58 value: '',
59 name: '',
60 autoComplete: 'off',
61};
64export default ProtoTextarea;