on dee2cd5 help sign in
bridge/src/components/old/ProtoInput.js
66 lines 1.8 kB history raw
1import React from 'react';
2import PropTypes from 'prop-types';
4import { getDomProps } from '../../lib/base';
6const ProtoInput = props => {
7 return (
8 <input
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 disabled={props.disabled}
22 type={props.type}
23 name={props.name}
24 style={props.style}
25 value={props.value}
26 autoFocus={props.autoFocus}
27 readOnly={props.readOnly}
28 maxLength={props.maxLength}
29 autoComplete={props.autoComplete}
30 />
31 );
32};
34ProtoInput.propTypes = {
35 disabled: PropTypes.bool,
36 onChange: PropTypes.func,
37 onBlur: PropTypes.func,
38 onFocus: PropTypes.func,
39 onKeyPress: PropTypes.func,
40 className: PropTypes.string,
41 style: PropTypes.object,
42 children: PropTypes.node,
43 autoFocus: PropTypes.bool,
44 readOnly: PropTypes.bool,
45 name: PropTypes.string,
46 value: PropTypes.string,
47 autoComplete: PropTypes.string,
48 type: PropTypes.string,
49};
51ProtoInput.defaultProps = {
52 disabled: false,
53 autoFocus: false,
54 onChange: () => {},
55 onBlur: () => {},
56 onFocus: () => {},
57 onKeyPress: () => {},
58 style: {},
59 className: '',
60 value: '',
61 name: '',
62 autoComplete: 'off',
63 type: 'input',
64};
66export default ProtoInput;