35 lines
725 B
Vue
35 lines
725 B
Vue
<template>
|
|
<div class="base-checkbox" v-cy="'checkbox'">
|
|
<input
|
|
type="checkbox"
|
|
:id="checkboxId"
|
|
class="is-sr-only"
|
|
:checked="modelValue"
|
|
@change="(event) => emit('update:modelValue', (event.target as HTMLInputElement).checked)"
|
|
:disabled="disabled || undefined"
|
|
/>
|
|
<slot :checkboxId="checkboxId" />
|
|
</div>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import {ref} from 'vue'
|
|
import {createRandomID} from '@/helpers/randomId'
|
|
|
|
defineProps({
|
|
modelValue: {
|
|
type: Boolean,
|
|
default: false,
|
|
},
|
|
disabled: {
|
|
type: Boolean,
|
|
default: false,
|
|
},
|
|
})
|
|
|
|
const emit = defineEmits<{
|
|
(event: 'update:modelValue', value: boolean): void
|
|
}>()
|
|
|
|
const checkboxId = ref(`fancycheckbox_${createRandomID()}`)
|
|
</script> |