<script lang="ts" name="rc-radio" 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 radioValue = ref('')

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