<script lang="ts" name="rc-checkbox" setup>
import type { FormCreateProps } from '@form-create/element-ui'
import RcCreateOption from '../rc-options/create-option.vue'
import { onMounted, ref } from 'vue'

const props = defineProps<{
  formCreateInject: FormCreateProps & {
    field: string
  }
  defaultValue: string
}>()

const checkList = ref<string[]>([])

onMounted(() => {
  if (props.defaultValue) {
    checkList.value = [props.defaultValue]
  }
})
</script>
<template>
  <RcCreateOption :formCreateInject="formCreateInject" v-slot="{ options }">
    <el-checkbox-group v-model="checkList">
      <el-checkbox
        v-for="item in options"
        size="large"
        :key="item.key"
        :value="item.label"
        :label="item.label"
      />
    </el-checkbox-group>
  </RcCreateOption>
</template>
