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