-
Notifications
You must be signed in to change notification settings - Fork 3
/
ConnectedInput.js
113 lines (102 loc) · 2.58 KB
/
ConnectedInput.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
102
103
104
105
106
107
108
109
110
111
112
113
import Input from 'element-ui/lib/input'
import noop from 'lodash/noop'
import camelCase from 'lodash/camelCase'
import ConnectedControlMixin from '../mixins/ConnectedControl'
const ConnectedInput = {
props: {
name: {
type: String,
required: true,
},
type: String,
value: [String, Number],
maxlength: Number,
minLength: Number,
placeholder: String,
clearable: Boolean,
disabled: Boolean,
size: String,
prefixIcon: String,
suffixIcon: String,
rows: Number,
autosize: Boolean,
autocomplete: {
type: String,
default: 'off',
},
readonly: Boolean,
max: Number,
min: Number,
step: Number,
resize: String,
autofocus: Boolean,
form: String,
tabindex: Number,
append: [String, Number, Boolean],
prepend: [String, Number, Boolean],
validators: Array,
asyncValidators: Array,
handleFocus: {
type: Function,
default: noop,
},
handleBlur: {
type: Function,
default: noop,
},
handleChange: {
type: Function,
default: noop,
},
handleClear: {
type: Function,
default: noop,
},
/* Detached Store Props */
detached: {
type: Boolean,
default: false,
},
initialValues: Object,
},
mixins: [ConnectedControlMixin],
methods: {
renderComponent(value, setValue) {
return (
<Input
class={this.class}
name={camelCase(this.name)}
type={this.type}
value={value}
maxlength={this.maxlength}
minLength={this.minLength}
placeholder={this.placeholder}
clearable={this.clearable}
disabled={this.isFieldDisabled}
size={this.controlSize}
prefix-icon={this.prefixIcon}
suffix-icon={this.suffixIcon}
rows={this.rows}
autosize={this.autosize}
autocomplete={this.autocomplete}
readonly={this.readonly}
max={this.max}
min={this.min}
step={this.step}
resize={this.resize}
autofocus={this.autofocus}
form={this.form}
tabindex={this.tabindex}
on-input={setValue}
on-focus={this.handleFocus}
on-blur={this.handleFieldBlur}
on-change={this.handleFieldChange}
on-clear={this.handleClear}>
{Boolean(this.append) && <template slot="append">{this.append}</template>}
{Boolean(this.prepend) && <template slot="prepend">{this.prepend}</template>}
</Input>
)
},
},
}
export default ConnectedInput