2022-09-06 12:03:37 +00:00
|
|
|
<template>
|
2022-09-14 11:26:01 +00:00
|
|
|
<div :class="['p-checkbox p-component', { 'p-checkbox-focused': focused }]" @click.stop.prevent="onClick">
|
|
|
|
<div
|
|
|
|
ref="box"
|
|
|
|
:class="['p-checkbox-box p-component', { 'p-highlight': checked, 'p-disabled': $attrs.disabled, 'p-focus': focused }]"
|
|
|
|
role="checkbox"
|
|
|
|
:aria-checked="checked"
|
|
|
|
:tabindex="$attrs.disabled ? null : '0'"
|
|
|
|
@keydown.space.prevent="onClick"
|
|
|
|
@focus="onFocus($event)"
|
|
|
|
@blur="onBlur($event)"
|
|
|
|
>
|
|
|
|
<span :class="['p-checkbox-icon', { 'pi pi-check': checked }]"></span>
|
2022-09-06 12:03:37 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
name: 'RowCheckbox',
|
|
|
|
inheritAttrs: false,
|
|
|
|
emits: ['change'],
|
|
|
|
props: {
|
2022-09-14 11:26:01 +00:00
|
|
|
value: null,
|
2022-09-06 12:03:37 +00:00
|
|
|
checked: null
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
focused: false
|
|
|
|
};
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
onClick(event) {
|
|
|
|
if (!this.$attrs.disabled) {
|
|
|
|
this.focused = true;
|
|
|
|
this.$emit('change', {
|
|
|
|
originalEvent: event,
|
|
|
|
data: this.value
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
onFocus() {
|
|
|
|
this.focused = true;
|
|
|
|
},
|
|
|
|
onBlur() {
|
|
|
|
this.focused = false;
|
|
|
|
}
|
|
|
|
}
|
2022-09-14 11:26:01 +00:00
|
|
|
};
|
2022-09-06 12:03:37 +00:00
|
|
|
</script>
|