Fixed #1234 - Add input, focus, blur events for InputSwitch
parent
51976dacda
commit
b13d8d517f
|
@ -27,6 +27,18 @@ const InputSwitchEvents = [
|
||||||
{
|
{
|
||||||
name: "change",
|
name: "change",
|
||||||
description: "Callback to invoke on value change."
|
description: "Callback to invoke on value change."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "input",
|
||||||
|
description: "Callback to invoke on value change."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "focus",
|
||||||
|
description: "Callback to invoke when element receives focus."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "blur",
|
||||||
|
description: "Callback to invoke when element loses focus."
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,9 @@ declare class InputSwitch {
|
||||||
$emit(eventName: 'update:modelValue', value: boolean): this;
|
$emit(eventName: 'update:modelValue', value: boolean): this;
|
||||||
$emit(eventName: 'click', event: Event): this;
|
$emit(eventName: 'click', event: Event): this;
|
||||||
$emit(eventName: 'change', event: Event): this;
|
$emit(eventName: 'change', event: Event): this;
|
||||||
|
$emit(eventName: 'input', value: boolean): this;
|
||||||
|
$emit(eventName: 'focus', event: Event): this;
|
||||||
|
$emit(eventName: 'blur', event: Event): this;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default InputSwitch;
|
export default InputSwitch;
|
||||||
|
|
|
@ -29,15 +29,18 @@ export default {
|
||||||
this.$emit('click', event);
|
this.$emit('click', event);
|
||||||
this.$emit('update:modelValue', !this.modelValue);
|
this.$emit('update:modelValue', !this.modelValue);
|
||||||
this.$emit('change', event);
|
this.$emit('change', event);
|
||||||
|
this.$emit('input', !this.modelValue);
|
||||||
this.$refs.input.focus();
|
this.$refs.input.focus();
|
||||||
}
|
}
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
},
|
},
|
||||||
onFocus() {
|
onFocus(event) {
|
||||||
this.focused = true;
|
this.focused = true;
|
||||||
|
this.$emit('focus', event);
|
||||||
},
|
},
|
||||||
onBlur() {
|
onBlur(event) {
|
||||||
this.focused = false;
|
this.focused = false;
|
||||||
|
this.$emit('blur', event);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
|
|
@ -73,7 +73,6 @@ export default {
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h5>Events</h5>
|
<h5>Events</h5>
|
||||||
<p>Any valid event such as focus, blur and input are passed to the underlying input element. Following are the additional events to configure the component.</p>
|
|
||||||
<div class="doc-tablewrapper">
|
<div class="doc-tablewrapper">
|
||||||
<table class="doc-table">
|
<table class="doc-table">
|
||||||
<thead>
|
<thead>
|
||||||
|
@ -86,12 +85,27 @@ export default {
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td>click</td>
|
<td>click</td>
|
||||||
<td>-</td>
|
<td>event: Browser event</td>
|
||||||
<td>Callback to invoke on click.</td>
|
<td>Callback to invoke on click.</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>change</td>
|
<td>change</td>
|
||||||
<td>-</td>
|
<td>event: Browser event</td>
|
||||||
|
<td>Callback to invoke on value change.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>focus</td>
|
||||||
|
<td>event: Browser event</td>
|
||||||
|
<td>Callback to invoke when element receives focus.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>blur</td>
|
||||||
|
<td>event: Browser event</td>
|
||||||
|
<td>Callback to invoke when element loses focus.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>input</td>
|
||||||
|
<td>value: New value</td>
|
||||||
<td>Callback to invoke on value change.</td>
|
<td>Callback to invoke on value change.</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
Loading…
Reference in New Issue