2019-07-09 12:41:15 +00:00
|
|
|
<template>
|
|
|
|
<div class="p-checkbox p-component" @click="onClick">
|
|
|
|
<div class="p-hidden-accessible">
|
|
|
|
<input ref="input" type="checkbox" :checked="checked" @focus="onFocus($event)" @blur="onBlur($event)" :disabled="disabled">
|
|
|
|
</div>
|
2019-12-26 11:24:53 +00:00
|
|
|
<div ref="box" :class="['p-checkbox-box p-component', {'p-highlight': checked, 'p-disabled': $attrs.disabled, 'p-focus': focused}]" role="checkbox" :aria-checked="checked">
|
2020-05-02 09:46:30 +00:00
|
|
|
<span :class="['p-checkbox-icon', {'pi pi-check': checked}]"></span>
|
2019-07-09 12:41:15 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
inheritAttrs: false,
|
|
|
|
props: {
|
|
|
|
checked: null
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
focused: false
|
|
|
|
};
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
onClick(event) {
|
2020-09-24 15:39:36 +00:00
|
|
|
if (!this.$attrs.disabled) {
|
2019-07-09 12:41:15 +00:00
|
|
|
this.$emit('change', event);
|
|
|
|
this.$refs.input.focus();
|
|
|
|
}
|
|
|
|
},
|
2019-07-09 13:15:42 +00:00
|
|
|
onFocus() {
|
2019-07-09 12:41:15 +00:00
|
|
|
this.focused = true;
|
|
|
|
},
|
2019-07-09 13:15:42 +00:00
|
|
|
onBlur() {
|
2019-07-09 12:41:15 +00:00
|
|
|
this.focused = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|