This repository has been archived by the owner on Aug 14, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
textField.js
101 lines (95 loc) · 2.35 KB
/
textField.js
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import React from 'react';
import {noop} from 'lodash';
import PropTypes from '../../../utils/propTypes';
import Input from './input';
function TextField(props) {
const {
className,
defaultValue,
InputProps,
inputRef,
onBlur,
onChange,
onFocus,
placeholder,
value,
...other
} = props;
const InputElement = (
<Input
defaultValue={defaultValue}
value={value}
inputRef={inputRef}
onBlur={onBlur}
onChange={onChange}
onFocus={onFocus}
placeholder={placeholder}
{...InputProps}
/>
);
return (
<div
className={className}
{...other}
>
{InputElement}
</div>
);
}
TextField.propTypes = {
/**
* @ignore
*/
className: PropTypes.string,
/**
* The default value of the `Input` element.
*/
// eslint-disable-next-line react/require-default-props
defaultValue: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
/**
* Properties applied to the `Input` element.
*/
InputProps: PropTypes.shape({}),
/**
* Use that property to pass a ref callback to the native input component.
*/
inputRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({})]),
/**
* @ignore
*/
onBlur: PropTypes.func,
/**
* Callback fired when the value is changed.
*
* @param {object} event The event source of the callback.
* You can pull out the new value by accessing `event.target.value`.
*/
onChange: PropTypes.func,
/**
* @ignore
*/
onFocus: PropTypes.func,
/**
* The short hint displayed in the input before the user enters a value.
*/
placeholder: PropTypes.string,
/**
* The value of the `Input` element, required for a controlled component.
*/
// eslint-disable-next-line react/require-default-props
value: PropTypes.oneOfType([
PropTypes.string,
PropTypes.number,
PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.number])),
]),
};
TextField.defaultProps = {
className: '',
InputProps: {},
inputRef: {},
onBlur: noop,
onChange: noop,
onFocus: noop,
placeholder: '',
};
export default TextField;