2022-12-18 08:29:16 +09:00
|
|
|
<script setup lang="ts">
|
|
|
|
defineProps<{
|
2023-05-21 04:23:41 +09:00
|
|
|
label?: string
|
2022-12-18 08:29:16 +09:00
|
|
|
hover?: boolean
|
2023-05-21 04:23:41 +09:00
|
|
|
iconChecked?: string
|
|
|
|
iconUnchecked?: string
|
2022-12-18 08:29:16 +09:00
|
|
|
}>()
|
2023-08-01 18:43:55 +09:00
|
|
|
const modelValue = defineModel<boolean | null>()
|
2022-12-18 08:29:16 +09:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<label
|
|
|
|
class="common-checkbox flex items-center cursor-pointer py-1 text-md w-full gap-y-1"
|
2023-01-05 17:47:58 +09:00
|
|
|
:class="hover ? 'hover:bg-active ms--2 px-4 py-2' : null"
|
2023-05-21 04:23:41 +09:00
|
|
|
v-bind="$attrs"
|
2022-12-18 08:29:16 +09:00
|
|
|
@click.prevent="modelValue = !modelValue"
|
|
|
|
>
|
2023-05-21 04:23:41 +09:00
|
|
|
<span v-if="label" flex-1 ms-2 pointer-events-none>{{ label }}</span>
|
2022-12-18 08:29:16 +09:00
|
|
|
<span
|
2023-05-21 04:23:41 +09:00
|
|
|
:class="modelValue ? (iconChecked ?? 'i-ri:checkbox-line') : (iconUnchecked ?? 'i-ri:checkbox-blank-line')"
|
2023-01-05 17:47:58 +09:00
|
|
|
text-lg
|
2022-12-18 08:29:16 +09:00
|
|
|
aria-hidden="true"
|
|
|
|
/>
|
|
|
|
<input
|
|
|
|
v-model="modelValue"
|
|
|
|
type="checkbox"
|
|
|
|
sr-only
|
|
|
|
>
|
|
|
|
</label>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
.common-checkbox:focus-within {
|
|
|
|
outline: none;
|
|
|
|
border-bottom: 1px solid var(--c-text-base);
|
|
|
|
}
|
|
|
|
</style>
|