15
15
@change =" onChange"
16
16
@blur =" onBlur"
17
17
@focus =" onFocus"
18
+ v-on:keyup.enter =" $event.target.blur()"
18
19
:autofocus =" autofocus"
19
20
:disabled =" disabled"
20
21
:readonly =" readonly"
24
25
v-if =" controls"
25
26
class =" btn btn-decrement"
26
27
@mousedown =" start(decrement)"
28
+ @contextmenu.prevent
27
29
@touchstart =" $event.preventDefault(); start(decrement)"
28
30
@touchend =" $event.preventDefault(); stop($event)"
29
31
:disabled =" disabled || numericValue <= min"
35
37
v-if =" controls"
36
38
class =" btn btn-increment"
37
39
@mousedown =" start(increment)"
40
+ @contextmenu.prevent
38
41
@touchstart =" $event.preventDefault(); start(increment)"
39
42
@touchend =" $event.preventDefault(); stop($event)"
40
43
:disabled =" disabled || numericValue >= max"
44
47
</div >
45
48
</template >
46
49
<script >
50
+
47
51
const timeInterval = 100
48
52
49
53
export default {
@@ -97,6 +101,11 @@ export default {
97
101
controlsType: {
98
102
type: String ,
99
103
default: ' plusminus'
104
+ },
105
+
106
+ delayValidation: {
107
+ type: Boolean ,
108
+ default: false
100
109
}
101
110
102
111
},
@@ -105,7 +114,9 @@ export default {
105
114
numericValue: null ,
106
115
interval: null ,
107
116
startTime: null ,
108
- handler: Function
117
+ handler: Function ,
118
+ deferredValue: null ,
119
+ backingValue: null ,
109
120
}
110
121
},
111
122
watch: {
@@ -169,7 +180,12 @@ export default {
169
180
* Handle value on Input
170
181
*/
171
182
inputHandler (val ) {
172
- this .updateValue (this .toNumber (val), val)
183
+ if (this .delayValidation ) {
184
+ this .deferredValue = this .toNumber (val)
185
+ }
186
+ else {
187
+ this .updateValue (this .toNumber (val), val)
188
+ }
173
189
},
174
190
/**
175
191
* Update value on operation performed
@@ -189,6 +205,7 @@ export default {
189
205
return
190
206
}
191
207
this .numericValue = val
208
+ this .backingValue = val
192
209
this .$emit (' input' , val)
193
210
},
194
211
/**
@@ -222,13 +239,22 @@ export default {
222
239
* @param event - blur event on input
223
240
*/
224
241
onBlur (event ) {
242
+ if (this .delayValidation ) {
243
+ if (isNaN (parseFloat (this .deferredValue ))) {
244
+ this .updateValue (this .backingValue )
245
+ }
246
+ else {
247
+ this .updateValue (this .deferredValue )
248
+ }
249
+ }
225
250
this .$emit (' blur' , event )
226
251
},
227
252
/**
228
253
* On focus event trigger on input
229
254
* @param event
230
255
*/
231
256
onFocus (event ) {
257
+ this .backingValue = this .value
232
258
this .$emit (' focus' , event )
233
259
},
234
260
/**
0 commit comments