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