<template>
  <FlexView :direction="vertical ? 'column' : 'row'" align="center" :gap="10" wrap>
    <RadioGroup
      :modelValue="modelValue"
      @update:modelValue="emits('update:modelValue', $event)"
      :disabled="disabled"
      v-bind="$attrs"
    >
      <Radio
        v-for="it in options"
        :key="(it.value as string)"
        :name="(it.value as string)"
        :text="it.text"
      />
    </RadioGroup>
  </FlexView>
</template>

<script lang="ts" setup>
import { type PropType, ref, watch, onMounted } from 'vue';
import RadioGroup from '@/components/form/RadioGroup.vue';
import Radio from '@/components/form/Radio.vue';
import type { RadioValueOption } from './RadioValue';
import FlexView from '@/components/layout/FlexView.vue';

const props = defineProps({
  /**
   * 是否禁用
   */
  disabled: {
    type: Boolean,
    default: false
  },
  /**
   * 是否垂直方向
   */
  vertical: {
    type: Boolean,
    default: false
  },
  /**
   * 选项数据
   */
  options: {
    type: Object as PropType<RadioValueOption[]>,
    default: null,
  },
  modelValue: {
    type: [String, Number],
    default: null,
  },
});

const emits = defineEmits([
  'update:modelValue',
]);
</script>