Skip to content

Commit d4856f2

Browse files
committed
feat(input): add blur & focus api
1 parent 7a8dd25 commit d4856f2

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

src/common/mixins/input.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export default {
2+
methods: {
3+
focus() {
4+
this.$refs.input.focus()
5+
},
6+
blur() {
7+
this.$refs.input.blur()
8+
}
9+
}
10+
}

src/components/input/input.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
</template>
3131

3232
<script type="text/ecmascript-6">
33+
import inputMixin from '../../common/mixins/input'
3334
const COMPONENT_NAME = 'cube-input'
3435
const EVENT_INPUT = 'input'
3536
const EVENT_CHANGE = 'change'
@@ -38,6 +39,7 @@
3839
3940
export default {
4041
name: COMPONENT_NAME,
42+
mixins: [inputMixin],
4143
props: {
4244
value: [String, Number],
4345
type: {

src/components/textarea/textarea.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<template>
22
<div class="cube-textarea-wrapper" :class="{'cube-textarea_expanded': expanded, 'cube-textarea_active': isFocus}">
33
<textarea
4+
ref="input"
45
class="cube-textarea"
56
v-model="textareaValue"
67
v-bind="$props"
@@ -15,6 +16,7 @@
1516
</template>
1617

1718
<script type="text/ecmascript-6">
19+
import inputMixin from '../../common/mixins/input'
1820
const COMPONENT_NAME = 'cube-textarea'
1921
const EVENT_INPUT = 'input'
2022
@@ -25,6 +27,7 @@
2527
2628
export default {
2729
name: COMPONENT_NAME,
30+
mixins: [inputMixin],
2831
data() {
2932
return {
3033
textareaValue: this.value,

0 commit comments

Comments
 (0)