Fixed #1471 - Add input, focus, blur events for Checkbox

This commit is contained in:
Cagatay Civici 2021-08-25 09:58:21 +03:00
parent 53a69ebd72
commit a1cf1d4277
4 changed files with 37 additions and 19 deletions

View file

@ -45,26 +45,24 @@ const CheckboxProps = [
const CheckboxEvents = [
{
"name": "click",
"description": "Callback to invoke on value click.",
arguments: [
{
name: "event",
type: "object",
description: "Browser event"
}
]
name: "click",
description: "Callback to invoke on value click.",
},
{
"name": "change",
"description": "Callback to invoke on value change.",
arguments: [
name: "change",
description: "Callback to invoke on value change.",
},
{
name: "event",
type: "object",
description: "Browser event"
}
]
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."
}
];

View file

@ -13,6 +13,9 @@ declare class Checkbox {
$emit(eventName: 'update:page', value: any): this;
$emit(eventName: 'click', 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 Checkbox;

View file

@ -54,14 +54,17 @@ export default {
this.$emit('click', event);
this.$emit('update:modelValue', newModelValue);
this.$emit('change', event);
this.$emit('input', newModelValue);
this.$refs.input.focus();
}
},
onFocus() {
this.focused = true;
this.$emit('focus', event);
},
onBlur() {
this.focused = false;
this.$emit('blur', event);
}
},
computed: {

View file

@ -97,7 +97,6 @@ export default {
</div>
<h5>Events</h5>
<p>Any valid event such as focus and blur.</p>
<div class="doc-tablewrapper">
<table class="doc-table">
<thead>
@ -117,6 +116,21 @@ export default {
<td>change</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>
</tr>
</tbody>
</table>