<script setup>
import { useVModel } from "@vueuse/core";
const props = defineProps({
  modelValue: { type: [Boolean, null], required: false, default: false },
  disabled: { type: Boolean, required: false, default: false }
});
const emit = defineEmits([]);
const checked = useVModel(props, "modelValue", emit, { passive: true });
</script>

<template>
  <label
    class="n-checkbox select-none items-center hover:n-checkbox-hover n-disabled:n-disabled"
    :checked="checked || null"
    :disabled="disabled || null"
  >
    <input
      v-model="checked"
      type="checkbox"
      class="peer absolute op0"
      :disabled="disabled"
      @keypress.enter="checked = !checked"
    >
    <span class="n-checkbox-box n-transition n-checked:n-checkbox-box-checked peer-active:n-active-base peer-focus-visible:n-focus-base">
      <NIcon class="n-checkbox-icon scale-0 transform op0 n-transition n-checked:scale-100 n-checked:op100" />
    </span>
    <span :class="checked ? '' : 'op50'" class="n-transition"><slot /></span>
  </label>
</template>
