checkbox.vue 1011 B

12345678910111213141516171819202122232425262728
  1. <template>
  2. <div class="input checkbox" :style="{ width, height }" :class="{ disabled }">
  3. <input
  4. :disabled="disabled"
  5. :id="id"
  6. type="checkbox"
  7. class="replace-input"
  8. :checked="props.modelValue"
  9. @input="(ev:Event) => emit('update:modelValue', (ev.target as HTMLInputElement).checked)"
  10. />
  11. <span class="replace">
  12. <UIIcon :type="props.modelValue ? 'checkbox' : 'nor'" :size="props.width > props.height ? props.height : props.width" />
  13. </span>
  14. </div>
  15. <label class="label" v-if="props.label" :for="id">
  16. {{ props.label }}
  17. </label>
  18. </template>
  19. <script setup lang="ts">
  20. import UIIcon from '../../../icon/src/icon.vue'
  21. import { checkboxInputProps } from './checkbox'
  22. import { randomId } from '@kankan/utils'
  23. import { defineProps, defineEmits } from 'vue'
  24. const props = defineProps(checkboxInputProps)
  25. const emit = defineEmits(['update:modelValue'])
  26. const id = randomId(4)
  27. </script>