forked from quasarframework/quasar
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinput-mixin.js
More file actions
57 lines (56 loc) · 1.04 KB
/
input-mixin.js
File metadata and controls
57 lines (56 loc) · 1.04 KB
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
export default {
props: {
autofocus: Boolean,
name: String,
maxLength: [Number, String],
maxHeight: Number,
placeholder: String,
loading: Boolean
},
computed: {
inputPlaceholder () {
if ((!this.floatLabel && !this.stackLabel) || this.labelIsAbove) {
return this.placeholder
}
}
},
methods: {
focus () {
if (!this.disable) {
this.$refs.input.focus()
}
},
blur () {
this.$refs.input.blur()
},
select () {
this.$refs.input.select()
},
__onFocus (e) {
this.focused = true
this.$emit('focus', e)
},
__onBlur (e) {
this.focused = false
this.$emit('blur', e)
},
__onKeydown (e) {
this.$emit('keydown', e)
},
__onKeyup (e) {
this.$emit('keyup', e)
},
__onClick (e) {
this.focus()
this.$emit('click', e)
}
},
mounted () {
this.$nextTick(() => {
const input = this.$refs.input
if (this.autofocus && input) {
input.focus()
}
})
}
}