-
Notifications
You must be signed in to change notification settings - Fork 1
/
Input.js
executable file
·59 lines (50 loc) · 1.61 KB
/
Input.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
import React from 'react'
import Form from 'antd/lib/form';
import Input from 'antd/lib/input';
import Icon from '@ant-design/icons/lib/components/Icon';
import UserOutlined from "@ant-design/icons/UserOutlined";
import MailOutlined from "@ant-design/icons/MailOutlined";
import LockOutlined from "@ant-design/icons/LockOutlined";
import UnlockOutlined from "@ant-design/icons/UnlockOutlined";
import SafetyOutlined from "@ant-design/icons/SafetyOutlined";
import InfoCircleOutlined from "@ant-design/icons/InfoCircleOutlined";
const InputField = (props) => {
const {
_id,
displayName,
type,
onChange,
placeholder,
required, // By default is true, if equals false than ignore
icon,
focusInput,
error,
defaults
} = props
const requiredFix = required !== false;
const errorString = error ? error.errStr : null;
return (
<Form.Item
label={defaults.showLabels ? displayName : ''}
name={displayName}
rules={[{ required: {requiredFix}, message: {errorString} }]}
validateStatus={error}
>
<Input
autoFocus={focusInput}
prefix={<Icon component={icon || iconMapper[_id] || null} style={{color: "rgba(0,0,0,.25)"}} />}
placeholder={defaults.showPlaceholders ? placeholder : ''}
type={type}
onChange={(e) => onChange(e, _id)}/>
</Form.Item>
)
}
const iconMapper = {
username: UserOutlined,
email: MailOutlined,
password: LockOutlined,
confirmPassword: UnlockOutlined,
currentPassword: SafetyOutlined,
fullName: InfoCircleOutlined
}
export default InputField